Package spells

Source Code of spells.FireBall

package spells;

import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;

import physics.Vector2D;
import serverMessages.ClientEventOut;
import serverMessages.SpellCastEvent;
import units.Unit;
import Client.ClientGameState;
import Global_Package.Entity;
import Global_Package.Enums;
import Server.GameState;
import Server.UdpBroadCast;
import clientMessages.AlterSpell;
import clientMessages.NewSpell;
import effectsAndParticles.ParticleTest;

public class FireBall extends Projectile {
  private static final double moveForce=50;
  private static final double maxMoveSpeed=500;
  public ParticleTest particle;
  private static final double mass=0;
  public static final int type=Enums.basicTestSpell;
  private static final BufferedImage image=Enums.fireBall;
 
 
  public final static int castLimit=25;//casts per 30 seconds
  public FireBall(int ID, int OwnerID, double theta,Point2D initialLoc) {
    super(ID, OwnerID, type,mass , moveForce, maxMoveSpeed, initialLoc,castLimit,10);
    this.theta=theta;
    v=new Vector2D(Math.cos(theta),Math.sin(theta));
    //particle=new ParticleTest(initialLoc.getX(), initialLoc.getY(), Enums.smokeParticle, theta, type);
  }


 

  @Override
  public void render(Graphics2D g, ClientGameState game) {
    BufferedImage b=Enums.fireBall;
    System.out.println("ID from draw:"+ID);
    if(b==null)
      System.out.print("booooo");
    g.drawImage(b,(int) loc.getX()-b.getWidth(),(int)loc.getY()-b.getHeight(),b.getWidth(),b.getHeight(),null);
    //BufferedImage p=Enums.imageFromType(((FireBall) s).particle.type);
    //attempt some particle effects
//    for(int i=10;i<20;i+=7){
      //again just an attempt!
//      g.drawImage(p,(int) s.loc.getX()-i-p.getWidth(),(int) s.loc.getY()-i-p.getHeight(),p.getWidth()-11,p.getHeight()-11,null);
//      g.drawImage(p,(int) s.loc.getX()-i-p.getWidth(),(int) s.loc.getY()-p.getHeight(),p.getWidth()-11,p.getHeight()-11,null);
//      g.drawImage(p,(int) s.loc.getX()-p.getWidth(),(int) s.loc.getY()-p.getHeight(),p.getWidth()-11,p.getHeight()-11,null);
//    }
   
  }

  //oops?
  public void networkServerMessageOut(UdpBroadCast udp) {}
  public void onCollide(Entity u, GameState game) {
    // TODO Auto-generated method stub
   
 



  public void keyDown(KeyEvent e, ClientGameState game) {
    if (e.getKeyChar() == ' ') {
     
      networkClientMessageOut(game);
     
    }
   
  }

 


 
  public void alterSpell(int prop, int val) {
    // TODO Auto-generated method stub
   
  }

  @Override
  protected void mouseDown(Point2D e, ClientGameState game) {
    // TODO Auto-generated method stub
   
  }




  /**
   * return a version of class using data from NewSpell
   */
  public Spell newSpell(NewSpell s) {
    System.out.print("Fireball created with ID:"+s.ID);
    return new FireBall(s.ID,s.OwnerID,0,new Point2D.Double(s.x,s.y));
   
  }




  @Override
  public Spell newSpell(SpellCastEvent i, Unit u) {
    return new FireBall(i.ID,i.unitSource,i.theta,new Point2D.Double(u.getLoc().getX(),u.getLoc().getY()));
  }
}
TOP

Related Classes of spells.FireBall

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.