コード例 #1
0
ファイル: Program.cs プロジェクト: yinyangman/synthesis
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1())
     {
         game.Run();
     }
 }
コード例 #2
0
ファイル: Enemy.cs プロジェクト: yinyangman/synthesis
        public Enemy(Game1 game, Level level)
        {
            int randomType = Game1.Random.Next(0, 100);

            if (randomType < level.levelData.i_EnemyMinorChance)
            {
                ed_EnemyData = game.EnemyDataForType(EnemyData.Type.Normal);
            }
            else if (randomType < (level.levelData.i_EnemyMajorChance + level.levelData.i_EnemyMinorChance))
            {
                ed_EnemyData = game.EnemyDataForType(EnemyData.Type.Destroyer);
            }

            InitaliseEnemy(game);
        }
コード例 #3
0
ファイル: Engine.cs プロジェクト: yinyangman/synthesis
        public void COLLISION(Bullet tether, Particle particle, int ID, bool isAPhoton, Game1 game)
        {
            if (tetherState == TetherState.shooting)
            {
                if (tether.Rectangle.Intersects(particle.Rectangle))
                {
                    if (IntersectPixels(particle.RectanglePosTransform,
                                        particle.Texture.Width,
                                        particle.Texture.Height,
                                        particle.TextureData,
                                        tether.RectanglePosTransform,
                                        tether.Texture.Width,
                                        tether.Texture.Height,
                                        tether.TextureData))
                    {
                        if (particle.ParticleState == Particle.PState.Alive && particle.BeingAttacked == false)
                        {
                            particle.Color = Color.Aqua;
                            ship.TetheredParticleID = ID;
                            ship.IsPhoton = isAPhoton;
                            ship.Tethering = true;
                            particle.IsTethered = true;
                            tether.Alive = false;
                            tetherState = TetherState.tethered;
                            game.soundBank.PlayCue("tethered");

                            if (particle.Attacker != null)
                            {
                                particle.Attacker.i_KillingCounter = 0;
                                particle.Attacker.f_colour = 1.0f;
                                particle.Attacker.attacking = false;
                                particle.Attacker.f_Rotation = 0;
                            }
                            particle.BeingAttacked = false;
                            particle.Attacker = null;
                            if (particle.IsTethered == false)
                            {
                                particle.Color = Color.White;
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: Engine.cs プロジェクト: yinyangman/synthesis
        public void PauseCheck(Game1 game)
        {
            #region Controller
            GamePadState gamepadStateCurr = GamePad.GetState(PlayerIndex.One);
            if (gamepadStateCurr.IsButtonDown(Buttons.Start))
            {
                if (!game.gamepadStateOld.IsButtonDown(Buttons.Start))
                {
                    if (game.gameState == State.Gameplay)
                    {
                        game.gameState = State.Paused;
                    }
                    else if (game.gameState == State.Paused)
                    {
                        game.gameState = State.Gameplay;
                    }
                }
            }
            game.gamepadStateOld = gamepadStateCurr;
            #endregion
            #region Keyboard
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                if (game.lastEscape == false)
                {
                    if (game.gameState == State.Gameplay)
                    {
                        game.gameState = State.Paused;
                    }
                    else if (game.gameState == State.Paused)
                    {
                        game.gameState = State.Gameplay;
                    }
                }
                game.lastEscape = true;
            }
            else
            {
                game.lastEscape = false;
            }

            game.gamepadStateOld = gamepadStateCurr;
            #endregion
        }
コード例 #5
0
ファイル: Engine.cs プロジェクト: yinyangman/synthesis
        public void Update(GameTime gameTime, SoundBank soundBank, Game1 game)
        {
            if (game.gameState != State.Tutorial)
            {
                SegmentUpdate();

                if (Ambient.IsPlaying == false)
                {
                    Ambient.Play();
                }
                else if (Ambient.IsPaused == true)
                {
                    Ambient.Resume();
                }
                if (f_Fusions >= loadedLevel.levelData.i_TargetFusions)
                {
                    game.i_GameOverSel = 1;
                    game.f_LevelCompleteBonus = 500;
                    game.fd_Fader.BeginFadingToBlack(75, true, game);
                }
                if (dt_timer.Minute == 0 && dt_timer.Second == 0)
                {
                    game.fd_Fader.BeginFadingToBlack(75, true, game);
                }
                else
                {
                    dt_timer -= gameTime.ElapsedGameTime;
                }

                offset = ship.OffsetUpdate(offset);
                if (dead == true)
                {
                    UpdateExplosion(ship.Position);
                }
                #region Enemy Spawn and Update
                for (int i = 0; i < loadedLevel.levelData.i_MaxNumberEnemies; i++)
                {
                    if (enemies[i].EnemyCollision == true)
                    {
                        UpdateShieldSpark(enemies[i].EnemyCollisionPosition, enemies[i]);
                        enemies[i].ShieldSparkCounter++;
                        if (enemies[i].ShieldSparkCounter == 40)
                        {
                            enemies[i].EnemyCollision = false;
                            enemies[i].ShieldSparkCounter = 0;
                        }
                    }

                    if (enemies[i].IsParticleKill == true)
                    {
                        UpdateParticleKill(enemies[i].ParticleKillPosition, enemies[i].p_ParticleKilled, enemies[i]);
                        enemies[i].ParticleKillCounter++;
                        if (enemies[i].ParticleKillCounter == 40)
                        {
                            enemies[i].IsParticleKill = false;
                            enemies[i].ParticleKillCounter = 0;
                        }
                    }

                    if (enemies[i].Alive == true)
                    {
                        enemies[i].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, f_Friction);
                    }
                    else if (enemies[i].SpawnTimer == loadedLevel.levelData.i_EnemySpawnRate)
                    {
                        enemies[i] = new Enemy(game, loadedLevel);
                        enemies[i].LoadTexture(game.Content);
                        enemies[i].Spawn(offset, loadedLevel.levelBounds);
                        enemies[i].SpawnTimer = 0;
                        enemies[i].Rectangle = new Rectangle(((int)enemies[i].Position.X - (enemies[i].Texture.Width / 2)), ((int)enemies[i].Position.Y - (enemies[i].Texture.Height / 2)), enemies[i].Texture.Width, enemies[i].Texture.Height);
                        enemies[i].TextureData = new Color[enemies[i].Texture.Width * enemies[i].Texture.Height];
                        enemies[i].Texture.GetData(enemies[i].TextureData);
                    }
                }
                for (int i = 0; i < loadedLevel.levelData.i_MaxNumberEnemies; i++)
                {
                    if (enemies[i].Alive == false)
                    {
                        enemies[i].SpawnTimer++;
                        break;
                    }
                }
                #endregion
                #region Particles Spawning

                for (int i = 0; i < Photons.Length; i++)
                {
                    if (Photons[i].ParticleState == Particle.PState.Fusing)
                    {
                        if (Photons[i].i_Fusing > 50)
                        {
                            Photons[i].ParticleState = Particle.PState.Dead;
                            Photons[i].i_Fusing = 0;
                        }
                        else
                        {
                            Photons[i].i_Fusing++;
                        }
                    }
                    else if (Photons[i].ParticleState == Particle.PState.Colliding)
                    {
                        Photons[i].Velocity = new Vector2((((Photons[i].FusionPosition.X - Photons[i].Position.X) / Vector2.Distance(Photons[i].Position, Photons[i].FusionPosition)) * 10), (((Photons[i].FusionPosition.Y - Photons[i].Position.Y) / Vector2.Distance(Photons[i].Position, Photons[i].FusionPosition)) * 10));
                        Photons[i].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, f_Friction);
                        if (Photons[i].Position.X < (Photons[i].FusionPosition.X + 1) && Photons[i].Position.X > (Photons[i].FusionPosition.X - 1) && Photons[i].Position.Y < (Photons[i].FusionPosition.Y + 1) && Photons[i].Position.Y > (Photons[i].FusionPosition.Y - 1))
                        {
                            for (int j = 0; j < loadedLevel.levelData.i_MaxNumberFused; j++)
                            {
                                if (Fused[j].ParticleState == Particle.PState.Dead)
                                {
                                    Fused[j].ParticleState = Particle.PState.Spawning;
                                    Photons[i].ParticleState = Particle.PState.Fusing;
                                    Fused[j].Position = Photons[i].Position;
                                    break;
                                }
                            }
                        }
                    }
                    else if (Photons[i].ParticleState == Particle.PState.Alive)
                    {
                        if (Photons[i].IsTethered)
                        {
                            if (!ship.BoundSphere.Intersects(new BoundingSphere(new Vector3(Photons[i].Position, 0), (Photons[i].Texture.Width / 2))))
                            {
                                Vector2 distance = ship.Position - Photons[i].Position;
                                Photons[i].Velocity += Vector2.Normalize(distance) * 20;
                            }
                        }
                        else
                        {
                            Photons[i].Position -= new Vector2(0, 0.07f);
                        }
                        Photons[i].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, f_Friction);
                    }
                    else if (Photons[i].ParticleState == Particle.PState.Spawning)
                    {
                        if (Photons[i].Scale > 1)
                        {
                            Photons[i].Scale = 1.0f;
                            Photons[i].ParticleState = Particle.PState.Alive;
                        }
                        else
                        {
                            Photons[i].Scale += 0.02f;
                        }
                    }
                    else if (Photons[i].SpawnTimer == loadedLevel.levelData.i_PhotonSpawnRate)
                    {
                        Photons[i] = new Particle(loadedLevel.levelBounds);
                        Photons[i].LoadTex(t_Photon);
                        Photons[i].ParticleState = Particle.PState.Spawning;
                        Photons[i].Spawn(offset, loadedLevel.levelBounds, true);
                        Photons[i].SpawnTimer = 0;
                        soundBank.PlayCue("photonPop");
                    }
                }

                for (int i = 0; i < Chlor.Length; i++)
                {
                    if (Chlor[i].ParticleState == Particle.PState.Fusing)
                    {
                        if (Chlor[i].i_Fusing > 50)
                        {
                            Chlor[i].ParticleState = Particle.PState.Dead;
                            Chlor[i].i_Fusing = 0;
                        }
                        else
                        {
                            Chlor[i].i_Fusing++;
                        }
                    }
                    else if (Chlor[i].ParticleState == Particle.PState.Colliding)
                    {
                        Chlor[i].Velocity = new Vector2((((Chlor[i].FusionPosition.X - Chlor[i].Position.X) / Vector2.Distance(Chlor[i].Position, Chlor[i].FusionPosition)) * 10), (((Chlor[i].FusionPosition.Y - Chlor[i].Position.Y) / Vector2.Distance(Chlor[i].Position, Chlor[i].FusionPosition)) * 10));
                        Chlor[i].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, f_Friction);

                        if (Chlor[i].Position.X < (Chlor[i].FusionPosition.X + 1) && Chlor[i].Position.X > (Chlor[i].FusionPosition.X - 1) && Chlor[i].Position.Y < (Chlor[i].FusionPosition.Y + 1) && Chlor[i].Position.Y > (Chlor[i].FusionPosition.Y - 1))
                        {
                            Chlor[i].ParticleState = Particle.PState.Fusing;
                        }
                    }
                    else if (Chlor[i].ParticleState == Particle.PState.Alive)
                    {
                        if (Chlor[i].IsTethered)
                        {
                            if (!ship.BoundSphere.Intersects(new BoundingSphere(new Vector3(Chlor[i].Position, 0), (Chlor[i].Texture.Width / 2))))
                            {
                                Vector2 distance = ship.Position - Chlor[i].Position;
                                Chlor[i].Velocity += Vector2.Normalize(distance) * 20;
                            }
                        }
                        else
                        {
                            Chlor[i].Position += new Vector2(0, 0.07f);
                        }
                        Chlor[i].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, f_Friction);
                    }
                    else if (Chlor[i].ParticleState == Particle.PState.Spawning)
                    {
                        if (Chlor[i].Scale > 1)
                        {
                            Chlor[i].Scale = 1.0f;
                            Chlor[i].ParticleState = Particle.PState.Alive;
                        }
                        else
                        {
                            Chlor[i].Scale += 0.02f;
                        }
                    }
                    else if (Chlor[i].SpawnTimer == loadedLevel.levelData.i_ChloroSpawnRate)
                    {
                        Chlor[i] = new Particle(loadedLevel.levelBounds);
                        Chlor[i].LoadTex(t_Chlor);
                        Chlor[i].ParticleState = Particle.PState.Spawning;
                        Chlor[i].Spawn(offset, loadedLevel.levelBounds, false);
                        Chlor[i].SpawnTimer = 0;
                        soundBank.PlayCue("chlorPop");
                    }
                }

                for (int i = 0; i < loadedLevel.levelData.i_MaxNumberPhotons; i++)
                {
                    if (Photons[i].ParticleState == Particle.PState.Dead)
                    {
                        Photons[i].SpawnTimer++;
                        break;
                    }
                }
                for (int i = 0; i < loadedLevel.levelData.i_MaxNumberChloro; i++)
                {
                    if (Chlor[i].ParticleState == Particle.PState.Dead)
                    {
                        Chlor[i].SpawnTimer++;
                        break;
                    }
                }
                #endregion
            }

            GamePlay(gameTime, game);
        }
コード例 #6
0
ファイル: Level.cs プロジェクト: yinyangman/synthesis
 public void FinishedFadingToBlack(Game1 game)
 {
 }
コード例 #7
0
ファイル: Fader.cs プロジェクト: yinyangman/synthesis
        void FinishedFadingToBlack(Game1 game)
        {
            fadeToBlackDelegate(game);

            if (b_FadeInAgain == true)
            {
                BeginFadingIn(i_MasterFaderMax);
            }
            else
            {
                fadingMode = FadingMode.NoFade;
            }
        }
コード例 #8
0
ファイル: Engine.cs プロジェクト: yinyangman/synthesis
 public void EDGECOLLISION(Ship thing, Rectangle bounds, Game1 game)
 {
     if (thing.Position.Y < bounds.Y)
     {
         thing.Position += new Vector2(0, bounds.Y - thing.Position.Y);
         thing.Velocity *= new Vector2(1, -f_EdgeDamper);
         game.soundBank.PlayCue("sideBump");
     }
     else if (thing.Position.Y > bounds.Y + bounds.Height)
     {
         thing.Position -= new Vector2(0, thing.Position.Y - (bounds.Y + bounds.Height));
         thing.Velocity *= new Vector2(1, -f_EdgeDamper);
         game.soundBank.PlayCue("sideBump");
     }
     if (thing.Position.X < bounds.X)
     {
         thing.Position += new Vector2(bounds.X - thing.Position.X, 0);
         thing.Velocity *= new Vector2(-f_EdgeDamper, 1);
         game.soundBank.PlayCue("sideBump");
     }
     else if (thing.Position.X > bounds.X + bounds.Width)
     {
         thing.Position -= new Vector2(thing.Position.X - (bounds.X + bounds.Width), 0);
         thing.Velocity *= new Vector2(-f_EdgeDamper, 1);
         game.soundBank.PlayCue("sideBump");
     }
 }
コード例 #9
0
ファイル: Engine.cs プロジェクト: yinyangman/synthesis
        public void GamePlay(GameTime gameTime, Game1 game)
        {
            if (ship.Tethering == true)
            {
                if (ship.IsPhoton == true)
                {
                    if (Photons[ship.TetheredParticleID].Attacker != null)
                    {
                        Photons[ship.TetheredParticleID].Attacker.i_KillingCounter = 0;
                        Photons[ship.TetheredParticleID].Attacker.f_colour = 1.0f;
                        Photons[ship.TetheredParticleID].Attacker.attacking = false;
                        Photons[ship.TetheredParticleID].Attacker.f_Rotation = 0;
                    }

                    Photons[ship.TetheredParticleID].BeingAttacked = false;
                    Photons[ship.TetheredParticleID].Attacker = null;
                    if (Photons[ship.TetheredParticleID].IsTethered == false)
                    {
                        Photons[ship.TetheredParticleID].Color = Color.White;
                    }
                }
                else if (ship.IsPhoton == false)
                {
                    if (Chlor[ship.TetheredParticleID].Attacker != null)
                    {
                        Chlor[ship.TetheredParticleID].Attacker.i_KillingCounter = 0;
                        Chlor[ship.TetheredParticleID].Attacker.f_colour = 1.0f;
                        Chlor[ship.TetheredParticleID].Attacker.attacking = false;
                        Chlor[ship.TetheredParticleID].Attacker.f_Rotation = 0;
                    }

                    Chlor[ship.TetheredParticleID].BeingAttacked = false;
                    Chlor[ship.TetheredParticleID].Attacker = null;
                    if (Chlor[ship.TetheredParticleID].IsTethered == false)
                    {
                        Chlor[ship.TetheredParticleID].Color = Color.White;
                    }
                }
            }
            game.gamepadStateCurr = GamePad.GetState(PlayerIndex.One);
            if (dead == false)
            {
                ship.ShipMovement(game.gamepadStateCurr, offset);
                FireCheck(game);
            }
            PauseCheck(game);
            #region Enemy Movement
            for (int i = 0; i < loadedLevel.levelData.i_MaxNumberEnemies; i++)
            {
                if (enemies[i].Alive == true)
                {
                    enemies[i].EnemyMovement(ship, this);
                }
            }
            #endregion

            for (int i = 0; i < i_BulletMax; i++)
            {
                if (bullets[i].Alive == true)
                {
                    bullets[i].BulletMovement(ship);
                    bullets[i].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, 1.0f);
                }
                if (tethers[i].Alive == true)
                {
                    tethers[i].BulletMovement(ship);
                    tethers[i].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, 1.0f);
                }
            }

            #region Collision
            //if Photon collide with Chlor,  enemy1, enemy2

            //if Chlor collide with enemy1, enemy2

            //if Fused collide with enemy1, enemy2

            //if enemy1 collide with enemy2

            i_VibrateCounter = 0;

            //SHIP COLLISION
            #region SHIP COLLISION
            //EDGECOLLISION(ship, levelBounds);
            EDGECOLLISION(ship, loadedLevel.levelBounds, game);
            for (int i = 0; i < Photons.Length; i++)
            {
                if (Photons[i].ParticleState == Particle.PState.Alive)
                {
                    COLLISION(ship, Photons[i]);
                }
            }

            for (int i = 0; i < Chlor.Length; i++)
            {
                if (Chlor[i].ParticleState == Particle.PState.Alive)
                {
                    COLLISION(ship, Chlor[i]);
                }
            }

            if (ship.Hit == false)
            {
                for (int i = 0; i < enemies.Length; i++)
                {
                    if (enemies[i].Alive == true && ship.Hit == false)
                    {
                        COLLISION(ship, enemies[i], game);
                    }
                }
            }

            #endregion
            //PHOTON COLLISION
            #region PHOTON COLLISION

            for (int i = 0; i < Photons.Length; i++)
            {
                if (Photons[i].ParticleState == Particle.PState.Alive)
                {
                    EDGECOLLISION(Photons[i], loadedLevel.levelBounds);
                    for (int j = 0; j < Photons.Length; j++)
                    {
                        if (i != j)
                        {
                            COLLISION(Photons[i], Photons[j], false, game);
                        }
                    }
                }
            }

            for (int i = 0; i < Photons.Length; i++)
            {
                for (int j = 0; j < Chlor.Length; j++)
                {
                    if (Photons[i].ParticleState == Particle.PState.Alive && Chlor[j].ParticleState == Particle.PState.Alive)
                    {
                        //FusionCode
                        COLLISION(Photons[i], Chlor[j], true, game);
                    }
                }
            }

            for (int i = 0; i < Photons.Length; i++)
            {
                for (int j = 0; j < enemies.Length; j++)
                {
                    if (enemies[j].Alive == true && Photons[i].ParticleState == Particle.PState.Alive && Photons[i].IsTethered == false)
                    {
                        COLLISION(enemies[j], Photons[i]);
                    }
                }
            }

            #endregion
            //CHLOR COLLISION
            #region CHLOR COLLISION
            for (int i = 0; i < Chlor.Length; i++)
            {
                if (Chlor[i].ParticleState == Particle.PState.Alive)
                {
                    EDGECOLLISION(Chlor[i], loadedLevel.levelBounds);
                    for (int j = 0; j < Chlor.Length; j++)
                    {
                        if (i != j)
                        {
                            COLLISION(Chlor[i], Chlor[j], false, game);
                        }
                    }
                }
            }

            for (int i = 0; i < Chlor.Length; i++)
            {
                for (int j = 0; j < enemies.Length; j++)
                {
                    if (enemies[j].Alive == true && Chlor[i].ParticleState == Particle.PState.Alive && Photons[i].IsTethered == false)
                    {
                        COLLISION(enemies[j], Chlor[i]);
                    }
                }
            }
            #endregion
            //ENEMY COLLISION
            #region ENEMY COLLISION
            for (int i = 0; i < enemies.Length; i++)
            {
                EDGECOLLISION(enemies[i], loadedLevel.levelBounds);
                for (int j = 0; j < enemies.Length; j++)
                {
                    if (i != j)
                    {
                        if (enemies[i].Alive == true && enemies[j].Alive == true)
                        {
                            COLLISION(enemies[i], enemies[j]);
                        }
                    }
                }
            }
            #endregion
            //BULLET COLLISION
            #region BULLET COLLISION
            for (int i = 0; i < enemies.Length; i++)
            {
                for (int j = 0; j < bullets.Length; j++)
                {
                    if (enemies[i].Alive == true && bullets[j].Alive == true)
                    {
                        COLLISION(enemies[i], bullets[j], game);
                    }
                }
            }
            #endregion
            //TETHER COLLISION
            #region TETHER COLLISION

            for (int i = 0; i < tethers.Length; i++)
            {
                for (int j = 0; j < Photons.Length; j++)
                {
                    if (tethers[i].Alive)
                    {
                        if (tethers[i].Position.X < (ship.Position.X - 200))
                        {
                            tethers[i].Alive = false;
                        }
                        else if (tethers[i].Position.X > (ship.Position.X + 200))
                        {
                            tethers[i].Alive = false;
                        }
                        else if (tethers[i].Position.Y < (ship.Position.Y - 200))
                        {
                            tethers[i].Alive = false;
                        }
                        else if (tethers[i].Position.Y > (ship.Position.Y + 200))
                        {
                            tethers[i].Alive = false;
                        }
                        else
                        {
                            COLLISION(tethers[i], Photons[j], j, true, game);
                            COLLISION(tethers[i], Chlor[j], j, false, game);
                        }
                    }
                }
            }

            #endregion

            GamePad.SetVibration(PlayerIndex.One, (0.2f * i_VibrateCounter), (0.2f * i_VibrateCounter));
            #endregion

            for (int i = 0; i < Fused.Length; i++)
            {
                if (Fused[i].ParticleState == Particle.PState.Spawning)
                {
                    if (Fused[i].IsFusion == true)
                    {
                        UpdateFusionEffect(new Vector2((Fused[i].Position.X + (Fused[i].Texture.Width / 2)), (Fused[i].Position.Y - 15 + (Fused[i].Texture.Height / 2))), Fused[i]);
                        Fused[i].FusionCounter++;
                        if (Fused[i].FusionCounter == 70)
                        {
                            f_Fusions++;
                            Fused[i].IsFusion = false;
                            Fused[i].FusionCounter = 0;
                            Fused[i].ParticleState = Particle.PState.Alive;
                            if (game.gameState == State.Tutorial)
                            {
                                Tutorial tutorial = (Tutorial)loadedLevel;
                                tutorial.b_TutorialFusion = true;
                            }
                        }
                    }
                }
                if (Fused[i].ParticleState == Particle.PState.Alive)
                {
                    Fused[i].Velocity += new Vector2((((4096 - Fused[i].Position.X) / Vector2.Distance(Fused[i].Position, new Vector2(4096, 1152))) * 10), (((1152 - Fused[i].Position.Y) / Vector2.Distance(Fused[i].Position, new Vector2(4096, 1152)))) * 10);
                    Fused[i].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, f_Friction);
                }
            }

            UpdateEngineSmoke();
            ShieldPulse();
            ship.updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, f_Friction, tetherState);

            if (ship.Tethering == true)
            {
                for (int i = 0; i < i_StupidLineMax; i++)
                {
                    if (stupidline[i].Alive == true)
                    {
                        if (ship.IsPhoton == true)
                        {
                            stupidline[i].BulletMovement(Photons[ship.TetheredParticleID].Position, ship.Position, i, stupidline.Length);
                        }
                        else
                        {
                            stupidline[i].BulletMovement(Chlor[ship.TetheredParticleID].Position, ship.Position, i, stupidline.Length);
                        }
                        stupidline[i].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, 1);
                    }
                }
                for (int i = 0; i < i_StupidLineMax; i++)
                {
                    if (stupidline[i].Alive == false)
                    {
                        if (stupidline[i].i_SpawnTimer == 4)
                        {
                            stupidline[i].Alive = true;
                            stupidline[i].Position = ship.Position;
                            stupidline[i].i_SpawnTimer = 0;
                            break;
                        }
                        else
                        {
                            stupidline[i].i_SpawnTimer++;
                            break;
                        }
                    }
                }
            }
        }
コード例 #10
0
ファイル: Engine.cs プロジェクト: yinyangman/synthesis
        public void COLLISION(Particle particleA, Particle particleB, bool fusion, Game1 game)
        {
            if (particleA.Rectangle.Intersects(particleB.Rectangle))
            {

                if (IntersectPixels(particleB.RectanglePosTransform,
                                    particleB.Texture.Width,
                                    particleB.Texture.Height,
                                    particleB.TextureData,
                                    particleA.RectanglePosTransform,
                                    particleA.Texture.Width,
                                    particleA.Texture.Height,
                                    particleA.TextureData))
                {
                    if (fusion == true)
                    {
                        ship.Tethering = false;
                        tetherState = TetherState.detethered;
                        particleA.ParticleState = Particle.PState.Colliding;
                        particleB.ParticleState = Particle.PState.Colliding;
                        game.soundBank.PlayCue("fusion");
                        particleA.FusionPosition = new Vector2((particleA.Position.X + ((particleB.Position.X - particleA.Position.X) / 2)), (particleA.Position.Y + ((particleB.Position.Y - particleA.Position.Y) / 2)));
                        particleB.FusionPosition = new Vector2((particleB.Position.X + ((particleA.Position.X - particleB.Position.X) / 2)), (particleB.Position.Y + ((particleA.Position.Y - particleB.Position.Y) / 2)));
                    }
                    else if (fusion == false)
                    {
                        Vector2 impactSpeed;
                        Vector2 impulse;
                        float resultantImpulse;

                        impactSpeed = particleB.Velocity - particleA.Velocity;
                        impulse = Vector2.Normalize(particleB.Position - particleA.Position);
                        resultantImpulse = Vector2.Dot(impulse, impactSpeed);
                        if (resultantImpulse < 0)
                        {
                            resultantImpulse *= -1;
                        }
                        impulse = impulse * (float)Math.Sqrt(resultantImpulse);

                        particleB.Velocity += impulse;
                        particleA.Velocity -= impulse;
                    }
                }
            }
        }
コード例 #11
0
ファイル: Engine.cs プロジェクト: yinyangman/synthesis
 public void COLLISION(Enemy enemy, Bullet bullet, Game1 game)
 {
     if (bullet.Rectangle.Intersects(enemy.Rectangle))
     {
         if (IntersectPixels(enemy.RectanglePosTransform,
                             enemy.Texture.Width,
                             enemy.Texture.Height,
                             enemy.TextureData,
                             bullet.RectanglePosTransform,
                             bullet.Texture.Width,
                             bullet.Texture.Height,
                             bullet.TextureData))
         {
             bullet.Alive = false;
             enemy.EnemyShot(bullet, game);
         }
     }
 }
コード例 #12
0
ファイル: Enemy.cs プロジェクト: yinyangman/synthesis
        public void EnemyShot(Bullet bullet, Game1 game)
        {
            i_Health -= bullet.i_BulletDamage;
            game.soundBank.PlayCue("enemyDie");
            EnemyCollisionPosition = Position;// -new Vector2(enemy.Texture.Width / 2, enemy.Texture.Height / 2);
            EnemyCollision = true;

            if (i_Health <= 0)
            {
                i_Health = 0;
                Alive = false;

                if (EnemyType == EnemyData.Type.Destroyer)
                {
                    game.f_EnemiesBigKilled++;
                }
                else if (EnemyType == EnemyData.Type.Normal)
                {
                    game.f_EnemiesSmallKilled++;
                }

                if (closestParticle != null)
                {
                    closestParticle.BeingAttacked = false;
                    closestParticle.Attacker = null;
                    if (closestParticle.IsTethered == false)
                    {
                        closestParticle.Color = Color.White;
                    }
                }
            }
        }
コード例 #13
0
ファイル: Enemy.cs プロジェクト: yinyangman/synthesis
        public void InitaliseEnemy(Game1 game)
        {
            vPosition = Vector2.Zero;
            i_KillingCounter = 0;
            f_colour = 1.0f;
            i_SpawnTimer = 0;
            ShieldSpark = new ShieldSparkParticleSystem(game, 8);
            game.Components.Add(ShieldSpark);
            ParticleKill = new ParticleKillParticleSystem(game, 9);
            game.Components.Add(ParticleKill);
            attacking = false;

            i_Health = ed_EnemyData.i_MaxHealth;
        }
コード例 #14
0
ファイル: Tutorial.cs プロジェクト: yinyangman/synthesis
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, Engine engine, Game1 game)
        {
            spriteBatch.Draw(t_Tutorial, new Vector2(0, 0), new Color(1, 1, 1, (i_TutorialCounter / 100f)));
            spriteBatch.Draw(t_Grid, new Vector2(0, 0), new Color(1, 1, 1, (i_GridCounter / 100f)));
            spriteBatch.DrawString(game.fontSmallText, "Tachyon Emissions: " + funnyNo1 + "htz", new Vector2(32, 29), new Color(0, 1, 1, (i_Number2Counter / 20f)));
            spriteBatch.DrawString(game.fontSmallText, "Tractor Beam Cohesion: " + funnyNo2 + "%", new Vector2(32, 44), new Color(0, 1, 1, (i_Number3Counter / 20f)));
            spriteBatch.DrawString(game.fontSmallText, "Shield Matrix Variance: " + funnyNo3, new Vector2(32, 60), new Color(0, 1, 1, (i_Number4Counter / 20f)));
            spriteBatch.DrawString(game.fontSmallText, "AVA Targeting Alignment: " + funnyNo4, new Vector2(32, 75), new Color(0, 1, 1, (i_Number5Counter / 20f)));

            if (b_shield == true)
            {
                engine.engineSmoke.DrawParticle(gameTime, engine.offset);
                spriteBatch.Draw(engine.t_EngineSmoke, (engine.ship.Position + engine.offset + (Vector2.Transform(new Vector2(-9, 45), Matrix.CreateRotationZ((float)engine.ship.NextRotation)))), null, Color.Aqua, (float)engine.ship.NextRotation, new Vector2(0, 0), new Vector2(1.0f, 1.0f), SpriteEffects.None, 0);
                spriteBatch.Draw(engine.t_Shield, (engine.ship.Position + engine.offset), null, engine.Shield(), (float)engine.ship.NextRotation, new Vector2(30, 50), engine.v_ShieldSize, SpriteEffects.None, 0);
            }
            spriteBatch.Draw(t_TutorialOverlay, new Vector2(0, 0), new Color(1, 1, 1, (i_GridCounter / 75f)));
            spriteBatch.DrawString(game.fontName, "Synthesis Training Program: Ver 4.7", new Vector2(280, 0), new Color(0, 1, 1, (i_Number1Counter / 20f)));
            spriteBatch.Draw(t_TutorialText[(i_TextBubble - 1)], new Vector2(25, 580), new Color(1, 1, 1, (i_TutorialTextCounter / 75f)));
        }
コード例 #15
0
ファイル: Tutorial.cs プロジェクト: yinyangman/synthesis
        public override void Update(GameTime gameTime, Engine engine, Game1 game)
        {
            if (engine.i_ShipGridCounter < 75 && b_Grid == true)
            {
                engine.i_ShipGridCounter++;
            }
            else if (engine.i_ShipGridCounter == 75 && b_Grid == true)
            {
                b_Grid = false;
            }
            else if (i_GridCounter < 100 && b_Pulsing == false)
            {
                i_GridCounter++;
            }
            else if (i_GridCounter == 100 && b_Pulsing == false)
            {
                b_Pulsing = true;
            }
            else if (i_Number1Counter < 20)
            {
                i_Number1Counter++;
            }
            else if (i_Number2Counter < 20)
            {
                i_Number2Counter++;
            }
            else if (i_Number3Counter < 20)
            {
                i_Number3Counter++;
            }
            else if (i_Number4Counter < 20)
            {
                i_Number4Counter++;
            }
            else if (i_Number5Counter < 20)
            {
                i_Number5Counter++;
            }
            else if (engine.i_ShipCounter < 75)
            {
                engine.i_ShipCounter++;
            }
            else if (engine.i_ShipCounter == 75 && b_Grid == false && engine.i_ShipGridCounter > 0)
            {
                engine.i_ShipGridCounter--;
            }
            else if (engine.i_ShipCounter == 75 && b_Grid == false && engine.i_ShipGridCounter == 0 && b_shield == false)
            {
                b_shield = true;
            }
            else if (i_TutorialCounter < 100)
            {
                i_TutorialCounter++;
            }
            else if (i_TutorialTextCounter < 75)
            {
                i_TutorialTextCounter++;
            }
            else
            {
                #region Photon Updates
                if (engine.Photons[0].ParticleState == Particle.PState.Alive)
                {
                    if (engine.Photons[0].IsTethered)
                    {
                        if (!engine.ship.BoundSphere.Intersects(new BoundingSphere(new Vector3(engine.Photons[0].Position, 0), (engine.Photons[0].Texture.Width / 2))))
                        {
                            Vector2 distance = engine.ship.Position - engine.Photons[0].Position;
                            engine.Photons[0].Velocity += Vector2.Normalize(distance) * 20;
                        }
                    }
                    else
                    {
                        engine.Photons[0].Position -= new Vector2(0, 0.07f);
                    }
                    engine.Photons[0].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, engine.f_Friction);
                }
                else if (engine.Photons[0].ParticleState == Particle.PState.Spawning)
                {
                    if (engine.Photons[0].Scale > 1)
                    {
                        engine.Photons[0].Scale = 1.0f;
                        engine.Photons[0].ParticleState = Particle.PState.Alive;
                    }
                    else
                    {
                        engine.Photons[0].Scale += 0.02f;
                    }
                }
                else if (engine.Photons[0].ParticleState == Particle.PState.Fusing)
                {
                    if (engine.Photons[0].i_Fusing > 50)
                    {
                        engine.Photons[0].ParticleState = Particle.PState.Dead;
                        engine.Photons[0].i_Fusing = 0;
                    }
                    else
                    {
                        engine.Photons[0].i_Fusing++;
                    }
                }
                else if (engine.Photons[0].ParticleState == Particle.PState.Colliding)
                {
                    engine.Photons[0].Velocity = new Vector2((((engine.Photons[0].FusionPosition.X - engine.Photons[0].Position.X) / Vector2.Distance(engine.Photons[0].Position, engine.Photons[0].FusionPosition)) * 10), (((engine.Photons[0].FusionPosition.Y - engine.Photons[0].Position.Y) / Vector2.Distance(engine.Photons[0].Position, engine.Photons[0].FusionPosition)) * 10));
                    engine.Photons[0].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, engine.f_Friction);
                    if (engine.Photons[0].Position.X < (engine.Photons[0].FusionPosition.X + 1) && engine.Photons[0].Position.X > (engine.Photons[0].FusionPosition.X - 1) && engine.Photons[0].Position.Y < (engine.Photons[0].FusionPosition.Y + 1) && engine.Photons[0].Position.Y > (engine.Photons[0].FusionPosition.Y - 1))
                    {
                        for (int j = 0; j < levelData.i_MaxNumberFused; j++)
                        {
                            if (engine.Fused[j].ParticleState == Particle.PState.Dead)
                            {
                                engine.Fused[j].ParticleState = Particle.PState.Spawning;
                                engine.Photons[0].ParticleState = Particle.PState.Fusing;
                                engine.Fused[j].Position = engine.Photons[0].Position;
                                break;
                            }
                        }
                    }
                }
                #endregion
                #region Chloro Updates
                if (engine.Chlor[0].ParticleState == Particle.PState.Alive)
                {
                    if (engine.Chlor[0].IsTethered)
                    {
                        if (!engine.ship.BoundSphere.Intersects(new BoundingSphere(new Vector3(engine.Chlor[0].Position, 0), (engine.Chlor[0].Texture.Width / 2))))
                        {
                            Vector2 distance = engine.ship.Position - engine.Chlor[0].Position;
                            engine.Chlor[0].Velocity += Vector2.Normalize(distance) * 20;
                        }
                    }
                    else
                    {
                        engine.Chlor[0].Position += new Vector2(0, 0.07f);
                    }
                    engine.Chlor[0].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, engine.f_Friction);
                }
                else if (engine.Chlor[0].ParticleState == Particle.PState.Fusing)
                {
                    if (engine.Chlor[0].i_Fusing > 50)
                    {
                        engine.Chlor[0].ParticleState = Particle.PState.Dead;
                        engine.Chlor[0].i_Fusing = 0;
                    }
                    else
                    {
                        engine.Chlor[0].i_Fusing++;
                    }
                }
                else if (engine.Chlor[0].ParticleState == Particle.PState.Colliding)
                {
                    engine.Chlor[0].Velocity = new Vector2((((engine.Chlor[0].FusionPosition.X - engine.Chlor[0].Position.X) / Vector2.Distance(engine.Chlor[0].Position, engine.Chlor[0].FusionPosition)) * 10), (((engine.Chlor[0].FusionPosition.Y - engine.Chlor[0].Position.Y) / Vector2.Distance(engine.Chlor[0].Position, engine.Chlor[0].FusionPosition)) * 10));
                    engine.Chlor[0].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, engine.f_Friction);

                    if (engine.Chlor[0].Position.X < (engine.Chlor[0].FusionPosition.X + 1) && engine.Chlor[0].Position.X > (engine.Chlor[0].FusionPosition.X - 1) && engine.Chlor[0].Position.Y < (engine.Chlor[0].FusionPosition.Y + 1) && engine.Chlor[0].Position.Y > (engine.Chlor[0].FusionPosition.Y - 1))
                    {
                        engine.Chlor[0].ParticleState = Particle.PState.Fusing;
                    }
                }
                else if (engine.Chlor[0].ParticleState == Particle.PState.Spawning)
                {
                    if (engine.Chlor[0].Scale > 1)
                    {
                        engine.Chlor[0].Scale = 1.0f;
                        engine.Chlor[0].ParticleState = Particle.PState.Alive;
                    }
                    else
                    {
                        engine.Chlor[0].Scale += 0.02f;
                    }
                }
                #endregion
                #region Enemy Updates
                if (engine.enemies[0].EnemyCollision == true)
                {
                    engine.UpdateShieldSpark(engine.enemies[0].EnemyCollisionPosition, engine.enemies[0]);
                    engine.enemies[0].ShieldSparkCounter++;
                    if (engine.enemies[0].ShieldSparkCounter == 40)
                    {
                        engine.enemies[0].EnemyCollision = false;
                        engine.enemies[0].ShieldSparkCounter = 0;
                    }
                }

                if (engine.enemies[0].IsParticleKill == true)
                {
                    engine.UpdateParticleKill(engine.enemies[0].ParticleKillPosition, engine.enemies[0].p_ParticleKilled, engine.enemies[0]);
                    engine.enemies[0].ParticleKillCounter++;
                    if (engine.enemies[0].ParticleKillCounter == 40)
                    {
                        engine.enemies[0].IsParticleKill = false;
                        engine.enemies[0].ParticleKillCounter = 0;
                    }
                }
                if (engine.enemies[0].Alive == true)
                {
                    engine.enemies[0].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, engine.f_Friction);
                }
                #endregion
            }

            dt_TutorialTimer += gameTime.ElapsedGameTime;
            FunnyNumbers();

            if (b_Pulsing == true)
            {
                Pulsing();
            }

            if (TutMusic.IsPlaying == false)
            {
                TutMusic.Play();
            }
            else if (TutMusic.IsPaused == true)
            {
                TutMusic.Resume();
            }

            if (iTutorialState == 0)
            {
                tutCues[0].Play();
                iTutorialState++;
            }
            else if (iTutorialState == 1)
            {
                if (tutCues[0].IsStopped == true)
                {
                    iTutorialState++;
                }
            }
            else if (iTutorialState == 2)
            {
                totalPixelsTravelled.X += (float)Math.Sqrt(
                    (engine.ship.Position.X - lastShipPos.X) *
                    (engine.ship.Position.X - lastShipPos.X));

                totalPixelsTravelled.Y += (float)Math.Sqrt(
                    (engine.ship.Position.Y - lastShipPos.Y) *
                    (engine.ship.Position.Y - lastShipPos.Y));

                if ((totalPixelsTravelled.X + totalPixelsTravelled.Y) > 3000)
                {
                    tutCues[1].Play();
                    i_TextBubble = 2;
                    iTutorialState++;
                    dt_TutorialTimer = new DateTime(2000, 1, 1, 0, 0, 0, 0);
                    engine.Photons[0] = new Particle(new Vector2(768, 350));
                    engine.Photons[0].LoadTex(engine.t_Photon);
                    engine.Photons[0].ParticleState = Particle.PState.Spawning;
                    engine.Photons[0].Spawn(new Vector2(768, 350));
                    engine.Photons[0].SpawnTimer = 0;
                    game.soundBank.PlayCue("photonPop");
                }

                lastShipPos = engine.ship.Position;
            }
            else if (iTutorialState == 3)
            {
                if (dt_TutorialTimer.Second == 6)
                {
                    tutCues[2].Play();
                    i_TextBubble = 3;
                    iTutorialState++;
                    dt_TutorialTimer = new DateTime(2000, 1, 1, 0, 0, 0, 0);
                }
            }
            else if (iTutorialState == 4)
            {
                if (engine.tetherState == Engine.TetherState.tethered && dt_TutorialTimer.Second >= 11)
                {
                    tutCues[2].Stop(AudioStopOptions.Immediate);
                    tutCues[3].Play();
                    i_TextBubble = 4;
                    iTutorialState++;
                    dt_TutorialTimer = new DateTime(2000, 1, 1, 0, 0, 0, 0);
                }
            }
            else if (iTutorialState == 5)
            {
                if (engine.tetherState == Engine.TetherState.detethered && dt_TutorialTimer.Second >= 6)
                {
                    tutCues[4].Play();
                    i_TextBubble = 5;
                    iTutorialState++;
                    engine.Photons[0].ParticleState = Particle.PState.Dead;
                    dt_TutorialTimer = new DateTime(2000, 1, 1, 0, 0, 0, 0);
                    engine.Chlor[0] = new Particle(new Vector2(768, 350));
                    engine.Chlor[0].LoadTex(engine.t_Chlor);
                    engine.Chlor[0].ParticleState = Particle.PState.Spawning;
                    engine.Chlor[0].Spawn(new Vector2(768, 350));
                    engine.Chlor[0].SpawnTimer = 0;
                    game.soundBank.PlayCue("chlorPop");
                }
            }
            else if (iTutorialState == 6)
            {
                if (engine.tetherState == Engine.TetherState.tethered && engine.ship.IsPhoton == false && dt_TutorialTimer.Second >= 8)
                {
                    tutCues[5].Play();
                    i_TextBubble = 6;
                    iTutorialState++;
                    dt_TutorialTimer = new DateTime(2000, 1, 1, 0, 0, 0, 0);
                    engine.Photons[0] = new Particle(new Vector2(768, 350));
                    engine.Photons[0].LoadTex(engine.t_Photon);
                    engine.Photons[0].ParticleState = Particle.PState.Spawning;
                    engine.Photons[0].Spawn(new Vector2(768, 350));
                    engine.Photons[0].SpawnTimer = 0;
                    game.soundBank.PlayCue("photonPop");
                }
            }
            else if (iTutorialState == 7)
            {
                if (b_TutorialFusion == true && dt_TutorialTimer.Second >= 7)
                {
                    tutCues[6].Play();
                    i_TextBubble = 7;
                    iTutorialState++;
                    dt_TutorialTimer = new DateTime(2000, 1, 1, 0, 0, 0, 0);
                }
            }
            else if (iTutorialState == 8)
            {
                if (dt_TutorialTimer.Second >= 10 && tutBulletCounter > 20)
                {
                    tutCues[7].Play();
                    i_TextBubble = 8;
                    iTutorialState++;
                    dt_TutorialTimer = new DateTime(2000, 1, 1, 0, 0, 0, 0);
                }
            }
            else if (iTutorialState == 9)
            {
                if (dt_TutorialTimer.Second >= 10)
                {
                    tutCues[8].Play();
                    engine.enemies[0] = new Enemy(game, EnemyData.Type.Normal);
                    engine.enemies[0].LoadTexture(game.Content);
                    engine.enemies[0].Spawn(new Vector2(900, 100));
                    engine.enemies[0].SpawnTimer = 0;
                    engine.enemies[0].Rectangle = new Rectangle(((int)engine.enemies[0].Position.X - (engine.enemies[0].Texture.Width / 2)), ((int)engine.enemies[0].Position.Y - (engine.enemies[0].Texture.Height / 2)), engine.enemies[0].Texture.Width, engine.enemies[0].Texture.Height);
                    engine.enemies[0].TextureData = new Color[engine.enemies[0].Texture.Width * engine.enemies[0].Texture.Height];
                    engine.enemies[0].Texture.GetData(engine.enemies[0].TextureData);

                    i_TextBubble = 9;
                    iTutorialState++;
                    dt_TutorialTimer = new DateTime(2000, 1, 1, 0, 0, 0, 0);
                }
            }
            else if (iTutorialState == 10)
            {
                if (dt_TutorialTimer.Second >= 10 && engine.enemies[0].Alive == false)
                {
                    tutCues[9].Play();
                    engine.enemies[0] = new Enemy(game, EnemyData.Type.Destroyer);
                    engine.enemies[0].LoadTexture(game.Content);
                    engine.enemies[0].Spawn(new Vector2(900, 100));
                    engine.enemies[0].SpawnTimer = 0;
                    engine.enemies[0].Rectangle = new Rectangle(((int)engine.enemies[0].Position.X - (engine.enemies[0].Texture.Width / 2)), ((int)engine.enemies[0].Position.Y - (engine.enemies[0].Texture.Height / 2)), engine.enemies[0].Texture.Width, engine.enemies[0].Texture.Height);
                    engine.enemies[0].TextureData = new Color[engine.enemies[0].Texture.Width * engine.enemies[0].Texture.Height];
                    engine.enemies[0].Texture.GetData(engine.enemies[0].TextureData);

                    engine.Chlor[0] = new Particle(new Vector2(768, 350));
                    engine.Chlor[0].LoadTex(engine.t_Chlor);
                    engine.Chlor[0].ParticleState = Particle.PState.Spawning;
                    engine.Chlor[0].Spawn(new Vector2(768, 350));
                    engine.Chlor[0].SpawnTimer = 0;
                    game.soundBank.PlayCue("chlorPop");
                    i_TextBubble = 10;
                    iTutorialState++;
                    dt_TutorialTimer = new DateTime(2000, 1, 1, 0, 0, 0, 0);
                }
            }
            else if (iTutorialState == 11)
            {
                if (engine.enemies[0].Alive == false && dt_TutorialTimer.Second >= 9)
                {
                    tutCues[10].Play();
                    i_TextBubble = 11;
                    iTutorialState++;
                    dt_TutorialTimer = new DateTime(2000, 1, 1, 0, 0, 0, 0);
                }
            }
            else if (iTutorialState == 12)
            {
                if (dt_TutorialTimer.Second == 10)
                {
                    iTutorialState = 13;
                    dt_TutorialTimer = new DateTime(2000, 1, 1, 0, 0, 0, 0);
                }
            }
            else if (iTutorialState == 13)
            {
                game.fd_Fader.BeginFadingToBlack(75, true, this);
                iTutorialState++;
            }
        }
コード例 #16
0
ファイル: Tutorial.cs プロジェクト: yinyangman/synthesis
 public void FinishedFadingToBlack(Game1 game)
 {
     game.gameState = State.LevelIntro;
     TutMusic.Pause();
     dt_TutorialTimer = new DateTime(2000, 1, 1, 0, 0, 0, 0);
 }
コード例 #17
0
ファイル: Fader.cs プロジェクト: yinyangman/synthesis
 public void Initialize(Game1 newGame)
 {
     game = newGame;
 }
コード例 #18
0
ファイル: Fader.cs プロジェクト: yinyangman/synthesis
 public void BeginFadingToBlack(float max, bool fadeIn, Game1 game)
 {
     BeginFadingToBlack(max, fadeIn);
     fadeToBlackDelegate = new FinishedFadingToBlackDelegate(game.FinishedFadingToBlack);
 }
コード例 #19
0
ファイル: Engine.cs プロジェクト: yinyangman/synthesis
        public void COLLISION(Ship ship, Enemy enemy, Game1 game)
        {
            if (ship.Rectangle.Intersects(enemy.Rectangle))
            {

                if (IntersectPixels(enemy.RectanglePosTransform,
                                    enemy.Texture.Width,
                                    enemy.Texture.Height,
                                    enemy.TextureData,
                                    ship.RotationTransform,
                                    ship.Texture.Width,
                                    ship.Texture.Height,
                                    ship.TextureData))
                {

                    i_VibrateCounter++; //add to vibration amount

                    enemy.EnemyCollisionPosition = enemy.Position;// -new Vector2(enemy.Texture.Width / 2, enemy.Texture.Height / 2);
                    ship.ShipShield -= 25;
                    if (ship.ShipShield < 0)
                    {
                        //You are Dead
                        game.soundBank.PlayCue("shipExplode");
                        dead = true;
                    }
                    if (ship.ShipShield == 75)
                    {
                        game.soundBank.PlayCue("75percent");
                    }
                    else if (ship.ShipShield == 50)
                    {
                        game.soundBank.PlayCue("50percent");
                    }
                    else if (ship.ShipShield == 25)
                    {
                        game.soundBank.PlayCue("25percent");
                    }
                    else if (ship.ShipShield == 0)
                    {
                        ship.ShipShield = -1;
                        game.soundBank.PlayCue("shieldsdown");
                    }
                    else
                        enemy.EnemyCollision = true;
                    ship.Hit = true;
                    enemy.Alive = false;
                    game.soundBank.PlayCue("enemyDie");
                    game.vibrate = 20;

                    if (enemy.closestParticle != null)
                    {
                        enemy.closestParticle.BeingAttacked = false;
                        enemy.closestParticle.Attacker = null;
                        if (enemy.closestParticle.IsTethered == false)
                        {
                            enemy.closestParticle.Color = Color.White;
                        }
                    }
                }
            }
        }
コード例 #20
0
ファイル: Enemy.cs プロジェクト: yinyangman/synthesis
 public Enemy(Game1 game, EnemyData.Type type)
 {
     ed_EnemyData = game.EnemyDataForType(type);
     InitaliseEnemy(game);
 }
コード例 #21
0
ファイル: Engine.cs プロジェクト: yinyangman/synthesis
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Game1 game)
        {
            if (game.gameState != State.Tutorial)
            {
                spriteBatch.DrawString(game.font, f_Fusions.ToString("00") + "/" + loadedLevel.levelData.i_TargetFusions.ToString("00"), new Vector2(46, 727), Color.DarkGray);
                spriteBatch.DrawString(game.font, f_Fusions.ToString("00") + "/" + loadedLevel.levelData.i_TargetFusions.ToString("00"), new Vector2(47, 728), Color.White);
                spriteBatch.Draw(t_ClockBase, new Vector2(15, 650), Color.White);
                spriteBatch.DrawString(game.font, dt_timer.Minute.ToString("0") + ":" + dt_timer.Second.ToString("00"), new Vector2(25, 668), Color.Black);
                spriteBatch.Draw(t_Fused, new Vector2(10, 725), null, Color.White, 0, new Vector2(0, 0), new Vector2(0.5f, 0.5f), SpriteEffects.None, 0);
                for (int i = 0; i < 8; i++)
                {
                    if (i < segments)
                    {
                        spriteBatch.Draw(t_ClockSegFill[7 - i], new Vector2(15, 650), Color.White);
                    }
                }
            }

            engineSmoke.DrawParticle(gameTime, offset);
            spriteBatch.Draw(t_EngineSmoke, (ship.Position + offset + (Vector2.Transform(new Vector2(-9, 45), Matrix.CreateRotationZ((float)ship.NextRotation)))), null, Color.Aqua, (float)ship.NextRotation, new Vector2(0, 0), new Vector2(1.0f, 1.0f), SpriteEffects.None, 0);

            if (tetherState == Engine.TetherState.tethered)
            {
                for (int i = 0; i < i_StupidLineMax; i++)
                {
                    if (stupidline[i].Alive == true && tetherState == Engine.TetherState.tethered)
                    {
                        spriteBatch.Draw(stupidline[i].Texture, stupidline[i].Position + offset, null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
                    }
                }
            }
            for (int i = 0; i < Photons.Length; i++)
            {
                if (Photons[i].ParticleState == Particle.PState.Alive || Photons[i].ParticleState == Particle.PState.Spawning || Photons[i].ParticleState == Particle.PState.Colliding || Photons[i].ParticleState == Particle.PState.Fusing)
                {
                    spriteBatch.Draw(Photons[i].Texture, Photons[i].Position + offset, null, Photons[i].Color, 0, new Vector2(Photons[i].Texture.Width / 2, Photons[i].Texture.Height / 2), Photons[i].Scale, SpriteEffects.None, 0);
                }
            }
            for (int i = 0; i < Chlor.Length; i++)
            {
                if (Chlor[i].ParticleState == Particle.PState.Alive || Chlor[i].ParticleState == Particle.PState.Spawning || Chlor[i].ParticleState == Particle.PState.Colliding || Chlor[i].ParticleState == Particle.PState.Fusing)
                {
                    spriteBatch.Draw(Chlor[i].Texture, Chlor[i].Position + offset, null, Chlor[i].Color, 0, new Vector2(Chlor[i].Texture.Width / 2, Chlor[i].Texture.Height / 2), Chlor[i].Scale, SpriteEffects.None, 0);
                }
            }
            for (int i = 0; i < Fused.Length; i++)
            {
                if (Fused[i].ParticleState == Particle.PState.Alive)
                {
                    spriteBatch.Draw(Fused[i].Texture, Fused[i].Position + offset, null, Fused[i].Color, 0, new Vector2(Fused[i].Texture.Width / 2, Fused[i].Texture.Height / 2), 1, SpriteEffects.None, 0);
                }
                Fused[i].Fusion.DrawParticle(gameTime, offset);

            }

            for (int i = 0; i < loadedLevel.levelData.i_MaxNumberEnemies; i++)
            {
                enemies[i].ParticleKill.DrawParticle(gameTime, offset);
                if (enemies[i].Alive == true)
                {
                    spriteBatch.Draw(enemies[i].Texture, enemies[i].Position + offset, null, Color.White, enemies[i].f_Rotation, new Vector2(enemies[i].Texture.Width / 2, enemies[i].Texture.Height / 2), 1, SpriteEffects.None, 0);
                }
                enemies[i].ShieldSpark.DrawParticle(gameTime, offset);
            }

            if (dead == false)
            {
                Color shipColor = ship.Color;
                shipColor.A = (byte)((i_ShipCounter / 75f)*255);

                Color shipGridColor = ship.Color;
                shipGridColor.A = (byte)((i_ShipGridCounter / 75f)*255);

                spriteBatch.Draw(ship.Texture, (ship.Position + offset), null, shipColor, (float)ship.NextRotation, new Vector2(30, 50), new Vector2(1.0f, 1.0f), SpriteEffects.None, 0);
                spriteBatch.Draw(ship.Turret, (ship.Position + offset + Vector2.Transform(new Vector2(0, 20), Matrix.CreateRotationZ((float)ship.NextRotation))), null, shipColor, (float)ship.NextRotationTurret, new Vector2(12f, 18f), new Vector2(1.0f, 1.0f), SpriteEffects.None, 0);
                spriteBatch.Draw(t_ShipGrid, (ship.Position + offset), null, shipGridColor, (float)ship.NextRotation, new Vector2(30, 50), new Vector2(1.0f, 1.0f), SpriteEffects.None, 0);
            }
            else
            {
                spriteBatch.Draw(ship.Texture, (ship.Position + offset), null, new Color(0.2f, 0.2f, 0.2f), (float)ship.NextRotation, new Vector2(30, 50), new Vector2(1.0f, 1.0f), SpriteEffects.None, 0);
                spriteBatch.Draw(ship.Turret, (ship.Position + offset + Vector2.Transform(new Vector2(0, 20), Matrix.CreateRotationZ((float)ship.NextRotation))), null, Color.Black, (float)ship.NextRotationTurret, new Vector2(12f, 18f), new Vector2(1.0f, 1.0f), SpriteEffects.None, 0);

                if (i_ExplosionTimer < 100)
                {
                    shipExplosion.DrawParticle(gameTime, offset);
                    i_ExplosionTimer++;
                }
                else
                {
                    game.fd_Fader.BeginFadingToBlack(75, true, game);
                }
            }
            for (int i = 0; i < i_BulletMax; i++)
            {
                if (bullets[i].Alive == true)
                {
                    spriteBatch.Draw(bullets[i].Texture, bullets[i].Position + offset, null, Color.White, 0, new Vector2(bullets[i].Texture.Width / 2, bullets[i].Texture.Height / 2), 1, SpriteEffects.None, 0);
                }
                if (tethers[i].Alive == true)
                {
                    spriteBatch.Draw(tethers[i].Texture, tethers[i].Position + offset, null, Color.White, 0, new Vector2(tethers[i].Texture.Width / 2, tethers[i].Texture.Height / 2), 1, SpriteEffects.None, 0);
                }
            }

            if (game.gameState == State.Paused)
            {
                spriteBatch.Draw(game.fd_Fader.t_MasterFadeBlack , new Vector2(0, 0), new Color(1f, 1f, 1f, 0.5f));
                spriteBatch.DrawString(game.fontBig, "Paused", new Vector2(282, 277), Color.DarkGray);
                spriteBatch.DrawString(game.font, "Shield Strength: " + ship.ShieldStrength + "%", new Vector2(414, 419), Color.DarkGray);
                spriteBatch.DrawString(game.fontBig, "Paused", new Vector2(285, 280), Color.White);
                spriteBatch.DrawString(game.font, "Shield Strength: " + ship.ShieldStrength + "%", new Vector2(415, 420), Color.White);
            }

            if (b_shield)
            {
                spriteBatch.Draw(t_Shield, (ship.Position + offset), null, Shield(), (float)ship.NextRotation, new Vector2(30, 50), v_ShieldSize, SpriteEffects.None, 0);
            }

            spriteBatch.Draw(t_Crosshair, new Vector2((Mouse.GetState().X - (t_Crosshair.Width / 2)), (Mouse.GetState().Y - (t_Crosshair.Height / 2))), Color.White);
            spriteBatch.DrawString(game.font, ship.TurretDirection.ToString(), new Vector2(0, 0), Color.Red);
        }
コード例 #22
0
ファイル: Game1.cs プロジェクト: yinyangman/synthesis
        public void FinishedFadingToBlack(Game1 game)
        {
            if (gameState == State.Menu)
            {
                gameState = State.Loading;
            }
            else if (gameState == State.Loading)
            {
                gameState = State.GameIntro;
            }
            else if (gameState == State.GameIntro)
            {
                v_Video1.Dispose();

                if (TutorialOn == true)
                {
                    gameEngine.InitalizeLevel(LevelForName("Tutorial"), this);
                    gameState = State.Tutorial;
                }
                else if (TutorialOn == false)
                {
                    gameEngine.i_ShipCounter = 75;
                    gameEngine.InitalizeLevel(LevelForName(currentLevel), this);
                    gameState = State.Gameplay;
                }
            }
            else if (gameState == State.Gameplay)
            {
                gameEngine.Ambient.Pause();
                gameState = State.GameEnd;
            }
        }
コード例 #23
0
ファイル: Engine.cs プロジェクト: yinyangman/synthesis
        public void FireCheck(Game1 game)
        {
            #region Shooting
            #region Controller
            GamePadState gamepadStateCurr = GamePad.GetState(PlayerIndex.One);
            if (gamepadStateCurr.IsButtonDown(Buttons.RightTrigger))
            {
                if (i_FireRate == 7)
                {
                    i_FireRate = 0;
                    //FireBullet
                    for (int i = 0; i < i_BulletMax; i++)
                    {
                        if (bullets[i].Alive == false)
                        {
                            bullets[i].ResetBullet();
                            if (game.gameState == State.Tutorial)
                            {
                                Tutorial tutorial = (Tutorial)loadedLevel;
                                tutorial.tutBulletCounter++;
                            }
                            v_TurretDirection = ship.TurretDirection;
                            bullets[i].Fire(ship, v_TurretDirection);
                            game.soundBank.PlayCue("lazer");
                            break;
                        }
                    }
                }
                else
                {
                    i_FireRate++;
                }
            }
            else if (Mouse.GetState().LeftButton == ButtonState.Released && gamepadStateCurr.IsButtonDown(Buttons.RightTrigger) == false)
            {
                i_FireRate = 7;
            }
            #endregion
            #region Mouse
            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                if (i_FireRate == 7)
                {
                    i_FireRate = 0;
                    //FireBullet
                    for (int i = 0; i < i_BulletMax; i++)
                    {
                        if (bullets[i].Alive == false)
                        {
                            if (game.gameState == State.Tutorial)
                            {
                                Tutorial tutorial = (Tutorial)loadedLevel;
                                tutorial.tutBulletCounter++;
                            }
                            v_TurretDirection = ship.TurretDirection;
                            bullets[i].Position = new Vector2(0, 0);
                            bullets[i].Fire(ship, v_TurretDirection);
                            game.soundBank.PlayCue("lazer");
                            break;
                        }
                    }
                }
                else
                {
                    i_FireRate++;
                }
            }
            else if (Mouse.GetState().LeftButton == ButtonState.Released && gamepadStateCurr.IsButtonDown(Buttons.RightTrigger) == false)
            {
                i_FireRate = 7;
            }
            #endregion
            #endregion
            #region Tethering
            #region Controller
            if (gamepadStateCurr.IsButtonDown(Buttons.LeftTrigger))
            {
                switch (tetherState)
                {
                    case TetherState.shooting:
                        if (game.lastLTrigger == false)
                        {
                            game.soundBank.PlayCue("tetherFire");
                        }
                        //FireBullet
                        for (int i = 0; i < i_BulletMax; i++)
                        {
                            if (tethers[i].Alive == false)
                            {
                                v_TurretDirection = ship.TurretDirection;
                                tethers[i].Fire(ship, v_TurretDirection);
                                break;
                            }
                        }
                        break;

                    case TetherState.tethered:
                        if (game.lastLTrigger == false)
                        {
                            if (ship.IsPhoton)
                            {
                                Photons[ship.TetheredParticleID].IsTethered = false;
                                Photons[ship.TetheredParticleID].Color = Color.White;
                            }
                            else
                            {
                                Chlor[ship.TetheredParticleID].IsTethered = false;
                                Chlor[ship.TetheredParticleID].Color = Color.White;
                            }
                            tetherState = TetherState.detethered;
                            game.soundBank.PlayCue("deTether");
                        }
                        break;

                    case TetherState.detethered:
                        if (game.lastLTrigger == false)
                        {
                            tetherState = TetherState.shooting;
                        }
                        break;
                }

                game.lastLTrigger = true;
            }
            else
            {
                game.lastLTrigger = false;
            }
            #endregion
            #region Mouse
            if (Mouse.GetState().RightButton == ButtonState.Pressed)
            {
                switch (tetherState)
                {
                    case TetherState.shooting:
                        if (game.lastRMouse == false)
                        {
                            game.soundBank.PlayCue("tetherFire");
                        }
                        //FireBullet
                        for (int i = 0; i < i_BulletMax; i++)
                        {
                            if (tethers[i].Alive == false)
                            {
                                v_TurretDirection = ship.TurretDirection;
                                tethers[i].Fire(ship, v_TurretDirection);
                                break;
                            }
                        }
                        break;

                    case TetherState.tethered:

                        if (game.lastRMouse == false)
                        {
                            if (ship.IsPhoton)
                            {
                                Photons[ship.TetheredParticleID].IsTethered = false;
                                Photons[ship.TetheredParticleID].Color = Color.White;
                            }
                            else
                            {
                                Chlor[ship.TetheredParticleID].IsTethered = false;
                                Chlor[ship.TetheredParticleID].Color = Color.White;
                            }
                            tetherState = TetherState.detethered;
                            game.soundBank.PlayCue("deTether");
                        }
                        break;

                    case TetherState.detethered:
                        if (game.lastRMouse == false)
                        {
                            tetherState = TetherState.shooting;
                        }
                        break;
                }

                game.lastRMouse = true;
            }
            else
            {
                game.lastRMouse = false;
            }
            #endregion
            #endregion
        }
コード例 #24
0
ファイル: Engine.cs プロジェクト: yinyangman/synthesis
        public void InitalizeLevel(Level level, Game1 game)
        {
            loadedLevel = level;

            f_Fusions = 0;
            i_ShieldPulseCounter = 0;
            i_shipAlpha = 0.5f;
            i_PulseRate = 60;

            enemies = new Enemy[loadedLevel.levelData.i_MaxNumberEnemies];
            for (int j = 0; j < loadedLevel.levelData.i_MaxNumberEnemies; j++)
            {
                enemies[j] = new Enemy(game, loadedLevel);
                enemies[j].LoadTexture(game.Content);
                enemies[j].Rectangle = new Rectangle(((int)enemies[j].Position.X - (enemies[j].Texture.Width / 2)), ((int)enemies[j].Position.Y - (enemies[j].Texture.Height / 2)), enemies[j].Texture.Width, enemies[j].Texture.Height);
                enemies[j].TextureData = new Color[enemies[j].Texture.Width * enemies[j].Texture.Height];
                enemies[j].Texture.GetData(enemies[j].TextureData);
                enemies[j].ShieldSpark = new ShieldSparkParticleSystem(game, 3);
                game.Components.Add(enemies[j].ShieldSpark);
                enemies[j].ParticleKill = new ParticleKillParticleSystem(game, 4);
                game.Components.Add(enemies[j].ParticleKill);
            }

            Fused = new Particle[loadedLevel.levelData.i_MaxNumberFused];
            for (int j = 0; j < loadedLevel.levelData.i_MaxNumberFused; j++)
            {
                Fused[j] = new Particle(loadedLevel.levelBounds);
                Fused[j].Fusion = new FusionParticleSystem(game, 20);
                game.Components.Add(Fused[j].Fusion);
                Fused[j].LoadTex(t_Fused);
            }

            Photons = new Particle[loadedLevel.levelData.i_MaxNumberPhotons];
            for (int j = 0; j < loadedLevel.levelData.i_MaxNumberPhotons; j++)
            {
                Photons[j] = new Particle(loadedLevel.levelBounds);
                Photons[j].LoadTex(t_Photon);
                Photons[j].Fusion = new FusionParticleSystem(game, 20);
                game.Components.Add(Photons[j].Fusion);
            }
            Chlor = new Particle[loadedLevel.levelData.i_MaxNumberChloro];
            for (int j = 0; j < loadedLevel.levelData.i_MaxNumberChloro; j++)
            {
                Chlor[j] = new Particle(loadedLevel.levelBounds);
                Chlor[j].LoadTex(t_Chlor);
                Chlor[j].Fusion = new FusionParticleSystem(game, 20);
                game.Components.Add(Chlor[j].Fusion);
            }

            bullets = new Bullet[i_BulletMax];
            tethers = new Bullet[i_BulletMax];
            for (int j = 0; j < i_BulletMax; j++)
            {
                bullets[j] = new Bullet(t_Bullet);
                tethers[j] = new Bullet(t_Tether);
            }
            stupidline = new Bullet[i_StupidLineMax];
            for (int j = 0; j < i_StupidLineMax; j++)
            {
                stupidline[j] = new Bullet(t_Tether);
            }

            ship = new Ship(500, 350, t_Ship);
            ship.Turret = game.Content.Load<Texture2D>("Ship//turret");
            tetherState = TetherState.shooting;

            offset = ship.OffsetUpdate(offset);
            engineSmoke = new EngineParticleSystem(game, 9);
            game.Components.Add(engineSmoke);
            shipExplosion = new ExplosionParticleSystem(game, 9);
            game.Components.Add(shipExplosion);
        }
コード例 #25
0
ファイル: Level.cs プロジェクト: yinyangman/synthesis
 public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch, Engine engine, Game1 game)
 {
     spriteBatch.Draw(t_Background, (new Vector2(0, 0) + engine.offset), Color.White);
 }
コード例 #26
0
ファイル: Engine.cs プロジェクト: yinyangman/synthesis
        public void LEVELCOLLISION(Ship item, Game1 game)
        {
            if (item.Rectangle.Intersects(loadedLevel.levelData.levelLeft) ||
                item.Rectangle.Intersects(loadedLevel.levelData.levelRight) ||
                item.Rectangle.Intersects(loadedLevel.levelData.levelTop) ||
                item.Rectangle.Intersects(loadedLevel.levelData.levelBottom))
            {

                if (IntersectPixels(item.RotationTransform,
                                    item.Texture.Width,
                                    item.Texture.Height,
                                    item.TextureData,
                                    Matrix.Identity,
                                    loadedLevel.t_LevelBounds.Width,
                                    loadedLevel.t_LevelBounds.Height,
                                    loadedLevel.levelBoundsData))
                {

                    i_VibrateCounter++;

                    if (item.Position.Y < loadedLevel.levelData.levelTop.Height)
                    {
                        item.Position += new Vector2(0, 5);
                        item.Velocity *= new Vector2(1, -f_EdgeDamper);
                    }
                    else if (item.Position.Y > loadedLevel.levelData.levelTop.Height + loadedLevel.levelData.levelBottom.Y)
                    {
                        item.Position -= new Vector2(0, item.Position.Y - (loadedLevel.levelData.levelTop.Height + loadedLevel.levelData.levelBottom.Y));
                        item.Velocity *= new Vector2(1, -f_EdgeDamper);
                    }
                    if (item.Position.X < loadedLevel.levelData.levelTop.X)
                    {
                        item.Position += new Vector2(loadedLevel.levelData.levelTop.X - item.Position.X, 0);
                        item.Velocity *= new Vector2(-f_EdgeDamper, 1);
                    }
                    else if (item.Position.X > loadedLevel.levelData.levelTop.X + loadedLevel.levelData.levelRight.X)
                    {
                        item.Position -= new Vector2(item.Position.X - (loadedLevel.levelData.levelTop.X + loadedLevel.levelData.levelRight.X), 0);
                        item.Velocity *= new Vector2(-f_EdgeDamper, 1);
                    }

                }
            }
        }
コード例 #27
0
ファイル: Level.cs プロジェクト: yinyangman/synthesis
 public virtual void Update(GameTime gameTime, Engine engine, Game1 game)
 {
 }
コード例 #28
0
 /// <summary>
 /// Constructs a new ParticleSystem.
 /// </summary>
 /// <param name="game">The host for this particle system. The game keeps the 
 /// content manager and sprite batch for us.</param>
 /// <param name="howManyEffects">the maximum number of particle effects that
 /// are expected on screen at once.</param>
 /// <remarks>it is tempting to set the value of howManyEffects very high.
 /// However, this value should be set to the minimum possible, because
 /// it has a large impact on the amount of memory required, and slows down the
 /// Update and Draw functions.</remarks>
 protected ParticleSystem(Synthesis.Game1 game, int howManyEffects)
     : base(game)
 {
     this.game = game;
     this.howManyEffects = howManyEffects;
 }