AddUnit() 공개 메소드

public AddUnit ( int type, Vector2 pos ) : RTSUnit
type int
pos Vector2
리턴 RTSUnit
예제 #1
0
파일: RTSUnit.cs 프로젝트: Antr0py/VoxelRTS
        public static RTSUnit Deserialize(BinaryReader s, RTSTeam team, out int?target)
        {
            int     type = s.ReadInt32();
            RTSUnit e    = team.AddUnit(type, Vector2.Zero);

            if (e == null)
            {
                throw new Exception("Could Not Create A Unit That Was Previously Created");
            }
            e.UUID          = s.ReadInt32();
            e.State         = s.ReadInt32();
            e.ViewDirection = s.ReadVector2();
            e.GridPosition  = s.ReadVector2();
            e.Height        = s.ReadSingle();
            if (s.ReadBoolean())
            {
                target = s.ReadInt32();
            }
            else
            {
                target = null;
            }
            e.Health             = s.ReadInt32();
            e.MovementMultiplier = s.ReadSingle();
            e.Resources          = s.ReadInt32();
            if (s.ReadBoolean())
            {
                if (e.ActionController != null)
                {
                    e.ActionController.Deserialize(s);
                }
            }
            else
            {
                e.ActionController = null;
            }
            if (s.ReadBoolean())
            {
                if (e.CombatController != null)
                {
                    e.CombatController.Deserialize(s);
                }
            }
            else
            {
                e.CombatController = null;
            }
            if (s.ReadBoolean())
            {
                if (e.MovementController != null)
                {
                    e.MovementController.Deserialize(s);
                }
            }
            else
            {
                e.MovementController = null;
            }
            if (s.ReadBoolean())
            {
                if (e.AnimationController != null)
                {
                    e.AnimationController.Deserialize(s);
                }
            }
            else
            {
                e.AnimationController = null;
            }
            return(e);
        }
예제 #2
0
 public static RTSUnit Deserialize(BinaryReader s, RTSTeam team, out int? target)
 {
     int type = s.ReadInt32();
     RTSUnit e = team.AddUnit(type, Vector2.Zero);
     if(e == null) throw new Exception("Could Not Create A Unit That Was Previously Created");
     e.UUID = s.ReadInt32();
     e.State = s.ReadInt32();
     e.ViewDirection = s.ReadVector2();
     e.GridPosition = s.ReadVector2();
     e.Height = s.ReadSingle();
     if(s.ReadBoolean()) {
         target = s.ReadInt32();
     }
     else {
         target = null;
     }
     e.Health = s.ReadInt32();
     e.MovementMultiplier = s.ReadSingle();
     e.Resources = s.ReadInt32();
     if(s.ReadBoolean()) {
         if(e.ActionController != null) e.ActionController.Deserialize(s);
     }
     else {
         e.ActionController = null;
     }
     if(s.ReadBoolean()) {
         if(e.CombatController != null) e.CombatController.Deserialize(s);
     }
     else {
         e.CombatController = null;
     }
     if(s.ReadBoolean()) {
         if(e.MovementController != null) e.MovementController.Deserialize(s);
     }
     else {
         e.MovementController = null;
     }
     if(s.ReadBoolean()) {
         if(e.AnimationController != null) e.AnimationController.Deserialize(s);
     }
     else {
         e.AnimationController = null;
     }
     return e;
 }