Exemple #1
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //  Called when the object's state switches to active
    /// </summary>
    protected override void OnBuilt()
    {
        base.OnBuilt();

        if (_Player != null)
        {
            // Add tech level if required
            if (_Player.Level < TechLevelWhenBuilt)
            {
                _Player.Level = TechLevelWhenBuilt;
            }

            // Add to player's base list
            _Player.AddBase(_ClonedWorldObject as Base);
        }

        // Show any hidden base slots that are linked to the building slot
        if (AttachedBuildingSlot != null)
        {
            AttachedBuildingSlot.SetLinkedSlotsBase(this);
        }

        // Pass the building queue to the new building
        Base newBase = _ClonedWorldObject.GetComponent <Base>();

        if (newBase._PreviousBase != null)
        {
            for (int i = 0; i < newBase._PreviousBase.GetBuildingQueue().Count; i++)
            {
                // BUT DONT ADD OURSELF TO THE QUEUE
                if (newBase._PreviousBase.GetBuildingQueue()[i] != _ClonedWorldObject)
                {
                    // Add to queue
                    newBase.AddToQueue(newBase._PreviousBase.GetBuildingQueue()[i]);
                }
            }

            // Clear/destroy the previous building's queue
            newBase._PreviousBase.GetBuildingQueue().Clear();
            if (UI_BuildingQueueWrapper.Instance.ContainsQueue(newBase._PreviousBase._BuildingQueueUI))
            {
                UI_BuildingQueueWrapper.Instance.RemoveFromQueue(newBase._PreviousBase._BuildingQueueUI);
                Destroy(newBase._PreviousBase._BuildingQueueUI);
            }
        }

        // Create a rally point
        if (GameManager.Instance.RallyPointObject != null && RallyPointDefaultTransform != null)
        {
            // Set rally point
            _Rallypoint = ObjectPooling.Spawn(GameManager.Instance.RallyPointObject, RallyPointDefaultTransform.transform.position);
        }
    }
Exemple #2
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //  Called when the object's state switches to active
    /// </summary>
    protected override void OnBuilt()
    {
        base.OnBuilt();

        if (_Player != null)
        {
            // Add tech level if required
            if (_Player.Level < TechLevelWhenBuilt)
            {
                _Player.Level = TechLevelWhenBuilt;
            }

            // Add to player's base list
            _Player.AddBase(_ClonedWorldObject as Base);
        }

        // Show any hidden base slots that are linked to the building slot
        if (AttachedBuildingSlot != null)
        {
            AttachedBuildingSlot.SetLinkedSlotsBase(this);
        }

        // Pass the building queue to the new building
        Base newBase = _ClonedWorldObject.GetComponent <Base>();

        if (newBase._PreviousBase != null)
        {
            for (int i = 0; i < newBase._PreviousBase.GetBuildingQueue().Count; i++)
            {
                // BUT DONT ADD OURSELF TO THE QUEUE
                if (newBase._PreviousBase.GetBuildingQueue()[i] != _ClonedWorldObject)
                {
                    // Add to queue
                    newBase.AddToQueue(newBase._PreviousBase.GetBuildingQueue()[i]);
                }
            }

            // Clear/destroy the previous building's queue
            newBase._PreviousBase.GetBuildingQueue().Clear();
            ///newBase._PreviousBase._HealthBar.gameObject.SetActive(false);
            newBase._PreviousBase._ShowHealthbar = false;
            newBase._PreviousBase.gameObject.SetActive(false);

            if (UI_BuildingQueueWrapper.Instance.ContainsQueue(newBase._PreviousBase._BuildingQueueUI))
            {
                UI_BuildingQueueWrapper.Instance.RemoveFromQueue(newBase._PreviousBase._BuildingQueueUI);
                Destroy(newBase._PreviousBase._BuildingQueueUI);
            }

            //  Passes the new bases's building slot to the old bases's building slots's building (confusing right?)
            for (int i = 0; i < newBase._PreviousBase.TowerSlots.Count; ++i)
            {
                // Tower slots
                ///BuildingSlot oldBaseSlot = newBase._PreviousBase.TowerSlots[i];
                ///BuildingSlot newBaseSlot = newBase.TowerSlots[i];
                ///if (oldBaseSlot.GetBuildingOnSlot() != null)
                ///{
                ///    oldBaseSlot.GetBuildingOnSlot().AttachedBuildingSlot = newBaseSlot;
                ///}

                ///if(newBase._PreviousBase.TowerSlots[i].GetBuildingOnSlot() != null)
                ///{
                ///    newBase.TowerSlots[i].GetBuildingOnSlot().AttachedBuildingSlot = newBase._PreviousBase.TowerSlots[i];
                ///}
            }

            // Passes the new bases's building slot to the old bases's building slots's building (confusing right?)
            for (int i = 0; i < newBase._PreviousBase.DepotSlots.Count; ++i)
            {
                // Depot slots
                ///BuildingSlot oldBaseSlot = newBase._PreviousBase.DepotSlots[i];
                ///BuildingSlot newBaseSlot = newBase.DepotSlots[i];
                ///if (oldBaseSlot.GetBuildingOnSlot() != null)
                ///{
                ///    oldBaseSlot.GetBuildingOnSlot().AttachedBuildingSlot = newBaseSlot;
                ///}

                ///if (newBase._PreviousBase.DepotSlots[i].GetBuildingOnSlot() != null)
                ///{
                ///    newBase.TowerSlots[i].GetBuildingOnSlot().AttachedBuildingSlot = newBase._PreviousBase.DepotSlots[i];
                ///}
            }
        }

        // Create a rally point
        if (GameManager.Instance.RallyPointObject != null && RallyPointDefaultTransform != null)
        {
            // Set rally point
            _Rallypoint = ObjectPooling.Spawn(GameManager.Instance.RallyPointObject, RallyPointDefaultTransform.transform.position);
        }
    }