/** ************************ Controls and Draw all Game drawing activities */ public void Draw(Canvas c) { if (PauseGame) { pause.onDraw(c); return; } for (DrawableUI a : GameObjects) { a.Draw(c); } for (Action a : ActiveActions) { a.Draw(c); } for (Effect a : Effects) { a.Draw(c); } }
/** ************************ Runs right before Draw on every frame */ public void Update() { if (PauseGame) return; if (ActiveActions.isEmpty()) { for (DrawableUI a : GameObjects) { if (!a.Disabled) a.Update(); } } else for (Action a : ActiveActions) { if (a.IsActionFinished()) ActiveActions.remove(a); } if (!Effects.isEmpty()) { for (Effect a : Effects) { if (a.IsFinished()) Effects.remove(a); else a.Update(); } } }
/** ***************************** Touch logic */ @Override public boolean onTouchEvent(MotionEvent event) { synchronized (getHolder()) { if (PauseGame) { pause.OnTouch(event); return super.onTouchEvent(event); } CreatePlayerPath(event); if (ActiveActions.isEmpty()) { for (DrawableUI a : GameObjects) { if (!a.Disabled) a.Touched(event); } } else for (Action a : ActiveActions) { a.TouchAction(event); } } return super.onTouchEvent(event); }
/** ******************************** Runs when surface is destroyed. */ public void Destroy() { for (DrawableUI a : GameObjects) { a.Destroy(); } }