Пример #1
0
        public void Update(GameTime gameTime)
        {
            if (PlayerAI != null)
            {
                PlayerAI.UpdateStep(gameTime);
            }

            PolygonCollisionResult FinalCollisionResult;
            Polygon FinalCollisionPolygon;
            Polygon FinalOtherPolygon;

            HashSet <Player> SetOtherPlayer = Owner.GetCollidingPlayers(this);

            foreach (Player ActivePlayer in SetOtherPlayer)
            {
                if (ActivePlayer.Collision.CollideWith(CollisionBox, Speed, out FinalCollisionResult, out FinalCollisionPolygon, out FinalOtherPolygon))
                {
                    OnCollision(ActivePlayer, FinalCollisionResult, FinalCollisionPolygon, FinalOtherPolygon);
                }
            }

            HashSet <WorldObject> SetWorldObject = Owner.GetCollidingWorldObjects(this);

            foreach (WorldObject ActiveWorldObject in SetWorldObject)
            {
                if (ActiveWorldObject.Collision.CollideWith(CollisionBox, Speed, out FinalCollisionResult, out FinalCollisionPolygon, out FinalOtherPolygon))
                {
                    OnCollision(ActiveWorldObject, FinalCollisionResult, FinalCollisionPolygon, FinalOtherPolygon);
                }
            }
        }
Пример #2
0
        public override void DoUpdate(GameTime gameTime)
        {
            PolygonCollisionResult FinalCollisionResult;
            Polygon FinalActiveWorldObject;
            Polygon FinalExplosionPolygon;

            HashSet <Player> SetOtherPlayer = Owner.GetCollidingPlayers(this);

            foreach (Player ActivePlayer in SetOtherPlayer)
            {
                if (ActivePlayer.Collision.CollideWith(CollisionBox, Speed, out FinalCollisionResult, out FinalActiveWorldObject, out FinalExplosionPolygon))
                {
                    OnCollision(ActivePlayer, FinalCollisionResult, FinalActiveWorldObject, FinalExplosionPolygon);
                }
            }

            bool CollisionWithWall = false;
            HashSet <WorldObject>    SetWorldObject           = Owner.GetCollidingWorldObjects(this);
            LinkedList <WorldObject> ListCollidingWorldObject = new LinkedList <WorldObject>();

            foreach (WorldObject ActiveWorldObject in SetWorldObject)
            {
                if (ActiveWorldObject.Collision.CollideWith(CollisionBox, Speed, out FinalCollisionResult, out FinalActiveWorldObject, out FinalExplosionPolygon))
                {
                    ListCollidingWorldObject.AddLast(ActiveWorldObject);
                    OnCollision(ActiveWorldObject, FinalCollisionResult, FinalExplosionPolygon, FinalActiveWorldObject);
                    CollisionWithWall = true;
                }
            }

            if (!CollisionWithWall)
            {
                Move(Speed);
            }
        }