enum:
//移动枚举
public enum STEP
{
NONE = -1,
RUN = 0, //奔跑 游戏中
STOP, //停止 显示得分时
MISS, //失败 和怪物解除
NUM,
};
Update:
//各个状态的执行
//位置
switch (this.step)
{
case STEP.RUN:
{
//速度
if (this.is_running)
{
this.run_speed += OwnPlayerControl.run_speed_add * Time.deltaTime;
}
else
{
//减速
}
this.run_speed = Mathf.Clamp(this.run_speed, 0.0f, RUN_SPEED_MAX);
//应用于本rigidbody的velocity
Vector3 new_velocity = this.GetComponent<Rigidbody>().velocity;
new_velocity.x = run_speed;
//y坐标速度不变
if (new_velocity.y > 0.0f)
{
new_velocity.y = 0.0f;
}
//应用new_velocity
this.GetComponent<Rigidbody>().velocity = new_velocity;//Vector3
//按W键快速前进 用于调试
if (Input.GetKeyDown(KeyCode.W))
{
Vector3 new_position = this.transform.position;
new_position.x += 100*OwnFloorControl.WIDTH * OwnFloorControl.MODEL_NUM;
this.transform.position = new_position;
}
//按space空格跳跃 用于调试
if (Input.GetKeyDown(KeyCode.Space))
{
Vector3 new_position = this.transform.position;
new_position.y += JUMP_HEIGHT;
this.transform.position = new_position;
}
}
break;