Beispiel #1
0
        void RunProjectileAttacks()
        {
            foreach (Entity entity in Engine.Entities)
            {
                Projectile projectile = entity as Projectile;
                if (projectile == null)
                {
                    continue;
                }

                if (projectile.CanAttack() == false)
                {
                    continue;
                }

                foreach (Entity subentity in Engine.Entities)
                {
                    if (projectile == subentity)
                    {
                        continue;
                    }

                    if (projectile.CanAttack() == false)
                    {
                        break;
                    }

                    Character character = subentity as Character;
                    if (character != null)
                    {
                        ProjectileAttack(projectile, character);
                    }

                    Projectile otherprojectile = subentity as Projectile;
                    if (otherprojectile != null)
                    {
                        if (projectile.Team == otherprojectile.Team)
                        {
                            continue;
                        }
                        if (Collision.HasCollision(projectile, ClsnType.Type1Attack, otherprojectile, ClsnType.Type1Attack) == false)
                        {
                            continue;
                        }

                        ProjectileContact(projectile, otherprojectile);
                    }
                }
            }
        }
Beispiel #2
0
        Boolean CanBlock(Entity attacker, Character target, HitDefinition hitdef, Boolean rangecheck)
        {
            if (attacker == null)
            {
                throw new ArgumentNullException("attacker");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (hitdef == null)
            {
                throw new ArgumentNullException("hitdef");
            }

            if (rangecheck == true && Collision.HasCollision(attacker, ClsnType.Type1Attack, target, ClsnType.Type2Normal) == false)
            {
                return(false);
            }

            if (hitdef.Targeting == AffectTeam.None)
            {
                return(false);
            }
            if (((hitdef.Targeting & AffectTeam.Enemy) != AffectTeam.Enemy) && (attacker.Team != target.Team))
            {
                return(false);
            }
            if (((hitdef.Targeting & AffectTeam.Friendly) != AffectTeam.Friendly) && (attacker.Team == target.Team))
            {
                return(false);
            }

            if (target.CommandManager.IsActive("holdback") == false)
            {
                return(false);
            }
            if (InGuardDistance(attacker, target, hitdef) == false)
            {
                return(false);
            }

            if (target.StateType == StateType.Airborne && (hitdef.GuardFlag.HitAir == false || target.Assertions.NoAirGuard == true))
            {
                return(false);
            }
            if (target.StateType == StateType.Standing && (hitdef.GuardFlag.HitHigh == false || target.Assertions.NoStandingGuard == true))
            {
                return(false);
            }
            if (target.StateType == StateType.Crouching && (hitdef.GuardFlag.HitLow == false || target.Assertions.NoCrouchingGuard == true))
            {
                return(false);
            }
            if (target.StateType == StateType.Prone)
            {
                return(false);
            }

            if (target.Life <= hitdef.GuardDamage && hitdef.CanGuardKill == true)
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        Boolean CanHit(Entity attacker, Character target, HitDefinition hitdef)
        {
            if (attacker == null)
            {
                throw new ArgumentNullException("attacker");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (hitdef == null)
            {
                throw new ArgumentNullException("hitdef");
            }

            if (Collision.HasCollision(attacker, ClsnType.Type1Attack, target, ClsnType.Type2Normal) == false)
            {
                return(false);
            }

            if (hitdef.Targeting == AffectTeam.None)
            {
                return(false);
            }
            if (((hitdef.Targeting & AffectTeam.Enemy) != AffectTeam.Enemy) && (attacker.Team != target.Team))
            {
                return(false);
            }
            if (((hitdef.Targeting & AffectTeam.Friendly) != AffectTeam.Friendly) && (attacker.Team == target.Team))
            {
                return(false);
            }

            if (target.StateType == StateType.Standing && hitdef.HitFlag.HitHigh == false)
            {
                return(false);
            }
            if (target.StateType == StateType.Crouching && hitdef.HitFlag.HitLow == false)
            {
                return(false);
            }
            if (target.StateType == StateType.Airborne && hitdef.HitFlag.HitAir == false)
            {
                return(false);
            }
            if (target.StateType == StateType.Prone && hitdef.HitFlag.HitDown == false)
            {
                return(false);
            }
            if (target.MoveType == MoveType.BeingHit && hitdef.HitFlag.ComboFlag == HitFlagCombo.No)
            {
                return(false);
            }
            if (target.MoveType != MoveType.BeingHit && hitdef.HitFlag.ComboFlag == HitFlagCombo.Yes)
            {
                return(false);
            }

            if (target.DefensiveInfo.HitBy1.CanHit(hitdef.HitAttribute) == false)
            {
                return(false);
            }
            if (target.DefensiveInfo.HitBy2.CanHit(hitdef.HitAttribute) == false)
            {
                return(false);
            }

            if (target.DefensiveInfo.IsFalling == true)
            {
                if (attacker is Player)
                {
                    Player player = attacker as Player;

#warning Juggling system is weird
                    Int32 neededjugglepoints = EvaluationHelper.AsInt32(player, player.StateManager.CurrentState.JugglePoints, 0);
                    //if (neededjugglepoints > target.JugglePoints) return false;
                }
            }

            return(true);
        }
Beispiel #4
0
        protected virtual void HandlePushing()
        {
            if (PushFlag == false)
            {
                return;
            }

            foreach (var entity in Engine.Entities)
            {
                var c = FilterEntityAsCharacter(entity, AffectTeam.Enemy);
                if (c == null)
                {
                    continue;
                }

                if (c.PushFlag == false)
                {
                    continue;
                }

                if (Collision.HasCollision(this, ClsnType.Type2Normal, c, ClsnType.Type2Normal) == false)
                {
                    continue;
                }

                if (CurrentLocation.X >= c.CurrentLocation.X)
                {
                    var lhs_pos = GetLeftLocation();
                    var rhs_pos = c.GetRightLocation();

                    var overlap = rhs_pos - lhs_pos;

                    if (overlap > 0)
                    {
                        var actualpush = c.MoveLeft(new Vector2(overlap, 0));

                        if (actualpush.X != -overlap)
                        {
                            var reversepush = overlap - actualpush.X;
                            MoveRight(new Vector2(reversepush, 0));
                        }
                    }
                    else if (overlap < 0)
                    {
                    }
                }
                else
                {
                    var lhs_pos = GetRightLocation();
                    var rhs_pos = c.GetLeftLocation();

                    var overlap = lhs_pos - rhs_pos;

                    if (overlap > 0)
                    {
                        var actualpush = c.MoveRight(new Vector2(overlap, 0));

                        if (actualpush.X != overlap)
                        {
                            var reversepush = overlap - actualpush.X;
                            MoveLeft(new Vector2(reversepush, 0));
                        }
                    }
                }
            }
        }