コード例 #1
0
ファイル: UnitFactory.cs プロジェクト: simooo93/Exams
        public static IUnit Create(UnitType type, string name, int x, int y, IEnumerable<IUnit> targets )
        {
            IUnit character;
            switch (type)
            {
                case UnitType.Warrior:
                    character = new Warrior(x, y, name, new WarriorCombatHandler(targets));
                    character.CombatHandler.Unit = character;
                    break;
                    case UnitType.Mage:
                    character = new Mage(x, y, name, new MageCombatHandler(targets));
                    character.CombatHandler.Unit = character;
                    break;
                    case UnitType.IceGiant:
                    character = new IceGiant(x, y, name, new IceGiantCombatHandler(targets));
                    character.CombatHandler.Unit = character;
                    break;
                default:
                    throw new GameException("There is no such unit");

            }

            return character;
        }
コード例 #2
0
 public MageCombatHandler(Mage mage)
 {
     this.Unit = mage;
 }