Beispiel #1
0
        void LoadDifficulty()
        {
            MenuReset("Select Difficulty");
            Add(new MenuOption("Normal", delegate()
            {
                Miasma.ResetUpgradePool();
                Miasma.stage = 0;
                Miasma.wave  = 0;
                Miasma.hard  = false;

                Miasma.LeaveMenu();
                Miasma.player.UpdateStats();
                Miasma.Save();
                Sounds.PlayMusic(1);
            }));
            Add(new MenuOption("Hard", delegate()
            {
                Miasma.ResetUpgradePool();
                Miasma.stage = 0;
                Miasma.hard  = true;
                Miasma.wave  = 0;
                Miasma.LeaveMenu();
                Miasma.player.UpdateStats();
                Miasma.Save();
                Sounds.PlayMusic(1);
            }));
            Add(new MenuOption("Back", delegate()
            {
                LoadMainMenu();
            }));
        }
Beispiel #2
0
 public void LoadPause()
 {
     MenuReset("Paused");
     Add(new MenuOption("Back to Game", delegate()
     {
         Miasma.LeaveMenu();
     },
                        delegate()
     {
         if (Controls.JustPushedPause())
         {
             Miasma.LeaveMenu();
         }
     }));
     Add(new MenuOption("To Main Menu", delegate()
     {
         Miasma.instance.NewGameReset();
         LoadMainMenu();
     },
                        delegate()
     {
         if (Controls.JustPushedPause())
         {
             Miasma.LeaveMenu();
         }
     }));
 }
Beispiel #3
0
 public override void SpecialUpdate()
 {
     speed = parent.speed * 1.3f;
     if (!Miasma.BossIsActive())
     {
         health = 0;
     }
     if (team == 1)
     {
         infectTime++;
     }
     if (infectTime > 60 || team == 0)
     {
         for (int i = 0; i < Miasma.gameEntities.Count; i++)
         {
             if (Miasma.gameEntities[i].maxHealth != -1 && Miasma.gameEntities[i].Hitbox.Intersects(Hitbox) && team != Miasma.gameEntities[i].team)
             {
                 if (!(parent.blocks.Contains(Miasma.gameEntities[i]) && team == 0))
                 {
                     Miasma.gameEntities[i].Strike(10);
                     health = 0;
                     break;
                 }
             }
         }
     }
     if (guarding)
     {
         rotation = 0;
         if ((moveTo - Position).Length() < speed)
         {
             Position = moveTo;
             Velocity = Vector2.Zero;
             rotation = 0f;
         }
         else
         {
             Velocity = Functions.PolarVector(speed, Functions.ToRotation(moveTo - Position));
         }
     }
     else
     {
         Velocity = Functions.PolarVector(Velocity.Length(), rotation + (float)Math.PI / 2);
         rotation = Functions.SlowRotation(rotation, 0, (float)Math.PI / 30);
         if (rotation == 0)
         {
             guarding = true;
         }
     }
     if (team == 1)
     {
         if (Miasma.random.Next(5) == 0)
         {
             new Particle(Position, Functions.PolarVector((float)Miasma.random.NextDouble() * 2f, Functions.RandomRotation()), Miasma.random.Next(2), 15);
         }
     }
 }
Beispiel #4
0
        public override void SpecialUpdate()
        {
            if (team == 1 && justInfected)
            {
                rotation    += (float)Math.PI;
                justInfected = false;
            }
            counter++;
            Velocity = Functions.PolarVector(4, rotation);
            if (counter > preWingDeployTime + wingDeployTime)
            {
                Vector2 aimAt = new Vector2(0, 0);
                if (team == 1)
                {
                    if (Miasma.BossIsActive())
                    {
                        aimAt = Miasma.boss.Position;
                    }
                }
                else
                {
                    aimAt = Miasma.player.Position;
                }
                rotation = Functions.SlowRotation(rotation, Functions.ToRotation(aimAt - Position), (float)Math.PI / 240);
            }
            if (team == 1)
            {
                if (Miasma.random.Next(5) == 0)
                {
                    new Particle(Position, Functions.PolarVector((float)Miasma.random.NextDouble() * 2f, Functions.RandomRotation()), Miasma.random.Next(2), 15);
                }
            }
            bool explode = false;

            for (int i = 0; i < Miasma.gameEntities.Count; i++)
            {
                if (Miasma.gameEntities[i].maxHealth != -1 && Miasma.gameEntities[i].Hitbox.Intersects(Hitbox) && team != Miasma.gameEntities[i].team)
                {
                    explode = true;
                }
            }
            if (explode)
            {
                for (int i = 0; i < Miasma.gameEntities.Count; i++)
                {
                    if (Miasma.gameEntities[i].maxHealth != -1 && Miasma.gameEntities[i].Hitbox.Intersects(new Rectangle((int)Position.X - blastRadius, (int)Position.Y - blastRadius, blastRadius * 2, blastRadius * 2)) && team != Miasma.gameEntities[i].team)
                    {
                        Miasma.gameEntities[i].Strike(10);
                    }
                }
                health = 0;
            }
            if (Position.Y > 850)
            {
                health = 0;
            }
        }
Beispiel #5
0
 public override void MainUpdate()
 {
     if (canDespawn)
     {
         NormalMovement();
         acting = -1;
         home.X = Position.X > 300 ? 600 : 0;
         if (Position.X < 20 || Position.X > 580)
         {
             health = 0;
         }
     }
     else if (!Miasma.BossIsActive())
     {
         home.X += (float)Math.Cos(trigCounter) * .2f;
     }
     if (team == 1)
     {
         InfectedUpdate();
         if (Miasma.random.Next(5) == 0)
         {
             new Particle(Position, Functions.PolarVector((float)Miasma.random.NextDouble() * 2f, Functions.RandomRotation()), Miasma.random.Next(2), 15);
         }
         foreach (Upgrade upgrade in Miasma.player.upgrades)
         {
             if (upgrade != null)
             {
                 upgrade.InfectedShipUpdate(this);
             }
         }
     }
     else
     {
         if (acting == 0)
         {
             ActionUpdate();
         }
         else
         {
             if (acting > 0)
             {
                 if (acting == 1)
                 {
                     ActionStart();
                 }
                 acting--;
             }
             NormalMovement();
         }
     }
 }
Beispiel #6
0
 public override void MainUpdate()
 {
     if (!Miasma.BossIsActive())
     {
         health = 0;
     }
     rotation += angularVelocity;
     for (int b = 0; b < beamTips.Length; b++)
     {
         beamTips[b] = Position + Functions.PolarVector(beamLength, rotation + b * (float)Math.PI / 2);
     }
     if (!launched)
     {
         Position = beholder.GetPosition() + Functions.PolarVector(10f, beholder.GetRotation());
         Velocity = Vector2.Zero;
     }
     else
     {
         if (beamLength < maxBeamLength)
         {
             beamLength += maxBeamLength / 50;
         }
         if (beamLength > 6)
         {
             Sounds.beamLighting.PlayContinuous();
             foreach (Vector2 tip in beamTips)
             {
                 if (Miasma.random.Next(10) == 0)
                 {
                     new Particle(tip, Vector2.Zero, 7, 30);
                 }
                 Vector2?collisionAt = null;
                 if (Functions.RectangleLineCollision(Miasma.player.Hitbox, Position, tip, ref collisionAt))
                 {
                     Miasma.player.Strike(10);
                     beamLength = 0;
                     for (int i = 0; i < 20; i++)
                     {
                         new Particle((Vector2)collisionAt, Functions.PolarVector((float)Miasma.random.NextDouble() * 4f, Functions.RandomRotation()), 7, 15);
                     }
                 }
             }
         }
     }
     if (Position.Y < -50)
     {
         health = 0;
     }
 }
Beispiel #7
0
        public override void InfectedUpdate()
        {
            Vector2 flyTo        = Miasma.player.Position + (Vector2.UnitY * -20f);
            float   goalRotation = (float)Math.PI;

            if (Miasma.BossIsActive() && Miasma.boss is Jupiter)
            {
                flyTo        = Miasma.player.Position + (Vector2.UnitY * 20f);
                goalRotation = 0f;
            }
            infectTimer++;
            if (health > 10)
            {
                Velocity = (flyTo - Position);
                if (Velocity.Length() > speed)
                {
                    ShieldOff();
                    Velocity.Normalize();
                    Velocity *= speed;
                    rotation  = Functions.ToRotation(Velocity) - (float)Math.PI / 2;
                }
                else
                {
                    ShieldOn();
                    rotation = Functions.SlowRotation(rotation, goalRotation, (float)Math.PI / 30);
                }
                if (infectTimer % 60 == 0)
                {
                    health--;
                }
                foreach (SpartanClaw claw in claws)
                {
                    claw.AimTowardSavedPosition(0);
                }
            }
            else
            {
                ShieldOff();
                Velocity = Vector2.Zero;
                rotation = Functions.SlowRotation(rotation, goalRotation, (float)Math.PI / 30);
                infectTimer2++;
                shootPattern(infectTimer2);
                if (infectTimer2 > preShootTime + postShootTime + 60)
                {
                    health = 0;
                }
            }
        }
Beispiel #8
0
 public override void MainUpdate()
 {
     if (!Miasma.BossIsActive())
     {
         health = 0;
     }
     if (activated)
     {
         Velocity = (goTo - Position);
         if (Velocity.Length() > speed)
         {
             Velocity.Normalize();
             Velocity  *= speed;
             chargeTime = 0;
         }
         else if (Velocity.Length() == 0)
         {
             chargeTime++;
             if (chargeTime < shotTime)
             {
                 for (int i = 0; i < 1; i++)
                 {
                     float r = Functions.RandomRotation() * -.5f;
                     new Particle(Position + Vector2.UnitY * -12f + Functions.PolarVector(15, r), Functions.PolarVector(-1, r), 7, 15);
                 }
             }
             else if (chargeTime == shotTime)
             {
                 new LightningBolt(Position + Vector2.UnitY * -12f, Vector2.UnitY * -10, 0, team);
             }
             else if (chargeTime > shotTime + 60)
             {
                 pickSpot();
             }
         }
     }
     else
     {
         Velocity = Vector2.Zero;
     }
     if (team == 1)
     {
         health = 0;
     }
 }
Beispiel #9
0
        public void LoadMainMenu()
        {
            Miasma.Load();
            MenuReset("Miasma");
            string prog = "0";

            if (Miasma.wave == 10)
            {
                prog = "Boss";
            }
            else
            {
                prog = "" + (Miasma.wave + 1);
            }
            if (Miasma.stage > 0 || Miasma.wave > 0)
            {
                Add(new MenuOption("Continue (stage: " + (Miasma.stage + 1) + "-" + prog + ", " + (Miasma.hard ? "hard" : "normal") + ")", delegate()
                {
                    MenuReset();

                    Miasma.gameState = GameScene.Combat;
                    Sounds.PlayMusic(1);
                    Miasma.player.UpdateStats();
                }));
            }
            Add(new MenuOption("New Game", delegate()
            {
                LoadDifficulty();
            }));
            Add(new MenuOption("Settings", delegate()
            {
                LoadSettingsMenu();
            }));
            Add(new MenuOption("Extras", delegate()
            {
                LoadExtrasMenu();
            }));
            Add(new MenuOption("Quit", delegate()
            {
                Miasma.instance.Exit();
            }));
        }
Beispiel #10
0
        public void Draw(SpriteBatch spritebatch)
        {
            Vector2 textSize = Miasma.font.MeasureString(text);

            spritebatch.DrawString(Miasma.font, partialText, position - textSize * .5f, miasmic ? Miasma.MiasmaColor(): Color.White);
            if (drawExtras != null)
            {
                drawExtras(spritebatch, position, textSize, miasmic);
            }

            /*
             * if (sliderPosition != -1)
             * {
             *  Texture2D bar = Miasma.UISprites[5];
             *  spritebatch.Draw(bar, position + Vector2.UnitX * (textSize.X * .5f + 20), null, miasmic ? Miasma.MiasmaColor() : Color.White, 0, new Vector2(0, 1.5f), new Vector2(1, 1), SpriteEffects.None, 0);
             *  Texture2D slider = Miasma.UISprites[6];
             *  spritebatch.Draw(slider, position + Vector2.UnitX * (textSize.X * .5f + 20 + sliderPosition), null, miasmic ? Miasma.MiasmaColor() : Color.White, 0, new Vector2(3.5f, 4.5f), new Vector2(1, 1), SpriteEffects.None, 0);
             * }*/
        }
    // Update is called once per frame
    void Update()
    {
        if(player == null){
            player = GameObject.FindGameObjectWithTag("Player").GetComponent(typeof(PlayerScript)) as PlayerScript;
            twin_fang = new Twin_Fang(player, twin_fang_object);
            noxious_blast = new Noxious_Blast(player, noxious_blast_object);
            miasma = new Miasma(player, miasma_object);
        }

        if(!alive && !staleWin){
            player.setWin(true);
            staleWin = true;
            return;
        }

        if(Time.time > deathTimer && !alive)
            Destroy(gameObject);

        if(!player.isAlive())
            return;

        Vector3 lookat = player.getGameObject().transform.position;
        lookat.y = gameObject.transform.position.y;
        gameObject.transform.LookAt(lookat);

        //If the Player is too far away to be aggroed, do not cast spells.
        if(Vector3.Distance(player.getGameObject().transform.position, gameObject.transform.position) > aggroRange)
            return;

        //Phase 1
        if(phase == 1){
            //If the player is poisoned, use twin fangs
            if(player.isPoisoned() && twin_fang.offCooldown() && !animator.isPlaying){
                animator.Play("Spell2");
                twin_fang.setInitialPosition(gameObject.transform.position);
                twin_fang.Execute();
                return;
            }

            //If off cooldown, attempt to use Noxious Blast to poison player
            if(noxious_blast.offCooldown() && !animator.isPlaying){
                animator.Play("Spell1");
                noxious_blast.Execute();
                return;
            }
            //Otherwise, autoattack
            if(nextAttack < Time.time){
                GameObject attack = (GameObject) Instantiate(autoAttack, gameObject.transform.position, Quaternion.identity);
                PhysicsProjectileScript projectile = attack.GetComponent(typeof(PhysicsProjectileScript)) as PhysicsProjectileScript;
                projectile.setTimeToLive(10);
                projectile.setDamage(weaponDamage);
                projectile.setSpeed(25);
                projectile.setDestination(player.getGameObject().transform.position);
                nextAttack = Time.time + 3;
            }

            if((currentHealth / maxHealth) < .66){
                //Phase Transition
                transitionPhase();
            }

        }

        else if (phase == 2){
            //If the player is poisoned, use twin fangs
            if(player.isPoisoned() && twin_fang.offCooldown()){
                animator.Play("Spell2");
                twin_fang.setInitialPosition(gameObject.transform.position);
                twin_fang.Execute();
                return;
            }

            //If off cooldown, attempt to use Miasma to poison player
            if(miasma.offCooldown()){
                animator.Play("Spell2");
                miasma.Execute();
                return;
            }

            //Otherwise, autoattack
            if(nextAttack < Time.time){
                GameObject attack = (GameObject) Instantiate(autoAttack, gameObject.transform.position, Quaternion.identity);
                PhysicsProjectileScript projectile = attack.GetComponent(typeof(PhysicsProjectileScript)) as PhysicsProjectileScript;
                projectile.setTimeToLive(10);
                projectile.setDamage(weaponDamage * 1.3f);
                projectile.setSpeed(35);
                projectile.setDestination(player.getGameObject().transform.position);
                nextAttack = Time.time + 3;
            }

            if((currentHealth / maxHealth) < .33){
                //Phase Transition
                transitionPhase();
            }

        }

        else{
            //If the player is poisoned, use twin fangs
            if(player.isPoisoned() && twin_fang.offCooldown()){
                animator.Play("Spell2");
                twin_fang.setInitialPosition(gameObject.transform.position);
                twin_fang.Execute();
                return;
            }

            //If off cooldown, attempt to use Noxious Blast or Miasma to poison player
            if(noxious_blast.offCooldown()){
                animator.Play("Spell1");
                noxious_blast.Execute();
                return;
            }

            if(miasma.offCooldown()){
                animator.Play("Spell2");
                miasma.Execute();
                return;
            }

            //Otherwise, autoattack
            if(nextAttack < Time.time){
                GameObject attack = (GameObject) Instantiate(autoAttack, gameObject.transform.position, Quaternion.identity);
                PhysicsProjectileScript projectile = attack.GetComponent(typeof(PhysicsProjectileScript)) as PhysicsProjectileScript;
                projectile.setTimeToLive(10);
                projectile.setDamage(weaponDamage * 1.5f);
                projectile.setSpeed(35);
                projectile.setDestination(player.getGameObject().transform.position);
                nextAttack = Time.time + 3;
            }
        }
    }
Beispiel #12
0
        void SliderUI(SpriteBatch spritebatch, Vector2 position, Vector2 textSize, bool miasmic, int value)
        {
            Texture2D bar = Miasma.UISprites[5];

            spritebatch.Draw(bar, position + Vector2.UnitX * (textSize.X * .5f + 20), null, miasmic ? Miasma.MiasmaColor() : Color.White, 0, new Vector2(0, 1.5f), new Vector2(1, 1), SpriteEffects.None, 0);
            Texture2D slider = Miasma.UISprites[6];

            spritebatch.Draw(slider, position + Vector2.UnitX * (textSize.X * .5f + 20 + value), null, miasmic ? Miasma.MiasmaColor() : Color.White, 0, new Vector2(3.5f, 4.5f), new Vector2(1, 1), SpriteEffects.None, 0);
        }
    // Use this for initialization
    void Start()
    {
        alive = true;
        debuffs = new Hashtable();
        phase = 1;
        animator = gameObject.GetComponent(typeof(Animation)) as Animation;
        //We generally like to avoid try catch blockes. However, in Unity, it is required that a "dummy" instance of every object be
        //present at the beginning of the game, or more mobs cannot be spawned. Since this "dummy" instance is present before the player
        //is instantied, it will be unable to find the player, and this initialization will fail. To remedy this situation, we surround
        //this assignment in a try-catch, then look to update the assignment in the "update" function. Future iterations should look
        //to address this Unity flaw.
        try{
            player = GameObject.FindGameObjectWithTag("Player").GetComponent(typeof(PlayerScript)) as PlayerScript;
            twin_fang = new Twin_Fang(player, twin_fang_object);
            noxious_blast = new Noxious_Blast(player, noxious_blast_object);
            miasma = new Miasma(player, miasma_object);
        } catch{
            ;
        }

        maxHealth = 750 * Mathf.Pow(2, player.Level);
        weaponDamage = 15 * Mathf.Pow(2, player.Level);
        currentHealth = maxHealth;
    }
Beispiel #14
0
        void ExtraText(SpriteBatch spritebatch, Vector2 position, Vector2 textSize, bool miasmic, String value)
        {
            Vector2 mySize = Miasma.font.MeasureString(value);

            spritebatch.DrawString(Miasma.font, value, (position - mySize * .5f) + (mySize.X * .5f + textSize.X * .5f) * Vector2.UnitX, miasmic ? Miasma.MiasmaColor() : Color.White);
        }
Beispiel #15
0
        void LoadSettingsMenu()
        {
            MenuReset("Settings");
            Add(new MenuOption("Miasma Color", delegate()
            {
                LoadColorMenu();
            }));
            Add(new MenuOption("Sound Effects volume", delegate()
            {
            }, delegate()
            {
                if (Controls.ControlLeft())
                {
                    if (Sounds.sfxVolume > 0)
                    {
                        Sounds.sfxVolume--;
                    }
                }
                if (Controls.ControlRight())
                {
                    if (Sounds.sfxVolume < 100)
                    {
                        Sounds.sfxVolume++;
                    }
                }
            }, delegate(SpriteBatch spritebatch, Vector2 position, Vector2 textSize, bool miasmic)
            {
                SliderUI(spritebatch, position, textSize, miasmic, Sounds.sfxVolume);
            }));
            Add(new MenuOption("Music volume", delegate()
            {
            }, delegate()
            {
                if (Controls.ControlLeft())
                {
                    if (Sounds.musicVolume > 0)
                    {
                        Sounds.musicVolume--;
                        Sounds.UpdateMusicVolume();
                    }
                }
                if (Controls.ControlRight())
                {
                    if (Sounds.musicVolume < 100)
                    {
                        Sounds.musicVolume++;
                        Sounds.UpdateMusicVolume();
                    }
                }
            }, delegate(SpriteBatch spritebatch, Vector2 position, Vector2 textSize, bool miasmic)
            {
                SliderUI(spritebatch, position, textSize, miasmic, Sounds.musicVolume);
            }));
            Add(new MenuOption("Keyboard Controls", delegate()
            {
                LoadKeyboardConfig();
            }));
            Add(new MenuOption("Gamepad Controls", delegate()
            {
                LoadGamepadConfig();
            }));


            Add(new MenuOption("Back", delegate()
            {
                Miasma.Save();
                LoadMainMenu();
            }));
        }
Beispiel #16
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            Texture2D texture = Miasma.EntitySprites[entityID];

            spriteBatch.Draw(texture, Position, null, Miasma.MiasmaColor(), rotation, new Vector2(texture.Width, texture.Height) * .5f, new Vector2(1, 1), SpriteEffects.None, 0);
        }
Beispiel #17
0
        void LoadColorMenu()
        {
            MenuReset("Miasma Color");
            Add(new MenuOption("Classic", delegate()
            {
                Miasma.Save();
                LoadMainMenu();
            },
                               delegate()
            {
                Miasma.myColor = ColorOptions.Purple;
            }));
            Add(new MenuOption("Plague", delegate()
            {
                Miasma.Save();
                LoadMainMenu();
            },
                               delegate()
            {
                Miasma.myColor = ColorOptions.Orange;
            }));

            Add(new MenuOption("Alien", delegate()
            {
                Miasma.Save();
                LoadMainMenu();
            },
                               delegate()
            {
                Miasma.myColor = ColorOptions.Green;
            }));
            Add(new MenuOption("Flesh", delegate()
            {
                Miasma.Save();
                LoadMainMenu();
            },
                               delegate()
            {
                Miasma.myColor = ColorOptions.Pink;
            }));
            Add(new MenuOption("Dark", delegate()
            {
                Miasma.Save();
                LoadMainMenu();
            },
                               delegate()
            {
                Miasma.myColor = ColorOptions.Dark;
            }));
            Add(new MenuOption("Spectre", delegate()
            {
                Miasma.Save();
                LoadMainMenu();
            },
                               delegate()
            {
                Miasma.myColor = ColorOptions.Spectre;
            }));
            Add(new MenuOption("Rainbow", delegate()
            {
                Miasma.Save();
                LoadMainMenu();
            },
                               delegate()
            {
                Miasma.myColor = ColorOptions.Rainbow;
            }));
        }