Ejemplo n.º 1
0
    /// <summary>
    /// Called when the building is being constructed
    /// Changes the layer from wireframe to building
    /// </summary>
    /// <param name="time"></param>
    /// <returns></returns>
    private IEnumerator ConstructionTimer(float time)
    {
        yield return(new WaitForSeconds(3));

        thisBuilding.layer = LayerMask.NameToLayer("Buildings");

        foreach (Transform child in thisBuilding.transform)
        {
            if (child.name != "Range" && child.name != "BulletPool")
            {
                child.gameObject.layer = LayerMask.NameToLayer("Buildings");

                if (child.childCount > 0)
                {
                    foreach (Transform grandChild in child)
                    {
                        grandChild.gameObject.layer = LayerMask.NameToLayer("Buildings");
                    }
                }
            }
        }
        constructed = true;

        if (buildingType == BuildingType.turret)
        {
            rangeDetector = GetComponentInChildren <RangeDetector>();
            rangeDetector.Ready(range);
        }

        //light.enabled = true;
        EnemySpawner.enemySpawnerInstance.AddToBuildingList(thisBuilding);
        ResourceManager.resourceManagerInstance.AddBuilding(buildingType);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Initial setup of the enemy object
    /// </summary>
    /// <param name="target"></param>
    public virtual void SpawnUnit(GameObject target)
    {
        navAgent.enabled = true;
        rangeDetector    = transform.GetChild(2).GetComponent <RangeDetector>();
        rangeDetector.Ready(range);
        hasTarget = false;

        usedProjectiles      = new List <GameObject>();
        availableProjectiles = new List <GameObject>();

        foreach (Transform obj in projectilePool)
        {
            availableProjectiles.Add(obj.gameObject);
        }

        ChangeState(state);
    }
Ejemplo n.º 3
0
    public virtual void SpawnUnit()
    {
        navAgent         = GetComponent <NavMeshAgent>();
        navAgent.enabled = true;

        unitPool = GameObject.Find("PlayerUnitPool").transform;

        if (unitType != UnitType.engineer)
        {
            rangeDetector = transform.GetChild(2).GetComponent <RangeDetector>();
            rangeDetector.Ready(range);
            hasTarget = false;

            usedProjectiles      = new List <GameObject>();
            availableProjectiles = new List <GameObject>();

            foreach (Transform obj in projectilePool)
            {
                availableProjectiles.Add(obj.gameObject);
            }
        }
    }