Ejemplo n.º 1
0
        /// <summary>
        /// Interacts with the given object and interaction type.
        /// </summary>
        /// <param name="otherObject">The object to interaction type.</param>
        /// <param name="interactionType">The type of interaction to take place.</param>
        public override InteractionActions InteractWith(GameObject otherObject, InteractionTypes interactionType)
        {
            if (otherObject.ItemType != ItemList.NullItem && interactionType == InteractionTypes.Collision)
            {
                PickUpItem(otherObject);
            }
            else
            {
                switch (otherObject.ObjectName)
                {
                    case "Door":
                        if (interactionType == InteractionTypes.PlayerAction)
                        {
                            Door door = (Door)otherObject;

                            if (!door.IsOpen)
                            {
                                if (!itemArray[(byte)door.LockType])
                                    hudCallback("This door is locked.", false, true);
                                else if (door.LinkedRoomName == "(unassigned)")
                                    hudCallback("This door appears to go nowhere.", false, true);
                                else
                                    door.Open();

                                return InteractionActions.None;
                            }
                        }
                        else if (!otherObject.IsSolid && interactionType == InteractionTypes.Collision)
                        {
                            Door door = (Door)otherObject;
                            if (door.IsRoomLoaded)
                                roomCallback(door.LinkedRoom);
                            else
                            {
                                loadingDoor = door;
                                GameManager.ToggleFreeze(true);
                                hudCallback("Loading room...", false, false);
                            }

                            if (door.Orientation == Door.DoorOrientations.FacingLeft)
                                ResetActionStates(XDirection.Right);
                            else
                                ResetActionStates(XDirection.Left);

                            return InteractionActions.None;
                        }
                        break;

                    case "SavePoint":
                        if (interactionType == InteractionTypes.PlayerAction)
                        {
                            currentHealth = maxHealth;
                            saveCallback();
                            return InteractionActions.None;
                        }
                        break;
                    case "Lever":
                        if (interactionType == InteractionTypes.PlayerAction)
                        {
                            otherObject.SwitchLever();
                            return InteractionActions.Lever;
                        }
                        break;
                    default:
                        return InteractionActions.None;
                }
            }
            return InteractionActions.None;
        }