Example #1
0
        protected virtual void HandlePushing()
        {
            if (PushFlag == false)
            {
                return;
            }

            foreach (Entity entity in Engine.Entities)
            {
                Character 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)
                {
                    Single lhs_pos = GetLeftLocation();
                    Single rhs_pos = c.GetRightLocation();

                    Single overlap = rhs_pos - lhs_pos;

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

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

                    Single overlap = lhs_pos - rhs_pos;

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

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