コード例 #1
0
    public void OnTriggerEnter(Collider other)
    {
        //Debug.Log("other is " + other.gameObject.name);

        if (other.gameObject.tag == "Decal")
        {
            Sprite tmp = other.gameObject.GetComponent <SpriteRenderer>().sprite;
            closeDecals.Add(other.gameObject);
            //Debug.Log("NPC Detected");
        }
        if (other.gameObject.tag == "NPC" && !deadNPCs.Contains(other.gameObject))
        {
            nearbyNPCs.Add(other.gameObject);
        }
        if (!seesObj && !closeMiss && other.isTrigger == false)
        {
            LayerMask newMask = LayerMask.GetMask("walls");
            if (other.gameObject.tag == "Ignore" && !Physics.Linecast(transform.position, other.gameObject.transform.position, newMask, QueryTriggerInteraction.UseGlobal))
            {
                ItemActionInterface actions = other.GetComponent <ItemActionInterface>();
                Rigidbody           body    = other.attachedRigidbody;
                if (actions != null && body != null && body.velocity.magnitude > 2)
                {
                    seesObj = true;
                    setSurprised();
                    Debug.Log("Just seen it");
                }
            }
        }
    }
コード例 #2
0
ファイル: Haunt.cs プロジェクト: mitchellmarshe/3dcapstone
    //Sets up the haunt/unhaunt actions buttons when initially looking at an object
    //Also stores the object and the implemented abstract ItemActionInterface
    // associated with that object

    /*public void prepForHaunt(GameObject item, ItemActionInterface itemInfo)
     * {
     *  lastItemObject = item;
     *  lastItemInterface = itemInfo;
     *  myController.setItemInfo(myHauntActions);
     *
     *  dynamicButtonUpdaterScript.receiveItemObject(gameObject, myHauntActions);
     *  dynamicButtonUpdaterScript.setStates(myHauntActions.states);
     * } */

    //This is called to progress down a tree of actions
    public void goFowardAHaunt(ItemActionInterface info)
    {
        //Debug.Log("before global item is: " + myGlobal.itemInfo );
        previousMenus.Enqueue(myGlobal.itemInfo);
        //Debug.Log("new global item is " + info);

        myGlobal.itemInfo = info;

        dynamicButtonUpdaterScript.receiveItemObject(myGlobal.itemInfo.gameObject, info);
        //dynamicButtonUpdaterScript.setStates(info.states);
    }
コード例 #3
0
ファイル: Global.cs プロジェクト: mitchellmarshe/3dcapstone
    void Awake()
    {
        #if UNITY_STANDALONE_WIN
        Debug.Log("Win");
        platform = false;
        #elif UNITY_STANDALONE_OSX
        Debug.Log("OSX");
        platform = false;
        #elif UNITY_ANDROID
        Debug.Log("Android");
        platform = true;
        #elif UNITY_IOS
        Debug.Log("IOS");
        platform = true;
        #else
        Debug.Log("Unsupported");
        platform = false;
        #endif

        height = Screen.height;
        width  = Screen.width;

        itemInfo   = null;
        possessing = false;
        //possesMove = false;
        haunted      = false;
        mouseLocked  = true;
        placingDecal = false;
        decided      = false;
        action       = Action.None;
        selectedItem = null;
        //inMenus = false;
        points = 0;

        currentScene = SceneManager.GetActiveScene().buildIndex;
        startScene   = 1;
        mainScene    = 2;

        tutorial = true;
    }
コード例 #4
0
    private void rayCheck()
    {
        if (!global.possessing)
        {
            Vector3    rayOrigin = cameraComponent.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.0f));
            RaycastHit rayHit;
            if (Physics.Raycast(rayOrigin, cameraComponent.transform.forward, out rayHit, 3)) // 3 is the length of the ray drawn
            {
                GameObject other = rayHit.collider.gameObject;
                if (other.tag == "Item")
                {
                    //Call Dynamic button system
                    if (decalOpen)
                    {
                        decalStates = dynamicButtonUpdaterScript.getStates();
                    }

                    ItemActionInterface tmp = other.GetComponent <ItemActionInterface>();
                    itemInfo = myHauntActions;
                    //myHauntScript.prepForHaunt(other, tmp);
                    decalOpen = false;
                    //dynamicButtonUpdaterScript.receiveItemObject(gameObject, myHauntActions);
                }
                // do stuff like check other for tags or w/e you like
            }
            else
            {
                if (!decalOpen)
                {
                    selectorIcon.sprite = null;
                    itemInfo            = myDecalActions;
                    dynamicButtonUpdaterScript.receiveItemObject(gameObject, myDecalActions);
                    selectorText.text = "Decal";
                    //dynamicButtonUpdaterScript.setStates(decalStates);
                    decalOpen = true;
                }
            }
        }
        //Debug.DrawRay(rayOrigin, gameCam.transform.forward * 3, Color.green); // this will draw a green line in editor for debugging
    }
コード例 #5
0
 public void OnCloseTriggerEnter(Collider other)
 {
     if (!closeMiss && other.isTrigger == false && other.gameObject.tag != "Decal")
     {
         //Debug.Log("Close Miss!!");
         LayerMask newMask = LayerMask.GetMask("walls");
         if (other.gameObject.tag == "Ignore" && !Physics.Linecast(transform.position, other.gameObject.transform.position, newMask, QueryTriggerInteraction.UseGlobal))
         {
             ItemActionInterface actions = other.GetComponent <ItemActionInterface>();
             Rigidbody           body    = other.attachedRigidbody;
             if (actions != null && body != null && body.velocity.magnitude > 2)
             {
                 if (seesObj)
                 {
                     //Debug.Log("I saw the obj first");
                     StopAllCoroutines();
                     stopped           = true;
                     myAgent.isStopped = true;
                     setAllAnimBoolsToBool(false);
                     myAnimator.SetBool("surprisedDuck", true);
                     myAnimator.SetTrigger("fireTransition");
                     addFear(250);
                     IEnumerator coro = idling(2);
                     StartCoroutine(coro);
                     //saySomethingGeneral(generalQuotes);
                     mySkinMeshRend.material.mainTexture = human_surprised;
                     reactionFace = true;
                 }
                 else
                 {
                     setSurprisedDuck();
                 }
                 closeMiss = true;
             }
         }
     }
 }
コード例 #6
0
    private void clickCheck()
    {
        if (!global.possessing)
        {
            RaycastHit rayHit;
            Ray        ray = cameraComponent.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out rayHit))
            {
                GameObject other = rayHit.collider.gameObject;
                if (other.tag == "Item")
                {
                    if (decalOpen)
                    {
                        decalStates = dynamicButtonUpdaterScript.getStates();
                    }

                    ItemActionInterface tmp = other.GetComponent <ItemActionInterface>();
                    itemInfo = myHauntActions;
                    //myHauntScript.prepForHaunt(other, tmp);
                    decalOpen = false;
                }
            }
            else
            {
                if (!decalOpen)
                {
                    selectorIcon.sprite = null;
                    itemInfo            = myDecalActions;
                    dynamicButtonUpdaterScript.receiveItemObject(gameObject, myDecalActions);
                    selectorText.text = "Decal";
                    //dynamicButtonUpdaterScript.setStates(decalStates);
                    decalOpen = true;
                }
            }
        }
    }
コード例 #7
0
    // This is called in 2 cases
    // 1. the player is looking/selected an object and will now display the option to haunt
    // 2. The player chose to haunt an object
    public void receiveItemObject(GameObject item, ItemActionInterface itemInfo)
    {
        selectorText.text = item.name;
        global.itemInfo   = itemInfo;
        enableAllButtons();
        setStates(global.itemInfo.states);
        string[] names = itemInfo.getActionNames();

        action1Text.text = names[0];

        if (names[0] == "Open2")
        {
            action1Image.sprite = icons1[0];
        }
        else if (names[0] == "Close2")
        {
            action1Image.sprite = icons1[1];
        }
        else if (names[0] == "Open1")
        {
            action1Image.sprite = icons1[2];
        }
        else if (names[0] == "Close1")
        {
            action1Image.sprite = icons1[3];
        }
        else if (names[0] == "Burst" ||
                 names[0] == "POP*" ||
                 names[0] == "Explode")
        {
            action1Image.sprite = icons1[4];
        }
        else if (names[0] == "Power" ||
                 names[0] == "On/Off" ||
                 names[0] == "Jazz")
        {
            action1Image.sprite = icons1[5];
        }
        else if (names[0] == "Slam" ||
                 names[0] == "Haunt Call" ||
                 names[0] == "Spookify" ||
                 names[0] == "Shake")
        {
            action1Image.sprite = icons1[6];
        }
        else if (names[0] == "Crumble")
        {
            action1Image.sprite = icons1[7];
        }
        else if (names[0] == "Random Pitch")
        {
            action1Image.sprite = icons1[8];
        }
        else if (names[0] == "Distort")
        {
            action1Image.sprite = icons1[9];
        }
        else if (names[0] == "Shoot Soda*")
        {
            action1Image.sprite = icons1[10];
        }

        action2Text.text = names[1];

        if (names[1] == "Smoke")
        {
            action2Image.sprite = icons2[0];
        }
        else if (names[1] == "Sound")
        {
            action2Image.sprite = icons2[1];
        }
        else if (names[1] == "Volume Up")
        {
            action2Image.sprite = icons2[2];
        }
        else if (names[0] == "Power" ||
                 names[0] == "On/Off" ||
                 names[0] == "Jazz")
        {
            action2Image.sprite = icons1[5];
        }
        else if (names[1] == "Overload*" ||
                 names[1] == "POP*")
        {
            action2Image.sprite = icons2[3];
        }

        action3Text.text = names[2];

        if (names[2] == "Back...")
        {
            action3Image.sprite = icons3[0];
        }
        else if (names[2] == "Explode")
        {
            action3Image.sprite = icons2[3];
        }

        action4Text.text = names[3];

        if (names[3] == "Special")
        {
            action4Image.sprite = icons4[0];
        }
        else if (names[3] == "Volume Down")
        {
            action4Image.sprite = icons4[1];
        }

        global.selectedItem = item;

        Image tmpImage = item.GetComponentInChildren <Image>();

        if (tmpImage == null || tmpImage.sprite == null)
        {
            selectorIcon.sprite = selectorIconDefault;
        }
        else
        {
            selectorIcon.sprite = tmpImage.sprite;
        }
    }
コード例 #8
0
    public override void callAction4()
    {
        ItemActionInterface tmp = gameObject.GetComponent <SpecialRadioActions>();

        myHaunt.goFowardAHaunt(tmp);
    }
コード例 #9
0
    public override void  callAction1()
    {
        ItemActionInterface tmp = gameObject.GetComponent <PowerActions>();

        myHaunt.goFowardAHaunt(tmp);
    }
コード例 #10
0
 public void setItemInfo(ItemActionInterface itemInterface)
 {
     itemInfo = itemInterface;
 }