Package spells

Source Code of spells.Spell

package spells;

import java.awt.geom.Point2D;

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

public abstract class Spell extends MovableEntity {
 
 
 
  protected final double moveForce;
  protected final double maxMoveSpeed;
  protected float timeout;
  public final int castLimit;
  public Spell(int ID, int OwnerID, int type,double mass,double moveForce,double maxMoveSpeed,Point2D initialLoc,int castlimit,float timeout) {
    super(ID, OwnerID,type,mass);
    //this.OwnerID = OwnerID;
    this.moveForce=moveForce;
    this.maxMoveSpeed=maxMoveSpeed;
    this.loc = initialLoc;
    this.v = new Vector2D();
    this.a = new Vector2D();
    this.timeout = timeout;
    this.castLimit=castlimit;
  }

 
  //public abstract void newSpell(NewSpell s, ClientGameState g);
  public abstract void alterSpell(int prop, int val);
 
  public void newSpell(NewSpell s, ClientGameState g) {
    //no inital theta if you need it its gotten after the first move spell(if its a moving spell)
    for(Entity e : Enums.effectiveMap.values()){
      if(e.checkType(type)){
        Spell s1=(Spell)e;
        g.getSpells().put(s.ID,s1.newSpell(s));
       
      }
    }
  }
 
  public abstract Spell newSpell (NewSpell s );
  public void networkClientMessageOut(ClientGameState game) {
    double direction = 0;
    try {
      direction =game.Player.getTheta();
      game.Sockets.pushSpellCast(type, game.Player.ID,0, 0,0, direction);
     
    } catch (Exception e1) {
      System.out.println("Error");
    }
   
  }
 
 
  public void networkServerMessageIn(ClientEventOut in,GameState g) {
    SpellCastEvent i=(SpellCastEvent)in;
    Unit u=g.getUnits().get(i.unitSource);
    if(u !=null){
      g.getSpells().put(i.ID,newSpell(i,  u));
      g.udp.newSpell(i.ID, i.unitSource, i.type, u.getLoc().getX(),u.getLoc().getY());
    }else{
     
    }
  }
 
  public abstract Spell newSpell (SpellCastEvent s ,Unit u);
  public void networkServerMessageOut(UdpBroadCast udp,double x, double y) {
    udp.moveSpell(ID, x, y);
  }
 
  public void remove(GameState g) {
    g.getSpells().remove(ID);
    g.udp.removeSpell(ID);
    System.out.print("removeSpell");
  }
}
TOP

Related Classes of spells.Spell

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.