/// <summary> /// Meant for a platoon still in ghost mode: Spawn() should be called /// to activate the units. /// </summary> public void AddSingleUnit() { GhostPlatoon.AddSingleUnit(); GameObject unit = Instantiate(Unit.Prefab); MatchSession.Current.Factory.MakeUnit( Unit, unit, this); BoxCollider collider = unit.GetComponentInChildren <BoxCollider>(); unit.SetActive(false); collider.enabled = true; Units.Add(unit.GetComponent <UnitDispatcher>()); }
/// <summary> /// Create a ghost platoon without a corresponding real platoon, to be used /// for buy previews. /// </summary> public static GhostPlatoonBehaviour CreatePreviewMode( Unit unit, PlayerData owner, int unitCount) { GhostPlatoonBehaviour ghost = Instantiate( Resources.Load <GameObject>( "GhostPlatoon")).GetComponent <GhostPlatoonBehaviour>(); ghost.Initialize(unit, owner); while (unitCount > 0) { ghost.AddSingleUnit(); unitCount--; } return(ghost); }