public void RemoveActorFromScene(ControllableActor actor) { if (actor != null && controllableSceneActors.Contains(actor)) { controllableSceneActors.Remove(actor); } }
public bool TryEquipNewActor(ControllableActor actor) { if (!HasActor()) { ChangeControlledActor(actor); } return(HasActor()); }
// Initialize the team member with a team, then link them to inputs, then try to get an actor public TeamMember(Player player, Teams team) { this.player = player; controlledActor = null; myTeam = team; RegisterPlayerInput(); ChangeControlledActor(SearchForNewActor()); }
public void AddActorToScene(ControllableActor actor) { if (actor != null && !controllableSceneActors.Contains(actor)) { controllableSceneActors.Add(actor); } if (OnActorRegister != null) { OnActorRegister(actor); } }
void Awake() { aggroTrigger = GetComponent <SphereCollider>(); controllableActor = GetComponent <ControllableActor>(); animState = GetComponent <AnimationState>(); damageState = GetComponent <ContinuousDamageController>(); myRegister = GetComponent <ActorTeamRegister>(); myTrans = transform; status = GetComponent <Status>(); status.OnDamage += SwitchTargetOnDamage; status.OnHPZero += HPZeroCallback; }
void ChangeControlledActor(ControllableActor newActor) { changing = true; if (newActor != null && newActor.IsUncontrolled()) { newActor.SetToControlled(player.controllers.Joysticks); ReleaseControlledActor(); controlledActor = newActor; currentActorActions = controlledActor.GetAllAvailableActions(); LinkInputToControlledActor(currentActorActions); controlledActor.OnRemoveFromScene += ReleaseControlledActor; } changing = false; }
void ReleaseControlledActor() { if (controlledActor != null) { Debug.Log("Releasing control over the actor"); controlledActor.OnRemoveFromScene -= ReleaseControlledActor; controlledActor.SetToUncontrolled(); DelinkInputToControlledActor(currentActorActions); controlledActor = null; } if (!changing) { // This will still be called when you switch teams ChangeControlledActor(SearchForNewActor()); } }
void ActorRegistered(ControllableActor actor) { newRegisteredActors.Add(actor); }
public LinkedList <ControllableActor> GetAlliedUncontrolledActors(Teams alliedTeam, ControllableActor current) { List <ControllableActor> eligibleActors = new List <ControllableActor>(); foreach (var actor in controllableSceneActors) { var validActor = actor != null && actor.GetTeam() == alliedTeam; var currentlyControllable = actor.IsUncontrolled() || actor == current; if (validActor && currentlyControllable) { eligibleActors.Add(actor); } } eligibleActors.OrderBy(a => a.isHighPriorityActor); return(new LinkedList <ControllableActor>(eligibleActors)); }