private void Start()
    {
        anim         = GetComponent <Animator>();
        targetHolder = GetComponent <TargetHolder>();

        transform.position = currentWayPoint.transform.position;

        clone = Instantiate(CloneFrebab, transform.position, transform.rotation, transform);

        visualTimer = timeToMove;
        ChangeWaypoint(true);
    }
예제 #2
0
    void Start()
    {
        agent   = GetComponent <NavMeshAgent>();
        targetH = GetComponent <TargetHolder>();
        eHealth = GetComponent <EnemyHealth>();

        path = new NavMeshPath();

        agent.stoppingDistance = stopDist;
        agent.acceleration     = float.MaxValue;
        agent.speed            = chaseSpeed;
        agent.SetDestination(targetH.Target.position);
        StartCoroutine(GetDestinationWithDelay(0.1f));
    }
예제 #3
0
    /// <summary>
    /// Spawn the first object in its queue and if there are more left, keep
    /// itself open too keep spawning
    /// </summary>
    /// <param name="callerWave">The wave commanding the spawns</param>
    /// <param name="minDistanceToNext">The minimum distance a newly spawned
    /// enemy must have to this spawner until it can spawn the next monster in
    /// the queue.</param>
    /// <returns></returns>
    public GameObject StartSpawning(CombatWave callerWave, float minDistanceToNext)
    {
        if (spawnQueue.Count == 0)
        {
            return(null);
        }

        _callerWave        = callerWave;
        _minDistanceToNext = minDistanceToNext;

        _lastSpawned = Instantiate(spawnQueue.Peek(), transform.position, transform.rotation);
        spawnQueue.Dequeue();

        TargetHolder target = _lastSpawned.GetComponent <TargetHolder>();

        if (target != null)
        {
            target.Target = _callerWave.enemyTarget;
        }
        else
        {
            Debug.LogWarning($"Enemy from {_lastSpawned.name} doesn't have a TargetHolder Component");
        }

        if (_lastSpawned.GetComponent <WaypointMovement>())
        {
            GetComponent <Waypoint>().ToggleOccupation();
            _lastSpawned.GetComponent <WaypointMovement>().SetCurrentWaypoint(GetComponent <Waypoint>());
        }

        if (spawnQueue.Count > 0)
        {
            _openForSpawning = true;
        }

        return(_lastSpawned);
    }
예제 #4
0
 private void Start()
 {
     anim    = GetComponentInChildren <Animator>();
     targetH = GetComponent <TargetHolder>();
     jagMov  = GetComponent <JaguarMovement>();
 }
예제 #5
0
 protected virtual void Start()
 {
     anim    = GetComponent <Animator>();
     targetH = GetComponent <TargetHolder>();
     StartCoroutine(LockAttackForSeconds(2));
 }
예제 #6
0
    private void Update()
    {
        if (_openForSpawning)
        {
            bool _canSpawn = false;

            if (!_usesWayPointMovement)
            {
                if (_lastSpawned == null)
                {
                    _canSpawn = true;
                }
                else
                {
                    // If the newest spawn is far away enough, spawn the next in the queue.
                    float distance = (_lastSpawned.transform.position - transform.position).sqrMagnitude;

                    if (distance >= _minDistanceToNext)
                    {
                        _canSpawn = true;
                    }
                }
            }

            else
            {
                Waypoint thisWP = GetComponent <Waypoint>();

                float distance = (_lastSpawned.transform.position - transform.position).sqrMagnitude;

                if (distance >= _minDistanceToNext)
                {
                    for (int i = 0; i < thisWP.outgoingConnections.Count; i++)
                    {
                        if (!thisWP.outgoingConnections[i].isOccupied)
                        {
                            _canSpawn = true;
                            break;
                        }
                    }
                }
            }

            if (_canSpawn)
            {
                _lastSpawned = Instantiate(spawnQueue.Peek(), transform.position, transform.rotation);
                TargetHolder target =
                    _lastSpawned.GetComponent <TargetHolder>();
                if (target != null)
                {
                    target.Target = _callerWave.enemyTarget;
                }
                else
                {
                    Debug.LogError($"Enemy from {_lastSpawned.name} doesn't have a TargetHolder Component");
                }


                if (_usesWayPointMovement)
                {
                    GetComponent <Waypoint>().ToggleOccupation();
                    _lastSpawned.GetComponent <WaypointMovement>().SetCurrentWaypoint(GetComponent <Waypoint>());
                }

                _lastSpawned.layer = 9;
                spawnQueue.Dequeue();
                _callerWave.AddLateSpawnedEnemy(enemy, _lastSpawned);
            }

            if (spawnQueue.Count == 0)
            {
                _openForSpawning = false;
            }
        }
    }
 void Awake()
 {
     _target = GetComponent <TargetHolder>();
     _object = GetComponent <AreaObjectCalculator>();
 }