public override void OnStateEnter(BaseStateMachine m) { foreach (int i in selectedObject) { ai.toggleObjects[i].ToggleGenericObject(); } }
public override void OnShowComplete(WindowParams param_ = null) { base.OnShowComplete(param_); AuthState startState; if (windowsParameters != null) { AuthWindowParams authParams = (AuthWindowParams)windowsParameters; startState = authParams.startState; _authData = authParams.authData; } else { startState = AuthState.LOGIN; _authData = new AuthData(); } loginState.OnSignUpClick += (AuthData authData_) => { SwitchState(AuthState.SIGNUP, authData_); }; signupState.OnLogInClick += (AuthData authData_) => { SwitchState(AuthState.LOGIN, authData_); }; _stateSwitcher = new BaseStateMachine <AuthState, AuthWindowState> (); _stateSwitcher.Add(AuthState.LOGIN, loginState); _stateSwitcher.Add(AuthState.SIGNUP, signupState); SwitchState(startState, _authData); }
/// <summary> /// Được gọi bởi máy trạng thái khi bắt đầu trạng thái này /// </summary> /// <param name="stateMachine"></param> public void EnterState(BaseStateMachine stateMachine) { foreach (Action action in enterActions) { action.DoAction(stateMachine); } }
//-------------------------------------------------------------------------------------------------------------- #region Constructor protected UiBaseJewelState(IUiJewel handler, BaseStateMachine fsm, Battle.UI.Jewel.UiJewelParameters.UiJewelParameters parameters) { Fsm = fsm; Handler = handler; Parameters = parameters; IsInitialized = true; }
public override void OnStateEnter(BaseStateMachine m) { ai.QuitPath(); if (searchBench) { Physics2D.OverlapCircleNonAlloc(localFSM.transform.position, 7, availableBenches); Collider2D b = null; foreach (Collider2D bench in availableBenches) { if (bench != null && bench.CompareTag("REST")) { b = bench; } } if (b != null) { ai.OnFinishPath += Rejuvenate; ai.SetDestination(b.transform.position); } else { //F**K IT Rejuvenate(); } } else { Rejuvenate(); } }
/// <summary> /// 重置对象 /// </summary> public virtual void Restore() { showLog = false; isGlobal = false; //if (m_materialReplaceEffectList != null) //{ // m_materialReplaceEffectList.Clear(); //} //if (m_showingMaterialReplaceEffect != null) //{ // m_showingMaterialReplaceEffect.Clear(); //} if (mEffectList != null) { mEffectList.Clear(); } //if (m_materialReplaceEffectList != null) //{ // m_materialReplaceEffectList.Clear(); //} //if (m_showingMaterialReplaceEffect != null) //{ // m_showingMaterialReplaceEffect.Clear(); //} stateMachine = null; }
public void DisAttachToTarget() { if (targetTrans != null) { BaseStateMachine machine = targetTrans.GetComponentInParent <BaseStateMachine>(); if (machine != null) { machine.outLineCount = machine.outLineCount - 1; if (null != OnDisSelectedTarget) { OnDisSelectedTarget(machine.entityID); } //GfxBloodManager.ChangeBossBloodInfo(-1); } } DataCenter.LogicDataCenter.frontSightDataManager.FrontSightColor = Color.white; myTrans.parent = null; //MyParent = null; //MyMeshFilter.mesh = null; TargetController = null; targetTrans = null; //IsAttachTo = false; }
//-------------------------------------------------------------------------------------------------------------- #region Constructor protected UiBaseCardState(IUiCard handler, BaseStateMachine fsm, UiCardParameters parameters) { Fsm = fsm; Handler = handler; Parameters = parameters; IsInitialized = true; }
//动作触发,添加绑定光效 public void BindLighting(int LightingID) { if (showLog) { Trace.Log("Animation Add Bind Light" + LightingID); } if (!lightingEffectEnable) //挂动作上的光效,如果物体已经被隐藏,那直接不挂了 { return; } LightEffectParam param = new LightEffectParam(); param.srcObject = gameObject; param.sourcePos = gameObject.transform.position; param.targetPos = gameObject.transform.position; if (stateMachine == null) { stateMachine = GetComponent <BaseStateMachine>(); } if (stateMachine) { param.nSrcEntityID = stateMachine.entityID; } AddLighting(LightingID, param); }
public override void OnStateEnter(BaseStateMachine m) { Vector2 dir = localFSM.transform.position - ai.target.position; RaycastHit2D hit = Physics2D.Raycast(localFSM.transform.position, dir.normalized, 20, 1 << LayerMask.NameToLayer("Concrete")); if (hit.collider) { NNInfo info = AstarPath.active.GetNearest(hit.point, NNConstraint.Default); escapePoint = info.position; } else { NNInfo info = AstarPath.active.GetNearest((Vector2)localFSM.transform.position + dir.normalized * 20, NNConstraint.Default); escapePoint = info.position; } //Debug.Log("<Color=yellow>MY SPEED IS:</Color>" + ai.controller.speed); ai.OnFinishPath += FinishFleePoint; ai.SetDestination(escapePoint); ai.speed = 3; //throw new System.NotImplementedException(); }
protected UiBaseCharacterState(IUiCharacter handler, BaseStateMachine fsm, UiCharacterParameters parameters) { Fsm = fsm; Handler = handler; IsInitialized = true; Parameters = parameters; }
// Use this for initialization public IEnumerator Start() { if (SwitchList.Count <= 0) { bNeedToUpdate = false; } InitAll(); if (!SceneManager.isLoadingScene) { DisableAll(); m_pFSM = GetComponentInParent <BaseStateMachine>(); if (!m_pFSM) { enabled = false; yield break; } m_entityView = EntityFactory.getEntityViewByID(m_pFSM.entityID); } else { //bNeedToUpdate = false; GameUtil.StartCoroutineHelper(this, PreWarmEffect()); } bInit = true; yield return(sections); }
/// <summary> /// 重置 /// </summary> public void Restore() { CacheSkin(); //要在他们之前清理,因为动态脚本是依赖静态脚本的 DestroyDynamicCommopnent(); if (skinControl) { skinControl.Clear(); skinControl = null; } if (m_property) { m_property.Restore(); m_property = null; } if (m_stateMachine) { m_stateMachine.Clear(); m_stateMachine.ResetAllMembers(); m_stateMachine = null; } if (m_LightEffectManager) { m_LightEffectManager.Clear(); m_LightEffectManager.Restore(); m_LightEffectManager = null; } m_SkillCtrl = null; UBloodManager.Instance.DestroyBlood(ID); commands.Clear(); //commands = null; }
/// <summary> /// Thực hiện các hành động /// </summary> /// <param name="stateMachine"></param> private void DoUpdateActions(BaseStateMachine stateMachine) { foreach (Action action in updateActions) { action.DoAction(stateMachine); } }
/// <summary> /// Được gọi bởi máy trạng thái khi thoát khỏi trạng thái này /// </summary> /// <param name="stateMachine"></param> public void ExitState(BaseStateMachine stateMachine) { foreach (Action action in exitActions) { action.DoAction(stateMachine); } }
public UiCardTarget(IUiCard handler, Camera camera, BaseStateMachine fsm, UiCardParameters parameters) : base(handler, fsm, parameters) { var screenCenter = new Vector2(Screen.width, Screen.height) / 2; WorldCenter = camera.ScreenToWorldPoint(screenCenter).WithZ(0); Speed = 8; }
protected StateMachineState() { this.Machine = new BaseStateMachine { MachineName = this.ToString() }; this.Machine.CurrentStateChanged += new Action <BaseState, BaseState>(this.OnCurrentStateChanged); }
private void Start() { stateMachine = GetComponentInParent <BaseStateMachine>(); animator = GetComponent <Animator>(); BaseStateMachine.OnPlayerJump += PlayerJumpAnimation; Debug.Log("Subscribed on jump event"); }
public override void OnStateUpdate(BaseStateMachine m) { Debug.DrawRay(escapePoint, Vector2.up); Debug.DrawRay(escapePoint, Vector2.down); Debug.DrawRay(escapePoint, Vector2.left); Debug.DrawRay(escapePoint, Vector2.right); //throw new System.NotImplementedException(); }
public override void PlayerMoving(BaseStateMachine player) { player.variableJoystick.AxisOptions = AxisOptions.Both; Vector3 movingDirection = Vector3.forward * player.variableJoystick.Vertical + Vector3.right * player.variableJoystick.Horizontal; Vector3 rotationDirection = Vector3.forward * player.variableJoystick.rotationVertical + Vector3.right * player.variableJoystick.rotationHorizontal; player.rb.AddForce(movingDirection * player.speed * Time.deltaTime, ForceMode.VelocityChange); }
/// <summary> /// Được gọi bởi máy trạng thái khi cập trạng thái này /// </summary> /// <param name="stateMachine"></param> public void UpdateState(BaseStateMachine stateMachine) { if (CheckTransitions(stateMachine)) { return; } DoUpdateActions(stateMachine); }
public override void Initialize(BaseStateMachine m) { this.localFSM = m; ai = m.transform.parent.GetComponent <AiCore>(); routeList = ai.transform.GetComponent <RouteList>(); //ai.OnFinishPath += NextPoint; Debug.Log("INIT " + name + " State.....................DONE"); //throw new System.NotImplementedException(); }
private bool EnteredDefaultState(BaseStateMachine player) { bool triggerIsActive = false; if (player.triggerDefault.activeSelf) { triggerIsActive = true; } return(triggerIsActive); }
// 小地图点击事件 // yPos忽略,只是为了凑参数个数 // opCode: 0-进攻信号 1-撤退信号 2-上帝视角 3-寻路 public void OnMinimapClick(float xPos, float yPos, float zPos, int opCode) { Vector3 vec3Pos = new Vector3(xPos, yPos, zPos); SendMinimapClickPosToSkillCtrl(vec3Pos); // 进攻撤退信号 if (EntityFactory.MainHero != null) { MouseCtrl mouseCtrl = EntityFactory.MainHero.GetComponentInChildren <MouseCtrl>(); if (mouseCtrl != null) { if (opCode != (int)EMinimapClickType.EMCT_GodEyeMove) { if (mouseCtrl.OnMinimapClick(xPos, yPos, zPos)) { return; } } else if (mouseCtrl.IsTeamCommandStart()) { // 拖信息标示UI时屏蔽上帝视角消息 MyInvokeQ._Invoke("CancelGodEyeMove"); return; } } } // 进入上帝视角 if (opCode == (int)EMinimapClickType.EMCT_GodEyeMode || opCode == (int)EMinimapClickType.EMCT_GodEyeMove) { // 如果角色处于战斗状态,不能进上帝视角 if (EntityViewCommandHandler.mainHeroState == 3) { GameUtil.ShowSystemMessage(EMChatTipID.CHAT_TIP_WAR_CHANGE_GODEYE_IN_BATTLE); return; } GodEyeByMainHero(vec3Pos); return; } // 寻路 if (opCode == (int)EMinimapClickType.EMCT_Navigate) { BaseStateMachine sm = EntityFactory.MainHero.GetComponent <BaseStateMachine>(); if (sm != null) { // 需要确定一下y。 todo sm.AutoMoveTo(vec3Pos); } return; } }
public bool DoTransition(BaseStateMachine stateMachine) { bool result = condition.CheckCondition(stateMachine); if (result) { stateMachine.SetState(state); } return(result); }
private bool EnteredInFishingState(BaseStateMachine player) { bool triggerIsActive = false; if (player.triggerFishing) { triggerIsActive = true; } return(triggerIsActive); }
public static BaseStateMachine GetStateMachine(int entityID) { U3D_Render.EntityView ev = EntityFactory.getEntityViewByID(entityID); if (U3D_Render.EntityView.isNullOrEmpty(ev)) { return(null); } BaseStateMachine machine = ev.StateMachine; return(machine); }
private void DoDefaultPlayerMoving(BaseStateMachine player) { PlayerMoving(player); player.defaultPlayerAnimation.PlayerMovingAnimation(); #if UNITY_EDITOR if (Input.GetKeyDown(KeyCode.Space)) { PlayerJump(player); } #endif }
/// <summary> /// Kiểm tra các chuyển đổi /// </summary> /// <param name="stateMachine"></param> /// <returns></returns> private bool CheckTransitions(BaseStateMachine stateMachine) { foreach (Transition transition in transitions) { if (transition.DoTransition(stateMachine)) { return(true); } } return(false); }
public override void OnStateEnter(BaseStateMachine m) { hasEnded = false; waypointIndex = 0; ai.controller.speed = speed; ai.SetDestination(routeList.routes[selectedRoute].GetGlobalPoint(waypointIndex)); ai.stopMove = false; ai.OnFinishPath += NextPoint; done = false; //Debug.Log("MY STATE IS " + name + " AND MY ROUTE IS " + selectedRoute); //throw new System.NotImplementedException(); }