Last active
August 29, 2015 14:15
-
-
Save akirayu101/8a838e566338e3ee92e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 空state,不产生任何的效果 | |
class State(object): | |
def __init__(self): | |
pass | |
def enter(self, entity, param_table, state_maintain, global_maintain): | |
pass | |
def update(self, entity, param_table, state_maintain, global_maintain): | |
pass | |
def leave(self, entity, param_table, state_maintain, global_maintain): | |
state_maintain.clear() | |
def run(self, entity, param_table, state_maintain, global_maintain): | |
if state_maintain.get('init'): | |
# 已经跑过一次咯 | |
self.update(entity, param_table, state_maintain, global_maintain) | |
else: | |
self.enter(entity, param_table, state_maintain, global_maintain) | |
state_maintain['init'] = True | |
def stop(self, entity, param_table, state_maintain, global_maintain): | |
self.leave(entity, param_table, state_maintain, global_maintain) | |
class Accelerate_State(State): | |
def enter(self, entity, param_table, state_maintain, global_maintain): | |
state_maintain['orig_speed'] = entity.speed | |
entity.speed += param_table['speed'] | |
def level(self, entity, param_table, state_maintain, global_maintain): | |
entity.speed = state_maintain['orig_speed'] | |
state_maintain.clear() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment