Ejemplo n.º 1
0
        public void update(Enemy parent, GameTime currentTime, LevelState parentWorld)
        {
            int     check_corners = 0;
            Vector2 nextStep_temp = new Vector2(parent.Position.X + parent.Velocity.X, parent.Position.Y + parent.Velocity.Y);
            bool    on_wall       = parentWorld.Map.hitTestWall(nextStep_temp);

            while (check_corners != 4)
            {
                if (on_wall != true)
                {
                    if (check_corners == 0)
                    {
                        nextStep_temp = new Vector2(parent.Position.X + parent.Dimensions.X + parent.Velocity.X, parent.Position.Y + parent.Velocity.Y);
                    }
                    else if (check_corners == 1)
                    {
                        nextStep_temp = new Vector2(parent.Position.X + parent.Velocity.X, parent.Position.Y + parent.Dimensions.Y + parent.Velocity.Y);
                    }
                    else if (check_corners == 2)
                    {
                        nextStep_temp = new Vector2(parent.Position.X + parent.Dimensions.X + parent.Velocity.X, parent.Position.Y + parent.Dimensions.Y + parent.Velocity.Y);
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    if (parent.Direction_Facing == GlobalGameConstants.Direction.Right)
                    {
                        parent.Direction_Facing = GlobalGameConstants.Direction.Left;
                        parent.Velocity         = new Vector2(-1.0f, 0.0f);
                        break;
                    }
                    else if (parent.Direction_Facing == GlobalGameConstants.Direction.Left)
                    {
                        parent.Direction_Facing = GlobalGameConstants.Direction.Right;
                        parent.Velocity         = new Vector2(1.0f, 0.0f);
                        break;
                    }
                    else if (parent.Direction_Facing == GlobalGameConstants.Direction.Up)
                    {
                        parent.Direction_Facing = GlobalGameConstants.Direction.Down;
                        parent.Velocity         = new Vector2(0.0f, 1.0f);
                        break;
                    }
                    else if (parent.Direction_Facing == GlobalGameConstants.Direction.Down)
                    {
                        parent.Direction_Facing = GlobalGameConstants.Direction.Up;
                        parent.Velocity         = new Vector2(0.0f, -1.0f);
                        break;
                    }
                }
                on_wall = parentWorld.Map.hitTestWall(nextStep_temp);
                check_corners++;
            }

            if (parent.Change_Direction_Time > 1000)
            {
                change_direction             = Game1.rand.Next(4);
                parent.Change_Direction_Time = 0.0f;
                if (change_direction == 0)
                {
                    parent.Velocity         = new Vector2(1.0f, 0.0f);
                    parent.Direction_Facing = GlobalGameConstants.Direction.Right;
                }
                else if (change_direction == 1)
                {
                    parent.Velocity         = new Vector2(-1.0f, 0.0f);
                    parent.Direction_Facing = GlobalGameConstants.Direction.Left;
                }
                else if (change_direction == 2)
                {
                    parent.Velocity         = new Vector2(0.0f, -1.0f);
                    parent.Direction_Facing = GlobalGameConstants.Direction.Up;
                }
                else if (change_direction == 3)
                {
                    parent.Velocity         = new Vector2(0.0f, 1.0f);
                    parent.Direction_Facing = GlobalGameConstants.Direction.Down;
                }
            }
        }
Ejemplo n.º 2
0
 public void daemonupdate(Player parent, GameTime currentTime, LevelState parentWorld)
 {
     offset = (float)Math.Sin(currentTime.TotalGameTime.TotalMilliseconds / 1000f) * 0.2f;
 }
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            updateRocketAndExplosion(parent, currentTime, parentWorld);


            if (state == RocketLauncherState.IdleWait)
            {
                if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= 20)
                {
                    if (!rocket.active && !explosion.active)
                    {
                        parent.Velocity = Vector2.Zero;

                        timer = 0;
                        state = RocketLauncherState.WindUp;

                        if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                        {
                            slot1 = true;
                            parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lRocket" : "rRocket");
                        }
                        else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                        {
                            slot1 = false;
                            parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rRocket" : "lRocket");
                        }

                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= ammo_consumption;
                        }
                        else
                        {
                            GameCampaign.Player2_Ammunition -= ammo_consumption;
                        }

                        parent.Animation_Time = 0;
                        parent.LoopAnimation  = false;
                    }
                    else
                    {
                        parent.Disable_Movement = false;
                        parent.State            = Player.playerState.Moving;
                    }
                }
                else
                {
                    parent.Disable_Movement = false;
                    parent.State            = Player.playerState.Moving;
                }
            }
            else if (state == RocketLauncherState.WindUp)
            {
                timer += currentTime.ElapsedGameTime.Milliseconds;

                if (timer > windUpDuration)
                {
                    timer = 0;
                    state = RocketLauncherState.Shooting;

                    AudioLib.playSoundEffect(rocketSound);

                    parentWorld.Particles.pushRocketCasing(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGun" : "lGun").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGun" : "lGun").WorldY));

                    if (slot1)
                    {
                        rocket = new Rocket(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY), parent.Direction_Facing);
                    }
                    else
                    {
                        rocket = new Rocket(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldY), parent.Direction_Facing);
                    }
                }


                for (int i = 0; i < parentWorld.EntityList.Count; i++)
                {
                    float distance = Vector2.Distance(parentWorld.EntityList[i].Position, new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY));
                    if (distance <= 1000 && parentWorld.EntityList[i] is Enemy)
                    {
                        ((Enemy)parentWorld.EntityList[i]).Sound_Alert    = true;
                        ((Enemy)parentWorld.EntityList[i]).Sound_Position = new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY);
                    }
                }
            }
            else if (state == RocketLauncherState.Shooting)
            {
                timer += currentTime.ElapsedGameTime.Milliseconds;

                if (timer > shootDuration)
                {
                    timer = 0;
                    state = RocketLauncherState.CoolDown;
                }
            }
            else if (state == RocketLauncherState.CoolDown)
            {
                parent.Disable_Movement = false;
                parent.State            = Player.playerState.Moving;

                timer += currentTime.ElapsedGameTime.Milliseconds;

                if (timer > coolDownDuration)
                {
                    timer = 0;
                    state = RocketLauncherState.IdleWait;
                }
            }
            else if (state == RocketLauncherState.InvalidState)
            {
                throw new Exception("Invalid Rocket Launcher State");
            }
        }
Ejemplo n.º 4
0
            public void update(LevelState parentWorld, GameTime currentTime, Entity parent)
            {
                active_timer += currentTime.ElapsedGameTime.Milliseconds;
                if (active)
                {
                    switch (state)
                    {
                    case GrenadeState.Travel:
                        if (active_timer > max_active_time)
                        {
                            state        = GrenadeState.Explosion;
                            active_timer = 0.0f;
                            dimensions   = new Vector2(96, 96);
                            position     = CenterPoint - (dimensions / 2);
                        }
                        else
                        {
                            nextStep_temp = new Vector2(position.X - (dimensions.X / 2) + velocity.X, (position.Y + velocity.X));

                            on_wall = parentWorld.Map.hitTestWall(nextStep_temp);
                            int check_corners = 0;
                            while (check_corners != 4)
                            {
                                if (on_wall == false)
                                {
                                    if (check_corners == 0)
                                    {
                                        nextStep_temp = new Vector2(position.X + (dimensions.X / 2) + velocity.X, position.Y + velocity.Y);
                                    }
                                    else if (check_corners == 1)
                                    {
                                        nextStep_temp = new Vector2(position.X + velocity.X, position.Y - (dimensions.Y / 2) + velocity.Y);
                                    }
                                    else if (check_corners == 2)
                                    {
                                        nextStep_temp = new Vector2(position.X + velocity.X, position.Y + dimensions.Y + velocity.Y);
                                    }
                                    else
                                    {
                                        position += velocity;
                                    }
                                    on_wall = parentWorld.Map.hitTestWall(nextStep_temp);
                                }
                                else
                                {
                                    state = GrenadeState.Explosion;
                                    AudioLib.playSoundEffect("testExplosion");
                                    active_timer = 0.0f;
                                    dimensions   = new Vector2(96, 96);
                                    position     = position - (dimensions / 2);
                                    break;
                                }
                                check_corners++;
                            }
                        }

                        if (on_wall == false)
                        {
                            foreach (Entity en in parentWorld.EntityList)
                            {
                                if (en == parent)
                                {
                                    continue;
                                }
                                else if (grenadeHitTest(en))
                                {
                                    state        = GrenadeState.Explosion;
                                    active_timer = 0.0f;
                                    dimensions   = new Vector2(96, 96);
                                    position     = position - (dimensions / 2);
                                    AudioLib.playSoundEffect("testExplosion");
                                    break;
                                }
                            }
                        }
                        position += velocity;
                        break;

                    case GrenadeState.Explosion:
                        explosion_timer += currentTime.ElapsedGameTime.Milliseconds;

                        foreach (Entity en in parentWorld.EntityList)
                        {
                            if (grenadeHitTest(en))
                            {
                                Vector2 direction = en.CenterPoint - CenterPoint;
                                en.knockBack(direction, 3.0f, 10);
                            }
                        }

                        if (explosion_timer > max_explosion_timer)
                        {
                            active_timer = 0.0f;
                            state        = GrenadeState.Reset;
                        }
                        break;

                    case GrenadeState.Reset:
                        dimensions = new Vector2(16, 16);
                        position   = new Vector2(0, 0);
                        active     = false;
                        break;
                    }
                }
            }
        public ShopKeeper(LevelState parentWorld, Vector2 position)
        {
            this.parentWorld = parentWorld;
            this.position    = position;
            this.velocity    = Vector2.Zero;
            this.dimensions  = GlobalGameConstants.TileSize;

            this.direction_facing = GlobalGameConstants.Direction.Down;

            greetingMessage = "Welcome to " + CampaignLobbyState.randomNames[Game1.rand.Next() % CampaignLobbyState.randomNames.Length] + "'s shop!";
            playerInRange   = false;

            state = ShopKeeperState.Normal;

            health              = 40;
            projectile          = new FireBall(new Vector2(-10, -10), 0.0f);
            projectile.active   = false;
            fireballDelayPassed = 0.0f;

            switchItemPressed = false;

            shopKeeperFrameAnimationTest = AnimationLib.getFrameAnimationSet("fireball");
            buyPic         = AnimationLib.getFrameAnimationSet("buyPic");
            leftBuyButton  = AnimationLib.getFrameAnimationSet("gamepadLB");
            rightBuyButton = AnimationLib.getFrameAnimationSet("gamepadRB");

            //test shop data for now
            {
                for (int i = 0; i < 3; i++)
                {
                    int rValue = Game1.rand.Next() % 14;
                    if (rValue == 9)
                    {
                        rValue = 4;
                    }                                // casting an int to item enum; no index for 9

                    itemsForSale[i] = (GlobalGameConstants.itemType)rValue;
                }

                for (int i = 0; i < 3; i++)
                {
                    itemPrices[i] = GlobalGameConstants.WeaponDictionary.weaponInfo[(int)itemsForSale[i]].price;
                    itemIcons[i]  = GlobalGameConstants.WeaponDictionary.weaponInfo[(int)itemsForSale[i]].pickupImage;
                }
            }

            items[0] = new Pickup(parentWorld, new Vector2(-500, -500), itemsForSale[0]);
            items[1] = new Pickup(parentWorld, new Vector2(-500, -500), itemsForSale[1]);
            items[2] = new Pickup(parentWorld, new Vector2(-500, -500), itemsForSale[2]);
            parentWorld.EntityList.AddRange(items);

            directionAnims = new AnimationLib.SpineAnimationSet[4];
            directionAnims[(int)GlobalGameConstants.Direction.Up]   = AnimationLib.loadNewAnimationSet("shopUp");
            directionAnims[(int)GlobalGameConstants.Direction.Down] = AnimationLib.loadNewAnimationSet("shopDown");
            directionAnims[(int)GlobalGameConstants.Direction.Left] = AnimationLib.loadNewAnimationSet("shopRight");
            directionAnims[(int)GlobalGameConstants.Direction.Left].Skeleton.FlipX = true;
            directionAnims[(int)GlobalGameConstants.Direction.Right] = AnimationLib.loadNewAnimationSet("shopRight");
            for (int i = 0; i < 4; i++)
            {
                directionAnims[i].Animation = directionAnims[i].Skeleton.Data.FindAnimation("idle");
            }

            for (int i = 0; i < 3; i++)
            {
                InGameGUI.prices[i].active      = true;
                InGameGUI.prices[i].description = GlobalGameConstants.WeaponDictionary.weaponInfo[(int)itemsForSale[i]].name;
                InGameGUI.prices[i].price       = GlobalGameConstants.WeaponDictionary.weaponInfo[(int)itemsForSale[i]].price.ToString();
                InGameGUI.prices[i].position    = position + new Vector2((-3 * GlobalGameConstants.TileSize.X) + (i * 3f * GlobalGameConstants.TileSize.X), (2.5f * GlobalGameConstants.TileSize.Y)) - (Game1.tenbyFive14.MeasureString(InGameGUI.prices[i].price) / 2) + new Vector2(0, 16);
            }
        }
            public void update(LevelState parentWorld, GameTime currentTime, Entity parent)
            {
                time_passed += currentTime.ElapsedGameTime.Milliseconds;

                for (int i = 0; i < parentWorld.EntityList.Count; i++)
                {
                    if (parentWorld.EntityList[i] == parent)
                    {
                        continue;
                    }
                    if (hitTestEntity(parentWorld.EntityList[i]))
                    {
                        Vector2 direction = parentWorld.EntityList[i].CenterPoint - position;
                        parentWorld.EntityList[i].knockBack(direction, knockback_magnitude, bullet_damage, parent);
                    }
                }

                if (time_passed > max_bullet_time)
                {
                    parentWorld.Particles.pushImpactEffect(position - new Vector2(24), Color.White);
                    time_passed = 0.0f;
                    active      = false;
                }
                else
                {
                    nextStep_temp = new Vector2(position.X - (dimensions.X / 2) + velocity.X, (position.Y + velocity.X));
                }

                bool on_wall       = parentWorld.Map.hitTestWall(nextStep_temp);
                int  check_corners = 0;

                while (check_corners != 4)
                {
                    if (on_wall == false)
                    {
                        if (check_corners == 0)
                        {
                            nextStep_temp = new Vector2(position.X + (dimensions.X / 2) + velocity.X, position.Y + velocity.Y);
                        }
                        else if (check_corners == 1)
                        {
                            nextStep_temp = new Vector2(position.X + velocity.X, position.Y - (dimensions.Y / 2) + velocity.Y);
                        }
                        else if (check_corners == 2)
                        {
                            nextStep_temp = new Vector2(position.X + velocity.X, position.Y + dimensions.Y + velocity.Y);
                        }
                        else
                        {
                            position += velocity;
                        }
                        on_wall = parentWorld.Map.hitTestWall(nextStep_temp);
                    }
                    else
                    {
                        parentWorld.Particles.pushImpactEffect(position - new Vector2(24), Color.White);

                        active      = false;
                        time_passed = 0.0f;
                    }
                    check_corners++;
                }
            }
Ejemplo n.º 7
0
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            position = parent.CenterPoint;

            for (int i = 0; i < pellet_count; i++)
            {
                if (shotgun_pellets[i].active == true)
                {
                    shotgun_pellets[i].update(parentWorld, currentTime, parent);

                    if (shotgun_pellets[i].hit_enemy && !damage_delay_flag)
                    {
                        damage_delay_flag  = true;
                        damage_delay_timer = 0.0f;
                    }
                }
            }

            if (pellet_count == max_pellets)
            {
                inactive_pellets = 0;
                for (int i = 0; i < pellet_count; i++)
                {
                    if (shotgun_pellets[i].active == false)
                    {
                        inactive_pellets++;
                    }
                }

                if (inactive_pellets == max_pellets)
                {
                    pellet_count = 0;
                }
            }

            if (shotgun_active == false && (parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= 5)
            {
                switch (parent.Direction_Facing)
                {
                case GlobalGameConstants.Direction.Right:
                    pellet_angle_direction = (float)(-1 * Math.PI / 12);
                    break;

                case GlobalGameConstants.Direction.Left:
                    pellet_angle_direction = (float)(Math.PI / 1.09);
                    break;

                case GlobalGameConstants.Direction.Up:
                    pellet_angle_direction = (float)(-1 * Math.PI / 1.74);
                    break;

                default:
                    pellet_angle_direction = (float)(Math.PI / 2.4);
                    break;
                }

                AudioLib.playSoundEffect(shot_gun_sound);
                parentWorld.Particles.pushShotGunCasing(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGun" : "lGun").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGun" : "lGun").WorldY));

                for (int i = 0; i < max_pellets; i++)
                {
                    parent.Animation_Time = 0;
                    float angle = (float)((Game1.rand.Next() % pellet_angle_interval) + pellet_angle_direction);

                    if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                    {
                        shotgun_pellets[i]             = new Pellets(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY), angle);
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lShotgun" : "rShotgun");

                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= 1;
                        }
                        else if (parent.Index == InputDevice2.PPG_Player.Player_2)
                        {
                            GameCampaign.Player2_Ammunition -= 1;
                        }
                    }
                    else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                    {
                        shotgun_pellets[i]             = new Pellets(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldY), angle);
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rShotgun" : "lShotgun");

                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= 1;
                        }
                        else if (parent.Index == InputDevice2.PPG_Player.Player_2)
                        {
                            GameCampaign.Player2_Ammunition -= 1;
                        }
                    }

                    pellet_count++;
                }
                shotgun_active       = true;
                shotgun_active_timer = 0.0f;
            }
            parent.State = Player.playerState.Moving;
        }
        public void daemonupdate(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            if (showedMessage == false)
            {
                showedMessage = true;

                parentWorld.pushMessage("The fabled Bushido Blade...");
                parentWorld.pushMessage("...all strikes by this blade are perfect...");
                parentWorld.pushMessage("...but one who disgraces its perfection shall die.");
            }

            glowTime += currentTime.ElapsedGameTime.Milliseconds;
            parent.LoadAnimation.Skeleton.B = (float)(Math.Sin(glowTime / 500f) / 2 + 0.5);
            parent.LoadAnimation.Skeleton.R = (float)((-1 * Math.Sin(glowTime / 500f)) / 10 + 0.9);
            parent.LoadAnimation.Skeleton.G = (float)((-1 * Math.Sin(glowTime / 500f)) / 10 + 0.9);

            Vector2 parentVelocity = parent.Velocity * -1;

            if (parentVelocity == Vector2.Zero)
            {
                parentVelocity = new Vector2(0, -1);
            }
            double randOffset = (Game1.rand.NextDouble() * Math.PI / 2) - (Math.PI / 4);

            if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType())
            {
                parentWorld.Particles.pushDotParticle(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lHand" : "rHand").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lHand" : "rHand").WorldY), (float)(Math.Atan2(parentVelocity.Y, parentVelocity.X) + randOffset), Color.Lerp(Color.Yellow, Color.YellowGreen, (float)Game1.rand.NextDouble()));
            }
            else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType())
            {
                parentWorld.Particles.pushDotParticle(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rHand" : "lHand").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rHand" : "lHand").WorldY), (float)(Math.Atan2(parentVelocity.Y, parentVelocity.X)), Color.Lerp(Color.Yellow, Color.YellowGreen, (float)Game1.rand.NextDouble()));
            }

            if (GameCampaign.Player_Health != player_health && GameCampaign.Player_Health > 0)
            {
                bushido_state = BushidoState.bushido;
            }

            if (bushido_state == BushidoState.bushido)
            {
                for (int i = 0; i < 6; i++)
                {
                    parentWorld.Particles.pushDirectedParticle2(parent.CenterPoint, Color.Yellow, (float)(Math.PI * 2 * (i / 6f)));
                }

                for (int i = 0; i < 30; i++)
                {
                    parentWorld.Particles.pushDotParticle2(parent.CenterPoint, 0, Color.YellowGreen, 5 + (i / 10.0f));
                    parentWorld.Particles.pushDotParticle2(parent.CenterPoint, (float)(Math.PI / 2), Color.YellowGreen, 5 + (i / 10.0f));
                }

                for (int i = 0; i < 10; i++)
                {
                    parentWorld.Particles.pushGib(parent.CenterPoint);

                    parentWorld.Particles.pushBloodParticle(parent.CenterPoint);
                    parentWorld.Particles.pushBloodParticle(parent.CenterPoint);
                    parentWorld.Particles.pushBloodParticle(parent.CenterPoint);
                }

                GameCampaign.Player_Health      = 0;
                parent.LoadAnimation.Skeleton.A = 0;
                parent.Velocity = Vector2.Zero;
                position        = parent.CenterPoint - new Vector2(24.0f * 3.0f, 24.0f * 3.0f);
                //animate bushido death
                animation_time += currentTime.ElapsedGameTime.Milliseconds;

                if (animation_time > 700)
                {
                    bushido_state  = BushidoState.preslash;
                    animation_time = 0.0f;
                }
            }
            if (enemy_explode == true)
            {
                animation_time += currentTime.ElapsedGameTime.Milliseconds;
                if (animation_time > 700)
                {
                    animation_time = 0.0f;
                    enemy_explode  = false;
                }
            }
        }
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            item_direction  = parent.Direction_Facing;
            parent.Velocity = Vector2.Zero;

            item_state_time += currentTime.ElapsedGameTime.Milliseconds;

            switch (bushido_state)
            {
            case BushidoState.preslash:
                parent.Animation_Time = 0.0f;

                if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                {
                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lSlash" : "rSlash");
                }
                else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                {
                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rSlash" : "lSlash");
                }

                switch (item_direction)
                {
                case GlobalGameConstants.Direction.Right:
                    position.X = parent.Position.X + parent.Dimensions.X;
                    position.Y = parent.Position.Y;
                    break;

                case GlobalGameConstants.Direction.Left:
                    position.X = parent.Position.X - hitbox.X;
                    position.Y = parent.Position.Y;
                    break;

                case GlobalGameConstants.Direction.Up:
                    position.Y = parent.Position.Y - hitbox.Y;
                    position.X = parent.CenterPoint.X - hitbox.X / 2;
                    break;

                default:
                    position.Y = parent.CenterPoint.Y + parent.Dimensions.Y / 2;
                    position.X = parent.CenterPoint.X - hitbox.X / 2;
                    break;
                }
                if (item_state_time > delay)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        parentWorld.Particles.pushDotParticle(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lHand" : "rHand").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lHand" : "rHand").WorldY), (float)(Game1.rand.NextDouble() * 2 * Math.PI), Color.Lerp(Color.Yellow, Color.YellowGreen, (float)Game1.rand.NextDouble()));
                    }

                    bushido_state = BushidoState.slash;
                    sword_swing   = true;
                }
                break;

            case BushidoState.slash:
                foreach (Entity en in parentWorld.EntityList)
                {
                    if (en is Enemy || en is ShopKeeper)
                    {
                        if (hitTest(en))
                        {
                            Vector2 betweenVector       = en.CenterPoint - parent.CenterPoint;
                            Vector2 betweenVectorNormal = Vector2.Normalize(betweenVector);

                            for (int i = 0; i < 6; i++)
                            {
                                parentWorld.Particles.pushDirectedParticle2(parent.CenterPoint + (betweenVector / 2), Color.Yellow, (float)(Math.PI * 2 * (i / 6f)));
                            }

                            for (int i = 0; i < 30; i++)
                            {
                                parentWorld.Particles.pushDotParticle2(parent.CenterPoint + (betweenVector / 2), (float)(Math.Atan2(betweenVector.Y, betweenVector.X) + Math.PI / 2), Color.YellowGreen, 5 + (i / 10.0f));
                                parentWorld.Particles.pushDotParticle2(parent.CenterPoint + (betweenVector / 2), (float)(Math.Atan2(betweenVector.Y, betweenVector.X) - Math.PI / 2), Color.YellowGreen, 5 + (i / 10.0f));
                            }

                            Vector2 direction = en.CenterPoint - parent.CenterPoint;
                            en.knockBack(direction, knockback_magnitude, sword_damage, parent);
                            enemy_explode          = true;
                            enemy_explode_position = en.CenterPoint - new Vector2(24.0f * 3.0f, 24.0f * 3.0f);
                        }
                    }
                }
                bushido_state = BushidoState.endslash;
                break;

            default:
                parent.State            = Player.playerState.Moving;
                item_state_time         = 0.0f;
                parent.Disable_Movement = true;
                sword_swing             = false;
                bushido_state           = BushidoState.preslash;
                break;
            }
        }
Ejemplo n.º 10
0
        public TileMap(LevelState parent, DungeonGenerator.DungeonRoom[,] room, Vector2 tileSize)
        {
            tileSkin = new Texture2D[5];

            this.size     = new TileDimensions(room.GetLength(0) * GlobalGameConstants.TilesPerRoomWide, room.GetLength(1) * GlobalGameConstants.TilesPerRoomHigh);
            this.tileSize = tileSize;

            this.parent = parent;

            map      = new TileType[size.x, size.y];
            floorMap = new FloorType[size.x, size.y];
            mapMod   = new WallMod[size.x, size.y];

            Random rand = new Random();

            for (int i = 0; i < floorMap.GetLength(0); i++)
            {
                for (int j = 0; j < floorMap.GetLength(1); j++)
                {
                    int randVal = Game1.rand.Next() % 100;

                    if (randVal > 15)
                    {
                        floorMap[i, j] = Game1.rand.Next() % 2 == 0 ? FloorType.A : FloorType.B;
                    }
                    else if (randVal > 10)
                    {
                        floorMap[i, j] = Game1.rand.Next() % 2 == 0 ? FloorType.C : FloorType.D;
                    }
                    else if (randVal > 5)
                    {
                        floorMap[i, j] = Game1.rand.Next() % 2 == 0 ? FloorType.E : FloorType.F;
                    }
                    else
                    {
                        floorMap[i, j] = Game1.rand.Next() % 2 == 0 ? FloorType.G : FloorType.H;
                    }
                }
            }

            for (int i = 0; i < room.GetLength(0); i++)
            {
                for (int j = 0; j < room.GetLength(1); j++)
                {
                    if (room[i, j].attributes != null)
                    {
                        ChunkManager.Chunk c = ChunkLib.getRandomChunkByValues(room[i, j].attributes.ToArray(), rand);

                        if (c == null)
                        {
                            throw new Exception("NO CHUNK FOR VALUES");
                        }

                        if (c != null)
                        {
                            foreach (ChunkManager.Chunk.ChunkAttribute attr in c.Attributes)
                            {
                                if (!room[i, j].attributes.Contains(attr.AttributeName))
                                {
                                    room[i, j].attributes.Add(attr.AttributeName);
                                }
                            }

                            if (c != null)
                            {
                                for (int p = 0; p < GlobalGameConstants.TilesPerRoomWide; p++)
                                {
                                    for (int q = 0; q < GlobalGameConstants.TilesPerRoomHigh; q++)
                                    {
                                        map[(i * GlobalGameConstants.TilesPerRoomWide) + p, (j * GlobalGameConstants.TilesPerRoomHigh) + q] = (TileType)(c.tilemap[(q * GlobalGameConstants.TilesPerRoomHigh) + p]);
                                    }
                                }

                                room[i, j].chunkName = c.Name;

                                if (room[i, j].attributes.Contains("start"))
                                {
                                    int startX = 0;
                                    int startY = 0;

                                    while (c.tilemap[startY * GlobalGameConstants.TilesPerRoomHigh + startX] == 1)
                                    {
                                        startX = rand.Next() % GlobalGameConstants.TilesPerRoomWide;
                                        startY = rand.Next() % GlobalGameConstants.TilesPerRoomHigh;
                                    }

                                    startPosition.X = (i * GlobalGameConstants.TilesPerRoomWide * GlobalGameConstants.TileSize.X) + ((GlobalGameConstants.TilesPerRoomWide / 2) * GlobalGameConstants.TileSize.X);
                                    startPosition.Y = (j * GlobalGameConstants.TilesPerRoomHigh * GlobalGameConstants.TileSize.Y) + ((GlobalGameConstants.TilesPerRoomHigh / 2) * GlobalGameConstants.TileSize.Y);
                                }

                                if (room[i, j].intensity > 0.95f)
                                {
                                    endFlagPosition.X = (i * GlobalGameConstants.TilesPerRoomWide * GlobalGameConstants.TileSize.X) + ((GlobalGameConstants.TilesPerRoomWide / 2) * GlobalGameConstants.TileSize.X);
                                    endFlagPosition.Y = (j * GlobalGameConstants.TilesPerRoomHigh * GlobalGameConstants.TileSize.Y) + ((GlobalGameConstants.TilesPerRoomHigh / 2) * GlobalGameConstants.TileSize.Y);
                                }
                            }
                            else
                            {
                                for (int p = 0; p < GlobalGameConstants.TilesPerRoomWide; p++)
                                {
                                    for (int q = 0; q < GlobalGameConstants.TilesPerRoomHigh; q++)
                                    {
                                        map[(i * GlobalGameConstants.TilesPerRoomWide) + p, (j * GlobalGameConstants.TilesPerRoomHigh) + q] = TileType.TestWall;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        //fill a room with empty tiles if it is empty
                        for (int p = 0; p < GlobalGameConstants.TilesPerRoomWide; p++)
                        {
                            for (int q = 0; q < GlobalGameConstants.TilesPerRoomHigh; q++)
                            {
                                map[(i * GlobalGameConstants.TilesPerRoomWide) + p, (j * GlobalGameConstants.TilesPerRoomHigh) + q] = TileType.TestWall;
                            }
                        }
                    }
                }
            }

            convertTestWallsToWalls();
        }
Ejemplo n.º 11
0
        public void update(Enemy parent, Entity player, GameTime currentTime, LevelState parentWorld)
        {
            /*Search for player***********************************************************************************************************/
            range_distance = parent.Range_Distance;

            sight_angle1 = parent.Sight_Angle1;
            sight_angle2 = parent.Sight_Angle2;

            angle        = (float)(Math.Atan2(player.CenterPoint.Y - parent.CenterPoint.Y, player.CenterPoint.X - parent.CenterPoint.X));
            distance     = Vector2.Distance(parent.CenterPoint, player.CenterPoint);
            wall_between = false;
            switch (parent.Direction_Facing)
            {
            case GlobalGameConstants.Direction.Right:
                if ((angle > (-1 * sight_angle2 + Math.PI / 2) && angle < (-1 * sight_angle1 + Math.PI / 2)) && distance < range_distance)
                {
                    wall_between = parentWorld.Map.playerInSight(angle, distance, parent, player);

                    if (!wall_between)
                    {
                        parent.Enemy_Found = true;
                    }
                }
                break;

            case GlobalGameConstants.Direction.Left:
                if ((angle > (sight_angle1 + Math.PI / 2) && angle < (sight_angle2 + Math.PI / 2)) && distance < range_distance)
                {
                    wall_between = parentWorld.Map.playerInSight(angle, distance, parent, player);

                    if (!wall_between)
                    {
                        parent.Enemy_Found = true;
                    }
                }
                break;

            case GlobalGameConstants.Direction.Up:
                if ((angle > (-1 * sight_angle2) && angle < (-1 * sight_angle1)) && distance < range_distance)
                {
                    wall_between = parentWorld.Map.playerInSight(angle, distance, parent, player);

                    if (!wall_between)
                    {
                        parent.Enemy_Found = true;
                    }
                }
                break;

            default:
                if ((angle > sight_angle1 && angle < sight_angle2) && distance < range_distance)
                {
                    wall_between = parentWorld.Map.playerInSight(angle, distance, parent, player);

                    if (!wall_between)
                    {
                        parent.Enemy_Found = true;
                    }
                }
                break;
            }
            //((RangeEnemy)parent).Angle = angle;
            /*End search for player ***************************************************************************************************************************/

            parent_direction_time_threshold = parent.Change_Direction_Time_Threshold;
            if (parent.Enemy_Found == false)
            {
                int     check_corners = 0;
                Vector2 nextStep_temp = new Vector2(parent.Position.X + parent.Velocity.X, parent.Position.Y + parent.Velocity.Y);
                bool    on_wall       = parentWorld.Map.hitTestWall(nextStep_temp);

                while (check_corners != 4)
                {
                    if (on_wall != true)
                    {
                        if (check_corners == 0)
                        {
                            nextStep_temp = new Vector2(parent.Position.X + parent.Dimensions.X + parent.Velocity.X, parent.Position.Y + parent.Velocity.Y);
                        }
                        else if (check_corners == 1)
                        {
                            nextStep_temp = new Vector2(parent.Position.X + parent.Velocity.X, parent.Position.Y + parent.Dimensions.Y + parent.Velocity.Y);
                        }
                        else if (check_corners == 2)
                        {
                            nextStep_temp = new Vector2(parent.Position.X + parent.Dimensions.X + parent.Velocity.X, parent.Position.Y + parent.Dimensions.Y + parent.Velocity.Y);
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        switch (parent.Direction_Facing)
                        {
                        case GlobalGameConstants.Direction.Right:
                            parent.Direction_Facing = GlobalGameConstants.Direction.Left;
                            parent.Velocity         = new Vector2(-1 * parent.Velocity_Speed, 0.0f);
                            break;

                        case GlobalGameConstants.Direction.Left:
                            parent.Direction_Facing = GlobalGameConstants.Direction.Right;
                            parent.Velocity         = new Vector2(parent.Velocity_Speed, 0.0f);
                            break;

                        case GlobalGameConstants.Direction.Up:
                            parent.Direction_Facing = GlobalGameConstants.Direction.Down;
                            parent.Velocity         = new Vector2(0.0f, parent.Velocity_Speed);
                            break;

                        default:
                            parent.Direction_Facing = GlobalGameConstants.Direction.Up;
                            parent.Velocity         = new Vector2(0.0f, -1 * parent.Velocity_Speed);
                            break;
                        }
                        break;
                    }
                    on_wall = parentWorld.Map.hitTestWall(nextStep_temp);
                    check_corners++;
                }

                if (parent.Change_Direction_Time > parent_direction_time_threshold)
                {
                    change_direction = Game1.rand.Next(4);
                    //change_direction_time = 0.0f;
                    if (parent.Change_Direction_Time > 2300)
                    {
                        switch (change_direction)
                        {
                        case 0:
                            parent.Direction_Facing = GlobalGameConstants.Direction.Right;
                            parent.Velocity         = new Vector2(parent.Velocity_Speed, 0.0f);
                            break;

                        case 1:
                            parent.Direction_Facing = GlobalGameConstants.Direction.Left;
                            parent.Velocity         = new Vector2(-1 * parent.Velocity_Speed, 0.0f);
                            break;

                        case 2:
                            parent.Direction_Facing = GlobalGameConstants.Direction.Up;
                            parent.Velocity         = new Vector2(0.0f, -1.0f * parent.Velocity_Speed);
                            break;

                        default:
                            parent.Direction_Facing = GlobalGameConstants.Direction.Down;
                            parent.Velocity         = new Vector2(0.0f, parent.Velocity_Speed);
                            break;
                        }
                        parent.Change_Direction_Time = 0.0f;
                    }
                    else
                    {
                        parent.Velocity = Vector2.Zero;
                    }
                }
            }
        }
Ejemplo n.º 12
0
        public Player(LevelState parentWorld, float initial_x, float initial_y, InputDevice2.PPG_Player index)
        {
            position = new Vector2(initial_x, initial_y);

            dimensions = new Vector2(32.0f, 58.5f);

            velocity = Vector2.Zero;

            if (index == InputDevice2.PPG_Player.Player_1)
            {
                Player_Right_Item = getItemWhenLoading(GameCampaign.Player_Right_Item);
                Player_Left_Item  = getItemWhenLoading(GameCampaign.Player_Left_Item);
            }
            else if (index == InputDevice2.PPG_Player.Player_2)
            {
                Player_Right_Item = getItemWhenLoading(GameCampaign.Player2_Item_1);
                Player_Left_Item  = getItemWhenLoading(GameCampaign.Player2_Item_2);
            }

            state = playerState.Moving;

            disable_movement = false;

            direction_facing = GlobalGameConstants.Direction.Down;

            this.parentWorld = parentWorld;

            if (index == InputDevice2.PPG_Player.Player_1)
            {
                if (GameCampaign.PlayerColor == 0)
                {
                    walk_down  = AnimationLib.loadNewAnimationSet("jensenDown");
                    walk_right = AnimationLib.loadNewAnimationSet("jensenRight");
                    walk_left  = AnimationLib.loadNewAnimationSet("jensenRight");
                    walk_up    = AnimationLib.loadNewAnimationSet("jensenUp");
                }
                else if (GameCampaign.PlayerColor == 1)
                {
                    walk_down  = AnimationLib.loadNewAnimationSet("jensenDown_RED");
                    walk_right = AnimationLib.loadNewAnimationSet("jensenRight_RED");
                    walk_left  = AnimationLib.loadNewAnimationSet("jensenRight_RED");
                    walk_up    = AnimationLib.loadNewAnimationSet("jensenUp_RED");
                }
                else if (GameCampaign.PlayerColor == 2)
                {
                    walk_down  = AnimationLib.loadNewAnimationSet("jensenDown_PURPLE");
                    walk_right = AnimationLib.loadNewAnimationSet("jensenRight_PURPLE");
                    walk_left  = AnimationLib.loadNewAnimationSet("jensenRight_PURPLE");
                    walk_up    = AnimationLib.loadNewAnimationSet("jensenUp_PURPLE");
                }
                else if (GameCampaign.PlayerColor == 3)
                {
                    walk_down  = AnimationLib.loadNewAnimationSet("jensenDown_BLUE");
                    walk_right = AnimationLib.loadNewAnimationSet("jensenRight_BLUE");
                    walk_left  = AnimationLib.loadNewAnimationSet("jensenRight_BLUE");
                    walk_up    = AnimationLib.loadNewAnimationSet("jensenUp_BLUE");
                }
                else if (GameCampaign.PlayerColor == 4)
                {
                    walk_down  = AnimationLib.loadNewAnimationSet("jensenDown_CYAN");
                    walk_right = AnimationLib.loadNewAnimationSet("jensenRight_CYAN");
                    walk_left  = AnimationLib.loadNewAnimationSet("jensenRight_CYAN");
                    walk_up    = AnimationLib.loadNewAnimationSet("jensenUp_CYAN");
                }
                else if (GameCampaign.PlayerColor == 5)
                {
                    walk_down  = AnimationLib.loadNewAnimationSet("jensenDown_BROWN");
                    walk_right = AnimationLib.loadNewAnimationSet("jensenRight_BROWN");
                    walk_left  = AnimationLib.loadNewAnimationSet("jensenRight_BROWN");
                    walk_up    = AnimationLib.loadNewAnimationSet("jensenUp_BROWN");
                }
            }
            else if (index == InputDevice2.PPG_Player.Player_2)
            {
                if (GameCampaign.Player2Color == 0)
                {
                    walk_down  = AnimationLib.loadNewAnimationSet("femaleJensenDown");
                    walk_right = AnimationLib.loadNewAnimationSet("femaleJensenRight");
                    walk_left  = AnimationLib.loadNewAnimationSet("femaleJensenRight");
                    walk_up    = AnimationLib.loadNewAnimationSet("femaleJensenUp");
                }
                else if (GameCampaign.Player2Color == 1)
                {
                    walk_down  = AnimationLib.loadNewAnimationSet("femaleJensenDown_RED");
                    walk_right = AnimationLib.loadNewAnimationSet("femaleJensenRight_RED");
                    walk_left  = AnimationLib.loadNewAnimationSet("femaleJensenRight_RED");
                    walk_up    = AnimationLib.loadNewAnimationSet("femaleJensenUp_RED");
                }
                else if (GameCampaign.Player2Color == 2)
                {
                    walk_down  = AnimationLib.loadNewAnimationSet("femaleJensenDown_PURPLE");
                    walk_right = AnimationLib.loadNewAnimationSet("femaleJensenRight_PURPLE");
                    walk_left  = AnimationLib.loadNewAnimationSet("femaleJensenRight_PURPLE");
                    walk_up    = AnimationLib.loadNewAnimationSet("femaleJensenUp_PURPLE");
                }
                else if (GameCampaign.Player2Color == 3)
                {
                    walk_down  = AnimationLib.loadNewAnimationSet("femaleJensenDown_BLUE");
                    walk_right = AnimationLib.loadNewAnimationSet("femaleJensenRight_BLUE");
                    walk_left  = AnimationLib.loadNewAnimationSet("femaleJensenRight_BLUE");
                    walk_up    = AnimationLib.loadNewAnimationSet("femaleJensenUp_BLUE");
                }
                else if (GameCampaign.Player2Color == 4)
                {
                    walk_down  = AnimationLib.loadNewAnimationSet("femaleJensenDown_CYAN");
                    walk_right = AnimationLib.loadNewAnimationSet("femaleJensenRight_CYAN");
                    walk_left  = AnimationLib.loadNewAnimationSet("femaleJensenRight_CYAN");
                    walk_up    = AnimationLib.loadNewAnimationSet("femaleJensenUp_CYAN");
                }
                else if (GameCampaign.Player2Color == 5)
                {
                    walk_down  = AnimationLib.loadNewAnimationSet("femaleJensenDown_BROWN");
                    walk_right = AnimationLib.loadNewAnimationSet("femaleJensenRight_BROWN");
                    walk_left  = AnimationLib.loadNewAnimationSet("femaleJensenRight_BROWN");
                    walk_up    = AnimationLib.loadNewAnimationSet("femaleJensenUp_BROWN");
                }
            }

            remove_from_list           = false;
            current_skeleton           = walk_right;
            current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("run");

            death = false;

            enemy_type = EnemyType.Player;

            this.index = index;

            setAnimationWeapons(walk_down, GlobalGameConstants.Direction.Right);
            setAnimationWeapons(walk_right, GlobalGameConstants.Direction.Right);
            setAnimationWeapons(walk_left, GlobalGameConstants.Direction.Left);
            setAnimationWeapons(walk_up, GlobalGameConstants.Direction.Right);
        }
 public void daemonupdate(Player parent, GameTime currentTime, LevelState parentWorld)
 {
     updateBullets(parent, currentTime, parentWorld);
 }
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            updateBullets(parent, currentTime, parentWorld);
            if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= 1.0f)
            {
                if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))
                {
                    fireTimer += currentTime.ElapsedGameTime.Milliseconds;

                    if (fireTimer > durationBetweenShots)
                    {
                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= ammo_consumption;
                        }
                        else
                        {
                            GameCampaign.Player2_Ammunition -= ammo_consumption;
                        }

                        fireTimer             = 0;
                        parent.Animation_Time = 0;
                        parentWorld.Particles.pushBulletCasing(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGun" : "rGun").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGun" : "rGun").WorldY));
                        pushBullet(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY), (float)((int)(parent.Direction_Facing) * (Math.PI / 2)));
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lMGun" : "rMGun");
                        parent.Velocity = Vector2.Zero;
                    }
                }
                else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))
                {
                    fireTimer += currentTime.ElapsedGameTime.Milliseconds;

                    if (fireTimer > durationBetweenShots)
                    {
                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= ammo_consumption;
                        }
                        else
                        {
                            GameCampaign.Player2_Ammunition -= ammo_consumption;
                        }

                        fireTimer             = 0;
                        parent.Animation_Time = 0;
                        parentWorld.Particles.pushBulletCasing(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGun" : "rGun").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGun" : "rGun").WorldY));
                        pushBullet(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldY), (float)((int)(parent.Direction_Facing) * (Math.PI / 2)));
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rMGun" : "lMGun");
                        parent.Velocity = Vector2.Zero;
                        for (int i = 0; i < parentWorld.EntityList.Count; i++)
                        {
                            float distance = Vector2.Distance(parentWorld.EntityList[i].Position, new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY));
                            if (distance <= 600 && parentWorld.EntityList[i] is Enemy)
                            {
                                ((Enemy)parentWorld.EntityList[i]).Sound_Alert    = true;
                                ((Enemy)parentWorld.EntityList[i]).Sound_Position = new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY);
                            }
                        }
                    }
                }
                else
                {
                    fireTimer = float.MaxValue;

                    parent.Disable_Movement = false;
                    parent.State            = Player.playerState.Moving;

                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation("idle");
                }
            }
            else
            {
                parent.State = Player.playerState.Moving;
                return;
            }
        }
Ejemplo n.º 15
0
 public void update(Enemy parent, Entity player, GameTime currentTime, LevelState parentWorld)
 {
     return;
 }
Ejemplo n.º 16
0
            public void update(LevelState parentWorld, GameTime currentTime, Entity parent)
            {
                if (active)
                {
                    parentWorld.Particles.pushDotParticle(position + new Vector2((float)Game1.rand.NextDouble() * dimensions.X, (float)Game1.rand.NextDouble() * dimensions.Y), (float)(1.5 * Math.PI), Color.DarkGreen);
                }

                switch (projectile_state)
                {
                case ProjectileState.Travel:
                    alive_timer += currentTime.ElapsedGameTime.Milliseconds;
                    position    += velocity;

                    if (alive_timer > max_alive_timer)
                    {
                        alive_timer       = 0.0f;
                        projectile_state  = ProjectileState.GrowPool;
                        original_position = CenterPoint;
                    }
                    else
                    {
                        nextStep_temp = new Vector2(position.X - (dimensions.X / 2) + velocity.X, (position.Y + velocity.X));

                        on_wall = parentWorld.Map.hitTestWall(nextStep_temp);
                        int check_corners = 0;
                        while (check_corners != 4)
                        {
                            if (on_wall == false)
                            {
                                if (check_corners == 0)
                                {
                                    nextStep_temp = new Vector2(position.X + (dimensions.X / 2) + velocity.X, position.Y + velocity.Y);
                                }
                                else if (check_corners == 1)
                                {
                                    nextStep_temp = new Vector2(position.X + velocity.X, position.Y - (dimensions.Y / 2) + velocity.Y);
                                }
                                else if (check_corners == 2)
                                {
                                    nextStep_temp = new Vector2(position.X + velocity.X, position.Y + dimensions.Y + velocity.Y);
                                }
                                else
                                {
                                    position += velocity;
                                }
                                on_wall = parentWorld.Map.hitTestWall(nextStep_temp);
                            }
                            else
                            {
                                projectile_state  = ProjectileState.GrowPool;
                                alive_timer       = 0.0f;
                                original_position = CenterPoint;
                                break;
                            }
                            check_corners++;
                        }

                        if (on_wall == false)
                        {
                            foreach (Entity en in parentWorld.EntityList)
                            {
                                if (en == parent || (en.Enemy_Type == EnemyType.Alien))
                                {
                                    continue;
                                }
                                else if (spitHitTest(en))
                                {
                                    projectile_state  = ProjectileState.GrowPool;
                                    alive_timer       = 0.0f;
                                    original_position = CenterPoint;
                                }
                            }
                        }
                    }
                    break;

                case ProjectileState.GrowPool:
                    damage_timer += currentTime.ElapsedGameTime.Milliseconds;
                    if (dimensions.X < max_dimensions && dimensions.Y < max_dimensions)
                    {
                        scale       = (dimensions.X + 1) / scale_factor;
                        dimensions += new Vector2(1, 1);
                        position    = original_position - (dimensions / 2);
                        alive_timer = 0.0f;
                        if (damage_timer > damage_timer_threshold)
                        {
                            foreach (Entity en in parentWorld.EntityList)
                            {
                                if (spitHitTest(en))
                                {
                                    if (en is Enemy && !(en is MutantAcidSpitter))
                                    {
                                        ((Enemy)en).Enemy_Life -= acid_damage;
                                    }
                                    else if (en is Player)
                                    {
                                        if (((Player)en).Index == InputDevice2.PPG_Player.Player_1)
                                        {
                                            GameCampaign.Player_Health -= acid_damage;
                                        }
                                        else if (((Player)en).Index == InputDevice2.PPG_Player.Player_2)
                                        {
                                            GameCampaign.Player2_Health -= acid_damage;
                                        }
                                    }
                                }
                            }
                            damage_timer = 0.0f;
                        }
                    }
                    else
                    {
                        projectile_state = ProjectileState.IdlePool;

                        /*alive_timer += currentTime.ElapsedGameTime.Milliseconds;
                         * if (alive_timer > max_pool_alive_timer)
                         * {
                         *  alive_timer = 0.0f;
                         *  projectile_state = ProjectileState.Reset;
                         * }*/
                    }
                    break;

                case ProjectileState.IdlePool:
                    alive_timer  += currentTime.ElapsedGameTime.Milliseconds;
                    damage_timer += currentTime.ElapsedGameTime.Milliseconds;
                    if (damage_timer > damage_timer_threshold)
                    {
                        foreach (Entity en in parentWorld.EntityList)
                        {
                            if (spitHitTest(en))
                            {
                                if (en is Enemy && !(en is MutantAcidSpitter))
                                {
                                    ((Enemy)en).Enemy_Life -= acid_damage;
                                }
                                else if (en is Player)
                                {
                                    if (((Player)en).Index == InputDevice2.PPG_Player.Player_1)
                                    {
                                        GameCampaign.Player_Health -= acid_damage;
                                    }
                                    else if (((Player)en).Index == InputDevice2.PPG_Player.Player_2)
                                    {
                                        GameCampaign.Player2_Health -= acid_damage;
                                    }
                                }
                            }
                        }
                        damage_timer = 0.0f;
                    }
                    if (alive_timer > max_pool_alive_timer)
                    {
                        alive_timer      = 0.0f;
                        projectile_state = ProjectileState.DecreasePool;
                    }
                    break;

                case ProjectileState.DecreasePool:
                    damage_timer += currentTime.ElapsedGameTime.Milliseconds;
                    if (dimensions.X > 0 && dimensions.Y > 0)
                    {
                        if (dimensions.X - 1 != 0)
                        {
                            scale = (dimensions.X - 1) / scale_factor;
                        }
                        else
                        {
                            scale = 0.0f;
                        }
                        dimensions -= new Vector2(1, 1);
                        position    = original_position - (dimensions / 2);
                        if (damage_timer > damage_timer_threshold)
                        {
                            foreach (Entity en in parentWorld.EntityList)
                            {
                                if (spitHitTest(en))
                                {
                                    if (en is Enemy && !(en is MutantAcidSpitter))
                                    {
                                        ((Enemy)en).Enemy_Life -= acid_damage;
                                    }
                                    else if (en is Player)
                                    {
                                        if (((Player)en).Index == InputDevice2.PPG_Player.Player_1)
                                        {
                                            GameCampaign.Player_Health -= acid_damage;
                                        }
                                        else if (((Player)en).Index == InputDevice2.PPG_Player.Player_2)
                                        {
                                            GameCampaign.Player2_Health -= acid_damage;
                                        }
                                    }
                                }
                            }
                            damage_timer = 0.0f;
                        }
                    }
                    else
                    {
                        active = false;
                    }
                    break;

                default:
                    break;
                }
            }
Ejemplo n.º 17
0
        public void daemonupdate(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            time_explosion += currentTime.ElapsedGameTime.Milliseconds;
            bomb_timer     += currentTime.ElapsedGameTime.Milliseconds;

            switch (bomb_state)
            {
            case Bomb_State.placed:
                animation_time += currentTime.ElapsedGameTime.Milliseconds;
                if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= 10)
                {
                    if (bomb_timer > 1500f / time_explosion * 50.0f)
                    {
                        bomb_timer = 0.0f;
                        AudioLib.playSoundEffect("bombBeep");
                    }

                    if (time_explosion > 1500)
                    {
                        if (parent.Index == InputDevice2.PPG_Player.Player_1)
                        {
                            GameCampaign.Player_Ammunition -= ammo_consumption;
                        }
                        else
                        {
                            GameCampaign.Player2_Ammunition -= ammo_consumption;
                        }

                        hitbox         = hitbox_exploded;
                        position       = new Vector2(center_placed_bomb.X - hitbox.X / 2, center_placed_bomb.Y - hitbox.Y / 2);
                        bomb_state     = Bomb_State.exploded;
                        time_explosion = 0.0f;
                        AudioLib.playSoundEffect("testExplosion");
                        animation_time = 0.0f;
                    }
                }
                else
                {
                    parent.State = Player.playerState.Moving;
                    bomb_state   = Bomb_State.none;
                    return;
                }
                break;

            case Bomb_State.exploded:
                //where hit test is done
                if (time_explosion > 700)
                {
                    bomb_state     = Bomb_State.reset;
                    time_explosion = 0.0f;
                }
                else
                {
                    foreach (Entity en in parentWorld.EntityList)
                    {
                        if (en is Player)
                        {
                            if (hitTest(en))
                            {
                                Vector2 direction = en.CenterPoint - center_placed_bomb;

                                float bomb_knockback_power = Vector2.Distance(center_placed_bomb, en.CenterPoint) / hitbox.X;

                                if (bomb_knockback_power < 1)
                                {
                                    bomb_knockback_power = 1.0f;
                                }

                                float temp_knockback_magnitude = knockback_magnitude / bomb_knockback_power;

                                en.knockBack(direction, temp_knockback_magnitude, bomb_damage, parent);
                            }
                        }
                        else if (en is Enemy || en is ShopKeeper)
                        {
                            if (hitTest(en))
                            {
                                Vector2 direction            = en.CenterPoint - center_placed_bomb;
                                float   bomb_knockback_power = Vector2.Distance(center_placed_bomb, en.CenterPoint) / hitbox.X;

                                if (bomb_knockback_power < 1)
                                {
                                    bomb_knockback_power = 1.0f;
                                }

                                float temp_knockback_magnitude = knockback_magnitude / bomb_knockback_power;

                                en.knockBack(direction, temp_knockback_magnitude, bomb_damage);
                            }
                        }
                    }
                }
                animation_time += currentTime.ElapsedGameTime.Milliseconds;
                break;

            case Bomb_State.none:
                break;

            default:
                hitbox         = hitbox_placed;
                animation_time = 0.0f;
                break;
            }
        }
 public void daemonupdate(Player parent, GameTime currentTime, LevelState parentWorld)
 {
     //
 }
Ejemplo n.º 19
0
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            for (int i = 0; i < laser_projectile.Count(); i++)
            {
                if (laser_projectile[i].active)
                {
                    laser_projectile[i].update(parentWorld, currentTime, parent);
                }
            }
            item_direction = parent.Direction_Facing;
            if (fire_projectile)
            {
                for (int i = 0; i < laser_projectile.Count(); i++)
                {
                    if (laser_projectile[i].active)
                    {
                        continue;
                    }
                    else
                    {
                        float bullet_angle = 0.0f;
                        if (item_direction == GlobalGameConstants.Direction.Right || item_direction == GlobalGameConstants.Direction.Left)
                        {
                            bullet_angle = 0.0f;
                        }
                        else
                        {
                            bullet_angle = (float)Math.PI / 2;
                        }

                        if ((GameCampaign.Player_Right_Item == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)))
                        {
                            if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= ammo_consumption)
                            {
                                AudioLib.playSoundEffect("lazorFire");
                                laser_projectile[i] = new laserProjectile(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY), (parent.Direction_Facing == GlobalGameConstants.Direction.Right) ? new Vector2(10, 0) : (parent.Direction_Facing == GlobalGameConstants.Direction.Left) ? new Vector2(-10, 0) : (parent.Direction_Facing == GlobalGameConstants.Direction.Up) ? new Vector2(0, -10) : new Vector2(0, 10), bullet_angle);
                                if (parent.Index == InputDevice2.PPG_Player.Player_1)
                                {
                                    GameCampaign.Player_Ammunition -= ammo_consumption;
                                }
                                else
                                {
                                    GameCampaign.Player2_Ammunition -= ammo_consumption;
                                }
                            }
                        }
                        else if ((GameCampaign.Player_Left_Item == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2)))
                        {
                            if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= ammo_consumption)
                            {
                                AudioLib.playSoundEffect("lazorFire");

                                laser_projectile[i] = new laserProjectile(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldY), (parent.Direction_Facing == GlobalGameConstants.Direction.Right) ? new Vector2(15, 0) : (parent.Direction_Facing == GlobalGameConstants.Direction.Left) ? new Vector2(-15, 0) : (parent.Direction_Facing == GlobalGameConstants.Direction.Up) ? new Vector2(0, -15) : new Vector2(0, 15), bullet_angle);
                                if (parent.Index == InputDevice2.PPG_Player.Player_1)
                                {
                                    GameCampaign.Player_Ammunition -= ammo_consumption;
                                }
                                else
                                {
                                    GameCampaign.Player2_Ammunition -= ammo_consumption;
                                }
                            }
                        }
                        parent.State = Player.playerState.Moving;
                        parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lLaser" : "rLaser");
                        fire_timer      = 0.0f;
                        fire_projectile = false;
                        return;
                    }
                }
            }
            else
            {
                parent.State = Player.playerState.Moving;
            }
        }
Ejemplo n.º 20
0
            public void update(LevelState parentWorld, GameTime currentTime, Entity parent)
            {
                time_alive += currentTime.ElapsedGameTime.Milliseconds;
                Vector2 nextStep_temp = Vector2.Zero;

                foreach (Entity en in parentWorld.EntityList)
                {
                    if (en is Enemy || en is ShopKeeper)
                    {
                        if (hitTest(en))
                        {
                            parentWorld.Particles.pushImpactEffect(position - new Vector2(24), Color.White);
                            hit_enemy  = true;
                            entity_hit = en;
                            active     = false;
                        }
                    }
                }

                if (time_alive > max_time_alive)
                {
                    active = false;
                }
                else
                {
                    nextStep_temp = new Vector2(position.X - (dimensions.X / 2) + velocity.X, (position.Y + velocity.X));
                }

                bool on_wall       = parentWorld.Map.hitTestWall(nextStep_temp);
                int  check_corners = 0;

                while (check_corners != 4)
                {
                    if (on_wall == false)
                    {
                        if (check_corners == 0)
                        {
                            nextStep_temp = new Vector2(position.X + (dimensions.X / 2) + velocity.X, position.Y + velocity.Y);
                        }
                        else if (check_corners == 1)
                        {
                            nextStep_temp = new Vector2(position.X + velocity.X, position.Y - (dimensions.Y / 2) + velocity.Y);
                        }
                        else if (check_corners == 2)
                        {
                            nextStep_temp = new Vector2(position.X + velocity.X, position.Y + dimensions.Y + velocity.Y);
                        }
                        else
                        {
                            position += velocity;
                        }
                        on_wall = parentWorld.Map.hitTestWall(nextStep_temp);
                    }
                    else
                    {
                        parentWorld.Particles.pushImpactEffect(position - new Vector2(24), Color.White);
                        active     = false;
                        time_alive = 0.0f;
                        break;
                    }
                    check_corners++;
                }
            }