Пример #1
0
    protected override IEnumerator AttackAnimation(TownCenter targetSquadUnit)
    {
        myNavMeshAgent.enabled = false;

        GameObject clone = ObjectPools.CurrentObjectPool.RockProjectilePool.GetPooledObject();

        if (clone != null)
        {
            Vector3 start = transform.position + Vector3.up;
            Vector3 end   = targetSquadUnit.transform.position;
            clone.SetActive(true);

            RockProjectile projectile = clone.GetComponent <RockProjectile>();
            projectile.SetDestination(start, targetSquadUnit.transform,
                                      attackDamage, damageType);

            start.y = 0f;
            end.y   = 0f;

            Vector3 direction = end - start;
            direction.Normalize();
            transform.forward = direction;
        }

        AnimateAttack();
        yield return(new WaitForSeconds(attackTime));

        myNavMeshAgent.enabled = true;
    }
Пример #2
0
 private void StartGame()
 {
     myTownCenter = FindObjectOfType <TownCenter>();
     if (currentEnemyWaveIndex < EnemyWaves.Length)
     {
         InstantiateEnemyWave(currentEnemyWaveIndex);
     }
 }
Пример #3
0
    virtual protected void Awake()
    {
        gM = GameManager.Instance;

        myTownCenter = gM.myTownCenter;

        mMovement   = GetComponent <MinerMovement>();
        mActions    = GetComponent <MinerAction>();
        mAnimations = GetComponentInChildren <MinerAnimations>();

        timeLeft = timeToTryFinding;
    }
    public override Vector3 CalculateMove(SquadUnit squadUnit, List <Transform> context, Squad squad)
    {
        List <Transform> filteredContext = (filter == null) ? context : filter.Filter(squadUnit, context);

        //if no neighbors, return no adjustment
        if (filteredContext.Count == 0)
        {
            return(Vector3.zero);
        }

        //find closest unit to attack
        float closestSqrMagnitude = 100f;

        if (squad.SquareAttackRadius > closestSqrMagnitude)
        {
            closestSqrMagnitude = squad.SquareAttackRadius;
        }
        Transform closestTransform = null;

        for (int i = 0; i < filteredContext.Count; ++i)
        {
            float sqrMagnitude = Vector3.SqrMagnitude(filteredContext[i].position - squadUnit.transform.position);
            if (sqrMagnitude < closestSqrMagnitude)
            {
                closestSqrMagnitude = sqrMagnitude;
                closestTransform    = filteredContext[i];
            }
        }

        if (closestTransform == null)
        {
            return(Vector3.zero);
        }

        TownCenter targetTownCenter = closestTransform.GetComponent <TownCenter>();

        if (targetTownCenter != null)
        {
            squadUnit.Attack(targetTownCenter);
        }

        return(Vector3.zero);
    }
Пример #5
0
        private void SeedPlayer(Player player, int offset)
        {
            Coordinate townCenterCoordinate = new Coordinate(offset, offset);
            TownCenter townCenter           = new TownCenter();

            player.AddEntity(townCenter);
            mapController.AddToMap(townCenterCoordinate, townCenter);

            Coordinate mineCoordinate = new Coordinate(offset + 2, offset + 2);
            Mine       mine           = new Mine();

            player.AddEntity(mine);
            mapController.AddToMap(mineCoordinate, mine);

            Coordinate workerCoordinate = new Coordinate(offset + 1, offset + 1);
            Worker     worker           = new Worker();

            player.AddEntity(worker);
            mapController.AddToMap(workerCoordinate, worker);
        }
Пример #6
0
    protected virtual IEnumerator AttackAnimation(TownCenter targetTownCenter)
    {
        myNavMeshAgent.enabled = false;

        Vector3 start = transform.position + Vector3.up;
        Vector3 end   = targetTownCenter.transform.position;

        start.y = 0f;
        end.y   = 0f;

        Vector3 direction = end - start;

        direction.Normalize();
        transform.forward = direction;

        AnimateAttack();
        targetTownCenter.ReceiveDamage(attackDamage, damageType);
        yield return(new WaitForSeconds(attackTime));

        myNavMeshAgent.enabled = true;
    }
    void InitializeArmyIcons()
    {
        if (myTownCenter == null)
        {
            myTownCenter = FindObjectOfType <TownCenter>();
        }

        icons            = new List <GameObject>();
        currentArmyIndex = 0;
        if (icons.Count == 0)
        {
            float startPosition = (myTownCenter.MaximumSquadNumber - 1) * spacing / -2f;
            for (int i = 0; i < myTownCenter.MaximumSquadNumber; ++i)
            {
                GameObject clone = Instantiate(EmptyIcon);
                clone.transform.SetParent(Armies.transform, false);

                clone.transform.localPosition = new Vector3(
                    startPosition + i * spacing, 0f, 0f);

                icons.Add(clone);
            }
        }
    }
Пример #8
0
 public void Attack(TownCenter targetTownCenter)
 {
     StartCoroutine(AttackAnimation(targetTownCenter));
 }
 void OnIslandLoaded()
 {
     myTownCenter = FindObjectOfType <TownCenter>();
     InitializeArmyIcons();
 }
 void Awake()
 {
     myTownCenter     = GetComponentInParent <TownCenter>();
     myParticleSystem = GetComponent <ParticleSystem>();
 }
Пример #11
0
 void Awake()
 {
     myTownCenter        = GetComponentInParent <TownCenter>();
     healthBarLocalScale = Vector3.one;
 }
Пример #12
0
 void Start()
 {
     HarvestedResources = new Units.Resources();
     if (playerView == null)
     {
         playerView = GetComponent<Camera>();
     }
     minimap = new Minimap();
     TownCenter center = new TownCenter();
     center.CreateFreeUnit(this, startPos, Quaternion.identity);
     m_selectionManager = new SelectionManager(this);
 }