Beispiel #1
0
        public void SpawnBall(EnemyAI ai)
        {
            stage = ThrowStage.Throwing;

            Vector3 ballPos = ai.transform.Find("ball").transform.position; // Timo

            var ob = UnityEngine.Object
                     .Instantiate(ai.throwingBall, ballPos, ai.transform.rotation)
                     .GetComponent <AIBall>();

            var vec = ai.GetTargetVector();

            ob.SetValues(ballPos, -vec, ai.GetTargetDistance(), -vec.y);

            ai.CurrentState = new IdleState();
        }
Beispiel #2
0
        public void Act(EnemyAI ai)
        {
            timer -= Time.deltaTime;

            if (timer <= 0)
            {
                float distance = ai.GetTargetDistance();
                if (distance < ai.throwDistance)
                {
                    int   rand = UnityEngine.Random.Range(0, 20);
                    State state;
                    ai.CurrentState = rand < 8 ? new ThrowState() as State : new MoveState();
                }
                else
                {
                    int rand = UnityEngine.Random.Range(0, 20);
                    Debug.Log(rand);
                    ai.CurrentState = rand < 5 ? new MoveState() as State : new ThrowState();
                }
            }
        }