//--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\ #region --Misc Methods (Public)-- public override void reset() { if (XMPP_CONNECTION.account.connectionConfiguration.disableStreamManagement) { state = SMState.PROHIBIT; Logger.Info("Stream management is disabled for account: " + XMPP_CONNECTION.account.getBareJid()); } else { state = SMState.DISABLED; } clientSMEnabled = false; serverSMEnabled = false; startListeningForMessages(); }
public void showReligionScreen() { smState = SMState.Religion; religionScreen.gameObject.SetActive(true); }
public void showPackageScreen() { smState = SMState.Package; pickPackageScreen.gameObject.SetActive(true); }
public void showAdvancedScreen() { smState = SMState.Advanced; }
public SMState NextState(byte c) { //for each byte we get its class , if it is first byte, we also get byte length int byteCls = PkgInt.GETFROMPCK(c, mModel.classTable); if (mCurrentState == SMState.Start) { mCurrentBytePos = 0; mCurrentCharLen = mModel.charLenTable[byteCls]; } //from byte's class and stateTable, we get its next state mCurrentState = (SMState)PkgInt.GETFROMPCK((int)mCurrentState * ((int)mModel.classFactor) + byteCls, mModel.stateTable); mCurrentBytePos++; return mCurrentState; }
public CodingStateMachine(SMModel sm) { mCurrentState = SMState.Start; mModel = sm; }
public void Reset() { mCurrentState = SMState.Start; }
public override void AddAI() { m_sm = new StateMachine(); string stateNameSleep = "Sleep"; string stateNameWakeUp = "WakeUp"; string stateNameIdle = "Idle"; string stateNameWalking = "Walking"; string stateNameAxeAttack = "AxeAttack"; string stateNameCannonAttack = "CannonAttack"; string stateNameJumpBack = "JumpBack"; string StateNameDied = "Died"; float axeAttackCoolDown = 6f; float cannonAttackCoolDown = 3f; float WalkCoolDown = 3f; onStateAction distanceCheck = _ => { float distance = this.CheckDistanceX(InGameVars.hero); var transSucceed = false; if ((distance > 80 || distance < 120)) { transSucceed = m_sm.TransState(stateNameAxeAttack); if (transSucceed) { return; } else { m_sm.SetData("WalkingBack", true); m_sm.SetData("distance", distance); var walkSucceed = m_sm.TransState(stateNameWalking); if (!walkSucceed) { m_sm.SetData("WalkingBack", false); } } } if (distance < 80 || (distance > 120 && distance < 160)) { if (distance < 80) { var random = UnityEngine.Random.Range(0f, 1f); Debug.Log(random); if (random > 0.3f) { var jumpSucceed = m_sm.TransState(stateNameJumpBack); if (jumpSucceed) { return; } } else { // 在板边,则直接开炮 if (this.isNearScreenHEdge()) { m_sm.TransState(stateNameCannonAttack); } else { m_sm.SetData("distance", distance); m_sm.SetData("WalkingBack", true); var walkSucceed = m_sm.TransState(stateNameWalking); if (!walkSucceed) { m_sm.SetData("WalkingBack", false); } } } } else { m_sm.SetData("distance", distance); m_sm.SetData("WalkingBack", false); m_sm.TransState(stateNameWalking); } } if (distance > 160) { if (!m_sm.TransState(stateNameCannonAttack)) { m_sm.SetData("distance", distance); m_sm.SetData("WalkingBack", false); m_sm.TransState(stateNameWalking); } } }; SMState stateDied = new SMState(StateNameDied); m_sm.AddState(stateDied); SMState stateSleep = new SMState(stateNameSleep); m_sm.AddState(stateSleep); stateSleep.OnEnterState = (_) => { m_wontBeHurt = true; }; stateSleep.OnExitState = (_) => { m_wontBeHurt = false; }; stateSleep.OnUpdate = (_) => { if (m_isAttacked) { if (m_anim.IsAnimationState(stateNameSleep)) { m_sm.TransState(stateNameWakeUp); m_anim.PlayAvoidRePlay("Awake"); } } }; // 起身 SMState stateWakeUp = new SMState(stateNameWakeUp); m_sm.AddState(stateWakeUp); stateWakeUp.OnEnterState = _ => { AttachToHPBar(GameManager.StatusBar.m_enemyHp); GameManager.cameraHandler.DisFollow(); }; stateWakeUp.OnUpdate = _ => { if (m_isAwake == 1) { m_sm.TransState(stateNameIdle); } }; SMState StateJumpBack = new SMState(stateNameJumpBack); m_sm.AddState(StateJumpBack); StateJumpBack.TransPreCheck = () => { return(m_sm.GetData <bool>("WalkCoolDown")); }; StateJumpBack.OnExitState = _ => { m_jumpVelocityX = 0; }; StateJumpBack.OnEnterState = _ => { JumpToScreenEdge(); new EnumTimer(() => { m_sm.TransState(stateNameCannonAttack); }, m_backJumpTime).StartTimeout(); }; // 站立状态 SMState StateIdle = new SMState(stateNameIdle); m_sm.AddState(StateIdle); StateIdle.OnEnterState = _ => { m_anim.PlayAvoidRePlay("Idle"); StopX(); }; StateIdle.OnUpdate = distanceCheck; SMState stateWalking = new SMState(stateNameWalking); m_sm.AddState(stateWalking); stateWalking.TransPreCheck = () => { return(m_sm.GetData <bool>("WalkCoolDown")); }; stateWalking.canTranlateToSelf = true; stateWalking.OnEnterState = _ => { var distance = m_sm.GetData <float>("distance"); var walkingBack = m_sm.GetData <bool>("WalkingBack"); if (distance < 80 || walkingBack) { Walk(-1); m_sm.SetData <bool>("isWalkingBack", true); } else { Walk(1); m_sm.SetData <bool>("isWalkingBack", false); } m_sm.SetData("WalkCoolDown", false); new EnumTimer(() => { m_sm.SetData("WalkCoolDown", true); m_sm.SetData("WalkingBack", false); }, WalkCoolDown).StartTimeout(); return; }; stateWalking.OnUpdate = state => { // 在板边,则直接开炮 if (this.isNearScreenHEdge()) { var isWalkingBack = m_sm.GetData <bool>("isWalkingBack"); if (isWalkingBack) { var random = UnityEngine.Random.Range(0f, 1f); if (random > 0.5) { if (!m_sm.TransState(stateNameCannonAttack)) { Walk(1); m_sm.SetData <bool>("isWalkingBack", false); } } else { Walk(1); m_sm.SetData <bool>("isWalkingBack", false); } } } if (!m_sm.GetData <bool>("WalkCoolDown")) { return; } distanceCheck.Invoke(state); }; SMState stateAxeAttack = new SMState(stateNameAxeAttack); m_sm.AddState(stateAxeAttack); stateAxeAttack.OnEnterState = _ => { StopX(); m_anim.PlayAvoidRePlay("AxeAttack"); m_sm.SetData("AxeAttackCoolDown", false); new EnumTimer(() => { m_sm.SetData("AxeAttackCoolDown", true); }, axeAttackCoolDown).StartTimeout(); }; stateAxeAttack.TransPreCheck = () => { return(m_sm.GetData <bool>("AxeAttackCoolDown")); }; SMState stateCannonAttack = new SMState(stateNameCannonAttack); m_sm.AddState(stateCannonAttack); stateCannonAttack.OnEnterState = _ => { StopX(); m_anim.PlayAvoidRePlay("FireCanon"); m_sm.SetData("CannonAttackCoolDown", false); new EnumTimer(() => { m_sm.SetData("CannonAttackCoolDown", true); }, cannonAttackCoolDown).StartTimeout(); }; stateCannonAttack.TransPreCheck = () => { return(m_sm.GetData <bool>("CannonAttackCoolDown")); }; m_sm.TransState(stateNameSleep); m_sm.SetData("AxeAttackCoolDown", true); m_sm.SetData("CannonAttackCoolDown", true); m_sm.SetData("WalkCoolDown", true); }
public StateMachine(Dictionary <string, SMState> _states) { states = _states; currentState = null; }
public SMExternalTrigger(SMState source, SMState target, StateMachineController.TransitionHandler handler) : base(source, target, handler) { //this.triggerActive = false; }
/// <see cref="SMTrigger.CurrentStateChanged"/> protected override void CurrentStateChanged(SMState currState, SMState prevState) { // this.triggerActive = (currState == this.sourceState); }