Package battleTank

Examples of battleTank.SpikePit


    }
   
    for (int i = 0; i < model.getObstacles().size(); i++) {
      Obstacle p = model.getObstacles().get(i);
      if (p instanceof SpikePit) {// for instance of SpikePit
        SpikePit sp = (SpikePit) p;
        SpikePitRectangle spRect = sp.getRectangle();
        g.drawImage(spRect.getImage(), spRect.xCoord(),
            spRect.yCoord(), null);
      }
      if (p instanceof Crate) {// for instance of crate
        Crate c = (Crate) p;
View Full Code Here


           
          }
        }
        // SpikePit's can not kill the AI either for difficulty purposes
        if (obs instanceof SpikePit) {
          SpikePit c = (SpikePit) obs;
          if (rect.intersects(c.getRectangle())) {
            p.recieveDamage(1);
            notifyObservers();
            setChanged();
          }
        }
      }
      notifyObservers();
      setChanged();
    }
   
    // Whenever the EnemyTank moves this will check to see if it has collided with anything. Depeding
    // on the object it has collided with the proper action will occur.
   
    if (o instanceof PlayerTank) {
      PlayerTank p = (PlayerTank) o;
      TankRectangle rect = p.getRectangle();
      for (Item i : itemList) {
        // Only one BubbleShield can be active at a time
        if (i instanceof BubbleShield) {
          BubbleShield c = (BubbleShield) i;
          if (c.getRectangle().intersects(p.getRectangle())) {
            if (p.getHealth() == 1) {
              c.activateEffect(p);
            }
            itemList.remove(c);
            notifyObservers();
            setChanged();
            break;
          }
        }
        if (i instanceof SpeedBoost) {
          SpeedBoost c = (SpeedBoost) i;
          if (c.getRectangle().intersects(p.getRectangle())) {
            if(!p.isActiveBoost()) {
            c.activateEffect(p);
            }
            itemList.remove(c);
            notifyObservers();
            setChanged();
            break;
          }
        }
        if (i instanceof IceBlock) {
          IceBlock c = (IceBlock) i;
          if (c.getRectangle().intersects(p.getRectangle())) {
            c.activateEffect(p);
            itemList.remove(c);
            notifyObservers();
            setChanged();
            break;
          }
        }
      }
      for (Obstacle obs : obstacleList) {
        // The PlayerTank will push the crate if it is movable
        if (obs instanceof Crate) {
          Crate c = (Crate) obs;
          if (rect.intersects(c.getRectangle())) {
            c.move(tankList.getFirst().getDirection());
          }
        }
        // The PlayerTank will push the TNT if it is movable
        if (obs instanceof TNT) {
          TNT c = (TNT) obs;
          if (rect.intersects(c.getRectangle())) {
            c.move(tankList.getFirst().getDirection());
          }
        }
        // If the PlayerTank collides with a FireRing it will die
        if (obs instanceof FireRing) {
          FireRing c = (FireRing) obs;
          if (rect.intersects(c.getRectangle())) {
            notifyObservers(new Point(p.getLocation().row - 12, p.getLocation().col - 12));
            p.recieveDamage(1);
          }
        }
        // If the PlayerTank collides with a SpikePit it will die
        if (obs instanceof SpikePit) {
          SpikePit c = (SpikePit) obs;
          if (rect.intersects(c.getRectangle())) {
            notifyObservers(new Point(p.getLocation().row - 12, p.getLocation().col - 12));
            p.recieveDamage(1);
          }
        }
      }
       
      notifyObservers();
      setChanged();
        }
    if (o instanceof Crate) {
      Crate c = (Crate) o;
      c.recieveDamage(1);
    }

  }
View Full Code Here

TOP

Related Classes of battleTank.SpikePit

Copyright © 2018 www.massapicom. 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.