Ejemplo n.º 1
0
    //Accumulate Knockback Vector
    public override StatusEffect GetOverwrite(StatusEffect other)
    {
        KnockbackEffect kbOther = ((KnockbackEffect)other);

        ((Knockback)this.action).vector += ((Knockback)kbOther.action).vector;
        return(this);
    }
Ejemplo n.º 2
0
 public StunEffect(KnockbackEffect e) : base(e)
 {
 }
Ejemplo n.º 3
0
        public void Update(Character player)
        {
            Rectangle playerRect = new Rectangle(player.Position.ToPoint(), new Point((int)player.CurrentAnimation.FrameSize.X * 5, (int)player.CurrentAnimation.FrameSize.Y * 5));

            foreach (Ability ability in abilities)
            {
                ability.Update();
                networkManager.SendAbilityUpdate(ability);
            }

            for (int i = 0; i < playerManager.clientPlayer.abilityBuffer.Count; i++)
            {
                CreateAbility(playerManager.clientPlayer.abilityBuffer[i]);
                CheckAbilityConditions(i);
                playerManager.clientPlayer.abilityBuffer.RemoveAt(i);
                i--;
            }            // Rect to check collision between player and projectile, will be moved to Character or removed all together 2 be replaced with pixel perfect


            for (int j = 0; j < networkManager.Players.Count; j++)
            {
                for (int i = 0; i < networkManager.ServerAbilities.Count; i++)
                {
                    if (networkManager.ServerAbilities[i].Username != networkManager.Username)
                    {
                        if (networkManager.ServerAbilities[i].Username == networkManager.Players[j].Username)
                        {
                            switch (networkManager.Players[j].Type)
                            {
                            case Player.ClassType.Wizard:
                                if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.Projectile)
                                {
                                    Rectangle rectangle = new Rectangle(new Point(networkManager.ServerAbilities[i].XPosition, networkManager.ServerAbilities[i].YPosition),
                                                                        new Point(networkManager.ServerAbilities[i].Animation.Width * (int)Game1.SCALE, networkManager.ServerAbilities[i].Animation.Height * (int)Game1.SCALE));
                                    if (HitBoxIntersectsRotatedRectangle(rectangle, (float)networkManager.ServerAbilities[i].Direction, Vector2.Zero, playerRect))
                                    {
                                        Ability ability = abilities.FirstOrDefault(a => a.Username == networkManager.ServerAbilities[i].Username &&
                                                                                   a.ID == networkManager.ServerAbilities[i].ID);
                                        if (ability != null)
                                        {
                                            ability.Kill();
                                        }
                                        //player.AddEffect(knockback, true);
                                        playerManager.IsFirstPlayerHit = true;
                                        player.TakeDamage(networkManager.ServerAbilities[i].Damage);
                                        KnockbackEffect knockback = new KnockbackEffect(networkManager.ServerAbilities[i].Direction, 20.0f, player, 1);
                                        networkManager.DeleteProjectile(networkManager.ServerAbilities[i].ID, networkManager.ServerAbilities[i].Username);
                                    }
                                }
                                break;

                            case Player.ClassType.Ogre:
                                if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.MeeleAttack)
                                {
                                    if (playerRect.Intersects(new Rectangle((int)networkManager.Players[j].XPosition, (int)networkManager.Players[j].YPosition, (int)networkManager.Players[j].Animation.Width * (int)Game1.SCALE, (int)networkManager.Players[j].Animation.Height * (int)Game1.SCALE)))
                                    {
                                        playerManager.IsFirstPlayerHit = true;
                                        player.TakeDamage(networkManager.ServerAbilities[i].Damage);
                                        KnockbackEffect knockback = new KnockbackEffect(networkManager.ServerAbilities[i].Direction, 20.0f, player, 1);
                                        networkManager.DeleteProjectile(networkManager.ServerAbilities[i].ID, networkManager.ServerAbilities[i].Username);
                                    }
                                }
                                else if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.AbilityOne)
                                {
                                }
                                else if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.AbilityTwo)
                                {
                                    if (playerRect.Intersects(new Rectangle((int)networkManager.Players[j].XPosition, (int)networkManager.Players[j].YPosition, (int)networkManager.Players[j].Animation.Width * (int)Game1.SCALE, (int)networkManager.Players[j].Animation.Height * (int)Game1.SCALE)))
                                    {
                                        playerManager.IsFirstPlayerHit = true;
                                        player.TakeDamage(networkManager.ServerAbilities[i].Damage);
                                        KnockbackEffect knockback = new KnockbackEffect(networkManager.ServerAbilities[i].Direction, 20.0f, player, 1);
                                        networkManager.DeleteProjectile(networkManager.ServerAbilities[i].ID, networkManager.ServerAbilities[i].Username);
                                    }
                                }
                                break;

                            case Player.ClassType.Huntress:
                                if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.Projectile)
                                {
                                    Rectangle rectangle = new Rectangle(new Point(networkManager.ServerAbilities[i].XPosition, networkManager.ServerAbilities[i].YPosition),
                                                                        new Point(networkManager.ServerAbilities[i].Animation.Width * (int)Game1.SCALE, networkManager.ServerAbilities[i].Animation.Height * (int)Game1.SCALE));
                                    if (HitBoxIntersectsRotatedRectangle(rectangle, (float)networkManager.ServerAbilities[i].Direction, Vector2.Zero, playerRect))
                                    {
                                        if (!player.AbilitesHitBy.Contains(networkManager.ServerAbilities[i]))
                                        {
                                            Ability ability = abilities.FirstOrDefault(a => a.Username == networkManager.ServerAbilities[i].Username &&
                                                                                       a.ID == networkManager.ServerAbilities[i].ID);
                                            if (ability != null)
                                            {
                                                ability.Kill();
                                            }
                                            playerManager.IsFirstPlayerHit = true;
                                            player.TakeDamage(networkManager.ServerAbilities[i].Damage);
                                            KnockbackEffect knockback = new KnockbackEffect(networkManager.ServerAbilities[i].Direction, 30.0f, player, 1.2f);
                                            networkManager.DeleteProjectile(networkManager.ServerAbilities[i].ID, networkManager.ServerAbilities[i].Username);
                                        }
                                    }
                                }
                                else if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.AbilityOne)
                                {
                                    if (playerRect.Intersects(new Rectangle(new Point(networkManager.ServerAbilities[i].XPosition, networkManager.ServerAbilities[i].YPosition),
                                                                            new Point(networkManager.ServerAbilities[i].Animation.Width * (int)Game1.SCALE, networkManager.ServerAbilities[i].Animation.Height * (int)Game1.SCALE))))
                                    {
                                        Ability ability = abilities.FirstOrDefault(a => a.Username == networkManager.ServerAbilities[i].Username &&
                                                                                   a.ID == networkManager.ServerAbilities[i].ID);
                                        if (ability != null)
                                        {
                                            ability.Kill();
                                        }
                                        playerManager.IsFirstPlayerHit = true;
                                        if (!player.AbilitesHitBy.Contains(networkManager.ServerAbilities[i]))
                                        {
                                            player.TakeDamage(networkManager.ServerAbilities[i].Damage);
                                            KnockbackEffect knockback = new KnockbackEffect(networkManager.ServerAbilities[i].Direction, 50.0f, player, 2);
                                            player.AbilitesHitBy.Add(networkManager.ServerAbilities[i]);
                                        }
                                    }
                                }
                                else if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.AbilityTwo)
                                {
                                    if (playerRect.Intersects(new Rectangle(new Point(networkManager.ServerAbilities[i].XPosition, networkManager.ServerAbilities[i].YPosition),
                                                                            new Point(networkManager.ServerAbilities[i].Animation.Width * (int)Game1.SCALE, networkManager.ServerAbilities[i].Animation.Height * (int)Game1.SCALE))))
                                    {
                                        Ability ability = abilities.FirstOrDefault(a => a.Username == networkManager.ServerAbilities[i].Username &&
                                                                                   a.ID == networkManager.ServerAbilities[i].ID);
                                        if (ability != null)
                                        {
                                            ability.Kill();
                                        }
                                        playerManager.IsFirstPlayerHit = true;
                                        if (!player.AbilitesHitBy.Contains(networkManager.ServerAbilities[i]))
                                        {
                                            if (ability is BearTrap b)
                                            {
                                                b.Activate();
                                            }
                                            player.TakeDamage(networkManager.ServerAbilities[i].Damage);
                                            player.AbilitesHitBy.Add(networkManager.ServerAbilities[i]);
                                            BearTrapEffect bearTrapEffect = new BearTrapEffect(player, 3);
                                        }
                                    }
                                }
                                break;

                            case Player.ClassType.TimeTraveler:
                                if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.Projectile)
                                {
                                    Rectangle rectangle = new Rectangle(new Point(networkManager.ServerAbilities[i].XPosition, networkManager.ServerAbilities[i].YPosition),
                                                                        new Point(networkManager.ServerAbilities[i].Animation.Width * (int)Game1.SCALE, networkManager.ServerAbilities[i].Animation.Height * (int)Game1.SCALE));
                                    if (HitBoxIntersectsRotatedRectangle(rectangle, (float)networkManager.ServerAbilities[i].Direction, Vector2.Zero, playerRect))
                                    {
                                        if (!player.AbilitesHitBy.Contains(networkManager.ServerAbilities[i]))
                                        {
                                            playerManager.IsFirstPlayerHit = true;
                                            player.TakeDamage(networkManager.ServerAbilities[i].Damage);
                                            //KnockbackEffect knockback = new KnockbackEffect(networkManager.ServerAbilities[i].Direction, 50.0f, player, 2);
                                            player.AbilitesHitBy.Add(networkManager.ServerAbilities[i]);
                                        }
                                    }
                                }
                                else if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.AbilityOne)
                                {
                                }
                                else if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.AbilityTwo)
                                {
                                    Vector2 circleCenter = new Vector2(networkManager.ServerAbilities[i].XPosition + AssetManager.TimeTravelerTimeZone.Width * Game1.SCALE / 2,
                                                                       networkManager.ServerAbilities[i].YPosition + AssetManager.TimeTravelerTimeZone.Height * Game1.SCALE / 2);
                                    if (HitBoxIntersectsCircle(playerRect, circleCenter, AssetManager.TimeTravelerTimeZone.Width * Game1.SCALE / 2))
                                    {
                                        playerManager.IsFirstPlayerHit = true;
                                        AlterTimeEffect timeZoneEffect = new AlterTimeEffect(-0.15f, player, 0.2f);
                                    }
                                }
                                break;

                            case Player.ClassType.Knight:
                                if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.MeeleAttack)
                                {
                                    if (playerRect.Intersects(new Rectangle((int)networkManager.Players[j].XPosition, (int)networkManager.Players[j].YPosition, (int)networkManager.Players[j].Animation.Width * (int)Game1.SCALE, (int)networkManager.Players[j].Animation.Height * (int)Game1.SCALE)))
                                    {
                                        playerManager.IsFirstPlayerHit = true;
                                        player.TakeDamage(networkManager.ServerAbilities[i].Damage);
                                        KnockbackEffect knockback = new KnockbackEffect(networkManager.ServerAbilities[i].Direction, 20.0f, player, 1);
                                        networkManager.DeleteProjectile(networkManager.ServerAbilities[i].ID, networkManager.ServerAbilities[i].Username);
                                    }
                                }
                                else if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.AbilityOne)
                                {
                                }
                                else if (networkManager.ServerAbilities[i].Type == AbilityOutline.AbilityType.AbilityTwo)
                                {
                                }
                                break;
                            }
                        }
                    }
                }
            }

            AbilityObstacleCollision();
            AbilityDeletionCheck();
        }