Beispiel #1
0
        }                                            //this component manages resource collectors

        public override void Init(GameManager gameMgr)
        {
            base.Init(gameMgr);

            //get the resource components
            TreasureComp = GetComponent <Treasure>();
            WorkerMgr    = GetComponent <WorkerManager>();

            //initialize the components
            WorkerMgr.Init();

            FactionID = -1;                                                    //set faction ID to -1 by default.

            plane.gameObject.SetActive(false);                                 //hide the resource's plane initially

            ID    = gameMgr.ResourceMgr.GetResourceID(resourceType.GetName()); //get the resource ID from the resource manager
            color = resourceType.GetMinimapIconColor();                        //assign the resource's color

            if (secondaryModel != null)                                        //if there's a secondary model, enable it and disable the initial one
            {
                secondaryModel.SetActive(false);

                if (secondarySelection != null)                     //if there's secondary selection
                {
                    secondarySelection.gameObject.SetActive(false); //and hide it
                    secondarySelection.Init(this.gameMgr, this);    //assign the same source for the secondary selection component
                }
            }

            collectOneUnitDuration /= gameMgr.GetSpeedModifier(); //set collection time regarding speed modifier

            ToggleModel(true);                                    //show the initial model
            gameMgr.MinimapIconMgr?.Assign(selection);            //assign the minimap icon

            gameMgr.ResourceMgr.AddResource(this);                //register the resource in the resource manager

            CustomEvents.OnResourceAdded(this);                   //trigger the resource added custom event
        }