public override bool OrderComplete() { if (transportableWaypoint != null && transportableWaypoint.interrupted) { platoon.Units.ForEach(x => x.GetComponent <TransporterBehaviour>().target = null); return(true); } if (loading) { if (transportableWaypoint.OrderComplete()) { module.SetTransported(transportableWaypoint.platoon); platoon.Units.ForEach(x => x.GetComponent <TransporterBehaviour>().target = null); transportableWaypoint.platoon.SetEnabled(false); return(true); } else { return(false); } //platoon.units.All(x => x.GetComponent<TransporterBehaviour>().loadingComplete());//premature true } else { if (platoon.Units.All(x => x.GetComponent <TransporterBehaviour>().unloadingComplete())) { module.SetTransported(null); return(true); } else { return(false); } } }
public void Initialize(UnitType t, PlayerData owner, int n) { Type = t; Owner = owner; var iconInstance = Instantiate(Resources.Load <GameObject>("Icon"), transform); Icon = iconInstance.GetComponent <IconBehaviour>(); Icon.BaseColor = Owner.Team.Color; var unitPrefab = Owner.Session.Factory.FindPrefab(t); for (int i = 0; i < n; i++) { var unitInstance = Owner.Session.Factory.MakeUnit(unitPrefab, Owner.Team.Color); var unitBehaviour = unitInstance.GetComponent <UnitBehaviour>(); unitBehaviour.SetPlatoon(this); Units.Add(unitBehaviour); var collider = unitInstance.GetComponentInChildren <BoxCollider>(); collider.enabled = true; } BuildModules(t); if (t == UnitType.AFV) { var ghost = GhostPlatoonBehaviour.Build(UnitType.Infantry, owner, n); Transporter.SetTransported(ghost.GetRealPlatoon()); ghost.SetOrientation(100 * Vector3.down, 0); ghost.SetVisible(false); } Movement.SetDestination(Vector3.forward); Icon.SetSource(Units); IsInitialized = true; }