public MoveActor(Battle battle, PartyMember actor, Think thinkState) : base(battle) { if (actor == null) { throw new Exception("PartyMember actor cannot be null"); } if (thinkState == null) { throw new Exception("Think thinkState cannot be null"); } this.Actor = actor; this.thinkState = thinkState; inputButtonListener = new InputButtonListener(new Dictionary <InputButton, ButtonEventHandlers> { { InputButton.Up, new ButtonEventHandlers(down: moveActorUp) }, { InputButton.Down, new ButtonEventHandlers(down: moveActorDown) }, { InputButton.Left, new ButtonEventHandlers(down: moveActorBack) }, { InputButton.Right, new ButtonEventHandlers(down: moveActorForward) }, { InputButton.A, new ButtonEventHandlers(up: Finish) }, { InputButton.B, new ButtonEventHandlers(up: cancel) } }); BattleStateRenderer = new MoveActorRenderer(this, thinkState.BattleStateRenderer); }
public override void Start() { if (isEnemy) { thinkAction.Target = Think.ChooseTargetForEnemyPartyMember(Battle); } else { partyBattleLayout = null; if (thinkAction.Type == ThinkActionType.Attack) { WeaponData weaponData = ResourceManager.GetWeaponData(thinkAction.OptionName); if (weaponData != null && weaponData.WeaponUseAgainst == WeaponUseAgainst.Enemy) { partyBattleLayout = Battle.EnemyPartyLayout; PotentialTarget = Battle.EnemyParty[0]; } } if (partyBattleLayout == null) { partyBattleLayout = Battle.PlayerPartyLayout; PotentialTarget = Battle.PlayerParty[0]; } BattleStateRenderer = new SelectTargetRenderer(this); } }
public void MovePartyMemberForward(PartyMember partyMember, BattleStates.Think thinkState) // first item/forward is towards middle of screen { if (!partyMember.HasStatusEffectOfType(StatusEffectType.Paralysis)) { movePartyMemberWithinList(partyMember, true, -1, thinkState); } }
public void MovePartyMemberBack(PartyMember partyMember, BattleStates.Think thinkState) // last item/back is towards edge of screen { if (!partyMember.HasStatusEffectOfType(StatusEffectType.Paralysis)) { movePartyMemberWithinList(partyMember, false, 1, thinkState); } }
public void MovePartyMemberDown(PartyMember partyMember, BattleStates.Think thinkState) { if (!partyMember.HasStatusEffectOfType(StatusEffectType.Paralysis)) { movePartyMemberAcrossLists(partyMember, false, 1, thinkState); } }
public MoveActor(Battle battle, PartyMember actor, Think thinkState) : base(battle) { if (actor == null) throw new Exception("PartyMember actor cannot be null"); if (thinkState == null) throw new Exception("Think thinkState cannot be null"); this.Actor = actor; this.thinkState = thinkState; inputButtonListener = new InputButtonListener(new Dictionary<InputButton, ButtonEventHandlers> { { InputButton.Up, new ButtonEventHandlers(down: moveActorUp) }, { InputButton.Down, new ButtonEventHandlers(down: moveActorDown) }, { InputButton.Left, new ButtonEventHandlers(down: moveActorBack) }, { InputButton.Right, new ButtonEventHandlers(down: moveActorForward) }, { InputButton.A, new ButtonEventHandlers(up: Finish) }, { InputButton.B, new ButtonEventHandlers(up: cancel) } }); BattleStateRenderer = new MoveActorRenderer(this, thinkState.BattleStateRenderer); }
private bool partyMemberIsThinking(PartyMember partyMember) { BattleStates.Think thinkState = CurrentBattleState as BattleStates.Think; if (thinkState != null) { return(thinkState.CurrentPartyMember == partyMember); } BattleStates.SelectTarget selectTargetState = CurrentBattleState as BattleStates.SelectTarget; if (selectTargetState != null) { return(selectTargetState.Actor == partyMember); } BattleStates.MoveActor moveActorState = CurrentBattleState as BattleStates.MoveActor; if (moveActorState != null) { return(moveActorState.Actor == partyMember); } return(false); }
private void movePartyMemberWithinList(PartyMember partyMember, bool edgeIndexIsZero, int nextRelativeIndex, BattleStates.Think thinkState) { if (!party.Contains(partyMember)) { return; } List <PartyMember> list = GetListWithPartyMember(partyMember); int partyMemberIndex = list.IndexOf(partyMember); if (partyMemberIndex != (edgeIndexIsZero ? 0 : list.Count - 1)) // if not at the end already { list.RemoveAt(partyMemberIndex); int index = partyMemberIndex + nextRelativeIndex; if (index == 0 && list.Count > 0 && thinkState.PartyMemberHasCompletedThinkAction(list[index])) { Weapon frontPartyMemberWeapon = list[index].EquippedWeapon; if (frontPartyMemberWeapon != null && frontPartyMemberWeapon.Data.WeaponType == WeaponType.Melee) { ++index; } } list.Insert(index, partyMember); } }
private void movePartyMemberAcrossLists(PartyMember partyMember, bool edgeListIndexIsZero, int nextListRelativeIndex, BattleStates.Think thinkState) { if (!party.Contains(partyMember)) { return; } List <PartyMember> list = GetListWithPartyMember(partyMember); int listIndex = layout.IndexOf(list); if (listIndex == (edgeListIndexIsZero ? 0 : layout.Count - 1)) // if the edge list { return; } List <PartyMember> nextList = layout[listIndex + nextListRelativeIndex]; int partyMemberPosition = Math.Min(list.IndexOf(partyMember), nextList.Count); list.Remove(partyMember); if (partyMemberPosition == 0 && nextList.Count > 0 && thinkState.PartyMemberHasCompletedThinkAction(nextList[partyMemberPosition])) { Weapon frontPartyMemberWeapon = nextList[partyMemberPosition].EquippedWeapon; if (frontPartyMemberWeapon != null && frontPartyMemberWeapon.Data.WeaponType == WeaponType.Melee) { ++partyMemberPosition; } } nextList.Insert(partyMemberPosition, partyMember); }