Esempio n. 1
0
 //Add by Guanchen liu
 //An interesting function that allow player to throw stuff
 void OnThrow()
 {
     if (currentItem == selectedItem.GrabObject && onHuman)
     {
         _selection.transform.parent = GameObject.Find("Chores").transform;
         currentItem = selectedItem.None;
         grabItem.GetComponent <Chores>().getTargetPosition().SetActive(false);
         var selectRigid = grabItem.gameObject.GetComponent <Rigidbody>();
         selectRigid.velocity    = Nathan.transform.forward * 10f;
         selectRigid.useGravity  = true;
         selectRigid.constraints = RigidbodyConstraints.None;
         grabItem     = null;
         currentChore = null;
     }
 }
Esempio n. 2
0
    void OnCollisionEnter(Collision other)
    {
        var otherScript = OtherGhost.GetComponent <GhostController>();

        if (other.gameObject.tag == "Human" && !onHuman)
        {
            if (!otherScript.onHuman)
            {
                OnTaking();
            }
            else if (otherScript.currentCond == ghostCond.onEjecting && !inProp)
            {
                Debug.Log("active");
                currentItem = selectedItem.None;
                otherScript.OnLeaving();
                OnTaking();
            }
        }
    }
Esempio n. 3
0
    /*--------------------------------------------------------------------------------------------------------------------*/
    /* ------------------------------------HUMAN INTERACTION METHODS------------------------------------------------------*/
    /*--------------------------------------------------------------------------------------------------------------------*/

    //Add by Guanchen Liu
    void OnGrabbing()
    {
        if (!humanScript.enabled)
        {
            //Debug.Log("pressed");
            if (_selection != null)
            {
                if (_selection.CompareTag("GrabObject") && !_selection.GetComponent <Chores>().complete())
                {
                    currentItem = selectedItem.GrabObject;
                    grabItem    = _selection;
                    _selection.GetComponent <Chores>().getTargetPosition().SetActive(true);
                }
                else if (_selection.CompareTag("CleanObject") && !_selection.GetComponent <Chores>().complete())
                {
                    currentItem = selectedItem.CleanObject;
                }
                currentChore = _selection.GetComponent <Chores>();
            }
        }
    }
Esempio n. 4
0
    //Add by Guanchen Liu
    //Origin: Enxuan
    //Access by Controller
    //This function will release the object when human is holding something
    void ReleaseObject()
    {
        // if(_selection != null){
        //     Sound: put down object Sound
        // }
        if (onHuman)
        {
            if (currentItem == selectedItem.GrabObject)
            {
                _selection.transform.parent = GameObject.Find("Chores").transform;

                currentItem = selectedItem.None;
                var selectRigid = grabItem.gameObject.GetComponent <Rigidbody>();
                selectRigid.useGravity = true;
                grabItem.GetComponent <Chores>().getTargetPosition().SetActive(false);
                selectRigid.constraints = RigidbodyConstraints.None;
                //test
                currentChore.placed();
                grabItem     = null;
                currentChore = null;
            }
        }
    }
Esempio n. 5
0
 get => selectedItem; set => SetProperty(ref selectedItem, value);
Esempio n. 6
0
        }//end

        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pzLBStartS_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //Grab  Items
            List <UserControl> listItems = new List <UserControl>();
            Switch             s         = Switch.SELECTED;


            try
            {
                GetItemsRecursive <UserControl>(pzLBStartS, ref listItems);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "GetItemsRecursive Error; PZStartPage.xaml.cs", MessageBoxButton.OK);
            }



            try
            {
                if (listItemDataS.Count > 0)
                {
                    foreach (selectedItem item in listItemDataS)
                    {
                        if (e.AddedItems[0].Equals(item.items.ToString()))
                        {
                            s = Switch.NOT_SELECTED;
                            listItemDataS.Remove(item);
                            break;
                        }
                    } //end foreach
                }     //end if
                else
                {
                    s = Switch.SELECTED;
                }//end else

                if (s == Switch.SELECTED)
                {
                    selectedItem item = new selectedItem();
                    item.items = Convert.ToInt16(e.AddedItems[0].ToString());
                    listItemDataS.Clear();
                    listItemDataS.Add(item);
                    sec = item.items;
                }//end if


                ///Switch statement for control the selection highlight state
                switch (s)
                {
                case Switch.SELECTED:
                {
                    if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
                    {
                        foreach (UserControl userControl in listItems)
                        {
                            VisualStateManager.GoToState(userControl, "Normal", true);
                        }        //end foreach

                        foreach (UserControl userControl in listItems)
                        {
                            if (e.AddedItems[0].Equals(userControl.DataContext))
                            {
                                VisualStateManager.GoToState(userControl, "Selected", true);
                            }
                        }
                    }        //end if
                } break;

                case Switch.NOT_SELECTED:
                {
                    if (e.RemovedItems.Count > 0 && e.RemovedItems[0] != null)
                    {
                        foreach (UserControl userControl in listItems)
                        {
                            if (e.RemovedItems[0].Equals(userControl.DataContext))
                            {
                                VisualStateManager.GoToState(userControl, "Normal", true);
                            } //end if
                        }     //end foreach
                    }         //end if
                } break;
                }//end switch
            }//end try
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error; PZStartPage.xaml.cs", MessageBoxButton.OK);
            }
        }//end
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pzLBWarnH_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //Grab  Items
            List <UserControl> listItems = new List <UserControl>();
            Switch             s         = Switch.NOT_SELECTED;


            try
            {
                GetItemsRecursive <UserControl>(pzLBWarnH, ref listItems);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "GetItemsRecursive Error; PZStartPage.xaml.cs", MessageBoxButton.OK);
            }



            try
            {
                if (listItemDataH.Count > 0)
                {
                    foreach (selectedItem item in listItemDataH)
                    {
                        if (e.AddedItems[0].Equals(item.items.ToString()))
                        {
                            s = Switch.NOT_SELECTED;
                            listItemDataH.Remove(item);
                            break;
                        }
                        else
                        {
                            s = Switch.SELECTED;
                        }
                    } //end foreach
                }     //end if
                else
                {
                    s = Switch.SELECTED;
                }//end else

                if (s == Switch.SELECTED)
                {
                    selectedItem item = new selectedItem();
                    switch (e.AddedItems[0].ToString())
                    {
                    case "01":
                    {
                        item.items = 1;
                    } break;

                    case "02":
                    {
                        item.items = 2;
                    } break;

                    case "03":
                    {
                        item.items = 3;
                    } break;

                    case "04":
                    {
                        item.items = 4;
                    } break;

                    case "05":
                    {
                        item.items = 5;
                    } break;

                    case "06":
                    {
                        item.items = 6;
                    } break;

                    case "07":
                    {
                        item.items = 7;
                    } break;

                    case "08":
                    {
                        item.items = 8;
                    } break;

                    case "09":
                    {
                        item.items = 9;
                    } break;

                    case "10":
                    {
                        item.items = 10;
                    } break;

                    case "11":
                    {
                        item.items = 11;
                    } break;

                    case "12":
                    {
                        item.items = 12;
                    } break;
                    }
                    //item.items = Convert.ToInt16(e.AddedItems[0].ToString());
                    listItemDataH.Clear();
                    listItemDataH.Add(item);

                    hour = item.items; // set hour for time packets
                }//end if


                ///Switch statement for control the selection highlight state
                switch (s)
                {
                case Switch.SELECTED:
                {
                    if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
                    {
                        foreach (UserControl userControl in listItems)
                        {
                            VisualStateManager.GoToState(userControl, "Normal", true);
                        }        //end foreach

                        foreach (UserControl userControl in listItems)
                        {
                            if (e.AddedItems[0].Equals(userControl.DataContext))
                            {
                                VisualStateManager.GoToState(userControl, "Selected", true);
                            }
                        }
                    }        //end if
                } break;

                case Switch.NOT_SELECTED:
                {
                    if (e.RemovedItems.Count > 0 && e.RemovedItems[0] != null)
                    {
                        foreach (UserControl userControl in listItems)
                        {
                            if (e.RemovedItems[0].Equals(userControl.DataContext))
                            {
                                VisualStateManager.GoToState(userControl, "Normal", true);
                            } //end if
                        }     //end foreach
                    }         //end if
                } break;
                }//end switch
            }//end try
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error; PZStartPage.xaml.cs", MessageBoxButton.OK);
            }
        }//end
 get => selectedItem; set => SetProperty(ref selectedItem, value, onChanged: OnSelectedItemChanged);
Esempio n. 9
0
    private void Awake()
    {
        player = new Controller();

        //Assign light variables to proper objects in scene
        lightSwitch    = GameObject.FindGameObjectWithTag("Lights");
        worldLighting  = GameObject.FindGameObjectWithTag("EnvironmentLights");
        backUpLighting = GameObject.FindGameObjectWithTag("BackUpLights");
        lightScript    = lightSwitch.GetComponent <LightScript>();
        //lightCooldown = 10f;
        lightEnable = true;

        //Assign gramophone variables to proper objects in scene
        gramophone  = GameObject.FindGameObjectWithTag("Gramophone");
        worldMusic  = GameObject.FindGameObjectWithTag("WorldMusic");
        musicScript = gramophone.GetComponent <GramophoneScript>();
        //musicCooldown = 10f;
        musicEnable = true;

        //Assign painting variables to proper objects in scene
        painting    = GameObject.FindGameObjectWithTag("Painting");
        paintScript = painting.GetComponent <PaintingScript>();
        //paintCooldown = 15f;
        paintEnable = true;

        prop       = GameObject.FindGameObjectWithTag("Prop");
        propScript = prop.GetComponent <PropScript>();

        //Assign player numbers and colors
        playernum = numplayers;
        numplayers++;

        //Add by Guanchen Liu
        //Assign nathan
        Nathan      = GameObject.Find("Nathan");
        humanScript = Nathan.GetComponent <HumanBehavior>();
        currentItem = selectedItem.None;
        currentCond = ghostCond.None;
        mainCamera  = GameObject.Find("MainCamera");
        sc          = mainCamera.GetComponent <CameraControl>();
        UI          = UIManager.instance.gameObject;
        var UICoolDown = UI.transform.Find("CoolDown").gameObject;

        // lightImage = UICoolDown.transform.GetChild(0).GetComponent<Image>();
        // musicImage = UICoolDown.transform.GetChild(1).GetComponent<Image>();
        // paintImage = UICoolDown.transform.GetChild(2).GetComponent<Image>();


        player.Gameplay.Grabbing.canceled += context => ReleaseObject();

        if (playernum == 0)
        {
            GameObject temp = GameObject.Find("Ghost_1");
            transform.position = temp.transform.position;
            Destroy(temp);
            mesh.material   = color1;
            gameObject.name = "Ghost_1";
        }
        if (playernum == 1)
        {
            GameObject temp = GameObject.Find("Ghost_2");
            transform.position = temp.transform.position;
            Destroy(temp);
            mesh.material   = color2;
            gameObject.name = "Ghost_2";
            backUpLighting.gameObject.SetActive(false);
            var UIScript = UI.GetComponent <UIManager>();
            Time.timeScale = 1.0f;
            UIScript.playStartImage();
        }

        var allGhost = GameObject.FindGameObjectsWithTag("Ghost");

        choreManger = GameObject.Find("ChoreManger").GetComponent <ChoreManger>();
    }
Esempio n. 10
0
    //Add by Guanchen Liu
    //Origin: Enxuan
    //Modified: Jordan Timm
    //Mods: Changed physcial items to UI based elements
    //This function will go through the human interaction when ghosts
    //on human.
    void humanTask()
    {
        if (!freezeHuman)
        {
            //_selection.GetComponent<Rigidbody>().isKinematic = true;

            if (currentItem == selectedItem.GrabObject)
            {
                if (_selection != null)
                {
                    UIManager.instance.UpdateChore(_selection.GetComponent <Chores>());
                    UIManager.instance.TriggerHintDeactivate();
                    //Sound: Grab Item Sound
                    Debug.Log("isgrabbing");
                    var grabPosition = Nathan.transform.Find("holdingPos").gameObject;
                    var selectRigid  = _selection.GetComponent <Rigidbody>();
                    _selection.transform.position = grabPosition.transform.position;
                    _selection.transform.parent   = Nathan.transform;
                    _selection.transform.forward  = Nathan.transform.forward;
                    // selectRigid.constraints =  RigidbodyConstraints.FreezeRotation;
                    selectRigid.useGravity = false;
                    //_selection.GetComponent<Rigidbody>().isKinematic = true;
                    // _selection.transform.position = Nathan.transform.position + Nathan.transform.forward * 1 + new Vector3(0.0f, -Nathan.transform.position.y, 0.0f);
                    // _selection.transform.rotation = Quaternion.LookRotation(Nathan.transform.forward);
                }
            }
            else if (currentItem == selectedItem.CleanObject)
            {
                UIManager.instance.TriggerHintDeactivate();

                if (_selection != null)
                {
                    UIManager.instance.UpdateChore(_selection.GetComponent <Chores>());

                    Nathan.GetComponent <Rigidbody>().isKinematic = true;
                    //Sound: Clean Sound around 5 seconds

                    //Turn on CleanTimer
                    UIManager.instance.CleanTimerToggle(true);
                    //Nathan.transform.GetChild(2).gameObject.SetActive(true);
                    //Nathan.transform.GetChild(2).transform.rotation = Quaternion.Euler(new Vector3 (0.0f, 0.0f, 0.0f));
                    //Transform timeBar = Nathan.transform.GetChild(2).GetChild(0);
                    if (cleanTimer < 1)
                    {
                        cleanTimer += Time.deltaTime * 0.2f;
                        UIManager.instance.UpdateCleanTimer(cleanTimer);
                    }
                    else
                    {
                        _selection.gameObject.SetActive(false);
                        cleanTimer = 0;

                        //Vector3 lTemp = timeBar.localScale;
                        //lTemp.x = 0.0f;
                        //timeBar.localScale = lTemp;

                        UIManager.instance.CleanTimerToggle(false);
                        UIManager.instance.UpdateCleanTimer(cleanTimer);

                        //Nathan.transform.GetChild(2).gameObject.SetActive(false);
                        _selection = null;
                        currentChore.finishClean();
                        currentItem  = selectedItem.None;
                        currentChore = null;
                    }
                }
            }
            else
            {
                Ray        ray = new Ray(Nathan.transform.position, Nathan.transform.forward);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit, 1.0f))
                {
                    if (!hit.transform.CompareTag("Human"))
                    {
                        Nathan.transform.GetChild(3).gameObject.SetActive(true);
                        if (hit.transform.CompareTag("GrabObject"))
                        {
                            UIManager.instance.TriggerHint(0);
                            //Nathan.transform.GetChild(3).GetChild(0).gameObject.SetActive(true);
                            //Nathan.transform.GetChild(3).GetChild(1).gameObject.SetActive(false);
                            _selection = hit.transform;
                        }
                        else if (hit.transform.CompareTag("CleanObject"))
                        {
                            UIManager.instance.TriggerHint(1);
                            //Nathan.transform.GetChild(3).GetChild(0).gameObject.SetActive(false);
                            //Nathan.transform.GetChild(3).GetChild(1).gameObject.SetActive(true);
                            _selection = hit.transform;
                        }
                        else
                        {
                            UIManager.instance.TriggerHintDeactivate();
                            //Nathan.transform.GetChild(3).GetChild(0).gameObject.SetActive(false);
                            //Nathan.transform.GetChild(3).GetChild(1).gameObject.SetActive(false);
                            _selection = null;
                        }
                    }
                }
                else
                {
                    UIManager.instance.TriggerHintDeactivate();
                    //Nathan.transform.GetChild(3).gameObject.SetActive(false);
                    _selection = null;
                }
            }
        }
    }