Esempio n. 1
0
        // perspectives: 0 = Show all, 1 = player's owngrid, 2 = player's enemygrid
        public CellStruct GetCellStruct(CellPerspective perspective)
        {
            //Default values
            CBldg bldg      = CBldg.hidden;
            bool  ded       = false;
            bool  dgb       = false;  //defenceGridBlock
            bool  mole      = false;
            int   mcnt      = 0;      // mole count
            bool  defect    = false;
            bool  lastHit   = false;
            bool  scouted   = false;
            bool  reflected = false;

            if (perspective == CellPerspective.All)               // Show everything as is
            {
                bldg      = this.bldg;
                ded       = this.destroyed;
                dgb       = this.defenceGridBlock;
                mole      = this.mole;
                mcnt      = mole ? this.molecount : 0;
                defect    = this.defected;
                lastHit   = this.lastHit;
                scouted   = this.scouted;
                reflected = this.reflected;
            }
            else if (perspective == CellPerspective.PlayersOwn)              // Show player's view
            {
                bldg      = this.bldg;
                ded       = this.destroyed;
                dgb       = this.defenceGridBlock;
                defect    = this.defected;
                lastHit   = this.lastHit;
                reflected = this.reflected;
            }
            else if (perspective == CellPerspective.PlayersEnemy)              // perspective 2 enemy's grid
            {
                if (this.vis || this.scouted)
                {
                    bldg      = this.bldg;
                    ded       = this.destroyed;
                    lastHit   = this.lastHit;
                    reflected = this.reflected;
                }
                scouted = this.scouted;
                dgb     = this.defenceGridBlock;             //always show these
                mole    = this.mole;
                mcnt    = mole ? this.molecount : 0;
                defect  = this.defected;
            }
            else
            {
                Debug.LogError("Big ol Warning! GetCellStruct unhandled perspective: " + perspective.ToString());
            }
            return(new CellStruct(bldg, ded, dgb, mole, mcnt, defect, lastHit, scouted, reflected));
        }
Esempio n. 2
0
 ////////////////////////Helper functions for game logic
 //Get specific side of grid (indexed by playerID)
 CellStruct[,] GetGridSide(int idx, CellPerspective perspective)
 {
     CellStruct [,] gridOut = new CellStruct[sizex, sizey];
     for (int x = 0; x < this.sizex; x++)
     {
         for (int y = 0; y < this.sizey; y++)
         {
             gridOut[x, y] = cells[idx][x, y].GetCellStruct(perspective);
         }
     }
     return(gridOut);
 }
Esempio n. 3
0
        //Used to help our randomizer functions that don't want to hit
        List <Vector2> GetLocsOfBldgs(int p, List <CBldg> bldgs, CellPerspective perspective, bool negate = false)
        {
            List <Vector2> ret = new List <Vector2>();

            foreach (Cell c in this.cells[p])
            {
                if (!negate)                 // I think I can simplify this logic...
                {
                    if (bldgs.Contains(c.GetCellStruct(perspective).bldg))
                    {
                        ret.Add(c.loc);
                    }
                }
                else
                {
                    if (!bldgs.Contains(c.GetCellStruct(perspective).bldg))
                    {
                        ret.Add(c.loc);
                    }
                }
            }
            return(ret);
        }