void StartDash(Vector3 direction) { dashDirection += direction; if (dashStart == 0) { dashStart = Utils.GetTimeMilli(); dashEnd = dashStart + singleDashDuration; CSDash msg = new CSDash(); msg.direction = new BVector3(); msg.direction.x = dashDirection.x; msg.direction.y = dashDirection.y; msg.direction.z = dashDirection.z; msg.duration = singleDashDuration; MSShare.func_SendMsg(msg); } else if ((dashEnd - dashStart) <= maxDashDuration) { dashEnd = Math.Min(dashEnd + singleDashDuration, dashStart + maxDashDuration); } }
void UpdatePosition() { var direction = new Vector3(0, 0, 0); // move directions if (MSShare.modControl.TryExecuteCommand(ModControl.Command.MOVE_FORWARD)) { // not dashing, then move if (dashEnd == 0) { direction += forward; } } if (MSShare.modControl.TryExecuteCommand(ModControl.Command.MOVE_BACKWARD)) { if (dashEnd == 0) { direction += back; } } if (MSShare.modControl.TryExecuteCommand(ModControl.Command.MOVE_LEFT)) { if (dashEnd == 0) { direction += left; } } if (MSShare.modControl.TryExecuteCommand(ModControl.Command.MOVE_RIGHT)) { if (dashEnd == 0) { direction += right; } } // dash directions if (MSShare.modControl.TryExecuteCommand(ModControl.Command.DASH_FORWARD)) { direction = new Vector3(0, 0, 0); StartDash(forward); } if (MSShare.modControl.TryExecuteCommand(ModControl.Command.DASH_BACKWARD)) { direction = new Vector3(0, 0, 0); StartDash(back); } if (MSShare.modControl.TryExecuteCommand(ModControl.Command.DASH_LEFT)) { direction = new Vector3(0, 0, 0); StartDash(left); } if (MSShare.modControl.TryExecuteCommand(ModControl.Command.DASH_RIGHT)) { direction = new Vector3(0, 0, 0); StartDash(right); } if (direction.x != 0.0f || direction.y != 0.0f || direction.z != 0.0f) { if (lastErrorCode != -1) { go.transform.Translate(direction * moveSpeed * Time.deltaTime); } MSShare.func_SendMsg(GetCSMove(direction)); } if (MSShare.modControl.TryExecuteCommand(ModControl.Command.JUMP)) { CSJump csjump = new CSJump(); csjump.playerId = MSShare.mainPlayerId; MSShare.func_SendMsg(csjump); StartJump(); } }