public TodorPlayer() { this.gamesCount = new int[StatesCount]; this.winsCount = new int[StatesCount]; this.successRate = Enumerable.Repeat(1d, StatesCount).ToArray(); this.state = (PlayerStateType)new Random().Next(0, StatesCount); }
public override void EndGame(EndGameContext context) { var stateIndex = (int)this.state; this.totalGamesCount++; this.gamesCount[stateIndex]++; if (context.WinnerName == this.Name) { this.winsCount[stateIndex]++; } if (this.totalGamesCount % this.stateEvaluationGamesCount == 0) { this.successRate[stateIndex] = (double)this.winsCount[stateIndex] / this.gamesCount[stateIndex]; int bestState = 0; double bestSuccessRate = 0; for (int i = 0; i < this.successRate.Length; i++) { if (this.successRate[i] >= bestSuccessRate) { bestState = i; bestSuccessRate = this.successRate[i]; } } this.state = (PlayerStateType)bestState; } }
private void Start() { if (Options.Instance.isFP_isFirst) { type = PlayerStateType.FirstPerson; } }
private void SetPullDownList(PlayerStateType state) { this.ClearPullDownList(); switch (state) { case PlayerStateType.None: this.SetBtnMenu(true); this.AddBtnToPullDownList(this.BtnShop.gameObject); this.AddBtnToPullDownList(this.BtnExchange.gameObject); break; case PlayerStateType.Browsing: this.SetBtnMenu(false); break; case PlayerStateType.Watching: this.SetBtnMenu(false); break; case PlayerStateType.Playing: this.SetBtnMenu(true); this.AddBtnToPullDownList(this.BtnAuto.gameObject); this.AddBtnToPullDownList(this.BtnRest.gameObject); this.AddBtnToPullDownList(this.BtnFinish.gameObject); this.AddBtnToPullDownList(this.BtnStatus.gameObject); break; case PlayerStateType.Exchange: this.SetBtnMenu(false); break; } }
public override void EndGame(EndGameContext context) { var stateIndex = (int)this.state; this.totalGamesCount++; this.gamesCount[stateIndex]++; if (context.WinnerName == this.Name) { this.winsCount[stateIndex]++; } if (this.totalGamesCount % this.stateEvaluationGamesCount == 0) { this.successRate[stateIndex] = (double)this.winsCount[stateIndex] / this.gamesCount[stateIndex]; int bestState = 0; double bestSuccessRate = 0; for (int i = 0; i < this.successRate.Length; i++) { if (this.successRate[i] >= bestSuccessRate) { bestState = i; bestSuccessRate = this.successRate[i]; } } this.state = (PlayerStateType)bestState; } }
public TodorPlayer() { this.gamesCount = new int[StatesCount]; this.winsCount = new int[StatesCount]; this.successRate = Enumerable.Repeat(1d, StatesCount).ToArray(); this.state = (PlayerStateType) new Random().Next(0, StatesCount); }
public PlayerState GetState(PlayerStateType _type) { if (!states.ContainsKey(_type)) { return(null); } return(states[_type]); }
void StopState() { if (curState != PlayerStateType.Empty) { states[(int)curState].OnStop(); player.onAnimationEvent -= states[(int)curState].OnAnimationEvent; curState = PlayerStateType.Empty; } }
public override bool CanChange(PlayerStateType nextPlayerState) { if (nextPlayerState == PlayerStateType.Stand || nextPlayerState == PlayerStateType.Jump) { return(true); } return(false); }
void InGameState(PlayerStateType gameState, params ClientToServerMessageType[] gameMessageTypes) { _State = ClientState.InGame; _PlayerState.State = gameState; var expectedMessageTypes = new HashSet <ClientToServerMessageType>(gameMessageTypes); expectedMessageTypes.Add(ClientToServerMessageType.Surrender); SetExpectedMessageTypes(expectedMessageTypes); }
public override bool CanChange(PlayerStateType nextPlayerState) { if (Owner.IsDead && nextPlayerState != PlayerStateType.Stand) { return(false); } return(true); }
IEnumerator RelievePass() { StateType = PlayerStateType.Dead; Deathtime++; _meshModel.SetActive(true); //FXrenderer.enabled = false; Deadparticles.Play(); _meshModel.SetActive(false); _photonView.RPC("RemoveAllBuff", RpcTarget.All); //屏幕特效 if (_photonView.IsMine) { _uiController.DisableSkill(); } _board.DataRefresh(this); yield return(new WaitForSeconds(1f)); StateType = PlayerStateType.Relieve; if (_photonView.IsMine) { transform.position = Map.GetRelievePoint(); } /*if (gameObject.GetComponent<PhotonView>().IsMine) * { * * transform.position = new Vector3(Random.Range(_minPosition.x,_maxPosition.x),Random.Range(_minPosition.y,_maxPosition.y)); * }*/ //屏幕特效 _board.DataRefresh(this); yield return(new WaitForSeconds(1f)); _meshModel.SetActive(true); //FXrenderer.enabled = true; //AvatarFx.enabled = true; _board.DataRefresh(this); yield return(new WaitForSeconds(1f)); if (_photonView.IsMine) { _uiController.AbleSkill(); } //AvatarFx.enabled = false; Controller.Rebuild(); //_photonView.RPC("Rebuild",RpcTarget.All); StateType = PlayerStateType.Alive; _board.DataRefresh(this); }
public void SwitchFromSZ_ToFP() { stateType = PlayerStateType.FirstPerson; szState.Lock(); szMemory.SetFPLocation(); switcher.MakeSwitchingAnimation(SwitchAnimType.SZ_TO_FP, switcher.GetFPCamParams()); }
public void SwitchFromFP_ToSZ(StageZone aimStageZone) { stateType = PlayerStateType.StageZone; fpsState.Lock(); szMemory.SetStartLocation(aimStageZone); szState.SetStageZoneParams(aimStageZone.GetStageZoneParams()); switcher.MakeSwitchingAnimation(SwitchAnimType.FP_TO_SZ, aimStageZone.GetDefaultCamParams()); }
public bool Climb() { if (!CanChangeState(PlayerStateType.Climb)) { return(false); } NextPlayerState = PlayerStateType.Climb; return(true); }
public bool Jump() { if (!CanChangeState(PlayerStateType.Jump)) { return(false); } NextPlayerState = PlayerStateType.Jump; return(true); }
public bool Stand() { if (!CanChangeState(PlayerStateType.Stand)) { return(false); } NextPlayerState = PlayerStateType.Stand; return(true); }
public bool Run() { if (!CanChangeState(PlayerStateType.Run)) { return(false); } NextPlayerState = PlayerStateType.Run; return(true); }
public void IntoState(PlayerStateType stateType, System.Object param = null) { //结束当前状态 if (curState != PlayerStateType.Empty) { states[(int)curState].OnStop(); player.onAnimationEvent -= states[(int)curState].OnAnimationEvent; } //开始新状态 curState = stateType; states[(int)stateType].Start(player, this, param); player.onAnimationEvent += states[(int)stateType].OnAnimationEvent; }
public void SetUserData(PlayerStateUserData data) { if (data == null) { return; } CurrentPlayerState = data.CurrentState; NextPlayerState = data.NextState; if (data.RunTime != null) { States[(int)CurrentPlayerState].SetUserData(data.RunTime); } }
public void GotoState(PlayerStateType _key) { if (!states.ContainsKey(_key)) { return; } currentState?.Exit(); previousState = currentState; CurrentStateType = _key; currentState = states[CurrentStateType]; currentState.Enter(); }
//同步积分/死亡数量/死亡状态 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.IsWriting) { stream.SendNext(this.Score); stream.SendNext(this.Deathtime); stream.SendNext(this.StateType); } else if (stream.IsReading) { this.Score = (int)stream.ReceiveNext(); this.Deathtime = (int)stream.ReceiveNext(); this.StateType = (PlayerStateType)stream.ReceiveNext(); } }
public void Init(Player player) { Owner = player; States = new BaseState[] { new StandState(Owner), new RunState(Owner), new JumpState(Owner), new ClimbState(Owner), new DeadState(Owner), }; CurrentPlayerState = PlayerStateType.Stand; NextPlayerState = PlayerStateType.Invalid; }
/// <summary> /// 移动 /// </summary> /// <returns></returns> public IEnumerator moveAnimation() { Transform t = this.transform; startPosition = t.position; moveTime = 0; while (moveTime < 1f) { moveTime += Time.deltaTime * moveSpeed; t.position = Vector3.Lerp(startPosition, endPosition, moveTime); yield return(null); } //移动结束 状态变为idle nowState = PlayerStateType.Idle; setInt(); yield return(0); }
private void Start() { fpsState = FPController.Instance; szState = SZController.Instance; switcher = StateSwitcher.Instance; szMemory = SZMemory.Instance; if (Options.Instance.isFP_isFirst) { stateType = PlayerStateType.FirstPerson; fpsState.Unlock(); } else { stateType = PlayerStateType.StageZone; szState.Unlock(); } }
private void ChangeState() { if (Owner == null) { return; } if (CurrentPlayerState != PlayerStateType.Invalid) { States[(int)CurrentPlayerState].Exit(); } CurrentPlayerState = NextPlayerState; NextPlayerState = PlayerStateType.Invalid; var state = States[(int)CurrentPlayerState]; state.Enter(); }
public void SetPlayerToState(PlayerStateType type) { if (playerState == type) { return; } switch (type) { default: case PlayerStateType.Normal: Game.MaxWantedLevel = 5; Game.LocalPlayer.Model = normalStateModel; FirefighterRole = FirefighterRole.None; break; case PlayerStateType.Firefighter: Game.MaxWantedLevel = 0; normalStateModel = Game.LocalPlayer.Model; Game.LocalPlayer.Model = Plugin.UserSettings.PEDS.FIREFIGHTER_MODEL; FirefighterRole = FirefighterRole.Engine; FireCalloutsManager.Instance.LoadCallouts(); FireCalloutsManager.Instance.ResetNextCalloutTimer(); break; case PlayerStateType.EMS: Game.MaxWantedLevel = 0; normalStateModel = Game.LocalPlayer.Model; Game.LocalPlayer.Model = Plugin.UserSettings.PEDS.EMS_MODEL; FirefighterRole = FirefighterRole.None; EMSCalloutsManager.Instance.LoadCallouts(); EMSCalloutsManager.Instance.ResetNextCalloutTimer(); break; } API.Functions.OnPlayerStateChanged(type, playerState); playerState = type; }
private void SetPlayerAnima(PlayerStateType playerStateType) { switch (playerStateType) { case PlayerStateType.Run: playerAnimator.SetBool("run", true); playerAnimator.SetBool("jump", false); playerAnimator.SetBool("down", false); break; case PlayerStateType.Jump: playerAnimator.SetBool("run", false); playerAnimator.SetBool("jump", true); playerAnimator.SetBool("down", false); break; case PlayerStateType.Down: playerAnimator.SetBool("run", false); playerAnimator.SetBool("jump", false); playerAnimator.SetBool("down", true); break; } }
/// <summary> /// 开始移动 direction= W/A/S/D /// </summary> /// <param name="direction"></param> public void move(string direction) { nowState = PlayerStateType.Moving; Transform t = this.transform; switch (direction) { case "W": endPosition = new Vector3(t.position.x, t.position.y, t.position.z + 1); break; case "S": endPosition = new Vector3(t.position.x, t.position.y, t.position.z - 1); break; case "A": endPosition = new Vector3(t.position.x - 1, t.position.y, t.position.z); break; case "D": endPosition = new Vector3(t.position.x + 1, t.position.y, t.position.z); break; } }
public void SetTurnStates() { State = PlayerStateType.MyTurn; Opponent.State = PlayerStateType.OpponentTurn; }
/// <summary> /// Called when the state is disabled /// </summary> /// <param name="newState">The new player state</param> public abstract void OnDisableState(PlayerStateType newState);
void InGameState(PlayerStateType gameState, params ClientToServerMessageType[] gameMessageTypes) { _State = ClientState.InGame; _PlayerState.State = gameState; var expectedMessageTypes = new HashSet<ClientToServerMessageType>(gameMessageTypes); expectedMessageTypes.Add(ClientToServerMessageType.Surrender); SetExpectedMessageTypes(expectedMessageTypes); }
private PlayerManager() { playerState = PlayerStateType.Normal; normalStateModel = Game.LocalPlayer.Model; }
/// <summary> /// Called when the state is enabled /// </summary> /// <param name="previousState">The previous player state</param> public abstract void OnEnableState(PlayerStateType previousState);
public bool CanChangeState(PlayerStateType type) { var state = States[(int)CurrentPlayerState]; return(state.CanChange(type)); }
public void FlipTurnState() { State = State == PlayerStateType.MyTurn ? PlayerStateType.OpponentTurn : PlayerStateType.MyTurn; }
public override bool CanChange(PlayerStateType nextPlayerState) { return(true); }