示例#1
0
 public Save(List <GameObject> ammos, List <GameObject> doors, List <GameObject> vents, List <GameObject> matchThreeObjects, List <GameObject> tutorials, GameObject character)
 {
     foreach (GameObject obj in ammos)
     {
         ammoInfos.Add(new ammoInfo(obj.GetComponent <PickupAmmoInteraction>()));
     }
     foreach (GameObject obj in matchThreeObjects)
     {
         matchThreeObjectInfos.Add(new matchThreeObjectInfo(obj.GetComponent <MatchThreeObject>()));
     }
     foreach (GameObject obj in tutorials)
     {
         tutorialInfos.Add(new tutorialInfo(obj.GetComponent <Tutorial>()));
     }
     foreach (GameObject obj in doors)
     {
         doorInfos.Add(new doorInfo(obj.GetComponent <DoorInteraction>()));
     }
     foreach (GameObject obj in vents)
     {
         DoorInteraction vent = obj.GetComponentInChildren <DoorInteraction>();
         doorInfos.Add(new doorInfo(vent.transform.parent.name, vent.isOpen, vent.isLocked));
     }
     player = new playerInfo(character.GetComponent <MyCharacterController>());
 }
示例#2
0
 public void MouthButton()
 {
     for (int i = 0; i < optionsImages.Length; i++)
     {
         optionsImages[i].CrossFadeAlpha(0, 0.25f, false);
         showingMenu = false;
     }
     if (currentItem != null)
     {
         DialogueManager.Instance.StartDialogue(currentItem.Mouth, currentItem.VoiceOversMouth);
     }
     if (currentDoor != null)
     {
         DialogueManager.Instance.StartDialogue(currentDoor.Mouth, currentDoor.VoiceOversMouth);
     }
     if (currentGhost != null && GhostInteraction.Saveable)
     {
         DialogueManager.Instance.StartDialogue(currentGhost.MouthSaveable, currentGhost.VoiceOversSaveable);
         currentGhost.Ghost.material = currentGhost.Happy;
         foreach (ParticleSystem p in currentGhost.Tears)
         {
             p.Stop();
         }
         StartCoroutine(door.Open(openDoor.transform.rotation));
     }
     else if (currentGhost != null)
     {
         DialogueManager.Instance.StartDialogue(currentGhost.Mouth, currentGhost.VoiceOversMouth);
     }
     currentItem  = null;
     currentGhost = null;
     currentDoor  = null;
 }
示例#3
0
    public static void readSave(Save save)
    {
        //Clear existing objects
        ClearMatchThreeObjects();
        ClearAmmoObjects();
        DestroyCharacter();
        //Create Player
        playerInfo playerInfo = save.player;

        player = Instantiate(CharacterObject).GetComponent <MyCharacterController>();
        player.transform.position = playerInfo.position.GetPosition();
        Vector3 orientation = playerInfo.orientation.GetOrientation();

        player.my_camera.GetComponent <camMouseLook>().Look(orientation);
        player.SetCrouchState(playerInfo.crouched, true);
        player.health = playerInfo.health;
        GunController gunController = player.my_pickup.gunController;

        for (int i = 0; i < playerInfo.ammo.Length; ++i)
        {
            gunController.arsenal[i].gun.ammo      = playerInfo.ammo[i];
            gunController.arsenal[i].is_in_arsenal = playerInfo.inArse[i];
        }
        gunController.equip_gun((GunController.gun_type)playerInfo.equip);
        //Create Match Threes
        foreach (matchThreeObjectInfo obj in save.matchThreeObjectInfos)
        {
            GameObject       newObj   = Instantiate(matchThreeObjectTypes.types[obj.type], GameObject.Find(obj.room).transform);
            MatchThreeObject newObjM3 = newObj.GetComponent <MatchThreeObject>();
            newObj.name = obj.name;
            newObj.transform.position = obj.position.GetPosition();
            newObjM3.match3_group_id  = (MatchThreeObject.match3_group_id_names)obj.group;
            newObjM3.apply_color();
        }
        //Create Ammo Pickups
        foreach (ammoInfo obj in save.ammoInfos)
        {
            GameObject            newObj     = Instantiate(AmmoObject);
            PickupAmmoInteraction newObjAmmo = newObj.GetComponent <PickupAmmoInteraction>();
            newObj.name = obj.name;
            newObj.transform.position    = obj.position.GetPosition();
            newObj.transform.eulerAngles = obj.rotation.GetOrientation();
            newObjAmmo.gun    = (GunController.gun_type)obj.type;
            newObjAmmo.amount = obj.amount;
        }
        //Set Door Parameters
        foreach (doorInfo obj in save.doorInfos)
        {
            DoorInteraction door = GameObject.Find(obj.name).GetComponentInChildren <DoorInteraction>();
            door.twistLock(obj.locked);
            door.swingDoor(obj.open, false);
        }
        //Temporary code for setting references
        foreach (GameObject tutorial in tutorials)
        {
            tutorial.GetComponent <Tutorial>().GetUIComponents(player.gameObject);
        }
    }
示例#4
0
 public void ExamineButton()
 {
     for (int i = 0; i < optionsImages.Length; i++)
     {
         optionsImages[i].CrossFadeAlpha(0, 0.25f, false);
         showingMenu = false;
     }
     if (currentItem != null)
     {
         DialogueManager.Instance.StartDialogue(currentItem.Eyes, currentItem.VoiceOversEyes);
     }
     if (currentGhost != null)
     {
         DialogueManager.Instance.StartDialogue(currentGhost.Eyes, currentGhost.VoiceOversEyes);
     }
     if (currentDoor != null)
     {
         DialogueManager.Instance.StartDialogue(currentDoor.Eyes, currentDoor.VoiceOversEyes);
     }
     currentItem  = null;
     currentGhost = null;
     currentDoor  = null;
 }
示例#5
0
    //IEnumerator RemoveItem() {
    //    yield return new WaitForSeconds(1);
    //    currentItem = null;
    //    currentGhost = null;
    //    currentDoor = null;
    //    yield break;
    //}


    public void InteractButton()
    {
        for (int i = 0; i < optionsImages.Length; i++)
        {
            optionsImages[i].CrossFadeAlpha(0, 0.25f, false);
            showingMenu = false;
        }
        if (currentItem != null && currentItem.Hand.Length >= 1)
        {
            DialogueManager.Instance.StartDialogue(currentItem.Hand, currentItem.VoiceOversHand);
            currentItem = null;
            return;
        }
        if (currentGhost != null && currentGhost.Hand.Length >= 1)
        {
            DialogueManager.Instance.StartDialogue(currentGhost.Hand, currentGhost.VoiceOversHand);
            currentGhost = null;
            return;
        }
        if (currentDoor != null && currentDoor.Hand.Length <= 0)
        {
            DialogueManager.Instance.StartDialogue(currentDoor.Hand, currentDoor.VoiceOversHand);
            currentDoor = null;
            SceneManager.LoadScene("LevelSelect");
            return;
        }
        if (!currentItem.Name.Contains("in inventory"))
        {
            inventory.Add(new Item(currentItem.Name, currentItem.Eyes, currentItem.Mouth,
                                   currentItem.Hand, currentItem.HandAfterPickup, currentItem.Image, currentItem));
        }
        currentItem.gameObject.tag = "Untagged";
        currentItem.gameObject.GetComponent <GlowObject>().GlowColor = Color.black;
        Globals.FirstStoryProgress++;
        currentItem = null;
    }
示例#6
0
    public void ShowMenuOnMouseClick(bool overrule = false, ItemInteraction item = null)
    {
        if (Physics.Raycast(ray, out hit) && !overrule)
        {
            if (hit.collider.tag == "Interactable" && !showingMenu)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    currentItem  = hit.collider.gameObject.GetComponent <ItemInteraction>();
                    playerMoving = true;
                }
            }
            if (hit.collider.tag == "Ghost" && !showingMenu)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    currentGhost = hit.collider.gameObject.GetComponent <GhostInteraction>();
                    playerMoving = true;
                }
            }
            if (hit.collider.tag == "Open Door" && !showingMenu)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    currentDoor  = hit.collider.gameObject.GetComponent <DoorInteraction>();
                    playerMoving = true;
                }
            }
        }
        if (overrule)
        {
            currentItem = item;
            showingMenu = true;

            middleImage.gameObject.SetActive(true);
            for (int i = 0; i < optionsImages.Length; i++)
            {
                canvasRenderers[i].SetAlpha(0);
                optionsImages[i].CrossFadeAlpha(1, 0.25f, false);
                MoveOptionsMenu();
            }
        }

        /*if (hit.collider.tag == "NotInteractable")
         * {
         *  for (int i = 0; i < optionsImages.Length; i++)
         *  {
         *      optionsImages[i].CrossFadeAlpha(0, 0.25f, false);
         *  }
         * }*/

        m_PointerEventData          = new PointerEventData(m_EventSystem);
        m_PointerEventData.position = Input.mousePosition;
        List <RaycastResult> results     = new List <RaycastResult>();
        List <string>        nameResults = new List <string>();

        m_Raycaster.Raycast(m_PointerEventData, results);
        foreach (RaycastResult r in results)
        {
            nameResults.Add(r.gameObject.name);
        }
        if (!nameResults.Contains("MiddleImage"))
        {
            for (int i = 0; i < optionsImages.Length; i++)
            {
                optionsImages[i].CrossFadeAlpha(0, 0.25f, false);
                showingMenu = false;
            }
            //StartCoroutine(RemoveItem());
        }
        //if(Input.GetMouseButtonDown(1)) {
        //    currentItem = null;
        //    for(int i = 0; i < optionsImages.Length; i++) {
        //        optionsImages[i].CrossFadeAlpha(0, 0.25f, false);
        //        showingMenu = false;
        //    }
        //}
    }
示例#7
0
    void Update()
    {
        RaycastHit hitInfo;
        Ray        ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
        Renderer   currRenderer;

        #region Highlight Object
        if (Physics.Raycast(ray.origin, ray.direction, out hitInfo, distanceToSee))
        {
            #region InteractionScript
            if (Input.GetKeyDown(KeyCode.E))
            {
                //Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
                RaycastHit hit;

                if (Physics.Raycast(ray.origin, ray.direction, out hit, interactionRadius))
                {
                    DoorInteraction doorObject = hit.collider.GetComponent <DoorInteraction>();
                    if (doorObject)
                    {
                        doorObject.Toggle();
                    }

                    FileCabinetScript fileCabinet = hit.collider.GetComponent <FileCabinetScript>();
                    if (fileCabinet)
                    {
                        fileCabinet.ToggleDrawer();
                    }

                    DrawerInteraction drawerObject = hit.collider.GetComponent <DrawerInteraction>();
                    if (drawerObject)
                    {
                        drawerObject.ToggleDrawer();
                    }

                    UI_Key keyObject = hit.collider.GetComponent <UI_Key>();
                    if (keyObject)
                    {
                        keyObject.KeyAdd();
                    }
                }
            }
            #endregion


            if (hitInfo.transform.tag == "collectible" || hitInfo.transform.tag == "key")
            {
                // collect object and delete it from scene, adding +1 to inventory
                if (Input.GetKey(KeyCode.E))
                {
                    if (hitInfo.transform.tag == "key")
                    {
                        trash.KeyAdd();
                        key += 1;
                        Debug.LogFormat("Keys: {0} ", key);
                    }
                    if (hitInfo.transform.tag == "collectible")
                    {
                        collectible += 1;
                        Debug.LogFormat("collectibles: {0} ", collectible);
                    }
                    Destroy(hitInfo.collider.gameObject);
                }
                currRenderer = hitInfo.collider.gameObject.GetComponent <Renderer>();

                if (currRenderer == renderer)
                {
                    return;
                }

                if (currRenderer && currRenderer != renderer)
                {
                    if (renderer)
                    {
                        renderer.sharedMaterial = originalMaterial;
                    }
                }

                if (currRenderer)
                {
                    renderer = currRenderer;
                }
                else
                {
                    return;
                }

                originalMaterial = renderer.sharedMaterial;

                tempMaterial            = new Material(originalMaterial);
                renderer.material       = tempMaterial;
                renderer.material.color = highlightColor;
            }
            else
            {
                if (renderer)
                {
                    renderer.sharedMaterial = originalMaterial;
                    renderer = null;
                }
            }
        }
        #endregion
    }
示例#8
0
    void Update()
    {
        key = GetComponent <UI_Key>();
        if (safeKey == true)
        {
            key.keyCount = 1;
        }
        Debug.Log(key.keyCount);
        Debug.LogFormat("safeKey interaction{0}", safeKey);

        if (Input.GetKeyDown(KeyCode.E))
        {
            Ray        ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
            RaycastHit hit;

            if (Physics.Raycast(ray.origin, ray.direction, out hit, interactionRadius))
            {
                DoorInteraction doorObject = hit.collider.GetComponent <DoorInteraction>();
                if (doorObject)
                {
                    Debug.Log(hit.collider.tag);
                    if (hit.collider.tag == "safe")
                    {
                        if (safeKey == true)
                        {
                            doorObject.Toggle();
                        }
                        else if (safeKey == false)
                        {
                            Debug.Log("no key");
                        }
                    }
                    if (doorObject.tag != "safe")
                    {
                        doorObject.Toggle();
                    }
                }

                // File Cabinet Interaction
                FileCabinetScript fileCabinet = hit.collider.GetComponent <FileCabinetScript>();
                if (fileCabinet)
                {
                    fileCabinet.ToggleDrawer();
                }

                // drawer interaction
                DrawerInteraction drawerObject = hit.collider.GetComponent <DrawerInteraction>();
                if (drawerObject)
                {
                    drawerObject.ToggleDrawer();
                }

                // Keyobject interaction
                UI_Key keyObject = hit.collider.GetComponent <UI_Key>();
                if (keyObject)
                {
                    safeKey = true;
                }

                DrawerInteractionHenry drawerObjectHenry = hit.collider.GetComponent <DrawerInteractionHenry>();
                if (drawerObjectHenry)
                {
                    drawerObjectHenry.ToggleDrawer();
                }
            }
        }
    }
示例#9
0
 public doorInfo(DoorInteraction obj)
 {
     name   = obj.name;
     open   = obj.isOpen;
     locked = obj.isLocked;
 }