/// <summary> /// 处理添加单位 /// </summary> /// <param name="army"></param> private void processAddArmy(GameObject army) { OtherArmyCtrl otherArmyCtrl = army.gameObject.GetComponent <OtherArmyCtrl>(); //therArmyCtrl.Init(); otherArmyCtrl.ArmySelectDelegate = processOtherArmySelect; OtherArmyCtrlList.Add(otherArmyCtrl); ArmyList.Add(army); }
public List <IUnit> ConstructArmy(int money, string name) { Random random = new Random(); var infantryFactory = new InfantryFactory(); var knightFactory = new KnightFactory(); var archerFactory = new ArcherFactory(); var healerFactory = new HealerFactory(); var wizardFactory = new WizardFactory(); while (money > 0) { int character = random.Next(1, 6); if (character == 1) { if (money >= DefaultSettings.Infantry.Price) { var newUnit = infantryFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } else { break; } } else if (character == 2) { if (money >= DefaultSettings.Knight.Price) { var newUnit = knightFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } else { if (money >= DefaultSettings.Infantry.Price) { var newUnit = infantryFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } else { break; } } } else if (character == 3) { if (money >= DefaultSettings.Archer.Price) { var newUnit = archerFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } else { if (money >= DefaultSettings.Infantry.Price) { var newUnit = infantryFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } else { break; } } } else if (character == 4) { if (money >= DefaultSettings.Healer.Price) { var newUnit = healerFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } else if (money >= DefaultSettings.Archer.Price) { Random between = new Random(); if (between.Next(1, 11) % 2 == 0) { var newUnit = archerFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } else { var newUnit = knightFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } } else { if (money >= DefaultSettings.Infantry.Price) { var newUnit = infantryFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } else { break; } } } else { if (money >= DefaultSettings.Wizard.Price) { var newUnit = wizardFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } else if (money >= DefaultSettings.Healer.Price) { var newUnit = healerFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } else if (money >= DefaultSettings.Archer.Price) { Random between = new Random(); if (between.Next(1, 11) % 2 == 0) { var newUnit = archerFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } else { var newUnit = knightFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } } else { if (money >= DefaultSettings.Infantry.Price) { var newUnit = infantryFactory.CreateUnit(); ArmyList.Add(newUnit); money -= newUnit.Price; } else { break; } } } } return(ArmyList); }
public void AddArmy(Army army, Pos dest) { // create new army object ArmyList.Add(army); manager.AddArmy(army, dest); }
public void Push(IUnit unit) { ArmyList.Add(unit); }