Ejemplo n.º 1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        //Stop player movement
        currentSpeed = 0;
        animator.SetFloat("Magnitude", 0);

        shouldAnimate = false;

        if (collision.gameObject.CompareTag("NPC") || collision.gameObject.CompareTag("NPC-SelfDestruct"))
        {
            NpcController npcCont = collision.gameObject.GetComponent <NpcController>();
            inConvo = true;
            if (npcCont.shouldDestroy)
            {
                Debug.Log("Destroying NPC");
                collision.gameObject.SetActive(false);
                inConvo       = false;
                shouldAnimate = true;
                return;
            }
            if (collision.gameObject.CompareTag("NPC-SelfDestruct"))
            {
                npcCont.shouldDestroy = true;
            }
            foreach (Dictionary <string, Quest> currQuestMap in inProgressQuests.Values)
            {
                foreach (Quest currQuest in currQuestMap.Values)
                {
                    //Already Have quest

                    if (npcCont.myName == currQuest.givenBy)
                    {
                        //Done
                        if (currQuest.completed())
                        {
                            //inProgressQuests[currQuest.type].Remove(currQuest.location);
                            if (GameObject.Find(currQuest.type + currQuest.location))
                            {
                                GameObject.Find(currQuest.type + currQuest.location).GetComponent <Image>().color = new Color32(150, 23, 94, 123);
                            }

                            OpenMessage();
                            npcCont.PlayConvoAfter();
                            unlockRoom(currQuest.roomUnlockedOnFinish);
                            Debug.Log(currQuest.roomUnlockedOnFinish + " unlocked!");
                            return;
                        }
                        //Middle
                        else
                        {
                            OpenMessage();
                            npcCont.PlayConvoDuring();
                            Debug.Log("Still need to do stuff!");
                            return;
                        }
                    }
                }
            }

            // First time
            OpenMessage();
            npcCont.PlayConvoBefore();

            if (npcCont.myName != "???")
            {
                AddQuest(npcCont);
            }
        }

        //Doors
        else if (collision.gameObject.CompareTag("Door") || collision.gameObject.CompareTag("VertDoor"))
        {
            string dest = collision.gameObject.GetComponent <Text>().text;

            if (rooms[dest])
            {
                if (collision.gameObject.CompareTag("Door") && !switched)
                {
                    StartCoroutine(Mask());
                    currScene = dest;
                    Debug.Log(dest);
                    GameObject cam = GameObject.FindGameObjectWithTag("MainCamera");
                    cam.GetComponent <sceneChange>().flipPlayer(false);
                    cam.GetComponent <sceneChange>().changeScene(dest);
                    switched = true;

                    GameObject.FindGameObjectWithTag("GUI").GetComponentInChildren <MiniMap>().UpdateMinimap(dest);
                }
                //VERTICAL DOORS ARE HANDLED BY THE DOORS THEMSELVES
                else if (collision.gameObject.CompareTag("VertDoor") && !switched)
                {
                    StartCoroutine(Mask());
                    currScene = dest;
                    Debug.Log(dest);
                    GameObject cam = GameObject.FindGameObjectWithTag("MainCamera");
                    cam.GetComponent <sceneChange>().flipPlayer(true);
                    cam.GetComponent <sceneChange>().changeScene(dest);
                    switched = true;

                    Debug.Log(dest);
                    GameObject.FindGameObjectWithTag("GUI").GetComponentInChildren <MiniMap>().UpdateMinimap(dest);
                }
            }
            else
            {
                Thought(dest);
                Debug.Log("DENIED accsess to: " + dest);
            }
        }
    }