public void SetStats(BaseCombatData cd) { texts[1].Text = cd.AttackDamage + "/" + cd.CriticalDamage; texts[3].Text = cd.MinRange + "-" + cd.MaxRange; texts[5].Text = cd.AttackTimer.ToString(); texts[7].Text = cd.Armor.ToString(); texts[9].Text = (cd.CriticalChance * 100f) + "%"; }
public static RTSUnitData Deserialize(BinaryReader s, GameState state, int index) { RTSUnitData data = new RTSUnitData(index); data.FriendlyName = s.ReadString(); data.InfoFile = s.ReadString(); data.Health = s.ReadInt32(); data.CapitalCost = s.ReadInt32(); data.PopulationCost = s.ReadInt32(); data.MaxCount = s.ReadInt32(); data.MovementSpeed = s.ReadSingle(); data.Impact = s.ReadInt32(); data.BuildTime = s.ReadInt32(); data.CarryingCapacity = s.ReadInt32(); data.IsWorker = s.ReadBoolean(); BaseCombatData.Deserialize(s, data.BaseCombatData); CollisionType ct = (CollisionType)s.ReadInt32(); Vector2 cc = s.ReadVector2(); bool cs = s.ReadBoolean(); switch (ct) { case CollisionType.Circle: float cr = s.ReadSingle(); data.ICollidableShape = new CollisionCircle(cr, cc, cs); break; case CollisionType.Rectangle: float cw = s.ReadSingle(); float cd = s.ReadSingle(); data.ICollidableShape = new CollisionRect(cw, cd, cc, cs); break; default: throw new Exception("Nonexistent Collision Type"); } data.BBox.Min = s.ReadVector3(); data.BBox.Max = s.ReadVector3(); data.DefaultActionController = state.Scripts[s.ReadString()]; data.DefaultCombatController = state.Scripts[s.ReadString()]; data.DefaultMoveController = state.Scripts[s.ReadString()]; data.DefaultAnimationController = state.Scripts[s.ReadString()]; return(data); }
public static void Serialize(BinaryWriter s, RTSUnitData data) { s.Write(data.FriendlyName); s.Write(data.InfoFile); s.Write(data.Health); s.Write(data.CapitalCost); s.Write(data.PopulationCost); s.Write(data.MaxCount); s.Write(data.MovementSpeed); s.Write(data.Impact); s.Write(data.BuildTime); s.Write(data.CarryingCapacity); s.Write(data.IsWorker); BaseCombatData.Serialize(s, data.BaseCombatData); s.Write((int)data.ICollidableShape.CollisionType); s.Write(data.ICollidableShape.Center); s.Write(data.ICollidableShape.IsStatic); switch (data.ICollidableShape.CollisionType) { case CollisionType.Circle: var cc = data.ICollidableShape as CollisionCircle; s.Write(cc.Radius); break; case CollisionType.Rectangle: var cr = data.ICollidableShape as CollisionRect; s.Write(cr.Width); s.Write(cr.Depth); break; } s.Write(data.BBox.Min); s.Write(data.BBox.Max); s.Write(data.DefaultActionController.TypeName); s.Write(data.DefaultCombatController.TypeName); s.Write(data.DefaultMoveController.TypeName); s.Write(data.DefaultAnimationController.TypeName); }