Exemplo n.º 1
0
    public void Resupply(ControlledDivision Host)
    {
        //find closest supply dump
        Func <TerrainMapTile, bool> findSupplyTile = tile => {
            return(tile.Supply > 100);
        };

        //UnityEngine.Profiling.Profiler.BeginSample("find supply");

        //find closest supply
        if (Host.TryFindKnownTileMatchingPred(findSupplyTile, out Vector3 foundPosition))
        {
            //Debug.Log($"resupply position : {foundPosition}");
            this.ReceiveOrder(Host, new Move(Host, Host.DivisionId, foundPosition));
            var supplyOrder = new GatherSuppliesOrder(Host, Host.DivisionId);
            // add the supply to Host
            Host.ReceiveOrder(supplyOrder);
            this.ReceiveOrder(Host, new WaitOrder(Host, Host.DivisionId, 2, x => {
                x.CancelOrder(supplyOrder.orderId);
            }));
        }
        else
        {
            RandomMove(Host);
        }

        //UnityEngine.Profiling.Profiler.EndSample();
    }
Exemplo n.º 2
0
    public void Recruit(ControlledDivision Host)
    {
        Func <TerrainMapTile, bool> findPopTile = tile => {
            return(tile.Population > 100);
        };

        //Debug.Log($"trying to recruit");
        //find closest populations
        if (Host.TryFindKnownTileMatchingPred(findPopTile, out Vector3 foundPosition))
        {
            //Debug.Log($"resupply position : {foundPosition}");
            this.ReceiveOrder(Host, new Move(Host, Host.DivisionId, foundPosition));
            // add the recruit to Host
            var recruitOrder = new RecruitOrder(Host, Host.DivisionId);
            Host.ReceiveOrder(recruitOrder);
            this.ReceiveOrder(Host, new WaitOrder(Host, Host.DivisionId, 2, x => {
                x.CancelOrder(recruitOrder.orderId);
            }));
        }
        else
        {
            RandomMove(Host);
        }
    }