Esempio n. 1
0
 private void displayAllResourceCount()
 {
     if (gameState == null)
     {
         Debug.Log("Null game state");
     }
     foreach (ResourceType rt in gameState.getAllResourceTypes())
     {
         this.resourceDisplay.updateResourceCount(rt, gameState.getStockpile(rt));
     }
 }
Esempio n. 2
0
 private void updateAiResourceDisplay()
 {
     Debug.Log("Updating ai resource display");
     Debug.Log(bank + ", " + stone + ", " + wood + ", " + silver);
     foreach (ResourceType rt in aiCurrentGameState.getAllResourceTypes())
     {
         //Debug.Log("update: " + rt + ", " + aiCurrentGameState.getStockpile(rt));
         aiResourceDisplay.updateCountAndRPT(rt, aiCurrentGameState.getStockpile(rt), aiCurrentGameState.getChangePerTick(rt));
     }
     aiResourceDisplay.updateWorkers();
 }
Esempio n. 3
0
    private void updateTargetDisplay(BuildingGS gameState, int indexActor)
    {
        Debug.Log("actor to update target display: " + indexActor);
        ResourceDisplayController rdc = meTargetDisplay;

        if (indexActor == indexAi)
        {
            rdc = aiTargetDisplay;
        }
        foreach (ResourceType rt in gameState.getAllResourceTypes())
        {
            rdc.updateCountAndRPT(rt, gameState.getStockpile(rt), gameState.getChangePerTick(rt));
        }
    }
Esempio n. 4
0
    private bool isTargetReached(int indexActor)
    {
        BuildingGS gsToCheck = GameController.gameState;

        if (indexActor == indexAi)
        {
            gsToCheck = aiCurrentGameState;
        }
        BuildingGS targetGs = targetGameStates[currentTargetGsIndex[indexActor]];

        foreach (ResourceType rt in gsToCheck.getAllResourceTypes())
        {
            if ((gsToCheck.getStockpile(rt) < targetGs.getStockpile(rt)) ||
                (gsToCheck.getChangePerTick(rt) < targetGs.getChangePerTick(rt)))
            {
                return(false);
            }
        }
        Debug.Log("Target reached for : " + indexActor);
        return(true);
    }
Esempio n. 5
0
    public static RemainingDistance estematedRemainingDistance(BuildingGS currentGS, BuildingGS targetGS)
    {
        // How far away are we from the target?
        RemainingDistance result = new RemainingDistance();

        // Compare numerical distance
        foreach (ResourceType rt in targetGS.getAllResourceTypes())
        {
            int currentStockpile = currentGS.getStockpile(rt);
            int targetStockpile  = targetGS.getStockpile(rt);
            int stockpileDelta   = Mathf.Max(0, targetStockpile - currentStockpile);
            result.updateStockpileDelta(stockpileDelta);


            int currentResourcePerTick = currentGS.getChangePerTick(rt);
            int targetResourcePerTick  = targetGS.getChangePerTick(rt);
            int rptDelta = Mathf.Max(0, targetResourcePerTick - currentResourcePerTick);
            result.updateCPTDelta(rt, rptDelta);

            int currentBestResourcePerTick = currentGS.getBestPossibleChangePerTick(rt);
            int bestPossibleRPTDelta       = Mathf.Max(0, targetResourcePerTick - currentBestResourcePerTick);
            result.updateBestPossibleCPTDelta(bestPossibleRPTDelta);

            if (currentResourcePerTick <= 0)
            {
                result.addInfinity();
            }
            else
            {
                float exactWaitTime = stockpileDelta / (float)currentResourcePerTick;
                int   estWaitTime   = (int)(exactWaitTime + 0.5f);
                result.updateWaitTime(estWaitTime);

                float bestPossibleWaitTime = stockpileDelta / (float)currentBestResourcePerTick;
                int   estBestWaitTime      = (int)(bestPossibleWaitTime + 0.5f);
                result.updateBestPossibleWaitTime(estBestWaitTime);
            }
        }
        return(result);
    }