Exemplo n.º 1
0
        protected virtual void GiveOrTake()
        {
            if (Requirement != null)
            {
                if (!FollowerInventory.Instance.Contains(Requirement))
                {
                    return;
                }
            }

            if (RequirementMissing != null)
            {
                if (FollowerInventory.Instance.Contains(RequirementMissing))
                {
                    return;
                }
            }

            if (Taken != null)
            {
                FollowerEvent.Trigger(FollowerEventTypes.Loss, Taken, null, null, Requirement, Reason);
            }

            if (Given != null)
            {
                FollowerEvent.Trigger(FollowerEventTypes.Gift, Given, null, null, Requirement, Reason);
                // we instantiate the given follower and make it follow the player
                _newPosition.z  = _givenFollower.transform.position.z;
                _newPosition.x  = LevelManager.Instance.Players[0].transform.position.x;
                _newPosition.y  = LevelManager.Instance.Players[0].transform.position.y;
                _newPosition.x -= xOffset;
                _givenFollower.transform.position = _newPosition;
                StartCoroutine(_givenFollower.StartFollowing());
            }
        }
Exemplo n.º 2
0
        public void OnMMEvent(FollowerEvent followerEvent)
        {
            switch (followerEvent.EventType)
            {
            case FollowerEventTypes.Buy:
                // adds to the inventory
                Add(followerEvent.Origin);
                _newText = "You've obtained <color=yellow>" + followerEvent.Origin.MessageDisplayText + "</color>. ";
                Story   += "Got <color=yellow>" + followerEvent.Origin.MessageDisplayText + "</color>. ";

                // test cost
                if (Contains(followerEvent.Cost))
                {
                    Remove(followerEvent.Cost);
                    _newText += "It cost you <color=yellow>" + followerEvent.Cost.MessageDisplayText + "</color>. ";
                    Story    += "Lost <color=yellow>" + followerEvent.Cost.MessageDisplayText + "</color>. ";
                }

                // test option
                if (followerEvent.Option != null)
                {
                    _newText += "You'll never get <color=yellow>" + followerEvent.Option.MessageDisplayText + "</color>.";
                }

                MessageEvent.Trigger(_newText);
                break;

            case FollowerEventTypes.Gift:
                Add(followerEvent.Origin);
                _newText = "You've got <color=yellow>" + followerEvent.Origin.MessageDisplayText + "</color> now";
                Story   += "Got <color=yellow>" + followerEvent.Origin.MessageDisplayText + "</color>. ";
                if (followerEvent.Reason != "")
                {
                    _newText += " because " + followerEvent.Reason + ".";
                }
                else
                {
                    _newText += ".";
                }
                MessageEvent.Trigger(_newText);
                GiftFeedback.PlayFeedbacks();
                break;

            case FollowerEventTypes.Loss:
                if (Contains(followerEvent.Origin))
                {
                    FollowerEvent.Trigger(FollowerEventTypes.Destroy, followerEvent.Origin, null, null, null, null);

                    _newText = "You just lost <color=yellow>" + followerEvent.Origin.MessageDisplayText + "</color>";
                    Story   += "Lost <color=yellow>" + followerEvent.Origin.MessageDisplayText + "</color>. ";
                    Remove(followerEvent.Origin);
                    if (followerEvent.Reason != "")
                    {
                        _newText += " because " + followerEvent.Reason + ".";
                    }
                    else
                    {
                        _newText += ".";
                    }
                    MessageEvent.Trigger(_newText);
                    LossFeedback.PlayFeedbacks();
                }
                break;
            }
        }