Package ru.vagrant_ai.questionmarkgame.util

Source Code of ru.vagrant_ai.questionmarkgame.util.Particle

package ru.vagrant_ai.questionmarkgame.util;

import java.util.ArrayList;
import java.util.List;

import org.newdawn.slick.Graphics;

import ru.vagrant_ai.questionmarkgame.main.GameplayState;
import ru.vagrant_ai.questionmarkgame.obj.particle.Exclamation;
import ru.vagrant_ai.questionmarkgame.obj.particle.Explosion;
import ru.vagrant_ai.questionmarkgame.obj.particle.Gunsmoke;
import ru.vagrant_ai.questionmarkgame.obj.particle.HPParticle;
import ru.vagrant_ai.questionmarkgame.obj.particle.Knife;
import ru.vagrant_ai.questionmarkgame.obj.particle.LightSourceLow;
import ru.vagrant_ai.questionmarkgame.obj.particle.LightSourceMid;
import ru.vagrant_ai.questionmarkgame.obj.particle.LightSourceStrong;
import ru.vagrant_ai.questionmarkgame.obj.particle.LightSourceStrongAdd;
import ru.vagrant_ai.questionmarkgame.obj.particle.Lightning;
import ru.vagrant_ai.questionmarkgame.obj.particle.PoisonCloud;
import ru.vagrant_ai.questionmarkgame.obj.particle.PoisonEffect;
import ru.vagrant_ai.questionmarkgame.obj.particle.Smoke;
import ru.vagrant_ai.questionmarkgame.obj.particle.Thorn;
import ru.vagrant_ai.questionmarkgame.obj.particle.Wrench;
import ru.vagrant_ai.questionmarkgame.util.list.PT;

/*
* MAIN particle system
*/

public class Particle {
 
  public static List<ru.vagrant_ai.questionmarkgame.obj.particle.Particle>   particle_array = new ArrayList<ru.vagrant_ai.questionmarkgame.obj.particle.Particle>();
 
  public static void addNew(PT pt, int arg0)
  {
    ru.vagrant_ai.questionmarkgame.obj.particle.Particle particle = null;
    switch(pt)
    {
    case HPUP:
    case HPDOWN:
      particle = new HPParticle(pt, arg0);
      break;
    default:
      break;
   
    particle_array.add(particle);
  }
 
  public static void addNew(PT pt, int quantity, float x, float y)
  {
    ru.vagrant_ai.questionmarkgame.obj.particle.Particle particle = null;
    switch(pt)
    {
      case SMOKE:
        particle = new Smoke(quantity, x, y);
        break;
      case GUNSMOKE:
        particle = new Gunsmoke(quantity, (int)x, (int)y);
        break;
    default:
      break;
    }
    particle_array.add(particle);
  }
 
  public static void addNew(PT pt, int x, int x_center, int y, int y_center)
  {
    ru.vagrant_ai.questionmarkgame.obj.particle.Particle particle = null;
    switch(pt)
    {
      case LIGHTNING:
        particle = new Lightning(x, x_center, y, y_center);
        break;
      default:
        break;
    }
    particle_array.add(particle);
  }
 
  public static void addNew(PT pt, int x, int y)
  {
    ru.vagrant_ai.questionmarkgame.obj.particle.Particle particle = null;
    switch(pt)
    {
      case THORN:
        particle = new Thorn(x, y);
        break;
      case WRENCH:
        particle = new Wrench(x, y);
        break;
      case EXCLAMATION:
        particle = new Exclamation(x, y);
        break;
      case LIGHT_SOURCE_LOW:
        particle = new LightSourceLow(x, y);
        break;
      case LIGHT_SOURCE_MID:
        particle = new LightSourceMid(x, y);
        break;
      case LIGHT_SOURCE_STRONG:
        particle = new LightSourceStrong(x, y);
        break;
      case LIGHT_SOURCE_STRONG_ADD:
        particle = new LightSourceStrongAdd(x, y);
        break;
      case EXPLOSION:
        particle = new Explosion(x, y);
        break;
      case POISON_EFFECT:
        particle = new PoisonEffect(x, y);
        break;
      case POISON_CLOUD:
        particle = new PoisonCloud(x, y);
        break;
      case KNIFE:
        particle = new Knife(x, y);
      default:
        break;
    }
    particle_array.add(particle);
  }

  public static void update_and_render(Graphics g)
  {
    for (int i = 0; i < particle_array.size(); ++i)
    {
      ru.vagrant_ai.questionmarkgame.obj.particle.Particle particle = particle_array.get(i);
      if (particle.id == PT.THORN || particle.id == PT.LIGHT_SOURCE_LOW
        || particle.id == PT.LIGHT_SOURCE_MID || particle.id == PT.LIGHT_SOURCE_STRONG_ADD
        || particle.id == PT.EXPLOSION || particle.id == PT.POISON_CLOUD)
      {
        if (!GameplayState.gamePaused()) particle.update();
        if (!particle.alive) particle_array.remove(i);
        else particle.render(g);
      }
    }
  }
 
  public static void update_and_render_2nd_layer(Graphics g)
  {
    for (int i = 0; i < particle_array.size(); ++i)
    {
      ru.vagrant_ai.questionmarkgame.obj.particle.Particle particle = particle_array.get(i);
      if (particle.id == PT.LIGHT_SOURCE_STRONG)
      {
        if (!GameplayState.gamePaused()) particle.update();
        if (!particle.alive) particle_array.remove(i);
        else particle.render(g);
      }
    }
  }

  public static void update_and_render_3nd_layer(Graphics g)
  {
    for (int i = 0; i < particle_array.size(); ++i)
    {
      ru.vagrant_ai.questionmarkgame.obj.particle.Particle particle = particle_array.get(i);
      if (particle.id != PT.THORN && particle.id != PT.LIGHT_SOURCE_LOW
        && particle.id != PT.LIGHT_SOURCE_MID && particle.id != PT.LIGHT_SOURCE_STRONG
        && particle.id != PT.LIGHT_SOURCE_STRONG_ADD && particle.id != PT.EXPLOSION
        && particle.id != PT.POISON_CLOUD)
      {
        if (!GameplayState.gamePaused()) particle.update();
        if (!particle.alive) particle_array.remove(i);
        else particle.render(g);
      }
    }
  }

}
TOP

Related Classes of ru.vagrant_ai.questionmarkgame.util.Particle

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.