private void ECommander_lost(object sender, EventArgs e) { Existence.getInstance().clear(); DyingExistence.getInstance().clear(); stageNum++; state = Def.State.EnemyInit; }
private void ECommander_won(object sender, EventArgs e) { Existence.getInstance().clear(); DyingExistence.getInstance().clear(); stageNum = 1; state = Def.State.GameOver; }
public void dying() { if (dyingAnimation.Count == 0) { canvas.Children.Remove(displayImage); DyingExistence.getInstance().remove(gmObj); return; } if (initialdeath) { imageState = 0; dyingCount = 0; initialdeath = false; displayImage.Source = dyingAnimation[imageState]; } if (dyingCount >= dyingCycle) { imageState++; if (!isDyingLoop && imageState >= dyingAnimation.Count) { canvas.Children.Remove(displayImage); DyingExistence.getInstance().remove(gmObj); if (canDispose != null) { canDispose(this, EventArgs.Empty); } return; } imageState++; dyingCount = 0; displayImage.Source = dyingAnimation[imageState]; } else { dyingCount++; } }
public GameScreen() { this.InitializeComponent(); exist = Existence.getInstance(); dying = DyingExistence.getInstance(); stage = Stage.getInstance(); //display = new Dictionary<GameObject, GameObjectImage>(); display = new ConcurrentDictionary <GameObject, GameObjectImage>(); playerDeathCount = 0; playerDeathImage = new Image(); playerRemainingImages = new List <Image>(); playerRemainNum = stage.remainingPlayerAttacker; //stage.clock += Stage_clock; TimerCallback callback = state => { Stage_clock(); }; timer = new Timer(callback, null, 0, Def.frameSpan); this.Loaded += delegate { this.keyholder.Focus(FocusState.Keyboard); this.keyholder.LostFocus += (s, e) => this.keyholder.Focus(FocusState.Keyboard); this.keyholder.IsTabStop = true; //Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TryResizeView(new Size { Width = Def.existWidth, Height = Def.existHeight }); }; }
//private void timerEvent(ThreadPoolTimer timer) private void timerEvent() { switch (state) { case Def.State.EnemyInit: state = Def.State.PlayerInit; eCommander = new EnemyCommander(stageNum); eCommander.teamDamage += ECommander_teamDamage; eCommander.lost += ECommander_lost; eCommander.won += ECommander_won; Wall.makeTemplateDefenceWall(); break; case Def.State.PlayerInit: state = Def.State.InGame; pCommander.organizeAttacker(); break; case Def.State.InGame: if (moveDic["left"]) { pCommander.moveLeft(); } if (moveDic["right"]) { pCommander.moveRight(); } oneShot = currentSpace && !previousSpace; previousSpace = currentSpace; if (oneShot) { pCommander.shot(); } if (eCommander != null) { eCommander.invade(pCommander.pAttackerCenter, (int)Def.ObjectID.EnemyID); } Existence.getInstance().moveAll(); break; case Def.State.BeShotDown: if (shotdownCount <= Def.shotdownTime) { shotdownCount++; } else { shotdownCount = 0; if (pCommander.remaining == 0) { Existence.getInstance().clear(); DyingExistence.getInstance().clear(); pCommander.initializePlayerValues(); state = Def.State.GameOver; } else { state = Def.State.PlayerInit; } } break; } }