Ejemplo n.º 1
0
        public void LoadContent(Byte enemyID, ExplodeType explodeType)
        {
            // Load the explosion rectangles on demand.
            Explosion explosion = ExplosionList[enemyID];

            explosion.LoadContent(MyGame.Manager.ImageManager.ExplodeRectangles[(Byte)explodeType]);
        }
Ejemplo n.º 2
0
        public override Int32 Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (GamePause)
            {
                return((Int32)CurrScreen);
            }

            // Log delta to monitor performance!
#if DEBUG
            //MyGame.Manager.Logger.Info(gameTime.ElapsedGameTime.TotalSeconds.ToString());
#endif

            // Move enemies.
            MyGame.Manager.EnemyManager.Update(gameTime);
            //MyGame.Manager.EnemyManager.CheckAllEnemies();		// TODO delete

            number = MyGame.Manager.InputManager.Number();
            if (Constants.INVALID_INDEX != number)
            {
                Byte      explodeIndex = (Byte)number;
                Explosion explosion    = MyGame.Manager.ExplosionManager.ExplosionList[explodeIndex];
                if (!explosion.IsExploding)
                {
                    Vector2     position    = GetPosition(explodeIndex);
                    Byte        diff        = (Byte)(number % 2);
                    ExplodeType explodeType = (ExplodeType)diff;
                    MyGame.Manager.ExplosionManager.LoadContent(explodeIndex, explodeType);
                    MyGame.Manager.ExplosionManager.Explode(explodeIndex, 5, explodeType, position);
                }
            }

            MyGame.Manager.ExplosionManager.Update(gameTime);
            return((Int32)CurrScreen);
        }
Ejemplo n.º 3
0
 internal ExplodeNode(ExplodeType explodeType, bool compound, ComparisonNode comparison)
 {
     ExplodeType = explodeType;
     Compound    = compound;
     Comparison  = comparison;
     Expression  = null;
     _values     = new List <DieResult>();
 }
Ejemplo n.º 4
0
    string GetPoolName(ExplodeType type)
    {
        switch (type)
        {
        case ExplodeType.Foe:
            return(PoolName.ExplodeFX);

        case ExplodeType.Potion:
            return(PoolName.PotionBreakFX);

        default:
            return(null);
        }
    }
Ejemplo n.º 5
0
        public void Explode(Byte enemyID, ExplodeType explodeType, Vector2 position)
        {
            Explosion explosion = ExplosionList[enemyID];

            if (explosion.IsExploding)
            {
                return;
            }

            Vector2 newPosition = position;

            newPosition.X += Constants.EXPLODE_OFFSET_X[(Byte)explodeType];
            newPosition.Y += Constants.EXPLODE_OFFSET_Y[(Byte)explodeType];
            explosion.SetPosition(newPosition);
            explosion.Explode(enemyID);

            ExplosionDict.Add(enemyID, explosion);
        }
Ejemplo n.º 6
0
        public override Int32 Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (GamePause)
            {
                return((Int32)CurrScreen);
            }


            timer += (UInt16)gameTime.ElapsedGameTime.Milliseconds;
            if (timer > beatDelay)
            {
                // Reset back to start.
                Complete();
                return((Int32)NextScreen);
            }

            for (Byte index = 0; index < maxExplode; index++)
            {
                if (flags[index])
                {
                    continue;
                }

                if (timer > delays[index])
                {
                    flags[index] = true;
                    Byte        enemyID     = index;
                    ExplodeType explodeType = GetRandomExplodeType();

                    MyGame.Manager.ExplosionManager.LoadContent(enemyID, explodeType);
                    MyGame.Manager.ExplosionManager.Explode(enemyID, explodeType, positions[index]);
                }
            }

            MyGame.Manager.ExplosionManager.Update(gameTime);
            if (0 != MyGame.Manager.ExplosionManager.ExplosionTest.Count)
            {
                IList <Byte> explosionTest = MyGame.Manager.ExplosionManager.ExplosionTest;
                for (Byte testIndex = 0; testIndex < explosionTest.Count; testIndex++)
                {
                    Byte        enemyID     = explosionTest[testIndex];
                    ExplodeType explodeType = GetRandomExplodeType();

                    MyGame.Manager.ExplosionManager.LoadContent(enemyID, explodeType);
                    positions[testIndex] = GetRandomPosition(enemyID);
                    MyGame.Manager.ExplosionManager.Explode(enemyID, explodeType, positions[testIndex]);
                }
            }


            UpdateFlag1(gameTime);
            if (Selected)
            {
                // Reset back to start.
                //MyGame.Manager.LevelManager.SetLevelIndex(0);
                Complete();
                return((Int32)NextScreen);
            }
            if (Flag1)
            {
                return((Int32)CurrScreen);
            }

            DetectSelect();
            if (Flag1)
            {
                MyGame.Manager.SoundManager.StopMusic();
                PlaySoundEffect();
                return((Int32)CurrScreen);
            }

            #region Events
            //MyGame.Manager.EventManager.ClearEvents();

            //// Move target unconditionally.
            //Vector2 pos1 = MyGame.Manager.SpriteManager.LargeTarget.Position;
            //Vector2 pos2 = MyGame.Manager.SpriteManager.SmallTarget.Position;

            //Single horz = MyGame.Manager.InputManager.Horizontal();
            //Single vert = MyGame.Manager.InputManager.Vertical();
            //MyGame.Manager.SpriteManager.SetMovement(horz, vert);
            //MyGame.Manager.SpriteManager.Update(gameTime);

            //Vector2 pos3 = MyGame.Manager.SpriteManager.LargeTarget.Position;
            //Vector2 pos4 = MyGame.Manager.SpriteManager.SmallTarget.Position;

            //if (pos1 != pos3)
            //{
            //    MyGame.Manager.EventManager.AddLargeTargetMoveEvent(pos3);
            //}
            //if (pos2 != pos4)
            //{
            //    MyGame.Manager.EventManager.AddSmallTargetMoveEvent(pos4);
            //}

            ////// Events.
            //MyGame.Manager.EventManager.ProcessEvents(gameTime);
            #endregion

            return((Int32)CurrScreen);
        }
Ejemplo n.º 7
0
        public override Int32 Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (GamePause)
            {
                return((Int32)CurrScreen);
            }

            // Log delta to monitor performance!
#if DEBUG
            //MyGame.Manager.Logger.Info(gameTime.ElapsedGameTime.TotalSeconds.ToString());
#endif

            // ENEMYS.
            // Update enemies and test collisions.
            MyGame.Manager.EnemyManager.Update(gameTime);
            if (MyGame.Manager.EnemyManager.EnemyTest.Count > 0)
            {
                Boolean collision = MyGame.Manager.CollisionManager.CheckOne();
                if (collision)
                {
                    return((Int32)ScreenType.Over);
                }

                // Iterate all enemy ships to test and add to misses.
                IList <Enemy> enemyTest = MyGame.Manager.EnemyManager.EnemyTest;
                for (Byte testIndex = 0; testIndex < enemyTest.Count; testIndex++)
                {
                    // TODO update score manager => 1x miss per enemy here!
                    // if (misses >= 4) then return game over

                    Enemy enemy = enemyTest[testIndex];
                    //MyGame.Manager.EnemyManager.CheckThisEnemy(enemy);
                    Byte enemyID = enemy.ID;

                    Boolean check = MyGame.Manager.EnemyManager.CheckThisEnemy(enemyID);
                    if (!check)
                    {
                        MyGame.Manager.EnemyManager.SpawnOneEnemy(enemyID);
                    }
                }
            }


            // TODO - is this redundant because Enemy "kill" target [ABOVE]
            //MyGame.Manager.EnemyManager.CheckAllEnemies();
            //if (MyGame.Manager.CollisionManager.EnemysCollisionList.Count > 0)
            //{
            //    // Check collisions here.
            //}


            // TODO - implement bullet logic... for now simulate slotID of bullet on last frame
            SByte number = MyGame.Manager.InputManager.Number();
            if (Constants.INVALID_INDEX != number)
            {
                // Retrieve slotID from bullet position
                // (determine if collision!)
                Byte slotID = (Byte)number;
                if (MyGame.Manager.EnemyManager.EnemyDict.ContainsKey(slotID))
                {
                    // Can kill initial enemy [at frame count = 0] because enemy will be "hidden".
                    Enemy enemy = MyGame.Manager.EnemyManager.EnemyDict[slotID];
                    if (0 != enemy.FrameCount)
                    {
                        // Collision!	Enemy dead and trigger explode...
                        MyGame.Manager.ScoreManager.UpdateGameScore(enemy.FrameIndex);

                        // TODO if DiffType == HARD and enemy.FrameCount = 9 OR 11 then enemy dead?
                        ExplodeType explodeType = enemy.FrameIndex < 4 ? ExplodeType.Small : ExplodeType.Big;
                        Byte        enemyID     = enemy.ID;
                        MyGame.Manager.ExplosionManager.LoadContent(enemyID, explodeType);
                        MyGame.Manager.ExplosionManager.Explode(enemyID, explodeType, enemy.Position);
                        enemy.Dead();
                    }
                }
                //else
                //{
                //    MyGame.Manager.Logger.Info("miss " + (slotID).ToString());		// TODO remove logging
                //}
            }


            // EXPLOSIONS.
            MyGame.Manager.ExplosionManager.Update(gameTime);
            if (MyGame.Manager.ExplosionManager.ExplosionTest.Count > 0)
            {
                // Iterate all enemy ships to test and add to misses.
                IList <Byte> explosionTest = MyGame.Manager.ExplosionManager.ExplosionTest;
                for (Byte testIndex = 0; testIndex < explosionTest.Count; testIndex++)
                {
                    Byte enemyID = explosionTest[testIndex];

                    Boolean check = MyGame.Manager.EnemyManager.CheckThisEnemy(enemyID);
                    if (!check)
                    {
                        MyGame.Manager.EnemyManager.SpawnOneEnemy(enemyID);
                    }
                }
            }

            // Finally, check to see if all enemies finished = level complete.
            Boolean gameover = MyGame.Manager.EnemyManager.CheckEnemiesNone();
            if (gameover)
            {
                return((Int32)ScreenType.Cont);                // TODO actually finished level!
            }


            return((Int32)CurrScreen);
        }
Ejemplo n.º 8
0
        protected void VerifyBullets(Boolean updateScore)
        {
            if (0 == MyGame.Manager.BulletManager.BulletTest.Count)
            {
                return;
            }

            IList <Bullet> bulletTest = MyGame.Manager.BulletManager.BulletTest;

            for (Byte testIndex = 0; testIndex < bulletTest.Count; testIndex++)
            {
                Bullet bullet = bulletTest[testIndex];
                SByte  testID = MyGame.Manager.CollisionManager.DetermineEnemySlot(bullet.Position);

                // Check to ensure bullet will something.
                if (Constants.INVALID_INDEX == testID)
                {
                    continue;
                }

                // Check to ensure bullet in same slot as enemy.
                Byte slotID = (Byte)testID;
                if (!MyGame.Manager.EnemyManager.EnemyDict.ContainsKey(slotID))
                {
                    continue;
                }

                // It could be possible that the enemy in this slot is already dead!
                Enemy enemy = MyGame.Manager.EnemyManager.EnemyDict[slotID];
                if (EnemyType.Dead == enemy.EnemyType)
                {
                    continue;
                }

                // Can kill initial enemy [at frame count = 0] because enemy will be "hidden".
                if (0 == enemy.FrameCount)
                {
                    continue;
                }

                // Check if bullet collides with enemy.
                Byte    enemyFrame = enemy.FrameIndex;
                Boolean collide    = MyGame.Manager.CollisionManager.BulletCollideEnemy(enemy.Position, bullet.Position, LevelType, enemyFrame);
                if (!collide)
                {
                    continue;
                }

                // Collision!	Enemy dead and trigger explode...
                if (updateScore)
                {
                    MyGame.Manager.SoundManager.PlaySoundEffect(SoundEffectType.Ship);
                    MyGame.Manager.ScoreManager.UpdateGameScore(enemyFrame);
                }

                ExplodeType explodeType = enemy.FrameIndex < 4 ? ExplodeType.Small : ExplodeType.Big;
                Byte        enemyID     = enemy.ID;
                MyGame.Manager.ExplosionManager.LoadContent(enemyID, explodeType);

                //Vector2 explosionPosition = enemy.Position;		//Use this to centralize explosion around enemy.
                Vector2 explosionPosition = bullet.Position;                            //Use this to centralize explosion around bullet.
                MyGame.Manager.ExplosionManager.Explode(enemyID, explodeType, explosionPosition);
                enemy.Dead();
            }
        }
Ejemplo n.º 9
0
    public void Explode(int centerX, int centerY, ExplodeType type)
    {
        Debug.Log("explode with " + centerX);
        //Tell cells around it that it was hit by explosion
        gameScript.GlobalNotify("Explosion at (" +centerX +","+centerY+")");

        // Have explosion for explode
        Instantiate(Resources.Load ("explosion"), grid[centerX, centerY].transform.position, Quaternion.identity);

        for (int x = (centerX > 0 ? centerX-1 : centerX); x <= centerX+1 && x < this.grid.GetLength(0); x++) {
            for (int y = (centerY > 0 ? centerY-1 : centerY); y <= centerY+1 && y < this.grid.GetLength(1); y++) {
                GetCell(x,y).handleCellDamage(2,type,GetCell(centerX,centerY));
                if (type == ExplodeType.Mine) {
                    CellScript curCell = GetCell(x,y);
                    if (curCell.curCellState == GameScript.CellState.Mine || curCell.isMineRadius) {
                        curCell.curCellState = GameScript.CellState.Available;
                        curCell.isMineRadius = false;
                        curCell.mineParentCell = null;
                    }
                }
            }
        }
    }
Ejemplo n.º 10
0
        public override Int32 Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (GamePause)
            {
                return((Int32)CurrScreen);
            }

            Boolean escape = MyGame.Manager.InputManager.Escape();

            if (escape)
            {
                return((Int32)PrevScreen);
            }

            checkLevelComplete = false;

            // Log delta to monitor performance!
#if DEBUG
            //string time = gameTime.ElapsedGameTime.TotalSeconds.ToString();
            //MyGame.Manager.Logger.Info(time);
            //Console.WriteLine(time);
            //System.Diagnostics.Debug.WriteLine(time);
#endif

            // TODO delete
            //MyGame.Manager.CollisionManager.ClearCollisionList();

            // Move target unconditionally.
            Single horz = MyGame.Manager.InputManager.Horizontal();
            Single vert = MyGame.Manager.InputManager.Vertical();
            MyGame.Manager.SpriteManager.SetMovement(horz, vert);
            MyGame.Manager.SpriteManager.Update(gameTime);


            // Test shooting enemy ships.
            Boolean fire = MyGame.Manager.InputManager.Fire();
            if (fire)
            {
                SByte bulletIndex = MyGame.Manager.BulletManager.CheckBullets();
                if (Constants.INVALID_INDEX != bulletIndex)
                {
                    // TODO check!
                    MyGame.Manager.SoundManager.PlaySoundEffect();

                    Vector2 position = MyGame.Manager.SpriteManager.LargeTarget.Position;
                    MyGame.Manager.BulletManager.Shoot((Byte)bulletIndex, position);
                }
            }


            // BULLETS.
            // Update bullets and test collision.
            MyGame.Manager.BulletManager.Update(gameTime);
            if (MyGame.Manager.BulletManager.BulletTest.Count > 0)
            {
                IList <Bullet> bulletTest = MyGame.Manager.BulletManager.BulletTest;
                for (Byte testIndex = 0; testIndex < bulletTest.Count; testIndex++)
                {
                    Bullet bullet = bulletTest[testIndex];
                    SByte  testID = MyGame.Manager.CollisionManager.DetermineEnemySlot(bullet.Position);

                    // Check to ensure bullet will something.
                    if (Constants.INVALID_INDEX == testID)
                    {
                        continue;
                    }

                    // Check to ensure bullet in same slot as enemy.
                    Byte slotID = (Byte)testID;
                    if (!MyGame.Manager.EnemyManager.EnemyDict.ContainsKey(slotID))
                    {
                        continue;
                    }

                    // It could be possible that the enemy in this slot is already dead!
                    Enemy enemy = MyGame.Manager.EnemyManager.EnemyDict[slotID];
                    if (EnemyType.Dead == enemy.EnemyType)
                    {
                        continue;
                    }

                    // Can kill initial enemy [at frame count = 0] because enemy will be "hidden".
                    Byte enemyCount = enemy.FrameCount;
                    if (0 == enemy.FrameCount)
                    {
                        continue;
                    }

                    // Check if bullet collides with enemy.
                    Byte    enemyFrame = enemy.FrameIndex;
                    Boolean collide    = MyGame.Manager.CollisionManager.BulletCollideEnemy(enemy.Position, bullet.Position, levelType, enemyFrame);
                    if (!collide)
                    {
                        continue;
                    }

                    // Collision!	Enemy dead and trigger explode...
                    MyGame.Manager.ScoreManager.UpdateGameScore(enemyFrame);

                    // TODO if DiffType == HARD and enemy.FrameCount = 9 OR 11 then enemy dead?
                    ExplodeType explodeType = enemy.FrameIndex < 4 ? ExplodeType.Small : ExplodeType.Big;
                    Byte        enemyID     = enemy.ID;
                    MyGame.Manager.ExplosionManager.LoadContent(enemyID, explodeType);
                    MyGame.Manager.ExplosionManager.Explode(enemyID, explodeType, enemy.Position);
                    enemy.Dead();
                }
            }

            // EXPLOSIONS.
            MyGame.Manager.ExplosionManager.Update(gameTime);
            if (MyGame.Manager.ExplosionManager.ExplosionTest.Count > 0)
            {
                // Iterate all enemy ships to test and add to misses.
                IList <Byte> explosionTest = MyGame.Manager.ExplosionManager.ExplosionTest;
                for (Byte testIndex = 0; testIndex < explosionTest.Count; testIndex++)
                {
                    Byte    enemyID = explosionTest[testIndex];
                    Boolean check   = MyGame.Manager.EnemyManager.CheckThisEnemy(enemyID);
                    if (!check)
                    {
                        MyGame.Manager.EnemyManager.SpawnOneEnemy(enemyID);
                    }
                    else
                    {
                        checkLevelComplete = true;
                    }
                }
            }

            // ENEMYS.
            // Update enemies and test collisions.
            MyGame.Manager.EnemyManager.Update(gameTime);
            if (MyGame.Manager.EnemyManager.EnemyTest.Count > 0)
            {
                // TODO delete
                //checkLevelComplete = true;

                // Enemy has maxed out frames so check for collision.
                LargeTarget   target    = MyGame.Manager.SpriteManager.LargeTarget;
                IList <Enemy> enemyTest = MyGame.Manager.EnemyManager.EnemyTest;

                for (Byte testIndex = 0; testIndex < enemyTest.Count; testIndex++)
                {
                    Enemy enemy = enemyTest[testIndex];
                    if (!invincibile)
                    {
                        // First check if enemy instantly kills target.
                        Boolean test = CheckEnemyKillTarget(enemy, target);

                        // Instant death!	Game Over.
                        if (test)
                        {
                            // Do NOT reset enemy here as we want to see Target killed by Enemy!
                            return((Int32)ScreenType.Dead);
                        }

                        // Enemy not kill target but missed so increment miss total.
                        MyGame.Manager.ScoreManager.IncrementMisses();
                        if (MyGame.Manager.ScoreManager.MissesTotal >= Constants.MAX_MISSES)
                        {
                            // If maximum misses then game over.
                            enemy.Reset();
                            return((Int32)ScreenType.Dead);
                        }
                    }

                    // Finally, check if anymore enemies to spawn...
                    Byte    enemyID = enemy.ID;
                    Boolean check   = MyGame.Manager.EnemyManager.CheckThisEnemy(enemyID);
                    if (!check)
                    {
                        MyGame.Manager.EnemyManager.SpawnOneEnemy(enemyID);
                    }
                    else
                    {
                        checkLevelComplete = true;
                    }
                }
            }


            // Update fire icon.
            Byte canShootIndex = Convert.ToByte(!MyGame.Manager.BulletManager.CanShoot);
            MyGame.Manager.IconManager.UpdateFireIcon(canShootIndex);


            // Finally, check to see if all enemies finished = level complete.
            if (checkLevelComplete)
            {
                Boolean noMoreEnemies = MyGame.Manager.EnemyManager.CheckEnemiesNone();
                if (noMoreEnemies)
                {
                    return((Int32)ScreenType.Finish);
                }
            }

            MyGame.Manager.ScoreManager.Update(gameTime);
            return((Int32)CurrScreen);
        }