Exemple #1
0
        public void HandleEnemies()
        {
            // Collision with weapons check

            foreach (KeyValuePair <int, WeaponObject[]> entry in mainPlayer.weaponDict)
            {
                foreach (WeaponObject w in entry.Value)
                {
                    if (w.isAlive && w.isSolid)
                    {
                        //for title1
                        if (iTitle.isAlive)
                        {
                            if (iTitle.CheckCollision(w.position, w.texture.Width, w.texture.Height))
                            {
                                w.isAlive = false;
                                iTitle.HP--;
                            }
                        }
                        //for title2
                        if (iiTitle.isAlive)
                        {
                            if (iiTitle.CheckCollision(w.position, w.texture.Width, w.texture.Height))
                            {
                                w.isAlive = false;
                                iiTitle.HP--;
                            }
                        }
                        //for title3
                        if (iiiTitle.isAlive)
                        {
                            if (iiiTitle.CheckCollision(w.position, w.texture.Width, w.texture.Height))
                            {
                                w.isAlive = false;
                                iiiTitle.HP--;
                            }
                        }
                    }
                }
            }

            //for title1
            if (iTitle.isKilled == true && iTitle.isAlive == false)
            {
                Game.Components.Remove(iTitle);
                iTitle.Dispose();
            }
            //for title2
            if (iiTitle.isKilled == true && iiTitle.isAlive == false)
            {
                Game.Components.Remove(iiTitle);
                iiTitle.Dispose();
            }
            //for title3
            if (iiiTitle.isKilled == true && iiiTitle.isAlive == false)
            {
                Game.Components.Remove(iiiTitle);
                iiiTitle.Dispose();
            }
        }
Exemple #2
0
        public override void Update(GameTime gameTime)
        {
            // Level logic update here


            Handle_and_CheckWeaponCollision(canyouseemeTitle);

            if (canyouseemeTitle.isKilled && IPreadytolearnTitle.isActive == false)
            {
                //continue to next message
                mainPlayer.activeTextureID = 8;
                timeCounter += gameTime.ElapsedGameTime.TotalMilliseconds;
                //enter only once
                if (timeCounter > 2000 && IPreadytolearnTitle.isActive == false)
                {
                    //add next message
                    IPreadytolearnTitle.isActive = true;
                    Game.Components.Add(IPreadytolearnTitle);
                    timeCounter = 0;
                }
            }


            if (IPreadytolearnTitle.isActive && lvl2warning1.isActive == false)
            {
                Handle_and_CheckWeaponCollision(IPreadytolearnTitle);

                if (IPreadytolearnTitle.isKilled)
                {
                    timeCounter += gameTime.ElapsedGameTime.TotalMilliseconds;

                    if (timeCounter > 2000)
                    {
                        lvl2warning1.isActive = true;
                        Game.Components.Add(lvl2warning1);
                        timeCounter = 0;
                    }
                }
            }



            if (lvl2warning1.isActive && keepafloat.isActive == false)
            {
                Handle_and_CheckWeaponCollision(lvl2warning1);

                if (lvl2warning1.isKilled)
                {
                    timeCounter += gameTime.ElapsedGameTime.TotalMilliseconds;

                    if (timeCounter > 2000)
                    {
                        keepafloat.isActive = true;
                        Game.Components.Add(keepafloat);
                        timeCounter = 0;
                    }
                }
            }



            if (keepafloat.isActive && letsstartthelearning.isActive == false)
            {
                Handle_and_CheckWeaponCollision(keepafloat);

                if (keepafloat.isKilled)
                {
                    timeCounter += gameTime.ElapsedGameTime.TotalMilliseconds;

                    if (timeCounter > 2000)
                    {
                        letsstartthelearning.isActive = true;
                        Game.Components.Add(letsstartthelearning);
                        timeCounter = 0;
                    }
                }
            }



            if (letsstartthelearning.isActive && forscience.isActive == false)
            {
                Handle_and_CheckWeaponCollision(letsstartthelearning);

                if (letsstartthelearning.isKilled)
                {
                    timeCounter += gameTime.ElapsedGameTime.TotalMilliseconds;

                    if (timeCounter > 1000)
                    {
                        forscience.isActive = true;
                        Game.Components.Add(forscience);
                        timeCounter = 0;
                    }
                }
            }



            if (forscience.isActive && apertureascii.isActive == false)
            {
                Handle_and_CheckWeaponCollision(forscience);

                if (forscience.isKilled)
                {
                    timeCounter += gameTime.ElapsedGameTime.TotalMilliseconds;

                    if (timeCounter > 1000)
                    {
                        apertureascii.isActive = true;
                        Game.Components.Add(apertureascii);
                        timeCounter = 0;

                        apertureascii.velocity    = new Vector2(5, 0);
                        apertureascii.friction    = 0;
                        apertureascii.speed       = 1;
                        apertureascii.isUnFading  = true;
                        apertureascii.customRGBA  = 20;
                        apertureascii.colorLerp.R = (byte)apertureascii.customRGBA;
                        apertureascii.colorLerp.G = (byte)apertureascii.customRGBA;
                        apertureascii.colorLerp.B = (byte)apertureascii.customRGBA;
                        apertureascii.colorLerp.A = (byte)apertureascii.customRGBA;

                        apertureascii.rotation = -0.001f;
                    }
                }
            }


            if (apertureascii.isActive && apertureascii.isKilled == false)
            {
                if (apertureascii.IsInsideScreen(apertureascii.texture))
                {
                    apertureascii.isWallBouncing = true;
                    apertureascii.rotation      += totalAngularVelocity;
                    mainPlayer.activeTextureID   = 9;

                    if (apertureascii.customRGBA > 200)
                    {
                        mainPlayer.activeTextureID = 10;
                    }

                    Handle_and_CheckWeaponCollisionLightUp(apertureascii, gameTime);
                }
            }

            if (apertureascii.isKilled)
            {
                isCompleted = true;
            }

            if (forscience.isAlive == false)
            {
                Game.Components.Remove(canyouseemeTitle);
                canyouseemeTitle.Dispose();

                Game.Components.Remove(IPreadytolearnTitle);
                IPreadytolearnTitle.Dispose();

                Game.Components.Remove(keepafloat);
                keepafloat.Dispose();


                Game.Components.Remove(letsstartthelearning);
                letsstartthelearning.Dispose();


                Game.Components.Remove(lvl2warning1);
                lvl2warning1.Dispose();

                Game.Components.Remove(forscience);
                forscience.Dispose();
            }

            PE1.UpdateParticles(PE1.ParticleArray, gameTime, (mainPlayer.position));

            if (mainPlayer.IsInsideScreen(mainPlayer.textureList[mainPlayer.activeTextureID]) == false)
            {
                mainPlayer.position = new Vector2(Game1.screenWidth / 2, Game1.screenHeight - 100);
            }


            base.Update(gameTime);
        }