void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
void Start() { cameraShake = Camera.main.GetComponent <CameraShake>(); score = FindObjectOfType <Score>(); dead = FindObjectOfType <DeadScreen>(); gameManager = FindObjectOfType <GameManager>(); trail = GetComponentInChildren <GameObject>(); float RandomScale = 0.5f; transform.localScale = new Vector3(RandomScale, RandomScale, RandomScale); trail.transform.localScale = new Vector3(RandomScale, RandomScale, RandomScale); }
void Die() { int highscore = PlayerPrefs.GetInt("highscore", 0); bool show = false; if (scoreNow > highscore) { PlayerPrefs.SetInt("highscore", scoreNow); highscore = scoreNow; show = true; } DeadScreen deadScreen = gameObject.GetComponent <DeadScreen>(); deadScreen.ShowDeadScreen(highscore, show); GameObject.Find("Level").GetComponent <Generation>().enabled = false; anim.SetBool("Jump", false); Destroy(bounceScript); Destroy(this); }
static void Main(string[] args) { settings.AntialiasingLevel = 8; MainWindow = new RenderWindow(new VideoMode(WidthWindow, HeightWindow), "Story of one Cube", Styles.None, settings); MainWindow.SetVerticalSyncEnabled(true); MainWindow.Closed += MainWindow_Closed; MainWindow.KeyPressed += MainWindow_KeyPressed; MainWindow.KeyReleased += MainWindow_KeyReleased; MainWindow.MouseMoved += MainWindow_MouseMoved; MainWindow.MouseButtonPressed += MainWindow_MouseButtonPressed; MainWindow.SetVerticalSyncEnabled(true); CharacterMovesAnimation.Init(); DeadScreen.Init(MainWindow); WinScreen.Init(MainWindow); MainMenu.Init(MainWindow); Background.Init(MainWindow); Sounds.Init(); Musics.Init(); Inventory.Init(); Interface.Init(); LevelChoosePage.Init(MainWindow); levelNow = new Level1(); Background.Set(0); musicNow = Musics.MainMenu; musicNow.Play(); while (MainWindow.IsOpen) { MainWindow.Clear(); Background.Draw(MainWindow); if (Background.IsLoaded) { if (windowModeNow == WindowMode.Menu) { MainMenu.DrawAndUpdate(MainWindow); } if (windowModeNow == WindowMode.LevelsChoose) { LevelChoosePage.DrawAndUpdate(MainWindow); } if (windowModeNow == WindowMode.Game) { levelNow.Update(MainWindow); levelNow.Draw(MainWindow); } if (windowModeNow == WindowMode.Dead) { levelNow.Draw(MainWindow); DeadScreen.DrawAndUpdate(MainWindow); } if (windowModeNow == WindowMode.Pause) { levelNow.Draw(MainWindow); DeadScreen.DrawAndUpdate(MainWindow); } if (windowModeNow == WindowMode.Win) { levelNow.Draw(MainWindow); WinScreen.DrawAndUpdate(MainWindow); } MainWindow.DispatchEvents(); } MainWindow.Display(); } }
private static void MainWindow_MouseButtonPressed(object sender, MouseButtonEventArgs e) { switch (windowModeNow) { case WindowMode.Game: { levelNow.MainCharacter.gunNow.MainCharShoot(Program.levelNow.MainCharacter, new Point(e.X, e.Y)); return; } case WindowMode.Dead: { DeadScreen.Click(); return; } case WindowMode.Menu: { switch (MainMenuChooseNow) { case MainMenuChoose.Exit: { MainWindow_Closed(new object(), new EventArgs()); return; } case MainMenuChoose.Story: { windowModeNow = WindowMode.LevelsChoose; return; } case MainMenuChoose.Arena: { levelNow = new Arena(); levelNow = levelNow.RestartLevel(); levelNow.LoadStuff(); windowModeNow = WindowMode.Game; return; } } return; } case WindowMode.LevelsChoose: { LevelChoosePage.Click(); return; } case WindowMode.Pause: { DeadScreen.Click(); return; } case WindowMode.Win: { WinScreen.Click(); return; } } }
private void Awake() { instance = this; isEnd = true; }
public static void deathMainChar() { DeadScreen.Restart(); DeadScreen.LoadStuff(); Program.windowModeNow = Program.WindowMode.Dead; }