Beispiel #1
0
        public Vector2 playerFall(GameTime gameTime, WorldObject playerObj)
        {
            Vector2 place = playerInWorld.PositionInWorldSpace;
            place.Y += jumpSpeed;
            float distToTravel = jumpSpeed;

            foreach (WorldObject obj in mWorld.worldObjectList)
            {
                if (playerObj.PositionInWorldSpace.Y <= obj.PositionInWorldSpace.Y - obj.TextureOrigin.Y)
                {
                    if (playerObj.Collides(obj) && !obj.IsTransparent)
                    {
                        isFalling = false;
                        //landSound.Play();
                        playerInWorld.Texture = playerTexture;
                        place.Y = obj.PositionInWorldSpace.Y - obj.TextureOrigin.Y;
                        if (!playerObj.Collides(obj)) place.Y = 100;
                        return playerObj.PositionInWorldSpace;
                    }
                }
            }
            return place;
        }
Beispiel #2
0
        /// <summary>
        /// Checks if sprite is it collides with other objects
        /// </summary>
        /// <param name="playerObj"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        public bool checkFalling(WorldObject playerObj, ref Vector2 position)
        {
            bool falling = true;
            foreach (WorldObject obj in mWorld.worldObjectList)
            {
                if (playerObj.Collides(obj) && !obj.IsTransparent)
                {
                    if (obj.DoesHurt)
                    {
                        position = playerData[0].startingPoint;

                    }
                    else if (obj.CanFall)
                    {
                        obj.isFalling = true;
                        obj.color = Color.Blue;
                        falling = false;
                    }
                    else
                    {
                        if (playerObj.PositionInWorldSpace.Y <= obj.PositionInWorldSpace.Y - obj.TextureOrigin.Y)
                        {
                            if (obj.IsMoving)
                            {
                                //position = obj.PositionInWorldSpace - obj.WorldSpaceToObjectSpace(position);
                                position.X += 1f * obj.direction;
                            }
                            falling = false;
                        }
                    }
                }
                else
                {
                    obj.color = Color.White;
                }
            }
            return falling;
        }
Beispiel #3
0
 public void objInteract(WorldObject playerObject)
 {
     foreach (WorldObject obj in mWorld.worldObjectList)
     {
         if (playerObject.Collides(obj))
         {
             if (obj.TextureName == "treasure") gameOver(1);
             if (obj.TextureName == "bottomPort")
             {
                 playerInWorld.PositionInWorldSpace = obj.PosToPort;
             }
             if (obj.DoesTalk)
             {
                 obj.isTalking = true;
                 camera.textTime = 0;
             }
         }
     }
 }