Пример #1
0
        public void ActivateBlock(Player player, double time, ScoreboardTemplate scoreboard)
        {
            int[]        playerCenter   = getCenterPlayer(new int[] { player.x, player.y });
            int[]        playerTile     = getTile(playerCenter[0], playerCenter[1]);
            Unit         playerStandsOn = units[playerTile[0], playerTile[1]];
            List <int[]> previousBlocks = player.GetPreviousBlock();

            //Explosive playerStandsOnMine = explosions[playerTile[0], playerTile[1]];
            switch (playerStandsOn)
            {
            case Boost x:
                PickupBoost(player, x);
                break;

            case Teleporter x:
                Teleport(player, x);
                break;

            default:
                break;
            }

            List <int[]> playerCorners = new List <int[]>();

            playerCorners.Add(new int[] { player.x, player.y });
            playerCorners.Add(new int[] { player.x, player.y + 14 });
            playerCorners.Add(new int[] { player.x + 14, player.y });
            playerCorners.Add(new int[] { player.x + 14, player.y + 14 });
            foreach (var playerCoordinate in playerCorners)
            {
                playerTile     = getTile(playerCoordinate[0], playerCoordinate[1]);
                playerStandsOn = explosions[playerTile[0], playerTile[1]];
                Unit playerStandsOnMine = units[playerTile[0], playerTile[1]];
                switch (playerStandsOn)
                {
                case Explosion x:
                    PlayerExplode(player, time, scoreboard, x.GetOwner());
                    break;

                case SuperExplosion x:
                    PlayerExplode(player, time, scoreboard, x.GetOwner());
                    break;

                default:
                    break;
                }
                switch (playerStandsOnMine)
                {
                case Mine x:
                    RegularMineExplosion(player, x, time, GetStillOccupiedBlocks(GetCurrentBlocks(player), previousBlocks));
                    break;

                case SuperMine x:
                    SuperMineExplosion(player, x, time, GetStillOccupiedBlocks(GetCurrentBlocks(player), previousBlocks));
                    break;

                default:
                    break;
                }
            }
            player.SetPreviousBlock(GetCurrentBlocks(player));
        }