protected override void PaintContent(Graphics graphics) { ICharacterState player1 = selectMenuPlayer1.CurrentCharacter; ICharacterState player2 = selectMenuPlayer2.CurrentCharacter; DrawBackground(graphics, background); DrawImage(graphics, udcLabel, 0, 0, cellX * 5, cellY * 5); graphics.DrawString("Выберите персонажей", mainFont, ColorConstants.CharacterSelectLabels, cellX * 7, cellY * 2); for (int i = 0; i < selectMenuPlayer1.Characters.Count; i++) { DrawImage(graphics, selectMenuPlayer1.Characters[i].Icon, cellX * i * 2 + cellX, cellY * 4, cellX * 2, cellX * 2); } if (!selectMenuPlayer1.Selected) { DrawImage(graphics, selectFirstImage, cellX * selectMenuPlayer1.Selection * 2 + cellX, cellY * 4, cellX * 2, cellX * 2); } DrawImage(graphics, player1.Image, cellX * 1, cellY * 10, cellY * 10, cellY * 10); graphics.DrawString(selectMenuPlayer1.Characters[selectMenuPlayer1.Selection].PlayerName, mainFont, selectMenuPlayer1.Selected? ColorConstants.Selected : ColorConstants.NonSelected, cellX, cellY * 8); if (!selectMenuPlayer2.Selected) { DrawImage(graphics, selectSecondImage, cellX * selectMenuPlayer2.Selection * 2 + cellX, cellY * 4, cellX * 2, cellX * 2); } graphics.DrawString(selectMenuPlayer2.Characters[selectMenuPlayer2.Selection].PlayerName, mainFont, selectMenuPlayer2.Selected ? ColorConstants.Selected : ColorConstants.NonSelected, cellX * 15, cellY * 8); DrawImage(graphics, player2.Image, cellX * 13, cellY * 10, cellY * 10, cellY * 10); }
private void JumpInput() { if (Input.GetButtonDown("Jump")) { state = state.Jump(playerSettings.jumpForce); } }
private void UpdateStateResponseToInput(IUserCmd cmd, ICharacterState stateManager, IAdaptiveContainer <IFsmInputCommand> commandsContainer, PlayerEntity playerEntity) { try { SingletonManager.Get <DurationHelp>().ProfileStart(CustomProfilerStep.StateUpdateResponseToInput); _fsmOutputs.ResetOutput(); // 更新状态机 stateManager.Update(commandsContainer, cmd.FrameInterval, _fsmOutputs.AddOutput, FsmUpdateType.ResponseToInput, playerEntity.fsmInputRelateInterface.Relate.GetFsmInputLimits()); // 更新手臂动画 playerEntity.characterBoneInterface.CharacterBone.SetWeaponPitch(_fsmOutputs.AddOutput, playerEntity.characterBone.WeaponPitch); // 更新一、三人称Animator _fsmOutputs.SetOutput(playerEntity); if (!SharedConfig.IsServer && playerEntity.thirdPersonAnimator.UnityAnimator.cullingMode != AnimatorCullingMode.AlwaysAnimate) { _logger.WarnFormat("wrong culling mode: {0}", playerEntity.thirdPersonAnimator.UnityAnimator.cullingMode); } } finally { SingletonManager.Get <DurationHelp>().ProfileEnd(CustomProfilerStep.StateUpdateResponseToInput); } }
private void UpdateStateResponseToAnimation(ICharacterState stateManager, IAdaptiveContainer <IFsmInputCommand> commandsContainer, AnimatorClipManager animatorClipManager, PlayerEntity playerEntity) { try { SingletonManager.Get <DurationHelp>().ProfileStart(CustomProfilerStep.StateUpdateResponseToAnimation); _fsmOutputs.ResetOutput(); // 更新状态机 stateManager.Update(commandsContainer, 0, _fsmOutputs.AddOutput, FsmUpdateType.ResponseToAnimation, playerEntity.fsmInputRelateInterface.Relate.GetFsmInputLimits()); // 更新Clip速率 animatorClipManager.Update(_fsmOutputs.AddOutput, playerEntity.thirdPersonAnimator.UnityAnimator, playerEntity.firstPersonAnimator.UnityAnimator, playerEntity.WeaponController().HeldWeaponAgent.ConfigId); // 更新Animator的Param _fsmOutputs.SetOutput(playerEntity); } finally { SingletonManager.Get <DurationHelp>().ProfileEnd(CustomProfilerStep.StateUpdateResponseToAnimation); } }
private void SprintDisableTest(ICharacterState state, IAdaptiveContainer <IFsmInputCommand> commands) { int slowDown = NoLimit; int prevSlowDown = state.GetSteepSlowDown(); if (IsLimitRun(state.GetSteepAngle(), prevSlowDown)) { for (int i = 0; i < commands.Length; ++i) { var v = commands[i]; if (v.Type == FsmInput.Sprint || v.Type == FsmInput.Run) { v.Type = FsmInput.Walk; _logger.DebugFormat("sprint to Walk due to move in water or is steep slope!, angle:{0}", state.GetSteepAngle()); slowDown = LimitRun; } } } else if (state.IsMoveInWater() || IsLimitSprint(state.GetSteepAngle(), prevSlowDown)) { for (int i = 0; i < commands.Length; ++i) { var v = commands[i]; if (v.Type == FsmInput.Sprint) { v.Type = FsmInput.Run; _logger.DebugFormat("sprint to run due to move in water or is steep slope!, angle:{0}", state.GetSteepAngle()); slowDown = LimitSprint; } } } state.SetSteepSlowDown(slowDown); }
private void ShootInput() { if (Input.GetButtonDown("Fire1")) { state = state.Shoot(bulletPool, transform.position); } }
public static ThirdPersonAction GetAction(ICharacterState state) { ThirdPersonAction ret; var stateActionInConfig = state.GetActionState(); switch (stateActionInConfig) { case ActionInConfig.SwitchWeapon: ret = ThirdPersonAction.SwitchWeapon; break; case ActionInConfig.PickUp: ret = ThirdPersonAction.PickUp; break; case ActionInConfig.Reload: ret = ThirdPersonAction.Reload; break; case ActionInConfig.SpecialReload: ret = ThirdPersonAction.SpecialReload; break; default: ret = ThirdPersonAction.EndOfTheWorld; break; } return(ret); }
public SwordmanAttack1(IMainCharacter mainCharacter) { step = 1f; results = new Collider[5]; this.mainCharacter = mainCharacter; caromState = new SwordmanAttack2(mainCharacter); } // end SwordmanAttack1
//public ArmorUnit characterArmors; public MyCharacter(string n, int hp, int dmg, int lvl, int tp, int arm) { name = n; healthPoints = hp; damage = dmg; level = lvl; type = tp; coordinateX = 0; coordinateY = 0; characterState = new NormalState(this); blindedState = new BlindedState(this); normalState = new NormalState(this); knockedoutState = new KnockedOutState(this); freezedState = new FreezedState(this); gold = 0; //characterArmors = new ArmorUnit("Shirts And pants", arm); //var json = JsonConvert.SerializeObject(this); //json = json.Remove(2, 41); //remove spellAction from string //var response = HttpClientToAPI.Instance().Post("players", json); //Player pl = JsonConvert.DeserializeObject<Player>(response); //id = pl.Id; //HttpClientToAPI.Instance().Post("coordinates", "{\"PlayerId\":" + id + ", \"CoordinateX\":0, \"CoordinateY\":0}"); }
public void ChangeState(ICharacterState newState) { // Leave like this for now if (CheckForValidStateChange(newState)) { currentState = newState; } }
public SwordmanAttack2(IMainCharacter mainCharacter) { step = 1f; halfExtents = new Vector3(0.3f, 0.5f, 0.6f); results = new Collider[5]; this.mainCharacter = mainCharacter; caromState = new SwordmanAttack3(mainCharacter); } // end SwordmanAttack1
void Start() { navAgent = GetComponent <NavMeshAgent>(); currentState = combatState; StartCoroutine(EnemyCheck()); }
private void CrouchInput() { if (Input.GetKeyDown(KeyCode.S)) { float inputX = Input.GetAxisRaw("Horizontal"); state = state.Crouch(inputX); } }
public static void CharacterUnmount(this ICharacterState State, Action holsterStart, Action holsterEnd, float unarmParam) { _loggerAdapter.Info("[Tmp]Interrupt"); State.InterruptAction(); State.ForceFinishGrenadeThrow(); State.Holster(holsterStart, holsterEnd, unarmParam); }
public void ChangeState(ICharacterState nextState) { if (currentState != null) { this.currentState.Exit(); } this.currentState = nextState; this.currentState.Enter(this); }
public void Start() { Debug.Assert(behaviour != null); character = GetComponent <Character> (); Debug.Assert(character != null); currentState = new IdleState(behaviour, character); }
private void Start() { flyBoy = GetComponent <CharacterController>(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = (false); CursorLockedVar = (true); state = Grounded; }
private void TransitionCharacterState(ICharacterState state) { if (characterState != null) { characterState.Exit(); } characterState = state; characterState.Enter(selected); //SetCombatMenu(); }
public static ThirdPersonPosture GetPosture(ICharacterState state) { ThirdPersonPosture ret; var stateInConfig = state.GetCurrentPostureState(); switch (stateInConfig) { case PostureInConfig.Stand: ret = ThirdPersonPosture.Stand; break; case PostureInConfig.Crouch: ret = ThirdPersonPosture.Crouch; break; case PostureInConfig.Prone: ret = ThirdPersonPosture.Prone; break; case PostureInConfig.ProneTransit: ret = ThirdPersonPosture.ProneTransit; break; case PostureInConfig.ProneToStand: ret = ThirdPersonPosture.ProneToStand; break; case PostureInConfig.ProneToCrouch: ret = ThirdPersonPosture.ProneToCrouch; break; case PostureInConfig.Swim: ret = ThirdPersonPosture.Swim; break; case PostureInConfig.Dive: ret = ThirdPersonPosture.Dive; break; case PostureInConfig.Dying: ret = ThirdPersonPosture.Dying; break; case PostureInConfig.Climb: ret = ThirdPersonPosture.Climb; break; default: ret = ThirdPersonPosture.EndOfTheWorld; break; } return(ret); }
public void ChangeState(ICharacterState newState) { if (currentState != null) { currentState.Exit(); } currentState = newState; currentState.Enter(this); }
// Token: 0x0600204B RID: 8267 RVA: 0x0009A550 File Offset: 0x00098750 public void Shoot(ICharacterState state) { if (state != null && this._nextShootTime < Time.time && this._currentSlot != null && (!(this._currentSlot.Logic is ProjectileWeapon) || this._currentSlot.View.ItemClass == UberstrikeItemClass.WeaponSplattergun)) { this._nextShootTime = Time.time + WeaponConfigurationHelper.GetRateOfFire(this._currentSlot.View); this.BeginShooting(); CmunePairList <BaseGameProp, ShotPoint> cmunePairList; this._currentSlot.Logic.Shoot(new Ray(this.ShootingPoint(state) + GameState.Current.Player.EyePosition, this.ShootingDirection(state)), out cmunePairList); this.EndShooting(); } }
// Token: 0x0600185D RID: 6237 RVA: 0x000828E4 File Offset: 0x00080AE4 public void Initialize(ICharacterState state, global::Avatar avatar) { this.State = state; this.State.OnDeltaUpdate += this.OnDeltaUpdate; this._transform.position = this.State.Position; if (!this.State.Player.IsAlive) { Debug.Log("Initialize as dead player at " + this.State.Position); } base.gameObject.name = string.Format("Player{0}_{1}", this.State.Player.Cmid, this.State.Player.PlayerName); this.SetAvatar(avatar); this.WeaponSimulator.UpdateWeapons((int)this.State.Player.CurrentWeaponSlot, this.State.Player.Weapons); }
public void Enter(Character selected = null, Map map = null) { EventManager.Instance.Raise(new CombatMenuEvent()); if (this.selected == null) { this.selected = selected; this.selected.ToggleHighlight(true); ICharacterState state = (selected.Moved || selected.Acted) ? new ActionState() : new MoveState() as ICharacterState; TransitionCharacterState(state); } EventManager.Instance.AddListener <CharacterStateTransitionEvent>(OnCharStateTransition); EventManager.Instance.Raise(new ColliderToggleEvent(false)); }
} // end Update public void PerformTransition(ICharacterState state) { if (null != currentState) { currentState.DoBeforeLeaving(); } // end if currentState = state; if (null != currentState) { currentState.DoBeforeEntering(); } } // end PerformTransition
void StateDataBaseInitialize() { stateDataBase = new ICharacterState[5]; stateDataBase[(int)CHARACTER_STATE.Idle] = GetComponent <FunKiBaseState>(); stateDataBase[(int)CHARACTER_STATE.Jump] = GetComponent <FunKiBaseJumpState>();; stateDataBase[(int)CHARACTER_STATE.ObstacleJump] = GetComponent <FunKiBaseObstacleState>(); stateDataBase[(int)CHARACTER_STATE.Falling] = GetComponent <FunKiFallingState>(); stateDataBase[(int)CHARACTER_STATE.Rigidity] = GetComponent <FunKiRigidityState>(); state = stateDataBase[(int)CHARACTER_STATE.Idle]; Debug.Log("캐릭터의 현재 상태 : " + state.ToString()); }
// Use this for initialization void Start() { rb = GetComponent <Rigidbody>(); anim = GetComponentInChildren <Animator>(); //particles = GetComponentInChildren<ParticleSystem>(); normalState = new NormalState(this); currentState = normalState; pushableLayer = LayerMask.GetMask("Pushable"); groundLayer = LayerMask.GetMask("Ground"); appliedForces = new Vector3(0f, 0f, 0f); }
/// <summary> /// 初始化 /// </summary> private void Initialize() { character = this; states = new ICharacterState[] { new CharacterState_Idle(character), new CharacterState_Walking(character), new CharacterState_Empty(character), new CharacterState_Holding(character) }; currentState = states[0]; animator = character.GetComponent <Animator>(); Debug.Log(animator); action = new Action(character); }
public bool CheckForValidStateChange(ICharacterState newState) { if (currentState == null) { return(true); } if (currentState.Id == newState.Id) { return(false); } return(true); }
public virtual void ChangeState(string StateName) { if (stateDictionary.ContainsKey(StateName)) { cState = StateName; stateCurrentTime = 1; currentState.OnInterrupted(); currentState = stateDictionary[StateName]; currentState.OnStart(); } else { Debug.Log("State " + StateName + " doesn't exist."); } }
protected override void PaintContent(Graphics graphics) { ICharacterState player = descriptionMenu.CurrentCharacter; DrawBackground(graphics, background); DrawImage(graphics, player.Image, cellX * -1, cellY * 2, cellX * 15, cellX * 15); graphics.DrawString(player.PlayerName, titleFont, ColorConstants.NormalColorBrush, new RectangleF(cellX * 12, cellY * 2, Width - cellX * 12, cellY * 6), stringFormatCenter); graphics.DrawString(player.CharacterDescription, descriptionFont, ColorConstants.NormalColorBrush, new RectangleF(cellX * 12, cellY * 8, Width - cellX * 12, Height - cellY * 8), stringFormatCenter); graphics.DrawString(player.StatsDescription, regularFont, ColorConstants.NormalColorBrush, new RectangleF(cellX * 12, cellY * 19, Width - cellX * 12, Height - cellY * 19), stringFormatNormal); graphics.DrawString(player.AbilitiesDescription, regularFont, ColorConstants.NormalColorBrush, new RectangleF(cellX * 2, cellY * 30, Width - cellX * 2, Height - cellY * 30), stringFormatNormal); }
//********************************* // VVVVV MONOBEHAVIOUR EVENTS VVVVV //********************************* void Start() { rigidbody = GetComponent<Rigidbody2D>(); animator = GetComponent<Animator>(); upAttackTrigger = Animator.StringToHash("UpAttack"); sideUpAttackTrigger = Animator.StringToHash("SideUpAttack"); sideAttackTrigger = Animator.StringToHash("SideAttack"); sideDownAttackTrigger = Animator.StringToHash("SideDownAttack"); downAttackTrigger = Animator.StringToHash("DownAttack"); airJumpTrigger = Animator.StringToHash("AirJump"); groundedHash = Animator.StringToHash("Grounded"); walkingHash = Animator.StringToHash("Walking"); stunnedHash = Animator.StringToHash("Stunned"); startXScale = transform.localScale.x; attacks = new Dictionary<Direction, Attack>(); attacks.Add(Direction.Up, upAttack); attacks.Add(Direction.RightUp, sideUpAttack); attacks.Add(Direction.Right, sideAttack); attacks.Add(Direction.RightDown, sideDownAttack); attacks.Add(Direction.Down, downAttack); attacks.Add(Direction.LeftDown, sideDownAttack); attacks.Add(Direction.Left, sideAttack); attacks.Add(Direction.LeftUp, sideUpAttack); currentState = new Idle(); currentState.OnEnter(this); inputComponent = GetComponent(typeof(IGetInput)) as IGetInput; instructions = new CharacterInstructions(); instructionsBuffer = new LinkedList<CharacterInstructions>(); for(int i = 0; i < inputBufferLength; i++) { instructionsBuffer.AddFirst(new CharacterInstructions()); } grounded = false; stunned = false; rigidbody.gravityScale = gravityScale; }
void Update() { //flip the character's x-scale to face left or right transform.localScale = new Vector3(facingRight ? startXScale : -startXScale, transform.localScale.y, transform.localScale.z); //fetch this frame's input from the input component //instructions.Clear(); //inputComponent.GetInput(ref instructions); CharacterInstructions thisFrameInstructions = instructionsBuffer.Last.Value; instructionsBuffer.RemoveLast(); thisFrameInstructions.Clear(); inputComponent.GetInput(ref thisFrameInstructions); instructionsBuffer.AddFirst(thisFrameInstructions); bool actionFound = false; foreach(CharacterInstructions i in instructionsBuffer) { if (i.actedOn) { break; } else { if (i.actionInstructions != CharacterInstructions.ActionInstructions.none) { instructions = i; actionFound = true; break; } } } if (!actionFound) { instructions = instructionsBuffer.First.Value; } //send this frame's input to the current state object //if this frame's input doesn't cause the character to change state, HandleInput returns null ICharacterState nextState = currentState.HandleInput(instructions); //if nextState is not null, we are switching states this frame. Call OnExit on the old state and OnEnter on the new state if (nextState != null) { currentState.OnExit(); currentState = nextState; currentState.OnEnter(this); } //now that we know for certain what state we're in this frame, call this state's Update function currentState.Update(); if (Mathf.Abs(rigidbody.velocity.x) > 0.1f) { animator.SetBool(walkingHash, true); } else { animator.SetBool(walkingHash, false); } }