예제 #1
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Human")
     {
         NewHuman human = collision.gameObject.GetComponentInParent <NewHuman>();
         human.Stats.Health -= 10;
         human.LastHitBy     = Owner;
         Destroy(gameObject);
         Debug.Log("hitting a human");
     }
     else
     {
         Destroy(gameObject);
     }
 }
예제 #2
0
    void Update()
    {
        UpdateGUI();
        if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1))
        {
            RaycastHit hitInfo = new RaycastHit();
            bool       hit     = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo);

            if (Input.GetMouseButtonDown(0))
            {
                if (hit)
                {
                    //Debug.Log("Hit " + hitInfo.transform.gameObject.name);
                    if (hitInfo.transform.gameObject.tag == "Human")
                    {
                        if (selectedHuman != null)
                        {
                            selectedHuman.Selected = false;
                        }
                        selectedHuman          = hitInfo.transform.gameObject.GetComponent <NewHuman>();
                        selectedHuman.Selected = true;
                        selectedHuman.fieldOfView.DisplayFieldOfView = true;
                        DisplayHumanFovToggle.isOn    = true;
                        DisplayHumanFovToggle.enabled = true;
                    }
                    else
                    {
                        DisplayHumanFovToggle.enabled = false;
                        DisplayHumanFovToggle.isOn    = false;
                        if (selectedHuman != null)
                        {
                            selectedHuman.fieldOfView.DisplayFieldOfView = false;
                            selectedHuman.Selected = false;
                        }
                        selectedHuman           = null;
                        HumanSelectedText.text  = "No";
                        HumanBehaviourText.text = "";
                        HumanHealthText.text    = "0";
                        HumanHungerText.text    = "0";
                        HumanMoneyText.text     = "0";
                    }
                }
                else
                {
                    Debug.Log("No hit");
                }
            }

            if (Input.GetMouseButtonDown(1))
            {
                if (hit && selectedHuman != null)
                {
                    if (selectedHuman.Think.CurrentAction().GetType() == typeof(FollowpathAction))
                    {
                        selectedHuman.Think.RemoveAction();
                    }
                    selectedHuman.Think.AddAction(new FollowpathAction(selectedHuman));
                    selectedHuman.TargetPosition = hitInfo.point;
                }
            }
        }
    }
 public HumanThinkBehaviour(NewHuman _human)
 {
     human = _human;
 }
예제 #4
0
 void AddHuman()
 {
     System.Random r            = new System.Random();
     int           index        = r.Next(0, 4);
     NewHuman      spawnedHuman = Instantiate(prefabMan, spawners[index].transform.position, Quaternion.identity) as NewHuman;
 }