Exemple #1
0
        //method called to add a unit to the APC:
        public bool Add(Unit unit)
        {
            if (IsFull()) //if the APC gets full, then do not add unit
            {
                return(false);
            }

            unit.gameObject.SetActive(false);           //hide unit object
            storedUnits.Add(unit);                      //add it to the stored units list
            unit.transform.SetParent(transform, true);  //make it a child object of the APC object (so that it moves with the APC)
            unit.CancelJob(Unit.jobType.all);           //cancel all the units jobs

            gameMgr.SelectionMgr.Selected.Remove(unit); //deselect unit in case it was selected

            currCapacity += unit.GetAPCSlots();         //increase the APC's current capacity

            AudioManager.Play(FactionEntity.AudioSourceComp, addUnitAudio, false);

            CustomEvents.OnAPCAddUnit(this, unit); //trigger custom event

            return(true);
        }