Exemple #1
0
        public void TakeBuildingBase(int originX, int originY)
        {
            if (m_gameField == null)
            {
                m_gameField = FindObjectOfType <GameFieldInitialization>();
            }
            m_takenBuildBases = new BuildingBaseBehaviour[buildingSize[0] * buildingSize[1]];
            BuildingBaseBehaviour[,] bases = m_gameField.GetBuildingBases();
            for (int i = 0; i < buildingSize[0]; i++)
            {
                for (int j = 0; j < buildingSize[1]; j++)
                {
                    bases[originX + i, originY + j].GainBuilding(gameObject);
                    m_takenBuildBases[m_useBaseCount] = bases[originX + i, originY + j];
                    m_useBaseCount++;
                }
            }
            float offsetX = (float)(buildingSize[0] / 2.0 - 0.5);
            float offsetY = (float)(buildingSize[1] / 2.0 - 0.5);

            gameObject.transform.position += new Vector3(offsetX, 0, offsetY);
        }
Exemple #2
0
 public bool CheckForBuild(int originX, int originY)
 {
     if (m_gameField == null)
     {
         m_gameField = FindObjectOfType <GameFieldInitialization>();
     }
     int[] fieldSize = m_gameField.GetFieldSize();
     BuildingBaseBehaviour[,] bases = m_gameField.GetBuildingBases();
     for (int i = 0; i < buildingSize[0]; i++)
     {
         for (int j = 0; j < buildingSize[1]; j++)
         {
             if (originX + i >= fieldSize[0] || originY + j >= fieldSize[1])
             {
                 return(false);
             }
             if (!bases[originX + i, originY + j].IsAvailable())
             {
                 return(false);
             }
         }
     }
     return(true);
 }