public BombAddon(ICharacterAddon add) { cooldown=0; next = add; bombsource = Resources.Load("Bomb")as GameObject; player=GameObject.FindGameObjectWithTag("Player"); }
// Use this for initialization void Start() { GEM.registerListener(this); addon= new BaseAddon(); history= new CareTaker(); history.memento= new Memento(jumpForce,moveAmount,addon); }
/* return a new object*/ public ICharacterAddon CreateAddon(ICharacterAddon addons,AddonType addonType) { switch (addonType) { case AddonType.Bomb: return new BombAddon(addons); case AddonType.Speed: return new StatAddon(addons,"Speed",0.3f); default: return new BombAddon(addons); } }
public StatAddon(ICharacterAddon add,string type,float amount) { next = add; PlayerMovement controller=GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerMovement>(); switch (type){ case "Speed": controller.IncreaseSpeed(amount); break; case "Life": //controller.IncreaseSpeed(amount); break; case "Defense": //controller.IncreaseSpeed(amount); break; } }
public Memento(float jump, float speed ,ICharacterAddon add) { jumpForce = jump; playerSpeed = speed; addon=add; }
void Restore(Memento memento) { jumpForce=memento.jumpForce; moveAmount=memento.playerSpeed; addon = memento.addon; }