Inheritance: MonoBehaviour
コード例 #1
0
 public override void WorkerFreed(PersonAI aI)
 {
     if (nearestStone != null)
     {
         nearestStone.Worker = null;
     }
     base.WorkerFreed(aI);
 }
コード例 #2
0
        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
ファイル: StunState.cs プロジェクト: pplans/ld-44
    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;
     }
 }
コード例 #9
0
        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
ファイル: World.cs プロジェクト: jagendar/CovertsLudumDare43
 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
ファイル: World.cs プロジェクト: jagendar/CovertsLudumDare43
 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();
 }