コード例 #1
0
        public override string Execute()
        {
            IUnit unit = factory.CreateUnit(Data[1]);

            repository.AddUnit(unit);
            return($"{this.Data[1]} added!");
        }
コード例 #2
0
 public void CreateArmy(IUnitFactory factory)
 {
     while (this.Money > 0)
     {
         var unit = factory.CreateUnit(this.Money);
         this.Money -= unit.Cost;
     }
 }
コード例 #3
0
        public override string Execute()
        {
            string unitType = Data[1];
            var    unit     = unitFactory.CreateUnit(unitType);

            repository.AddUnit(unit);
            return($"{unitType} added!");
        }
コード例 #4
0
        public override string Execute()
        {
            string unitType  = Data[1];
            IUnit  unitToAdd = factory.CreateUnit(unitType);

            repository.AddUnit(unitToAdd);
            string output = unitType + " added!";

            return(output);
        }
コード例 #5
0
    private void InitLevel()
    {
        var hqRed = new HeadQuartes(false);

        hqRed.SetFactory(_tankFactory);
        hqRed.UnitPrefab = _tankPrefab;
        hqRed.Prefab     = _hqRedPrefab;
        _buildings.Add(hqRed);
        _hqRed.Building = hqRed;
        AddUnit((IUnit)hqRed);

        var hqBlue = new HeadQuartes(true);

        hqBlue.SetFactory(_tankFactory);
        hqBlue.UnitPrefab = _tankPrefab;
        hqBlue.Prefab     = _hqBluePrefab;
        _buildings.Add(hqBlue);
        _hqBlue.Building = hqBlue;
        AddUnit((IUnit)hqBlue);

        var barracksRed = new Barracks(false);

        barracksRed.SetFactory(_soliderFactory);
        barracksRed.UnitPrefab = _soliderPrefab;
        barracksRed.Prefab     = _barracksRedPrefab;
        _buildings.Add(barracksRed);
        _barracksRed.Building = barracksRed;
        AddUnit((IUnit)barracksRed);

        var barracksBlue = new Barracks(true);

        barracksBlue.SetFactory(_soliderFactory);
        barracksBlue.UnitPrefab = _soliderPrefab;
        barracksBlue.Prefab     = _barracksBluePrefab;
        _buildings.Add(barracksBlue);
        _barracksBlue.Building = barracksBlue;
        AddUnit((IUnit)barracksBlue);


        var newTank = _tankFactory.CreateUnit(-9, -15, _tankPrefab, true);

        AddUnit(newTank);

        newTank = _tankFactory.CreateUnit(-8, -17, _tankPrefab, true);
        AddUnit(newTank);

        newTank = _tankFactory.CreateUnit(-8.5f, -13, _tankPrefab, true);
        AddUnit(newTank);

        var newSolider = _soliderFactory.CreateUnit(-8f, -15, _soliderPrefab, true);

        AddUnit(newSolider);

        newSolider = _soliderFactory.CreateUnit(-5.5f, -15, _soliderPrefab, true);
        AddUnit(newSolider);

        newSolider = _soliderFactory.CreateUnit(-5.5f, -3, _soliderPrefab, false);
        AddUnit(newSolider);

        newSolider = _soliderFactory.CreateUnit(-5.5f, -2, _soliderPrefab, false);
        AddUnit(newSolider);

        newSolider = _soliderFactory.CreateUnit(-5.5f, -1, _soliderPrefab, false);
        AddUnit(newSolider);

        newSolider = _soliderFactory.CreateUnit(-5.5f, -1, _soliderPrefab, false);
        AddUnit(newSolider);

        newSolider = _soliderFactory.CreateUnit(-4.5f, -1, _soliderPrefab, false);
        AddUnit(newSolider);

        newSolider = _soliderFactory.CreateUnit(-3.5f, -1, _soliderPrefab, false);
        AddUnit(newSolider);

        newSolider = _soliderFactory.CreateUnit(-2.5f, -1, _soliderPrefab, false);
        AddUnit(newSolider);

        newSolider = _soliderFactory.CreateUnit(-2.5f, -8, _soliderPrefab, false);
        AddUnit(newSolider);

        newSolider = _soliderFactory.CreateUnit(-6.5f, -1, _soliderPrefab, false);
        AddUnit(newSolider);

        newTank = _tankFactory.CreateUnit(-1.5f, -4, _tankPrefab, false);
        AddUnit(newTank);

        newSolider = _soliderFactory.CreateUnit(0f, 1, _soliderPrefab, false);
        AddUnit(newSolider);

        newTank = _tankFactory.CreateUnit(-1.5f, -0, _tankPrefab, false);
        AddUnit(newTank);
    }