public void NewGame() { WorldData = JsonUtility.FromJson <WorldData>(WorldDataAsset.text); WorldData.Init(); _worldGenData = JsonUtility.FromJson <WorldGenData>(WorldGenAsset.text); Icosphere = Instantiate(IcospherePrefab, transform); Icosphere.Init(Subdivisions); StaticState = new StaticState(); StaticState.Init(_worldGenData.Radius, Icosphere, WorldData); _simulation = new SimTick(StaticState); _tempState = new TempState(StaticState); int height = 3; for (int i = 0; i < _simStates.Length; i++) { _simStates[i] = new SimState(); _simStates[i].Init(StaticState); } WorldGen.Generate(StaticState.Count, height, _worldGenData, _simStates[_curSimStateIndex], StaticState); _initialized = true; NewGameEvent?.Invoke(_simStates[_curSimStateIndex]); }
public override void OnEvent(NewGameEvent evnt) { List <GameObject> tempGos = new List <GameObject>(); tempGos.AddRange(GlobalReferences.FreeParts); tempGos.AddRange(GlobalReferences.AffectedParts); for (int i = tempGos.Count - 1; i >= 0; --i) { var entity = tempGos[i].GetComponent <NetworkBlockBehaviour>().entity; if (entity.IsAttached && entity.IsOwner) { BoltNetwork.Destroy(tempGos[i]); } } foreach (GameObject go in GlobalReferences.FrozenParts.Values) { Destroy(go); } GlobalReferences.FreeParts.Clear(); GlobalReferences.FrozenParts.Clear(); GlobalReferences.AffectedParts.Clear(); GlobalReferences.NumOfParts = 0; GlobalReferences.Parts.Clear(); GlobalReferences.PartIDLedger.Clear(); GlobalReferences.PartSpawner.SpawnMultiple(PartsHolder.NumParts); }
//============================================================ // Event Handlers: //============================================================ private void NewGameButtonClicked() { if (NewGameEvent != null) { NewGameEvent.Invoke(); } }
private void startANewGameToolStripMenuItem_Click(object sender, EventArgs e) { if (NewGameEvent != null) { CellPointer.Image = B16_Ex06_1.Properties.Resources.CoinYellow; NewGameEvent.Invoke(); } }
private void NewGame(object sender, NewGameEvent e) { if (GameOn) { bool res = _view.MakeQuestion("Вы хотите потерять данные и начать новую игру?"); if (res == true) { StartNewGame(); } else { return; } } else { StartNewGame(); } }
public static void NewGame() { if (BoltNetwork.IsRunning) { var newGame = NewGameEvent.Create(); newGame.Send(); return; } List <GameObject> tempGos = new List <GameObject>(); tempGos.AddRange(GlobalReferences.FreeParts); tempGos.AddRange(GlobalReferences.AffectedParts); foreach (GameObject go in GlobalReferences.FrozenParts.Values) { tempGos.Add(go); } for (int i = tempGos.Count - 1; i >= 0; --i) { if (tempGos[i].GetComponent <Part>().ID != -1) { GlobalReferences.DeletePart((int)tempGos[i].GetComponent <Part>().ID); } else { MonoBehaviour.Destroy(tempGos[i]); } } GlobalReferences.FreeParts.Clear(); GlobalReferences.FrozenParts.Clear(); GlobalReferences.AffectedParts.Clear(); GlobalReferences.NumOfParts = 0; GlobalReferences.Parts.Clear(); GlobalReferences.PartSpawner.SpawnMultiple(PartsHolder.NumParts); }
public void NewGame() { NewGameEvent?.Invoke(); }
public void NewGame() { Physics2D.autoSimulation = true; Scores = 0; NewGameEvent?.Invoke(); }
public override bool ProcessKeyboard(KeyboardInfo info) { if (info.KeysPressed.Contains(AsciiKey.Get(Keys.N))) { NewGameEvent?.Invoke(this, new EventArgs()); return(true); } if (!_game.Player.IsAlive) { return(false); } if (info.KeysPressed.Contains(AsciiKey.Get(Keys.T))) { PlayerTeleportEvent?.Invoke(this, new EventArgs()); return(true); } var keyHit = false; var direction = new Point(); if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Up)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.NumPad8)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.NumPad7)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.NumPad9))) { direction.Y = -1; keyHit = true; } if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Down)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.NumPad2)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.NumPad1)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.NumPad3))) { direction.Y += 1; keyHit = true; } if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Left)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.NumPad4)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.NumPad7)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.NumPad1))) { direction.X -= 1; keyHit = true; } if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Right)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.NumPad6)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.NumPad9)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.NumPad3))) { direction.X += 1; keyHit = true; } if (keyHit) { PlayerMoveEvent?.Invoke(this, new PlayerMoveEventArgs(direction)); } return(keyHit); }