private void OnCollisionStay2D(Collision2D collision) { if (collision.gameObject.layer == 8 && collision.gameObject.GetComponent <Tree_Controller>().burning_ == true) { current_Ground_State_ = GROUND_STATE.DEATH; current_Area_State_ = AREA_STATE.DEATH; return; } if (collision.collider.tag != "BLOCK") { current_Area_State_ = AREA_STATE.GROUND; } if (collision.collider.tag == "ZERO") { current_Level_ = LEVEL.ZERO; } else if (collision.collider.tag == "PASSABLE") { current_Level_ = LEVEL.PASSABLE; } else { current_Level_ = LEVEL.ELSE; } }
void Decide() { switch (current_Area_State_) { case AREA_STATE.AIR: if (Input.GetKey(jump_) && double_Jump_ == false && prev_Jump == false) { current_Air_State_ = AIR_STATE.DOUBLE_JUMP; return; } if (last_Velocity_.y > 0) { if (Input.GetKey(move_Left_) ^ Input.GetKey(move_Right_)) // Move left or right but not jump { if (Input.GetKey(move_Left_)) { current_Air_State_ = AIR_STATE.MOVE_LEFT_AIR; } else if (Input.GetKey(move_Right_)) { current_Air_State_ = AIR_STATE.MOVE_RIGHT_AIR; } return; } else { current_Air_State_ = AIR_STATE.RISE; } } else { if (Input.GetKey(move_Left_) ^ Input.GetKey(move_Right_)) // Move left or right but not jump { if (Input.GetKey(move_Left_)) { current_Air_State_ = AIR_STATE.FALL_LEFT; } else { current_Air_State_ = AIR_STATE.FALL_RIGHT; } return; } else { current_Air_State_ = AIR_STATE.FALL; } } return; case AREA_STATE.GROUND: if (Input.GetKey(jump_) && prev_Jump == false) { if (Input.GetKey(move_Left_) ^ Input.GetKey(move_Right_)) { if (Input.GetKey(move_Left_)) { current_Ground_State_ = GROUND_STATE.JUMP_LEFT_ENTER; } else if (Input.GetKey(move_Right_)) { current_Ground_State_ = GROUND_STATE.JUMP_RIGHT_ENTER; } } else { current_Ground_State_ = GROUND_STATE.JUMP_ENTER; } return; } else if (Input.GetKey(drop_) && drop_Cooldown_ == 0 && current_Level_ == LEVEL.PASSABLE) { if (Input.GetKey(move_Left_) ^ Input.GetKey(move_Right_)) { if (Input.GetKey(move_Left_)) { current_Ground_State_ = GROUND_STATE.DROP_ENTER_LEFT; } else if (Input.GetKey(move_Right_)) { current_Ground_State_ = GROUND_STATE.DROP_ENTER_RIGHT; } } else { current_Ground_State_ = GROUND_STATE.DROP_ENTER; } return; } else { if (Input.GetKey(move_Left_) ^ Input.GetKey(move_Right_)) { if (Input.GetKey(move_Left_)) { current_Ground_State_ = GROUND_STATE.MOVE_LEFT_GROUND; } else if (Input.GetKey(move_Right_)) { current_Ground_State_ = GROUND_STATE.MOVE_RIGHT_GROUND; } return; } } current_Ground_State_ = GROUND_STATE.IDLE_GROUND; return; } current_Error_State_ = ERROR_STATE.ERROR; }