Ejemplo n.º 1
0
        private void die()
        {
            level.enemyGrid[tileX, tileY] = null;
            RetroGame.AddScore(ENEMY_KILL_SCORE);
            dying = true;
            double chance = RetroGame.rand.NextDouble();

            if (chance < CHANCE_TO_SPAWN_SAND_ON_DEATH || forceSandToSpawn)
            {
                int i = tileX;
                int j = tileY;
                level.collectables.Add(new Sand(Level.TEX_SIZE * level.xPos + i * Level.TILE_SIZE + 16, Level.TEX_SIZE * level.yPos + j * Level.TILE_SIZE + 16, level.xPos, level.yPos, i, j));
            }
        }
Ejemplo n.º 2
0
 public virtual bool collectedBy(Entity e)
 {
     if (!dying && ableToBeCollected)
     {
         collectedTime = latestGameTime.TotalGameTime.TotalMilliseconds;
         float randomScoreBonus = ((float)RetroGame.rand.NextDouble() - 0.5f) * (baseScore * COLLECTABLE_SCORE_RANDOM_BONUS_PERCENTAGE);
         if (baseScore > 0)
             RetroGame.AddScore((int)(baseScore + rampUpScoreBonus + randomScoreBonus));
         dying = true;
         ableToBeCollected = false;
         collectedByEntity = e;
         if (!string.IsNullOrEmpty(CollectedSound))
             SoundManager.PlaySoundOnce(CollectedSound);
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
        public virtual bool drillWall(int tileX, int tileY)
        {
            try
            {
                if (grid[tileX, tileY] != LevelContent.LevelTile.Wall)
                {
                    return(true);
                }
            }
            catch (IndexOutOfRangeException e)
            {
                return(false);
            }

            if (!drilledWalls.Contains(new Point(tileX, tileY)))
            {
                drilledWalls.Add(new Point(tileX, tileY));
            }
            grid[tileX, tileY] = LevelContent.LevelTile.Floor;
            pathfinding.costGrid[tileX, tileY] = Pathfinding.COST_FLOOR;
            resetPathfinding();

            Color tileColor = getTileColor(tileX, tileY);

            Color[] tileData = new Color[TILE_SIZE * TILE_SIZE];
            texFloor.GetData <Color>(tileData);
            for (int d = 0; d < tileData.Length; d++)
            {
                tileData[d] = tileData[d].Tint(tileColor, WALL_TINT_FACTOR);
            }
            levelOverlayTexture.SetData <Color>(0, new Rectangle(tileX * TILE_SIZE, tileY * TILE_SIZE, TILE_SIZE, TILE_SIZE), tileData, 0, TILE_SIZE * TILE_SIZE);

            double chance = RetroGame.rand.NextDouble();

            if (chance < CHANCE_TO_SPAWN_SAND_ON_DRILL)
            {
                int i = tileX;
                int j = tileY;
                collectables.Add(new Sand(TEX_SIZE * xPos + i * TILE_SIZE + 16, TEX_SIZE * yPos + j * TILE_SIZE + 16, xPos, yPos, i, j));
            }
            RetroGame.AddScore(DRILL_WALL_SCORE);
            RetroGame.HasDrilled = true;
            return(true);
        }
Ejemplo n.º 4
0
 public void UpdateDebugKeys()
 {
     //update debug keys
     if (pressedThisFrame(Keys.Y) && this == RetroGame.getHeroes()[0])
     {
         if (GetPowerup("Rocket") is RocketBurst)
         {
             RemovePowerup("Rocket");
             AddPowerup(typeof(RocketBoost));
         }
         else
         {
             if (HasPowerup("Rocket"))
             {
                 RemovePowerup("Rocket");
             }
             AddPowerup(typeof(RocketBurst));
         }
     }
     if (pressedThisFrame(Keys.U))
     {
         if (GetPowerup("Gun") is ShotForward)
         {
             RemovePowerup("Gun");
             AddPowerup(typeof(ShotSide));
         }
         else if (GetPowerup("Gun") is ShotSide)
         {
             RemovePowerup("Gun");
             AddPowerup(typeof(ShotCharge));
         }
         else if (GetPowerup("Gun") is ShotCharge)
         {
             RemovePowerup("Gun");
             AddPowerup(typeof(Flamethrower));
         }
         else if (GetPowerup("Flamethrower") is Flamethrower)
         {
             RemovePowerup("Flamethrower");
         }
         else
         {
             if (HasPowerup("Gun"))
             {
                 RemovePowerup("Gun");
             }
             AddPowerup(typeof(ShotForward));
         }
     }
     else if (pressedThisFrame(Keys.I))
     {
         if (GetPowerup("Retro") is RetroPort)
         {
             RemovePowerup("Retro");
             AddPowerup(typeof(RetroStasis));
         }
         else
         {
             if (HasPowerup("Retro"))
             {
                 RemovePowerup("Retro");
             }
             AddPowerup(typeof(RetroPort));
         }
     }
     else if (pressedThisFrame(Keys.O))
     {
         if (GetPowerup("Drill") is DrillFast && !(GetPowerup("Drill") is DrillBasic))
         {
             RemovePowerup("Drill");
             AddPowerup(typeof(DrillTriple));
         }
         else if (GetPowerup("Drill") is DrillTriple)
         {
             RemovePowerup("Drill");
             AddPowerup(typeof(DrillBasic));
         }
         else
         {
             if (HasPowerup("Drill"))
             {
                 RemovePowerup("Drill");
             }
             AddPowerup(typeof(DrillFast));
         }
     }
     else if (pressedThisFrame(Keys.P))
     {
         if (GetPowerup("Radar") is RadarPowerup)
         {
             RemovePowerup("Radar");
         }
         else
         {
             AddPowerup(typeof(RadarPowerup));
         }
     }
     else if (pressedThisFrame(Keys.B))
     {
         if (GetPowerup("Bomb") is BombTimed)
         {
             RemovePowerup("Bomb");
             AddPowerup(typeof(BombSet));
         }
         else
         {
             if (HasPowerup("Bomb"))
             {
                 RemovePowerup("Bomb");
             }
             AddPowerup(typeof(BombTimed));
         }
     }
     else if (pressedThisFrame(Keys.V))
     {
         if (playerIndex == 0)
         {
             if (GetPowerup("Chains") is FireChains)
             {
                 RemovePowerup("Chains");
             }
             else
             {
                 AddPowerup(typeof(FireChains));
             }
         }
     }
     else if (pressedThisFrame(Keys.OemOpenBrackets))
     {
         RetroGame.AddSand();
         RetroGame.AddScore(10000);
         RetroGame.AddBomb();
         for (int i = 0; i < 10; i++)
         {
             RetroGame.AddGem();
         }
     }
     else if (pressedThisFrame(Keys.OemCloseBrackets))
     {
         health -= INITIAL_HEALTH * 0.1f;
     }
     else if (pressedThisFrame(Keys.H)) /*MUSICTEST*/
     {
         SoundManager.PlaySoundAsMusic("LowRumble");
     }
     else if (pressedThisFrame(Keys.N))
     {
         SoundManager.StopMusic();
     }
     else if (pressedThisFrame(Keys.J))
     {
         SoundManager.SetMusicReverse(true);
     }
     else if (pressedThisFrame(Keys.M))
     {
         SoundManager.SetMusicReverse(false);
     }
     else if (pressedThisFrame(Keys.K))
     {
         SoundManager.SetMusicPitch(-1f);
     }
     else if (pressedThisFrame(Keys.OemComma))
     {
         SoundManager.SetMusicPitch(1f);
     }
     else if (pressedThisFrame(Keys.OemPeriod))
     {
         SoundManager.SetMusicPitch(0f);
     }
 }