Пример #1
0
 public bTownCenter getTownCenter()
 {
     if (_TownCenter == null)
     {
         _TownCenter = GameObject.FindObjectOfType <bTownCenter>();
     }
     return(_TownCenter);
 }
Пример #2
0
    // Called from MVC controller
    public void DemolishSomething()
    {
        //Dismiss all workers
        dismissCurrentWorker();
        SoundManager.Instance.PlayDemolish();
        SoundManager.Instance.PlayDemolish();
        // Debug.Log("Time to Destroy Something" );
        switch (eType)
        {
        case (BuildingType.House):
            bHouse house = this.GetComponent <bHouse>();
            house.DemolishAction(_level);
            Destroy(house);
            eType      = BuildingType.Vacant;
            eState     = BuildingState.Available;
            _sr.sprite = _sStateConstruction;
            // Debug.Log("Destroyed a house");
            break;

        case (BuildingType.Farm):
            bFarm farm = this.GetComponent <bFarm>();
            farm.DemolishAction();
            Destroy(farm);
            eType      = BuildingType.Vacant;
            eState     = BuildingState.Building;
            _sr.sprite = _sStateConstruction;
            // Debug.Log("Destroyed a Farm");
            break;

        case (BuildingType.Banner):
            bBanner banner = this.GetComponent <bBanner>();
            Destroy(banner);
            eType      = BuildingType.Vacant;
            eState     = BuildingState.Building;
            _sr.sprite = _sStateConstruction;
            Destroy(this.GetComponent <Animator>());
            // Debug.Log("Destroyed a Banner");
            break;

        case (BuildingType.Outpost):
            bOutpost outpost = this.GetComponent <bOutpost>();
            outpost.DemolishAction();
            Destroy(outpost);
            eType      = BuildingType.Vacant;
            eState     = BuildingState.Building;
            _sr.sprite = _sStateConstruction;

            //Need to Reset Worker Object to Base
            // tell UI menu RemoveOutpostWorkers
            UIAssignmentMenu.Instance.RemoveOutpostWorkers(_Workers);
            // tell game manager PlayerOutpostDestroyed
            GameManager.Instance.PlayerOutpostDestroyed(this);
            ResetWorkers();
            // Debug.Log("Destroyed an Outpost");
            break;

        case (BuildingType.TownCenter):
            bTownCenter btc = this.GetComponent <bTownCenter>();
            Destroy(btc);
            eType      = BuildingType.Vacant;
            eState     = BuildingState.Building;
            _sr.sprite = _sStateConstruction;
            // Debug.Log("Destroyed a TownCenter");
            break;

        case (BuildingType.GarbageCan):
            bGarbageCan garbagecan = this.GetComponent <bGarbageCan>();
            Destroy(garbagecan);
            eType      = BuildingType.Vacant;
            eState     = BuildingState.Building;
            _sr.sprite = _sStateConstruction;
            break;

        case (BuildingType.WoodPile):
            bWoodPile wp = this.GetComponent <bWoodPile>();
            Destroy(wp);
            eType      = BuildingType.Vacant;
            eState     = BuildingState.Building;
            _sr.sprite = _sStateConstruction;
            break;

        case (BuildingType.StonePile):
            bStonePile sp = this.GetComponent <bStonePile>();
            Destroy(sp);
            eType      = BuildingType.Vacant;
            eState     = BuildingState.Building;
            _sr.sprite = _sStateConstruction;
            break;
        }

        //Drop Demolished Resources
        GameObject pickup = Resources.Load <GameObject>("ResourceIcons/Collectable_Resource");

        if (pickup)
        {
            if (_level >= 1)
            {
                GameObject   ppp = GameObject.Instantiate(pickup, this.transform.position, this.transform.rotation);
                CoinResource cr  = ppp.GetComponent <CoinResource>();
                cr.setResourceType(ResourceManagerScript.ResourceType.Trash);
                cr.setResourceAmount(2 * _level);
            }
            if (_level >= 2)
            {
                GameObject   ppp = GameObject.Instantiate(pickup, this.transform.position, this.transform.rotation);
                CoinResource cr  = ppp.GetComponent <CoinResource>();
                cr.setResourceType(ResourceManagerScript.ResourceType.Wood);
                cr.setResourceAmount(2 * _level);
            }
            if (_level >= 3)
            {
                GameObject   ppp = GameObject.Instantiate(pickup, this.transform.position, this.transform.rotation);
                CoinResource cr  = ppp.GetComponent <CoinResource>();
                cr.setResourceType(ResourceManagerScript.ResourceType.Stone);
                cr.setResourceAmount(2 * _level);
            }
        }
        UpdateState();
        _DestroyMenu.showMenu(false, Vector3.zero, null, this);
        _level = 0; // handle the other stuff in demolish complete i guess
        StartCoroutine(DemolishCoroutine());
    }
Пример #3
0
 public void setTownCenter(bTownCenter tc)
 {
     _TownCenter = tc;
     _TownCenter.StartingBuildComplete();
     // StartCoroutine(TownCenterDelay());
 }