private void Awake()
 {
     _buildingPlace    = GetComponentInChildren <BuildingPlace>();
     _buildingPosition = _buildingPlace.ReturnBuildingPosition();
     //_playerStats = FindObjectOfType<PlayerInfo>().GetPlayerStats();
     defaultStage = 0;
 }
Beispiel #2
0
 /// <summary>
 /// Sets visible defend flag.
 /// </summary>
 /// <param name="enabled">If set to <c>true</c> enabled.</param>
 public void SetVisible(bool enabled)
 {
     if (enabled == true)
     {
         if (myState == MyState.Inactive)
         {
             buildingPlace = GetComponentInParent <BuildingPlace>();
             tower         = buildingPlace.GetComponentInChildren <Tower>();
             // Show defend flag
             activeDefendFlag = Instantiate(defendFlagPrefab);
             activeDefendFlag.transform.position = transform.position;
             myState = MyState.Active;
         }
     }
     else
     {
         if (myState == MyState.Active)
         {
             myState = MyState.Inactive;
             // Hide defense range
             tower.ShowRange(false);
             // Hide flag
             Destroy(activeDefendFlag);
         }
     }
 }
Beispiel #3
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
        anim = GetComponent <Animator>();
        Debug.Assert(spawnPoint, "Wrong initial settings");
        BuildingPlace buildingPlace = GetComponentInParent <BuildingPlace>();

        defPoint        = buildingPlace.GetComponentInChildren <DefendPoint>();
        cooldownCounter = cooldown;
        // Upgrade all existing defenders on tower build
        Dictionary <GameObject, Transform> oldDefenders = new Dictionary <GameObject, Transform>();

        foreach (KeyValuePair <GameObject, Transform> pair in defPoint.activeDefenders)
        {
            oldDefenders.Add(pair.Key, pair.Value);
        }
        defPoint.activeDefenders.Clear();
        foreach (KeyValuePair <GameObject, Transform> pair in oldDefenders)
        {
            // Spawn new defender in the same place
            Spawn(pair.Key.transform, pair.Value);
        }
        // Destroy old defenders
        foreach (KeyValuePair <GameObject, Transform> pair in oldDefenders)
        {
            Destroy(pair.Key);
        }
    }
Beispiel #4
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
        BuildingPlace buildingPlace = GetComponentInParent <BuildingPlace>();

        defendPoint = buildingPlace.GetComponentInChildren <DefendPoint>();
        tower       = GetComponentInParent <Tower>();
        Debug.Assert(defendPoint && tower, "Wrong initial settings");
    }
    private void Start()
    {
        BuildingPlace buildingPlaceScript = FindObjectOfType <BuildingPlace>();

        if (buildingPlaceScript != null)
        {
            onCallPreviewBuilding += buildingPlaceScript.AttachPreviewToCursor;
        }

        Factory factoryScript = FindObjectOfType <Factory>();

        if (factoryScript != null)
        {
            onCallCreateUnit += factoryScript.CreateUnit;
        }
    }
Beispiel #6
0
    /// <summary>
    /// Awake this instance.
    /// </summary>
    void Awake()
    {
        Debug.Assert(defendPointPrefab && defendFlagPrefab, "Wrong initial settings");
        // Get defend places from defend point prefab and place it on scene
        foreach (Transform defendPlace in defendPointPrefab.transform)
        {
            Instantiate(defendPlace.gameObject, transform);
        }
        // Create defend places list
        foreach (Transform child in transform)
        {
            defendPlaces.Add(child);
        }
        BuildingPlace buildingPlace = GetComponentInParent <BuildingPlace>();

        LookAtDirection2D((Vector2)(buildingPlace.transform.position - transform.position));
    }
Beispiel #7
0
    // Start is called before the first frame update
    void Start()
    {
        BuildingPlace buildingPlace = GetComponentInParent <BuildingPlace>();

        defendPoint     = buildingPlace.GetComponentInChildren <DefendPoint>();
        coolDownCounter = coolDown;
        //升级当前已生成的士兵
        foreach (Transform point in defendPoint.GetDefendPoint())
        {
            //如果防守点已经有士兵
            AIBehavior soldier = point.GetComponentInChildren <AIBehavior>();
            if (soldier != null)
            {
                //在相同的坐标上生成新的
                Spawn(soldier.transform, point);
                //摧毁之前的士兵
                Destroy(soldier.gameObject);
            }
        }
    }
Beispiel #8
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);
            }
        }
    }