Пример #1
0
 public CharacterState(CharacterState other)
 {
     Position       = other.Position;
     BombFuze       = other.BombFuze;
     BombRadius     = other.BombRadius;
     Bomb           = other.Bomb != null ? new BombState(other.Bomb) : null;
     DestroyedWalls = other.DestroyedWalls;
 }
Пример #2
0
 public CharacterState(Vector2Int position, float bombFuze, float bombRadius, BombState bomb)
 {
     Position       = position;
     BombFuze       = bombFuze;
     BombRadius     = bombRadius;
     Bomb           = bomb;
     DestroyedWalls = 0;
 }
 public BombState(BombState other)
 {
     RemainingFuze = other.RemainingFuze;
     Radius        = other.Radius;
     Position      = other.Position;
 }
Пример #4
0
        private static void SimulateBomb(CharacterState character)
        {
            BombState bomb = character.Bomb;

            bomb.RemainingFuze -= TIME_PER_TURN;

            if (bomb.RemainingFuze <= 0)
            {
                int x = bomb.Position.x;
                int y = bomb.Position.y;

                // Center
                character.DestroyedWalls += ExplodeTile(x, y);

                // Right
                for (int i = 1; i < bomb.Radius + 1; i++)
                {
                    if (_state.GetTerrainTypeAtPos(x + i, y) == TerrainType.Wall)
                    {
                        break;
                    }

                    character.DestroyedWalls += ExplodeTile(x + i, y);
                }

                // Left
                for (int i = 1; i < bomb.Radius + 1; i++)
                {
                    if (_state.GetTerrainTypeAtPos(x - i, y) == TerrainType.Wall)
                    {
                        break;
                    }

                    character.DestroyedWalls += ExplodeTile(x - i, y);
                }

                // Top
                for (int i = 1; i < bomb.Radius + 1; i++)
                {
                    if (_state.GetTerrainTypeAtPos(x, y + i) == TerrainType.Wall)
                    {
                        break;
                    }

                    character.DestroyedWalls += ExplodeTile(x, y + i);
                }

                // Bottom
                for (int i = 1; i < bomb.Radius + 1; i++)
                {
                    if (_state.GetTerrainTypeAtPos(x, y - i) == TerrainType.Wall)
                    {
                        break;
                    }

                    character.DestroyedWalls += ExplodeTile(x, y - i);
                }

                character.Bomb = null;
            }
        }
Пример #5
0
        public GameState(CharacterScript self)
        {
            MapScript originalMap = GameManagerScript.Instance.Map;

            Map = new TerrainType[originalMap.Width, originalMap.Height];
            for (int y = 0; y < originalMap.Height; y++)
            {
                for (int x = 0; x < originalMap.Width; x++)
                {
                    Map[x, y] = originalMap.GetTerrainTypeAtPos(x, y);
                }
            }

            List <CharacterScript> originalCharacters = GameManagerScript.Instance.Characters;

            Characters = new List <CharacterState>();
            for (int i = 0; i < originalCharacters.Count; i++)
            {
                CharacterScript original = originalCharacters[i];

                BombState bomb = null;
                if (!original.Bomb.IsReady)
                {
                    bomb = new BombState(
                        original.Bomb.RemainingFuze,
                        original.Bomb.Radius,
                        original.Bomb.Position
                        );
                }

                CharacterState character = new CharacterState(original.Position, original.BombFuze, original.BombRadius, bomb);

                Characters.Add(character);

                if (original == self)
                {
                    Self = character;
                }
            }

            Dictionary <Vector2Int, IItem> originalBonuses = GameManagerScript.Instance.Map.Items;

            Bonuses = new Dictionary <Vector2Int, BonusType>();
            foreach (KeyValuePair <Vector2Int, IItem> pair in originalBonuses)
            {
                BonusType type;
                switch (pair.Value)
                {
                case FuzeItemScript _:
                    type = BonusType.Fuze;
                    break;

                case RadiusItemScript _:
                    type = BonusType.Radius;
                    break;

                default:
                    throw new InvalidOperationException($"Unknown item type: {pair.Value.GetType()}");
                }

                Bonuses.Add(pair.Key, type);
            }
        }