Examples of TNT


Examples of battleTank.TNT

            rect.yCoord(), null);
      }
     

      if (p instanceof TNT) {// for instance of TNT
        TNT tnt = (TNT) p;
        TNTRectangle tntRect = tnt.getRectangle();
        g.drawImage(tntRect.getImage(), tntRect.xCoord(),
            tntRect.yCoord(), null);
     
      }
View Full Code Here

Examples of battleTank.TNT

         
          // TNT's are destroyed when a projectile collides with them, they also create a blast radius
          // that will cause any object somewhat near the exploded TNT to take damage
         
          if (obs instanceof TNT) {
            TNT c = (TNT) obs;
            if (c.getRectangle().intersects(p.getRectangle())) {
              p.collided();
              projectileList.remove(p);
              c.recieveDamage(p.getDamage());
              notifyObservers(new Point(p.getLocation().row - 12, p.getLocation().col - 12));
              setChanged();
              break;
            }
          }
         
          //ImmovableBlock's can not be destroyed. If a projectile collides with one, the projectile is removed.
         
          if (obs instanceof ImmovableBlock) {
            ImmovableBlock c = (ImmovableBlock) obs;
            if (c.getRectangle().intersects(p.getRectangle())) {
              p.collided();
              projectileList.remove(p);
              c.recieveDamage(p.getDamage());
              notifyObservers(new Point(p.getLocation().row - 12, p.getLocation().col - 12));
              setChanged();
              break;

            }
          }

          //FireRing's can not be destroyed. If a projectile collides with one, the projectile is removed.
         
          if (obs instanceof FireRing) {
            FireRing c = (FireRing) obs;
            if (c.getRectangle().intersects(p.getRectangle())) {
              p.collided();
              projectileList.remove(p);
              c.recieveDamage(p.getDamage());
              notifyObservers(new Point(p.getLocation().row - 12, p.getLocation().col - 12));
              setChanged();
              break;

            }
          }

        }

        notifyObservers();
        setChanged();
      }
    }
   
    // Adds the created EnemyProjectile to the map whenever the enemy's shoot method is called. If there is
    // already a EnemyProjectile on the map this will keep track of that projectile's location and will determine
    // whether or not it has collided with any objects.
   
    if (o instanceof EnemyProjectile) {
      EnemyProjectile p = (EnemyProjectile) o;

      if (!projectileList.contains(p)) {
        projectileList.add(p);
        p.addObserver(this);
        notifyObservers();
        setChanged();
      } else {
       
        // The xCoord will be set to -1 when the Projectile goes off the screen. This will make sure it is properly removed from the map.
       
        if (p.getRectangle().xCoord() <= 0) {
          projectileList.remove(p);
          notifyObservers();
          setChanged();
        }
       
        // The projectile will destroy any item it collides with
       
        for (Item i : itemList) {
          if (i instanceof BubbleShield) {
            BubbleShield c = (BubbleShield) i;
            if (c.getRectangle().intersects(p.getRectangle())) {
              p.collided();
              projectileList.remove(p);
              itemList.remove(c);
              notifyObservers(new Point(c.getLocation().row - 12, c.getLocation().col - 12));
              setChanged();
              break;
            }
          }
          if (i instanceof IceBlock) {
            IceBlock c = (IceBlock) i;
            if (c.getRectangle().intersects(p.getRectangle())) {
              p.collided();
              projectileList.remove(p);
              itemList.remove(c);
              notifyObservers(new Point(c.getLocation().row - 12, c.getLocation().col - 12));
              setChanged();
              break;
            }
          }
          if (i instanceof SpeedBoost) {
            SpeedBoost c = (SpeedBoost) i;
            if (c.getRectangle().intersects(p.getRectangle())) {
              p.collided();
              projectileList.remove(p);
              itemList.remove(c);
              notifyObservers(new Point(c.getLocation().row - 12, c.getLocation().col - 12));
              setChanged();
              break;
            }
          }
        }
       
        //Removes the PlayerTank if it is hit by the EnemyTank's projectile
       
        for (PlayerTank h : tankList) {
          if (h.getRectangle().intersects(p.getRectangle())) {
            p.collided();
            projectileList.remove(p);
            notifyObservers(new Point(h.getLocation().row - 12, h.getLocation().col - 12));
            setChanged();
            h.recieveDamage(p.getDamage());
            break;
          }
        }

        for (Obstacle obs : obstacleList) {
         
          // Crate's are destroyed when a projectile collides with them
         
          if (obs instanceof Crate) {
            Crate c = (Crate) obs;
            if (c.getRectangle().intersects(p.getRectangle())) {
              p.collided();
              projectileList.remove(p);
              notifyObservers(new Point(c.getLocation().row - 12, c.getLocation().col - 12));
              setChanged();
              c.recieveDamage(p.getDamage());
              break;
            }
          }
         
          // TNT's are destroyed when a projectile collides with them, they also create a blast radius
          // that will cause any object somewhat near the exploded TNT to take damage
         
          if (obs instanceof TNT) {
            TNT c = (TNT) obs;
            if (c.getRectangle().intersects(p.getRectangle())) {
              p.collided();
              projectileList.remove(p);
              notifyObservers(new Point(c.getLocation().row - 12, c.getLocation().col - 12));
              setChanged();
              c.recieveDamage(p.getDamage());
              break;
            }
          }
         
          // ImmovableBlock's can not be destroyed. If a projectile collides with one, the projectile is removed.
         
          if (obs instanceof ImmovableBlock) {
            ImmovableBlock c = (ImmovableBlock) obs;
            if (c.getRectangle().intersects(p.getRectangle())) {
              p.collided();
              projectileList.remove(p);
              c.recieveDamage(p.getDamage());
              notifyObservers(new Point(p.getLocation().row - 12, p.getLocation().col - 12));
              setChanged();
              break;

            }
          }
         
          //FireRing's can not be destroyed. If a projectile collides with one, the projectile is removed.
         
          if (obs instanceof FireRing) {
            FireRing c = (FireRing) obs;
            if (c.getRectangle().intersects(p.getRectangle())) {
              p.collided();
              projectileList.remove(p);
              c.recieveDamage(p.getDamage());
              notifyObservers(new Point(p.getLocation().row - 12, p.getLocation().col - 12));
              setChanged();
              break;

            }
          }

        }

        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 EnemyTank) {
      EnemyTank p = (EnemyTank) o;
      TankRectangle rect = p.getRectangle();
     
      // When the EnemyTank collides with an item it will activate the item's effect on that EnemyTank
     
      for (Item i : itemList) {
        if (i instanceof BubbleShield) {
          BubbleShield c = (BubbleShield) i;
          if (c.getRectangle().intersects(p.getRectangle())) {
            // Can not have more than one BubbleShield active at a time
            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())) {
            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) {
        // This tank will push the crate if the crate is movable
        if (obs instanceof Crate) {
          Crate c = (Crate) obs;
          if (rect.intersects(c.getRectangle())) {
            c.move(tankList.getFirst().getDirection());
          }
        }
        // This tank will push the TNT if the TNT is movable
        if (obs instanceof TNT) {
          TNT c = (TNT) obs;
          if (rect.intersects(c.getRectangle())) {
            c.move(tankList.getFirst().getDirection());
          }
        }
        // FireRing's can not kill the AI for difficulty purposes
        if (obs instanceof FireRing) {
          FireRing c = (FireRing) obs;
          if (rect.intersects(c.getRectangle())) {
            p.recieveDamage(1);
            notifyObservers();
            setChanged();
           
          }
        }
        // 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

Examples of org.spout.vanilla.component.entity.substance.Tnt

  @Override
  public void onIgnite(Block block, Cause<?> cause) {
    // spawn a primed TntBlock
    Point pos = block.getPosition();
    World world = pos.getWorld();
    Tnt tnt = world.createEntity(pos, Tnt.class).add(Tnt.class);
    world.spawnEntity(tnt.getOwner());
    block.setMaterial(VanillaMaterials.AIR, cause);
  }
View Full Code Here

Examples of org.spout.vanilla.component.entity.substance.Tnt

    Block facingBlock = block.translate(this.getFacing(block));
    if (item.getMaterial().equals(VanillaMaterials.TNT)) {
      //Place Activated TNT entity at direction of Dispenser
      if (facingBlock.getMaterial().getShape() != null) {
        World world = facingBlock.getWorld();
        Tnt tnt = world.createEntity(facingBlock.getPosition(), Tnt.class).add(Tnt.class);
        tnt.getOwner().getPhysics().force(new Vector3f(0.5D, 0.5D, 0.5D));
        world.spawnEntity(tnt.getOwner());
        slot.addAmount(-1);
        return true;
      }
    } else if (item.getMaterial() instanceof SpawnEgg) {
      if (facingBlock.getMaterial().getShape() != null) {
View Full Code Here
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.