Ejemplo n.º 1
0
    private IEnumerator Start()
    {
        while (true)
        {
            if (state == CatState.Nyoom)
            {
                waitTime.SetValueToRandomFloat();
                Vector3 pos = CatHiveBrain.GetPositionOutside() + Vector3.up;
                agent.destination = pos;
                yield return(StartCoroutine(InteruptableWait(() => agent.remainingDistance <= agent.stoppingDistance, CatState.WalkToMech)));

                yield return(StartCoroutine(InteruptableWait(waitTime, CatState.WalkToMech)));
            }
            else if (state == CatState.WalkToMech)
            {
                agent.destination = mechTrans.localPosition + Vector3.up;
                while (agent.remainingDistance > agent.stoppingDistance)
                {
                    yield return(null);
                }
                yield return(StartCoroutine(InteruptableWait(waitForMechTime, CatState.PickedUp)));

                if (state != CatState.PickedUp)
                {
                    state = CatState.Nyoom;
                }
            }
            else if (state == CatState.PickedUp)
            {
                timeHeld += Time.deltaTime;
                if (UnityEngine.Random.value <= attackProbability.Evaluate(timeHeld))
                {
                    state = CatState.Attwwackking;
                }
                yield return(null);
            }
            else if (state == CatState.Attwwackking)
            {
                Attack();
                attackFrequency.SetValueToRandomFloat();
                yield return(StartCoroutine(InteruptableWait(attackFrequency, CatState.Soothed | CatState.Nyoom)));
            }
            else if (state == CatState.Soothed)
            {
                sootheDuration.SetValueToRandomFloat();
                yield return(StartCoroutine(InteruptableWait(sootheDuration, CatState.Nyoom)));

                if (state == CatState.Soothed)
                {
                    state = CatState.PickedUp;
                }
            }

            yield return(null);
        }
    }
Ejemplo n.º 2
0
 private void Awake()
 {
     control = this;
 }