public void Catch(PlayerCatcher player)
    {
        if (enemyState == EnemyState.Run)
        {
            return;
        }

        enemyState   = EnemyState.Run;
        currentSpeed = m_Settings.RunSpeed;

        FindDirection(player);
    }
    private void FindDirection(PlayerCatcher player)
    {
        var        moveDir  = transform.position - player.transform.position;
        Quaternion rotation = Quaternion.LookRotation(moveDir, Vector3.up);

        transform.rotation = rotation;

        if (prevCoroutine != null)
        {
            StopCoroutine(prevCoroutine);
        }

        prevCoroutine = StartCoroutine(FindRunDir());
    }
 public void Free(PlayerCatcher player)
 {
     enemyState = EnemyState.Free;
 }
Example #4
0
    void FixedUpdate()
    {
        if (!isOver && lastSpawn == null) {

            lastSpawnLocation = randomSpawnLocation();
            Vector3 location;
            switch (lastSpawnLocation) {
                case SPAWN_LOCATION.TOP:
                    location = new Vector3(0,0,zMax);
                    break;
                case SPAWN_LOCATION.RIGHT:
                    location = new Vector3(xMax,0,0);
                    break;
                case SPAWN_LOCATION.BOTTOM:
                    location = new Vector3(0,0,zMax);
                    break;
                case SPAWN_LOCATION.LEFT:
                default:
                    location = new Vector3(xMin,0,0);
                    break;
            }

            lastSpawn = Instantiate(
                fish[UnityEngine.Random.Range(0, fish.Length)],
                location,
                Quaternion.identity
            ) as PlayerCatcher;

            lastSpawn.player = player;

        }
    }