void PickUpObject()
    {
        Collider col = null;

        if (objectsInRange[objectsInRange.Count - 1].GetComponent <BoxCollider>() != null)
        {
            col = objectsInRange[objectsInRange.Count - 1].GetComponent <BoxCollider>();
        }
        else if (objectsInRange[objectsInRange.Count - 1].GetComponents <SphereCollider>()[1] != null)
        {
            col = objectsInRange[objectsInRange.Count - 1].GetComponents <SphereCollider>()[1];
        }
        else
        {
            return;
        }

        col.enabled                   = false;
        pickedUpRigidbody             = objectsInRange[objectsInRange.Count - 1].gameObject.GetComponent <Rigidbody>();
        pickedUpRigidbody.isKinematic = true;
        pickedUpRigidbody.gameObject.transform.parent        = pickedUpObjectParent;
        pickedUpRigidbody.gameObject.transform.localPosition = Vector3.zero;
        pickedUpObjectType = pickedUpRigidbody.gameObject.GetComponent <PickupableObjects>().ObjectType;

        OnPickUp?.Invoke(pickedUpObjectType);

        playerAnimations.ActivateAnimation(AnimationType.PickingUp);

        FreezePosition freezePos = pickedUpRigidbody.gameObject.GetComponent <FreezePosition>();

        if (freezePos != null)
        {
            freezePos.UnFreezePos();
        }
    }
    public void DropObject()
    {
        Collider col = pickedUpRigidbody.gameObject.GetComponent <BoxCollider>();

        if (col == null)
        {
            col = pickedUpRigidbody.gameObject.GetComponents <SphereCollider>()[1];
        }

        col.enabled = true;

        FreezePosition freezePos = pickedUpRigidbody.gameObject.GetComponent <FreezePosition>();

        if (freezePos != null)
        {
            freezePos.FreezePos();
        }

        pickedUpRigidbody.isKinematic = false;
        pickedUpRigidbody.gameObject.transform.parent = null;
        pickedUpRigidbody.AddForce(playerModel.forward * stats.DropForce);
        pickedUpRigidbody  = null;
        pickedUpObjectType = PickupableObjectType.None;

        OnDrop?.Invoke(PickupableObjectType.None);
    }
示例#3
0
 public Quest(QuestType type, float timeLimit, PickupableObjectType typeToGet, Transform npc)
 {
     TypeOfQuest = type;
     TimeLimit   = timeLimit;
     TypeToGet   = typeToGet;
     Npc         = npc;
 }
示例#4
0
    public void QuestCreated(Action <Quest> actionOnItemReceived, Quest quest)
    {
        OnObjectReceived += actionOnItemReceived;
        activeQuest       = quest;
        acceptedType      = activeQuest.TypeToGet;

        questFinishAction = actionOnItemReceived;
    }
示例#5
0
 public void SetSprite(QuestType type, PickupableObjectType objType)
 {
     if (type != QuestType.GetSomething)
     {
         taskImage.sprite = taskSprites[(int)type];
     }
     else
     {
         taskImage.sprite = bringItemSprites[(int)objType];
     }
 }
示例#6
0
 void ChangeSprite(PickupableObjectType type)
 {
     pickedUpObjectDisplay.sprite = pickupableObjectSprites[(int)type];
 }
示例#7
0
    Quest GetRandomizedQuest()
    {
        Transform randomNpc = NPCManager.Instance.NPCs[Random.Range(0, NPCManager.Instance.NPCs.Count)].transform;

        StateMachine stateMachine = randomNpc.gameObject.GetComponent <StateMachine>();

        int i = 0;

        while (stateMachine.CurrentState != NpcState.Happy)
        {
            randomNpc    = NPCManager.Instance.NPCs[Random.Range(0, NPCManager.Instance.NPCs.Count)].transform;
            stateMachine = randomNpc.gameObject.GetComponent <StateMachine>();
            i++;

            if (i == 100)
            {
                //Debug.LogError("Everyone is propably leaving");
                return(null);
            }
        }

        QuestType typeOfQuest = (QuestType)RandomExtension.ChooseFromMultipleWeighted(new List <int> {
            (int)QuestType.GetSomething,
            (int)QuestType.ChangeMusic, (int)QuestType.ThrowTheTrashOut, (int)QuestType.Puking
        }, new List <int> {
            55, 10, 25, 10
        });

        // Debug
        //typeOfQuest = QuestType.Puking;
        //typeOfQuest = QuestType.ThrowTheTrashOut;
        //typeOfQuest = QuestType.GetSomething;

        QuestState npcActiveQuest = randomNpc.gameObject.GetComponent <QuestState>();

        while (typeOfQuest == QuestType.ChangeMusic && changeMusicQuestActive)
        {
            typeOfQuest = (QuestType)RandomExtension.ChooseFromMultipleWeighted(new List <int> {
                (int)QuestType.GetSomething,
                (int)QuestType.ChangeMusic, (int)QuestType.ThrowTheTrashOut, (int)QuestType.Puking
            }, new List <int> {
                60, 10, 25, 5
            });
        }

        if (npcActiveQuest.ActiveQuest != null)
        {
            while (npcActiveQuest.ActiveQuest.TypeOfQuest == QuestType.Puking)
            {
                randomNpc = NPCManager.Instance.NPCs[Random.Range(0, NPCManager.Instance.NPCs.Count)].transform;
                i++;

                if (i == 100)
                {
                    typeOfQuest = QuestType.GetSomething;
                    break;
                }
            }
        }

        PickupableObjectType objType = PickupableObjectType.None;

        if (typeOfQuest == QuestType.GetSomething)
        {
            objType = (PickupableObjectType)RandomExtension.ChooseFromMultiple(new List <int> {
                (int)PickupableObjectType.Beer,
                (int)PickupableObjectType.Chips, (int)PickupableObjectType.Soda
            });
        }
        else if (typeOfQuest == QuestType.ThrowTheTrashOut)
        {
            objType = PickupableObjectType.Trash;
        }
        else if (typeOfQuest == QuestType.ChangeMusic)
        {
            changeMusicQuestActive = true;
        }

        return(new Quest(typeOfQuest, timeBeforeQuestFail, objType, randomNpc));
    }