Наследование: MonoBehaviour
Пример #1
0
 public override void WorkerFreed(PersonAI aI)
 {
     if (nearestStone != null)
     {
         nearestStone.Worker = null;
     }
     base.WorkerFreed(aI);
 }
        public ObjectsUnderCursor()
        {
            var objects = GetObjectsUnderCursor();

            Building = objects.Select(o => o.GetComponent <Building>()).FirstOrDefault(c => c != null);
            Tile     = objects.Select(o => o.GetComponent <Tile>()).FirstOrDefault(c => c != null);
            Person   = objects.Select(o => o.GetComponent <PersonAI>()).FirstOrDefault(c => c != null);
        }
Пример #3
0
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        personAI = animator.gameObject.GetComponent <PersonAI>();

        personAI.navMeshAgent.speed = 0;

        personAI.animations.SetTrigger("Die");
    }
Пример #4
0
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        personAI = animator.gameObject.GetComponent <PersonAI>();

        personAI.navMeshAgent.speed = 3f;

        personAI.animations.SetTrigger("StopAiming");

        personAI.suspicious.SetActive(true);
    }
Пример #5
0
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        personAI        = animator.gameObject.GetComponent <PersonAI>();
        playerTransform = (GameImpl.instance as GameImpl).m_player.transform;
        personAI.target = playerTransform.position;

        personAI.animations.ResetTrigger("StopAiming");
        personAI.animations.SetTrigger("StartAiming");
        shootDelay = shootInterval;

        personAI.alerted.SetActive(true);
    }
Пример #6
0
    public void Scream()
    {
        Collider[] colliders = Physics.OverlapSphere(transform.position, 8f, LayerMask.GetMask("Person"));
        foreach (Collider c in colliders)
        {
            if (c.transform == transform)             // Don't scare yourself
            {
                continue;
            }

            PersonAI person = c.transform.GetComponent <PersonAI>();
            if (person)
            {
                person.HearSomething(transform.position);
            }
        }
    }
Пример #7
0
 public override void WorkerAssigned(PersonAI aI)
 {
     base.WorkerAssigned(aI);
     aI.transform.position = spawnSpot.position;
     aI.UpdateCurrentTile();
     stoneNearby = CheckNearbyResources(this.transform.position);
     if (stoneNearby.Count == 0)
     {
         SetBuildingEmpty(stones);
         this.maxWorkers = 0;
         aI.Idle();
         return;
     }
     nearestStone        = GetShortestDistance(this.transform.position, stoneNearby, checkStoneRadius);
     nearestTile         = CheckNearbyTiles(nearestStone.placedTile, world);
     nearestStone.Worker = aI;
     aI.MoveToPosition(nearestTile);
 }
Пример #8
0
 public override void DoWork(PersonAI aI)
 {
     if (nearestStone == null)
     {
         aI.ReachedDestination = false;
         stoneNearby           = CheckNearbyResources(this.transform.position);
         if (stoneNearby.Count == 0)
         {
             SetBuildingEmpty(stones);
             this.maxWorkers = 0;
             aI.Idle();
             return;
         }
         nearestStone = GetShortestDistance(this.transform.position, stoneNearby, checkStoneRadius);
         nearestTile  = CheckNearbyTiles(nearestStone.placedTile, world);
         aI.MoveToPosition(nearestTile);
     }
     if (aI.ReachedDestination)
     {
         if (nearestStone == null || nearestStone.Worker != aI)
         {
             aI.ReachedDestination = false;
             stoneNearby           = CheckNearbyResources(this.transform.position);
             if (stoneNearby.Count == 0)
             {
                 SetBuildingEmpty(stones);
                 this.maxWorkers = 0;
                 aI.Idle();
                 return;
             }
             nearestStone = GetShortestDistance(this.transform.position, stoneNearby, checkStoneRadius);
             nearestTile  = CheckNearbyTiles(nearestStone.placedTile, world);
             aI.MoveToPosition(nearestTile);
         }
         GameplayController.instance.CurrentResources.Stone += stonePerWork;
         if (nearestStone.Anim != null)
         {
             nearestStone.Anim.Play();
         }
         nearestStone.Amount -= stonePerWork;
     }
 }
        public void SubComponentUpdate(PlayerController controller)
        {
            // TODO: Refactor this short circuit logic so its not so repetitive
            if (Input.GetMouseButtonDown(0))
            {
                dragTarget = controller.UnderCursor.Person;
                IsDragging = dragTarget != null;

                if (dragTarget != null)
                {
                    dragTarget.Grabbed();
                }
            }

            if (dragTarget == null)
            {
                IsDragging = false;
            }

            if (!IsDragging)
            {
                return;
            }

            Vector3 personOffset = new Vector3(0, -50, 0);
            Ray     personRay    = Camera.main.ScreenPointToRay(Input.mousePosition + personOffset);

            dragTarget.transform.position = personRay.origin + personRay.direction * 5;

            if (Input.GetMouseButtonUp(0))
            {
                dragTarget.DroppedOn(controller.UnderCursor);

                IsDragging = false;
            }
        }
Пример #10
0
 public void AddPerson(PersonAI person)
 {
     people.Add(person);
 }
Пример #11
0
 public override void DoWork(PersonAI aI)
 {
     GameplayController.instance.CurrentResources.Food += foodPerWork;
 }
Пример #12
0
 public virtual void WorkerAssigned(PersonAI aI)
 {
     currentWorkers++;
 }
Пример #13
0
 public override void WorkerAssigned(PersonAI aI)
 {
     base.WorkerAssigned(aI);
     aI.ReachedDestination = true;
     animPlayer.Play();
 }
Пример #14
0
 public abstract void DoWork(PersonAI aI);
Пример #15
0
 public virtual void WorkerFreed(PersonAI aI)
 {
     currentWorkers--;
 }
Пример #16
0
 public void RemovePerson(PersonAI person)
 {
     people.Remove(person);
 }
Пример #17
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
        {
            transform.Translate(new Vector3(Input.GetAxis("Horizontal") * speed * Time.deltaTime, 0, Input.GetAxis("Vertical") * speed * Time.deltaTime), Space.Self);
            //transform.Translate(new Vector3(Input.GetAxis("Horizontal")*speed*Time.deltaTime,0,Input.GetAxis("Vertical")*speed*Time.deltaTime));
        }
        if (Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0)
        {
            Mycamera.transform.Rotate(Input.GetAxis("Mouse Y") * rotateSpeed * Time.deltaTime, 0, 0);
            transform.Rotate(0, Input.GetAxis("Mouse X") * rotateSpeed * Time.deltaTime, 0);
            //Mycamera.transform.rotation = Quaternion.Euler(Mycamera.transform.rotation.eulerAngles.x, Mycamera.transform.rotation.eulerAngles.y,0);
        }



        if (Input.GetKeyDown(KeyCode.E))
        {
            RaycastHit hit;
            Physics.Raycast(Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)), out hit);
            if (hit.collider)
            {
                if (hit.distance < interactdist)
                {
                    PersonAI p = hit.collider.GetComponent <PersonAI>();
                    if (p)
                    {
                        p.state = 1;
                    }

                    dialogText.text = playerdialogs[currentdialog];
                    currentdialog++;
                    if (currentdialog >= playerdialogs.Length)
                    {
                        currentdialog = 0;
                    }
                    dialogText.gameObject.SetActive(true);
                    dialogText.GetComponent <dialog>().curTime = 0;
                    AudioSource.PlayClipAtPoint(growls[Random.Range(0, growls.Length)], transform.position, 0.3f);
                    talkcount++;
                }
            }
        }

        if (talkcount > 2)
        {
            canKill = true;
        }
        if (canKill && (level2 || level3))
        {
            fkey.SetActive(true);
            if (Input.GetKeyDown(KeyCode.F))
            {
                RaycastHit hit;
                Physics.Raycast(Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)), out hit);
                if (hit.collider)
                {
                    if (hit.distance < interactdist)
                    {
                        PersonAI p = hit.collider.GetComponent <PersonAI>();
                        if (p)
                        {
                            p.state = 1;
                        }
                        p.GetComponent <AudioSource>().enabled = false;
                        swipe.SetActive(true);
                        GetComponent <AudioSource>().Play();

                        killcount++;
                    }
                }
            }
        }



        if (talkcount >= talkneeded)
        {
            fade.GetComponent <fadeout>().enabled = true;
            if (fade.GetComponent <UnityEngine.UI.RawImage>().color.a >= 1)
            {
                Application.LoadLevel(nextlevel);
            }
        }
        if (killcount >= killneeded)
        {
            fade.GetComponent <fadeout>().enabled = true;
            if (fade.GetComponent <UnityEngine.UI.RawImage>().color.a >= 1)
            {
                Application.LoadLevel(nextlevel);
            }
        }
    }
Пример #18
0
 public override void WorkerFreed(PersonAI aI)
 {
     base.WorkerFreed(aI);
     animPlayer.Stop();
 }