예제 #1
0
        //a method called when the resource object is to be locally destroyed
        public void DestroyResourceLocal(Unit source)
        {
            amount = 0;                         //empty the resource
            CustomEvents.OnResourceEmpty(this); //trigger custom event

            //go through all curr collectors and stop their work
            Unit[] workersTemp = (Unit[])WorkerMgr.GetAll().Clone();  //clone the worker manager's array because stopping the resource collector work will modify the array directly
            foreach (Unit u in workersTemp)
            {
                u.CollectorComp.Stop();
            }

            if (destroyOnEmpty == false) //if the resource is not supposed to be destroyed
            {
                return;
            }

            if (TreasureComp)                                    //if this has a treasure component
            {
                TreasureComp.Trigger(source.FactionID, gameMgr); //trigger the treasure for the collector's faction
            }
            gameMgr.ResourceMgr.RemoveResource(this);            //remove resource from all resources list

            selection.DisableMinimapIcon();                      //remove resource's minimap icon from the minimap

            Destroy(gameObject);
        }
        //a method called when the resource object is to be locally destroyed
        public void DestroyResourceLocal(Unit source)
        {
            amount = 0;                         //empty the resource
            CustomEvents.OnResourceEmpty(this); //trigger custom event

            if (destroyOnEmpty == false)        //if the resource is not supposed to be destroyed
            {
                return;
            }

            if (TreasureComp)                                    //if this has a treasure component
            {
                TreasureComp.Trigger(source.FactionID, gameMgr); //trigger the treasure for the collector's faction
            }
            gameMgr.ResourceMgr.RemoveResource(this);            //remove resource from all resources list

            selection.DisableMinimapIcon();                      //remove resource's minimap icon from the minimap

            Destroy(gameObject);

            CustomEvents.OnResourceDestroyed(this);
        }