Esempio n. 1
0
    public void UpdateBar(FactionProgress fp, CellStruct[,] playerState, CellStruct[,] enemyState)
    {
        int boardCount = GUtils.Serialize(playerState).Count(cell => cell.bldg == this.displayBldg && !cell.destroyed && !cell.defected);    //count all friendly spaces not taken over

        boardCount         += GUtils.Serialize(enemyState).Count(cell => cell.bldg == this.displayBldg && !cell.destroyed && cell.defected); //count all enemy spaces taken over
        this.countText.text = boardCount.ToString();
        //Fill the bar based on total progress
        int count = fp.GetProgress(this.faction);

        this.fill.fillAmount = (float)count / this.maxInterval;
    }
Esempio n. 2
0
    //Called by logic core after eval actions
    //Called by pcobj on start
    public void ReportGridState(int p)
    {
        Debug.Log("Reporting Grid states to player '" + p + "'");
        CellStruct[][,] state = this.PB.GetPlayerGameState(p, false);
        CellStruct[]       pOwnGrid   = GUtils.Serialize(state[0]);
        CellStruct[]       pOtherGrid = GUtils.Serialize(state[1]);
        List <ActionAvail> aaList     = this.PB.GetActionAvailable(p);

        int[]      factionProgress = this.PB.GetFactionProgress(p).GetArray();
        Vector2 [] capitolLocs     = this.PB.capitolTowerLocs[p].ToArray();
        int[]      gridSize        = new int[] { sizex, sizey };
        bool       hitSunk         = this.PB.hitSunk[p]; // Player's last actions sunk one or more enemy ships

        ActionReq[]   lastActions = this.PB.GetLastActions(p).ToArray();
        GameBoardInfo gbi         = new GameBoardInfo(pOwnGrid, pOtherGrid, gridSize, aaList.ToArray(), factionProgress, capitolLocs, hitSunk, lastActions);

        this.mnm.playerSlots[p].RpcUpdatePlayBoard(gbi);
    }
Esempio n. 3
0
        //Get list of actions that can be used based on the current game state
        List <pAction> CheckCostsMet(CellStruct[][,] gState)
        {
            Dictionary <Faction, int> curProg = new Dictionary <Faction, int>();           // Current progress based on this game state

            foreach (Faction f in factionBldgMap.Keys)
            {
                int count = GUtils.Serialize(gState[0]).Count(cell => cell.bldg == factionBldgMap[f] && !cell.destroyed && !cell.defected);
                count += GUtils.Serialize(gState[1]).Count(cell => cell.bldg == factionBldgMap[f] && !cell.destroyed && cell.defected);
                curProg.Add(f, count);
            }
            this.factionProgress.UpdateProgress(curProg);
            List <pAction> retList = new List <pAction>();

            foreach (pAction action in actionParams.Keys)
            {
                ActionParam apm = actionParams[action];
                if (apm.enabled && this.factionProgress.GetProgress(apm.faction) >= apm.factionCost)
                {
                    retList.Add(action);
                }
            }
            return(retList);
        }