public override string ToString() { if (Head == null || Torso == null || Arm.Count < 2 || Leg.Count < 2) { return("Weneed more parts!"); } long totalEnergy = 0L; totalEnergy += Head.Energy; totalEnergy += Torso.Energy; totalEnergy += Arm.Select(a => a.Energy).Sum(); totalEnergy += Leg.Select(a => a.Energy).Sum(); if (totalEnergy > Energy) { return(""); } return(base.ToString()); }
public void AddArm(Arm arm) { if (Arm == null) { Arm = new List <Arm>(); } if (Arm.Count < 2) { Arm.Add(arm); } else { for (int i = 0; i < this.Arm.Count; i++) { if (Arm[i].Energy > arm.Energy) { Arm.RemoveAt(i); Arm.Add(arm); } } } }