protected virtual void Awake() { //get the reference of playmaker fsms. PlayMakerFSM[] fsms = GetComponents<PlayMakerFSM>(); foreach (PlayMakerFSM fsm in fsms) { if (fsm.FsmName == "FSM_Control") { FSM_Control = fsm; } if (fsm.FsmName == "FSM_Hit") { FSM_Hit = fsm; } if (fsm.FsmName == "FSM_Charge") { FSM_Charge = fsm; } } //initialize key variables. player = transform.GetComponent<PlayerBase>(); layer = GetComponent<exLayer>(); velocity = new Vector2(0, 0); comboLevel = 0; charMoveDir = MoveDir.Stop; downButton = BtnHoldState.None; initJumpSpeedStatic = jumpSpeed; initMoveSpeedStatic = moveSpeed; initAttackPowerStatic = attackPower; initInvincibleDuration = FSM_Hit.FsmVariables.GetFsmFloat("varInvincibleDuration").Value; currentPlatform = Game.instance.theBasePlatform; }
public virtual void ReleaseCharge(BtnHoldState _upButton) { }
public override void ReleaseCharge(BtnHoldState _upButton) { if (FSM_Charge.ActiveStateName == "Charge_Prepare") { FSM_Charge.Fsm.Event("To_StopCharge"); downButton = BtnHoldState.None; return; } if (FSM_Charge.ActiveStateName == "Charge_SpeedUp") { FSM_Charge.Fsm.Event("To_ChargeRecover"); downButton = BtnHoldState.None; } if (FSM_Charge.ActiveStateName == "Charge") { if (_upButton == downButton) { FSM_Control.Fsm.Event("To_ChargeRelease"); } FSM_Charge.Fsm.Event("To_ChargeRelease"); downButton = BtnHoldState.None; return; } }
public override void ReleaseCharge(BtnHoldState _upButton) { //only enters charge release state when it's already in charge loop state. if (FSM_Charge.ActiveStateName == "Charge_Loop_Armor") { if (_upButton == downButton) { FSM_Control.Fsm.Event("To_ChargeRelease"); FSM_Charge.Fsm.Event("To_ChargeRelease"); } FSM_Charge.Fsm.Event("To_StopCharge"); downButton = BtnHoldState.None; return; } else { downButton = BtnHoldState.None; FSM_Charge.Fsm.Event("To_StopCharge"); } }
//when a button is released, check if it's charged up enough. public override void ReleaseCharge(BtnHoldState _upButton) { //if charge is not ready, stop charge. if (FSM_Charge.ActiveStateName == "Charge_Prepare") { FSM_Charge.Fsm.Event("To_StopCharge"); downButton = BtnHoldState.None; return; } if (FSM_Charge.ActiveStateName == "Charge_Up") { if (_upButton == downButton) { FSM_Control.Fsm.Event("To_ShootUp"); } FSM_Charge.Fsm.Event("To_StopCharge"); downButton = BtnHoldState.None; return; } if (FSM_Charge.ActiveStateName == "Charge_Para") { if (_upButton == downButton) { FSM_Control.Fsm.Event("To_ShootPara"); } FSM_Charge.Fsm.Event("To_StopCharge"); downButton = BtnHoldState.None; return; } if (FSM_Charge.ActiveStateName == "Charge_Power") { if (_upButton == downButton) { FSM_Control.Fsm.Event("To_ShootPower"); } FSM_Charge.Fsm.Event("To_StopCharge"); downButton = BtnHoldState.None; return; } }