public SpeedContext(Mobile m, SpeedState speed, TimeSpan time, bool permanent, string name) { m_Mobile = m; m_Speed = speed; m_Name = name; m_Permanent = permanent; if (!permanent) { m_Timer = new SpeedTimer(this, time); m_Timer.Start(); } if (!m_Table.ContainsKey(m)) { m_Table.Add(m, new List <SpeedContext>()); } /*foreach (SpeedContext c in m_Table[m]) * { * if (c.Name == name) * RemoveContext(c); * }*/ RemoveContext(m, name); //If a new context with the same name as the old one gets added, the old will be replaced by the new one m_Table[m].Add(this); UpdateSpeed(m); }
public RQTalkMove(params object[] objs) : base() { position = (Vector3)objs[0]; stopRadius = (float)objs[1]; isForce = (bool)objs[2]; speedState = (SpeedState)objs[3]; }
public void ChangeTimeSpeed(SpeedState speedType) { if (speedType == m_speedState) { return; } m_speedState = speedType; switch (m_speedState) { case SpeedState.ZERO: m_currTimeScale = 0; break; case SpeedState.SLOW: m_currTimeScale = m_slowTimeScale; break; case SpeedState.NORMAL: m_currTimeScale = m_norTimeScale; break; case SpeedState.FAST: m_currTimeScale = m_fastTimeScale; break; } SetSpeedScale(m_currTimeScale); }
private SpeedState calculateSpeed(SpeedState speed) { switch (speed) { case SpeedState.Sprint: if (Entity.GetAttribute(AttribType.SprintSpeed) > 0) { return(SpeedState.Sprint); } else if (Entity.GetAttribute(AttribType.RunSpeed) > 0) { return(SpeedState.Run); } else { return(SpeedState.Walk); } case SpeedState.Run: if (Entity.GetAttribute(AttribType.RunSpeed) > 0) { return(SpeedState.Run); } else { return(SpeedState.Walk); } default: return(SpeedState.Walk); } }
public SingleAction(MonsterAction actionType, float execTime, SpeedState speed, Vector3 dirtion) { ActionType = actionType; ExecTime = execTime; Speed = speed; Dirtion = dirtion; }
void SpeedHintHandler() { switch (speed_state) { case SpeedState.acceleration: // Show acceleration hint. text.text = accelerate; // Goto deceleration hint after accelerating. if (is_accelerating && Time.time - start_t > 3f) { start_t = Time.time; speed_state = SpeedState.deceleration; } break; case SpeedState.deceleration: // Show deceleration hint. text.text = decelerate; // Go back to acceleration hint after decelerating. if (is_decelerating && Time.time - start_t > 3f) { speed_state = SpeedState.acceleration; tutorial_state = TutorialState.fire; } break; default: Debug.Log("Speed state Error!! Invalid speed state: " + speed_state.ToString()); break; } }
// Use this for initialization void Start() { rb = GetComponent <Rigidbody2D>(); messagePosted = false; state = SpeedState.SLOW; brakeTime = 0; lastFrame = Time.time; GameController.instance.GetAudioControl().SfxPlay(AudioControl.Sfx.slowdriving); }
public Request Req_FollowPath(Vector3[] path, bool isLoop, SpeedState state = SpeedState.Run) { if (Net != null && !Net.hasOwnerAuth && Entity != null && Entity.viewCmpt != null && Entity.viewCmpt.hasView) { Net.RPCServer(EPacketType.PT_NPC_RequestAiOp, (int)EReqType.FollowPath, path, isLoop, state); } return(Register(EReqType.FollowPath, path, isLoop, state)); }
private void TargetMode() { cameraState = CameraState.Target; speedState = SpeedState.Target; animator.SetBool(AnimatorConditionsPlayer.Running, false); if (OnTargetMode != null) { OnTargetMode(target); } }
public void KnockBack(Vector3 ob) { if (speedState != SpeedState.knockback) { knockBackObject = ob; knockback = knockBackForce; speedState = SpeedState.knockback; Debug.Log("got knocked"); } }
public void AddNetTransInfo(Vector3 pos, Vector3 rot, SpeedState speed, double controllerTime) { NetTranInfo netTransInfo = GetNetTransInfo(); netTransInfo.pos = pos; netTransInfo.rot = rot; netTransInfo.speed = speed; netTransInfo.contrllerTime = controllerTime; mNetTransInfos.Add(netTransInfo); }
public void Left(AccomplishMove callback, float time = 2.0f, SpeedState state = SpeedState.Walk) { Vector3 moveDirLocal = -Vector3.right; m_AutoMoveDir = Vector3.ProjectOnPlane(PETools.PEUtil.MainCamTransform.rotation * moveDirLocal, Vector3.up); m_CallBack = callback; m_AutoTime0 = Time.time; m_AutoTime1 = time; m_AutoSpeed = calculateSpeed(state); }
public RQFollowPath(params object[] objs) : base() { path = (Vector3[])objs[0]; isLoop = (bool)objs[1]; speedState = (SpeedState)objs[2]; if (path.Length != 0) { verifPos[0] = path[0]; verifPos[1] = path[path.Length - 1]; } }
public override void MoveTo(Vector3 targetPos, SpeedState state = SpeedState.Walk, bool avoid = true) { speed = state; m_MoveDestination = targetPos; if (m_MoveDestination != Vector3.zero) { m_MoveDirection = Vector3.zero; m_RotDirection = Vector3.zero; } }
public override void Deserialize(BinaryReader r) { r.ReadInt32(); position.x = r.ReadSingle(); position.y = r.ReadSingle(); position.z = r.ReadSingle(); stopRadius = r.ReadSingle(); isForce = r.ReadBoolean(); speedState = (SpeedState)r.ReadInt32(); }
private void NormalMode() { cState.ClearSprinting(); cameraState = CameraState.Normal; speedState = SpeedState.Walk; animator.SetBool(AnimatorConditionsPlayer.Running, false); target = null; if (OnNormalMode != null) { OnNormalMode(); } }
public override void Move(Vector3 dir, SpeedState state = SpeedState.Walk) { m_MoveDirection = dir; speed = state; if (dir != Vector3.zero) { m_MoveDestination = Vector3.zero; m_RotDirection = Vector3.zero; } }
public void MoveDirtion(Vector3 dir, AccomplishMove callback, float time = 2.0f, SpeedState state = SpeedState.Walk) { if (dir == Vector3.zero) { return; } m_AutoMoveDir = dir; m_CallBack = callback; m_AutoTime0 = Time.time; m_AutoTime1 = time; m_AutoSpeed = calculateSpeed(state); }
/// <summary> /// /// </summary> void UpdateMoveState() { if (ctrlType != ECtrlType.Mount || Entity.skEntity.IsSkillRunning()) { return; } if (m_Move == null) { return; } //if(PeInput.Get(PeInput.LogicFunction.InteractWithItem) && null != SelectItem_N.Instance && SelectItem_N.Instance.HaveOpItem()) //计算移动方向 Vector3 moveDirLocal = PeInput.GetAxisH() * Vector3.right + PeInput.GetAxisV() * Vector3.forward; m_MoveDir = Vector3.ProjectOnPlane(PETools.PEUtil.MainCamTransform.rotation * moveDirLocal, Vector3.up); //计算行走速度 if (PeInput.Get(PeInput.LogicFunction.SwitchWalkRun)) { m_MoveWalk = !m_MoveWalk; } SpeedState state = m_MoveWalk ? SpeedState.Walk : SpeedState.Run; if (PeInput.Get(PeInput.LogicFunction.Sprint) && Entity.GetAttribute(AttribType.SprintSpeed) > 0) { state = SpeedState.Sprint; } //移动 m_Move.Move(m_MoveDir.normalized, state); //跳跃 if ((m_SkillData.canSpace() || m_SkillData.canProunce()) && PeInput.Get(PeInput.LogicFunction.Jump)) { Jump(); } //左键攻击 if (m_SkillData.canAttack() && PeInput.Get(PeInput.LogicFunction.Attack)) { AttackL(); } //右键攻击:还需要定义右键攻击逻辑键 //if (PeInput.Get(PeInput.LogicFunction.Item_Use)) // AttackR(); }
/// <summary> /// Creates a new player object /// </summary> /// <param name="game"></param> public Player(Game game) { this.game = game; timer = new TimeSpan(0); curPosition = new Vector2(2, 352); Bounds = new BoundingRectangle(curPosition.X, curPosition.Y, 32, 45); moving_state = MovingState.Idle; prev_moving_state = MovingState.Idle; fighting_state = FightingState.Idle; speed_state = SpeedState.Normal; powerUpTimer = new TimeSpan(0); bomb = new Bomb(game); keyboard = Keyboard.GetState(); stamina = MAX_STAMINA; }
private void SprintMode() { cState.SetSprinting(); cameraState = CameraState.Sprint; speedState = SpeedState.Sprint; animator.SetBool(AnimatorConditionsPlayer.Running, true); target = null; if (SprintRoutine != null) { StopCoroutine(SprintRoutine); } SprintRoutine = Sprint(); StartCoroutine(SprintRoutine); if (OnSprintMode != null) { OnSprintMode(); } }
//public Vector3 GetPatrolPosition(Transform target) //{ // if (CheckSecond()) // { // m_LastPatrol = PEUtil.GetRandomPosition(Vector3.zero, PatrolRadiu, sndRadius); // } // return target.position + m_Anchor + m_LastPatrol; //} /* * 0 - 16 walk * 16 - 32 run * 32 - 64 sprint */ public SpeedState CalculateSpeedState(float sqrDistanceH) { SpeedState state = m_SpeedState; switch (state) { case SpeedState.None: m_SpeedState = SpeedState.Walk; break; case SpeedState.Walk: if (sqrDistanceH > maxWalkRadius * maxWalkRadius) { m_SpeedState = SpeedState.Run; } break; case SpeedState.Run: if (sqrDistanceH < minRunRadius * minRunRadius) { m_SpeedState = SpeedState.Walk; } if (sqrDistanceH > maxRunRadius * maxRunRadius) { m_SpeedState = SpeedState.Sprint; } break; case SpeedState.Sprint: if (sqrDistanceH < minSprintRadius * minSprintRadius) { m_SpeedState = SpeedState.Run; } break; default: m_SpeedState = SpeedState.Walk; break; } return(m_SpeedState); }
public void MoveToPosition(Vector3 pos, SpeedState speed = SpeedState.Walk) { foreach (PeEntity skEntity in m_Entities) { if (skEntity != null && !skEntity.IsDeath()) { Motion_Move mover = skEntity.GetComponent <Motion_Move>(); if (mover != null && Leader != null) { PeTrans tr1 = mover.GetComponent <PeTrans>(); PeTrans tr2 = Leader.GetComponent <PeTrans>(); if (tr1 != null && tr2 != null) { float r = 3 * Random.value * Mathf.Max(1.0f, Mathf.Max(tr1.radius, tr2.radius)); mover.MoveTo(pos + (tr1.position - tr2.position).normalized * r, speed); } } } } }
public void OnUserSpeedChange() { float delta = this._userSpeedVariable.Value - this._userOptimalSpeedVariable.Value; if (Mathf.Abs(delta) < this._goodSpeedDelta.Value) { this._speedState = SpeedState.GOOD; } else { if (delta < 0.0f) { this._speedState = SpeedState.SLOW; } else { this._speedState = SpeedState.FAST; } } }
void Update() { if (!firstKeyPressed && !messagePosted) { messagePosted = true; GameController.instance.GetUI().GetNotificationManager().ShowMessage("Press any key to start!", 2); } if (!firstKeyPressed && Input.anyKey) { firstKeyPressed = true; lastFrame = Time.time; if (Input.GetAxis("Vertical") >= 0) { state = SpeedState.FASTER; changeTime = Time.time; GameController.instance.GetAudioControl().SfxStop(AudioControl.Sfx.slowdriving); GameController.instance.GetAudioControl().SfxPlay(AudioControl.Sfx.faster); } } }
protected virtual void SetSpeedState() { if (!hold && rigidbodyMovable != null) { if (rigidbodyMovable.velocity.magnitude < 1) { speedState = SpeedState.None; } else if (currentVelocity == rigidbodyMovable.velocity.magnitude) { speedState = SpeedState.Same; } else if (currentVelocity > rigidbodyMovable.velocity.magnitude) { speedState = SpeedState.Deceleration; } else if (currentVelocity < rigidbodyMovable.velocity.magnitude) { speedState = SpeedState.Acceleration; } } }
public override void Deserialize(BinaryReader r) { int version = r.ReadInt32(); int length = r.ReadInt32(); path = new Vector3[length]; for (int i = 0; i < length; i++) { path[i].x = r.ReadSingle(); path[i].y = r.ReadSingle(); path[i].z = r.ReadSingle(); } isLoop = r.ReadBoolean(); if (version >= Version_002) { speedState = (SpeedState)r.ReadInt32(); } }
public AnswerBlock(Point Location, Color Color, Size Size, String Letter, int index, SpeedState State) { DrawMode = DrawMode.TopLeft; this.Size = Size; this.Location = Location; this.state = State; LetterLabel = new TextLabel() { Location = new Point(origin.X + (Size.Width / 2), origin.Y + (Size.Height / 6)), Color = Color.White, Font = new Font("Arial", 30, FontStyle.Bold) }; this.Color = Color; this.Letter = Letter; this.index = index; Buttons = new QuizButton[3]; PupolateButtons(); Disable(); }
public abstract void MoveTo(Vector3 targetPos, SpeedState state = SpeedState.Walk, bool avoid = true);
public abstract void Move(Vector3 dir, SpeedState state = SpeedState.Walk);