/// <summary>
    /// Gets the free defend position if it is.
    /// </summary>
    /// <returns>The free defend position.</returns>
    /// <param name="index">Index.</param>
    private Transform GetFreeDefendPosition()
    {
        Transform        res    = null;
        List <Transform> points = defPoint.GetDefendPoints();

        foreach (Transform point in points)
        {
            // If this point not busy already
            if (defendersList.ContainsValue(point) == false)
            {
                res = point;
                break;
            }
        }
        return(res);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
        Debug.Assert(spawnPoint, "Wrong initial settings");
        IPlacementArea placementArea = GetComponentInParent <IPlacementArea>();

        defPoint        = placementArea.transform.gameObject.GetComponentInChildren <DefendPoint>();
        cooldownCounter = cooldown;
        // Upgrade all existing defenders on tower build
        foreach (Transform point in defPoint.GetDefendPoints())
        {
            // If defend point already has defender
            Targetable defender = point.GetComponentInChildren <Targetable>();
            if (defender != null)
            {
                // Spawn new defender in the same place
                Spawn(defender.transform, point);
                // Destroy old defender
                Destroy(defender.gameObject);
            }
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
        Debug.Assert(spawnPoint, "Wrong initial settings");
        BuildingPlace buildingPlace = GetComponentInParent <BuildingPlace>();

        defPoint        = buildingPlace.GetComponentInChildren <DefendPoint>();
        cooldownCounter = cooldown;
        // Upgrade all existing defenders on tower build
        foreach (Transform point in defPoint.GetDefendPoints())
        {
            // If defend point already has defender
            AiBehavior defender = point.GetComponentInChildren <AiBehavior>();
            if (defender != null)
            {
                // Spawn new defender in the same place
                Spawn(defender.transform, point);
                // Destroy old defender
                Destroy(defender.gameObject);
            }
        }
    }