예제 #1
0
        public void CreateFog(char first, char second)
        {
            fog = new FogSquare[GRID_HEIGHT, GRID_WIDTH];

            for (int row = 0; row < GRID_HEIGHT; row++)
            {
                for (int column = 0; column < GRID_WIDTH; column++)
                {
                    GameObject fogGameObject = Instantiate(Resources.Load("Prefabs/fog") as GameObject);
                    FogSquare  fogSquare     = fogGameObject.AddComponent <FogSquare>();
                    fogSquare.Initialize(this, column, -row, -7);
                    fog[column, row] = fogSquare;
                }
            }

            if (second == ' ')
            {
                RemoveFog(first);
            }
            else
            {
                RemoveFog(first);
                RemoveFog(second);
            }
        }
예제 #2
0
        public override void SaveFog()
        {
            string writeFile     = Directory.GetCurrentDirectory() + "\\Assets\\Resources\\BoardTxtFiles\\FogS.txt";
            string stringToWrite = "";

            for (int row = 0; row < GRID_HEIGHT; row++)
            {
                stringToWrite += "\n";
                for (int column = 0; column < GRID_WIDTH; column++)
                {
                    FogSquare square = fog[column, row];
                    if (square.isActiveAndEnabled)
                    {
                        stringToWrite += '.';
                    }
                    else
                    {
                        stringToWrite += 'w';
                    }
                }
            }
            File.WriteAllText(writeFile, string.Empty);
            File.WriteAllText(writeFile, stringToWrite);
        }