コード例 #1
0
 public static void DestroyGwen()
 {
     //The canvases dispose of all of their children.
     sMenuCanvas?.Dispose();
     sGameCanvas?.Dispose();
     GameUi?.Dispose();
     GwenInitialized = false;
 }
コード例 #2
0
 void Awake()
 {
     if (PlayerPrefs.GetInt("HasStarted") == 1)
     {
         StartUi.SetActive(false);
         GameUi.SetActive(true);
         Time.timeScale = 1f;
     }
 }
コード例 #3
0
    public void CheckScore()
    {
        GameObject mygameobject = new GameObject();
        GameUi     gameui       = mygameobject.AddComponent <GameUi>();

        gameui.ScoreText = gameui.GetComponent <UnityEngine.UI.Text>();
        GameUi.Score     = 0;
        gameui.IncrementScore();
        Assert.AreEqual(GameUi.Score, 1);
    }
コード例 #4
0
 public StateTitle(TitleUi title, GameUi ui)
 {
     ui.gameObject.SetActive(false);
     Entered += (sender, arg) => title.ShowTitle(() =>
     {
         StateMachine.ChangeState(GameStates.Game);
         ui.gameObject.SetActive(true);
         ui.GetComponent <CanvasGroup>().DOFade(1, 0.3f);
     });
 }
コード例 #5
0
    void Start()
    {
        InitAudio();
        GameObject gameUiObject = GameObject.Find("GameUi");

        if (gameUiObject != null)
        {
            gameUi = gameUiObject.GetComponent <GameUi>();
        }
        InfectTree();
        InvokeRepeating("InfectTree", infectTreeAfter, infectTreeAfter);
    }
コード例 #6
0
 //Start method is used to initialize all the variables
 //It is unity default method which will be called at start for one time in game lifecycle
 void Start()
 {
     isGameStarted   = false;
     isflashdestoyed = false;
     MissingTime     = 5f;
     WaitForFlashes  = 3f;
     CountFlashes    = 0;
     index           = Random.Range(0, Size);
     GameUiClass     = GameObject.Find("GameController").GetComponent <GameUi> (); //Getting instance of class gameui to used later
     prefabflash     = new GameObject();
     AddItems();                                                                   //calling add items which add the items is list
 }
コード例 #7
0
 void Start()
 {
     if (self)
     {
         Destroy(this);
     }
     else
     {
         self = this;
     }
     FindObjectOfType <PlayerCar>().OnDeath += OnGameOver;
 }
コード例 #8
0
        public static void DestroyGwen()
        {
            //The canvases dispose of all of their children.
            sMenuCanvas?.Dispose();
            sGameCanvas?.Dispose();
            GameUi?.Dispose();

            // Destroy our target UI as well! Above code does NOT appear to clear this properly.
            if (Globals.Me != null)
            {
                Globals.Me.ClearTarget();
                Globals.Me.TargetBox?.Dispose();
                Globals.Me.TargetBox = null;
            }

            GwenInitialized = false;
        }
コード例 #9
0
    void Start()
    {
        rb = GetComponent <Rigidbody>();
        rb.freezeRotation = true;

        GameObject gameUiObject = GameObject.Find("GameUi");

        if (gameUiObject != null)
        {
            gameUi = gameUiObject.GetComponent <GameUi>();
            gameUi.UpdateMaxLoads(maxLoads);
            gameUi.UpdateWaterLoads(waterLoads);
            gameUi.UpdateAcidLoads(acidLoads);
        }

        InitAudio();
    }
コード例 #10
0
        //Actual Drawing Function
        public static void DrawGui()
        {
            if (!GwenInitialized)
            {
                InitGwen();
            }

            ErrorMsgHandler.Update();
            sGameCanvas.RestrictToParent = false;
            if (Globals.GameState == GameStates.Menu)
            {
                MenuUi.Draw();
            }
            else if (Globals.GameState == GameStates.InGame &&
                     ((!Interface.GameUi?.EscapeMenu?.IsHidden ?? true) || !HideUi))
            {
                GameUi.Draw();
            }
        }
コード例 #11
0
        public void AddGameObjects()
        {
            var mainMenu          = _mainMenuCreator.CreateMenu();
            var classSelectorMenu = _classSelectorMenuCreator.CreateMenu();

            var gameStats = new GameStats();
            var gameGrid  = new GameGrid();
            var gameUi    = new GameUi(gameStats, gameGrid);

            MainWindow.GameViewCanvas.Children.Add(mainMenu);
            MainWindow.GameViewCanvas.Children.Add(classSelectorMenu);
            MainWindow.GameViewCanvas.Children.Add(gameUi);

            MainWindow.MainMenu          = mainMenu;
            MainWindow.ClassSelectorMenu = classSelectorMenu;
            MainWindow.GameUi            = gameUi;
            MainWindow.GameStats         = gameStats;
            MainWindow.GameGrid          = gameGrid;
        }
コード例 #12
0
    // Start is called before the first frame update
    void Start()
    {
        waterLevelDefaultPosition = waterLevel.transform.localPosition;
        GameObject treesObject = GameObject.Find("Trees");

        if (treesObject != null)
        {
            trees = treesObject.GetComponent <Trees>();
        }

        GameObject gameUiObject = GameObject.Find("GameUi");

        if (gameUiObject != null)
        {
            gameUi = gameUiObject.GetComponent <GameUi>();
            gameUi.UpdateShrineMaxLoads(loadsToActivate);
        }

        InitAudio();
    }
コード例 #13
0
    public void Init()
    {
        if (Started)
        {
            return;
        }
        Started             = true;
        Events              = new Dictionary <string, List <Action> >();
        CurrentActiveLevels = new List <Level>();
        Pools = new Dictionary <string, PoolObjects>();

        if (PoolObjects != null)
        {
            foreach (var pool in PoolObjects)
            {
                RegisterPool(pool);
            }
        }

        GameUi = Instantiate <GameUi>(GameUi);
    }
コード例 #14
0
ファイル: Game.cs プロジェクト: bVidot/AnkamaGameJam
    // Use this for initialization
    void Start()
    {
        currentHouse   = PlayerManager.Instance.houseSelected;
        door           = FindObjectOfType <Door>();
        player         = FindObjectOfType <Player>();
        guitarHeroGame = GetComponent <GuitarHero>();
        fightGame      = GetComponent <Fight>();

        gameUi = FindObjectOfType <GameUi>();

        currentPlayerCash = 0;
        maxImpatience     = currentHouse.impatience;
        impatience        = 0;

        //ADRIEN
        conv = Resources.Load("Sounds/Conversation" + Random.Range(1, 3)) as AudioClip;

        switch (currentHouse.doorType)
        {
        case House.DoorType.Level1:
            doorType = Resources.Load("Doors/PoorDoor") as DoorType;
            break;

        case House.DoorType.Level2:
            doorType = Resources.Load("Doors/BasicDoor") as DoorType;
            break;

        case House.DoorType.Level3:
            doorType = Resources.Load("Doors/RichDoor") as DoorType;
            break;
        }
        clientCash = currentHouse.budget;
        fightGame.minimumFightJauge = doorType.strenght;
        fightGame.increaseValue     = PlayerManager.Instance.currentShoes.resistance;

        saleState = SaleState.Talk;
        door.SetTrigger("DoorLose");
        guitarHeroGame.StartSale();
    }
コード例 #15
0
ファイル: GameUi.cs プロジェクト: Skuuully/Gravity
    private void Awake()
    {
        if (_instance != null)
        {
            Debug.LogWarning("Creating 2nd instance of GameUi singleton");
            Destroy(this);
        }
        _instance = this;

        foreach (Transform t in transform)
        {
            if (t.gameObject.name == "InteractableText")
            {
                _interactableText = t.gameObject.GetComponent <TMP_Text>();
            }
        }

        if (_interactableText == null)
        {
            Debug.LogWarning("Unable to set up the interactable text");
        }
    }
コード例 #16
0
    public override void OnInspectorGUI()
    {
        if (_myScript == null)
            _myScript = (GameUi)target;

        if (_redStyle == null)
            _redStyle = new GUIStyle();
        _redStyle.normal.textColor = Color.red;

        GUILayout.Space(10);
        if (GUILayout.Button("Refresh UI", GUILayout.Width(UiUtils.GetPercent(Screen.width, 90)), GUILayout.Height(50)))
        {
            _myScript.RefreshCameraTransform();
            _myScript.RefreshUi(true);
        }

        GUILayout.Space(10);

        EditorGUILayout.BeginVertical("box");
        GUILayout.Space(5);

        GUILayout.Label("Resolution");
        GUILayout.Space(5);

        _myScript.InspectorScreenWidth = EditorGUILayout.IntField("Width :", _myScript.InspectorScreenWidth);
        _myScript.InspectorScreenHeight = EditorGUILayout.IntField("Height :", _myScript.InspectorScreenHeight);

        if (string.IsNullOrEmpty(Error) == false)
        {
            GUILayout.Space(10);
            GUILayout.Label(Error, _redStyle);
            GUILayout.Space(10);
        }
        _myScript.InspectorScreenName = EditorGUILayout.TextField("Name :", _myScript.InspectorScreenName);

        GUILayout.Space(10);
        if (GUILayout.Button("Add View Size"))
        {
            AddScreenResolution(_myScript.InspectorScreenName, _myScript.InspectorScreenWidth, _myScript.InspectorScreenHeight);
        }

        _myScript.InspectorControllerType = (ControllerType)EditorGUILayout.EnumPopup("Controller Type:", _myScript.InspectorControllerType);

        GUILayout.Space(10);
        if (GUILayout.Button("Populate"))
        {
            if (AndroidViewType == AndroidViewType.Landscape)
            {
                AddScreenResolution("4K UHD (Landscape)", 3840, 2160);
                AddScreenResolution("WQXGA + (Landscape)", 3200, 1800);
                AddScreenResolution("iPad Pro (Landscape)", 2732, 2048);
                AddScreenResolution("Samsung S6 (Landscape)", 2560, 1440);
                AddScreenResolution("Full HD (Landscape)", 1920, 1080);

                AddScreenResolution("HD (222:125) (Landscape)", 1776, 1000);

                AddScreenResolution("900p HD+ (Landscape)", 1600, 900);

                AddScreenResolution("HD ready (683:384) (Landscape)", 1366, 768);
                AddScreenResolution("iPhone 6 (667:375) (Landscape)", 1334, 750);

                AddScreenResolution("WXGA-H (Landscape)", 1280, 720);

                AddScreenResolution("iPhone 5 (71:40) (Landscape)", 1136, 640);
                AddScreenResolution("WSVGA (128:75) (Landscape)", 1024, 600);
                AddScreenResolution("PV (30:17) (Landscape)", 960, 544);
                AddScreenResolution("PV (53:30) (Landscape)", 848, 480);

                AddScreenResolution("IPhone 6 s(Landscape)", 667, 375);

                AddScreenResolution("nHD (Landscape)", 640, 360);

                AddScreenResolution("iPhone 5 s (71:40)(Landscape)", 568, 320);

                AddScreenResolution("Low (80:39) (Landscape)", 480, 234);
            }
        }

        GUILayout.Space(10);

        AndroidViewType = (AndroidViewType)EditorGUILayout.EnumPopup("Android View Type:", AndroidViewType);

        GUILayout.Space(10);

        foreach (var viewSize in EditorUtils.ViewSizes)
        {
            EditorGUILayout.BeginHorizontal();

            GUILayout.Label(viewSize.Name);
            GUILayout.Label(viewSize.Width.ToString());
            GUILayout.Label(viewSize.Height.ToString());

            if (GUILayout.Button("Set VS"))
            {
                EditorUtils.SetSizeToScreen(GameViewSizeGroupType.Android, viewSize.Width, viewSize.Height);

                _myScript.InspectorScreenWidth = viewSize.Width;
                _myScript.InspectorScreenHeight = viewSize.Height;
                _myScript.InspectorScreenName = viewSize.Name;

                _myScript.RefreshCameraTransform();
                _myScript.RefreshUi(true);
            }

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);
        }

        GUILayout.Space(5);
        EditorGUILayout.EndVertical();
    }
コード例 #17
0
        private void InitUi()
        {
            GameUi gameUi = new GameUi(this);

            gameUi.InitGameUi();
        }
コード例 #18
0
        static string TestGame(Game gameInput)
        {
            GameLogic gameLogic = new GameLogic();

            bool isWinner   = false;
            int  gameStatus = 0;
            var  game       = gameInput;

            do
            {
                var userYint = -1;
                Console.Clear();
                if (gameStatus == game.GetBoard().Length)
                {
                    isWinner = true;
                }

                do
                {
                    if (!game._playerZeroMovesNext)
                    {
                        Console.WriteLine("player 1 turn!");
                    }
                    else
                    {
                        Console.WriteLine("player 2 turn!");
                    }

                    Console.WriteLine("Give me Y");
                    GameUi.PrintBoard(game);

                    Console.Write(">>");
                    var y = Console.ReadLine();
                    Console.Clear();


                    if (!int.TryParse(y, out userYint))
                    {
                        Console.WriteLine($" {y} is not a number. Please Choose a number!");
                        Console.WriteLine("Try again!");
                        Console.WriteLine("Give me Y");
                        GameUi.PrintBoard(game);
                        y        = Console.ReadLine();
                        userYint = int.Parse(y);
                    }

                    if (int.Parse(y) > game.BoardWidth)
                    {
                        Console.WriteLine($" {y} you are trying to go out of the border!");
                        Console.WriteLine("Try again!");
                        Console.WriteLine("Give me Y");
                        GameUi.PrintBoard(game);
                        y        = Console.ReadLine();
                        userYint = int.Parse(y);
                    }

                    if (game.IsColumnFull(int.Parse(y)))
                    {
                        Console.WriteLine($" {y} Column is full, choose another one!s");
                        Console.WriteLine("Try again!");
                        Console.WriteLine("Give me Y");
                        GameUi.PrintBoard(game);
                        y        = Console.ReadLine();
                        userYint = int.Parse(y);
                    }
                } while (userYint < 0);


                gameStatus++;

                game.Move(userYint);
                saveGame(game);
            } while (!isWinner);

            return("GAME OVER");
        }
コード例 #19
0
ファイル: StateResult.cs プロジェクト: kefniark/ld40-gamejam
 public StateResult(ResultUi result, GameUi ui)
 {
     Result   = result;
     UI       = ui;
     Entered += StateResult_Entered;
 }
コード例 #20
0
 private void Start()
 {
     StartCoroutine(GameUi.FadeOutRoutine(Fade, 0.5f));
 }
コード例 #21
0
 public void pause()
 {
     Time.timeScale = 0f;
     GameUi.SetActive(false);
     pauseui.SetActive(true);
 }
コード例 #22
0
 private void Awake()
 {
     Instance = this;
     GameUi   = GetComponent <GameUi>();
 }
コード例 #23
0
        public static void Main()
        {
            GameUi gameConsoleUi = new GameUi();

            gameConsoleUi.Run();
        }
コード例 #24
0
 void Awake()
 {
     Instance = this;
 }
コード例 #25
0
ファイル: GameUi.cs プロジェクト: neilfarrier/2DGames
 void Awake()
 {
     instance = this;
     gameOverPanel.SetActive(false);
 }
コード例 #26
0
ファイル: GameUi.cs プロジェクト: kjuik/miniGameChess
 private void Awake()
 {
     Instance = this;
 }
コード例 #27
0
        public void StartGame()
        {
            bool restartGame = true;

            while (restartGame)
            {
                GameUi gameUi = new GameUi();
                gameUi.LaunchMenu();
                GameBoard       gameBoard = new GameBoard((int)gameUi.MatrixSize);
                Point           userCordInput;
                GameUi.ePlayers currentPlayer = GameUi.ePlayers.FirstPlayer;
                bool            continueGame = true;
                int             gameItrator = 0;
                int             thereNoOptionsForXPlayers = 0;
                List <Point>    moveOptions = null;
                bool            isLastTurnWasOk = true;
                int             player1Score = 0, player2Score = 0;
                while (continueGame)
                {
                    if (gameBoard.IsThereOptionsToPlay(currentPlayer, ref moveOptions))
                    {
                        if ((gameUi.GameMode == GameUi.eGameMode.PVc && currentPlayer == GameUi.ePlayers.SecondPlayer) || gameUi.GameMode == GameUi.eGameMode.CVc)
                        {
                            userCordInput = m_PcAi.AiTurn(gameBoard, currentPlayer);
                        }
                        else
                        {
                            gameBoard.CalcPlayersScore(out player1Score, out player2Score);
                            userCordInput = gameUi.NextTurn(gameBoard.CreatePrintingBoard(moveOptions), currentPlayer, isLastTurnWasOk, player1Score, player2Score);
                        }

                        if (gameBoard.TryAddDiscToLocation(userCordInput.x, userCordInput.y, (Disc.eColors)currentPlayer))
                        {
                            gameItrator++;
                            isLastTurnWasOk = true;
                        }
                        else
                        {
                            isLastTurnWasOk = false;
                        }

                        thereNoOptionsForXPlayers = 0;
                    }
                    else
                    {
                        thereNoOptionsForXPlayers++;
                        gameItrator++;
                    }

                    if (gameItrator % 2 == 0)
                    {
                        currentPlayer = GameUi.ePlayers.FirstPlayer;
                    }
                    else
                    {
                        currentPlayer = GameUi.ePlayers.SecondPlayer;
                    }

                    continueGame = thereNoOptionsForXPlayers < 2;
                }

                gameBoard.CalcPlayersScore(out player1Score, out player2Score);
                gameUi.GameOver(gameBoard.CreatePrintingBoard(moveOptions), player1Score, player2Score, ref restartGame);
            }
        }
コード例 #28
0
 public void resume()
 {
     Time.timeScale = 1f;
     GameUi.SetActive(true);
     pauseui.SetActive(false);
 }
コード例 #29
0
ファイル: GameUi.cs プロジェクト: MichFrie/RTSConcepts
 void Awake()
 {
     instance = this;
 }
コード例 #30
0
        //Gwen Low Level Functions
        public static void InitGwen()
        {
            //TODO: Make it easier to modify skin.
            if (Skin == null)
            {
                Skin = new TexturedBase(
                    GwenRenderer,
                    Globals.ContentManager.GetTexture(GameContentManager.TextureType.Gui, "defaultskin.png")
                    )
                {
                    DefaultFont = Graphics.UIFont
                };
            }

            MenuUi?.Dispose();

            GameUi?.Dispose();

            // Create a Canvas (it's root, on which all other GWEN controls are created)
            sMenuCanvas = new Canvas(Skin, "MainMenu")
            {
                Scale = 1f //(GameGraphics.Renderer.GetScreenWidth()/1920f);
            };

            sMenuCanvas.SetSize(
                (int)(Graphics.Renderer.GetScreenWidth() / sMenuCanvas.Scale),
                (int)(Graphics.Renderer.GetScreenHeight() / sMenuCanvas.Scale)
                );

            sMenuCanvas.ShouldDrawBackground = false;
            sMenuCanvas.BackgroundColor      = Color.FromArgb(255, 150, 170, 170);
            sMenuCanvas.KeyboardInputEnabled = true;

            // Create the game Canvas (it's root, on which all other GWEN controls are created)
            sGameCanvas = new Canvas(Skin, "InGame");

            //_gameCanvas.Scale = (GameGraphics.Renderer.GetScreenWidth() / 1920f);
            sGameCanvas.SetSize(
                (int)(Graphics.Renderer.GetScreenWidth() / sGameCanvas.Scale),
                (int)(Graphics.Renderer.GetScreenHeight() / sGameCanvas.Scale)
                );

            sGameCanvas.ShouldDrawBackground = false;
            sGameCanvas.BackgroundColor      = Color.FromArgb(255, 150, 170, 170);
            sGameCanvas.KeyboardInputEnabled = true;

            // Create GWEN input processor
            if (Globals.GameState == GameStates.Intro || Globals.GameState == GameStates.Menu)
            {
                GwenInput.Initialize(sMenuCanvas);
            }
            else
            {
                GwenInput.Initialize(sGameCanvas);
            }

            FocusElements         = new List <Framework.Gwen.Control.Base>();
            InputBlockingElements = new List <Framework.Gwen.Control.Base>();
            ErrorMsgHandler       = new ErrorHandler(sMenuCanvas, sGameCanvas);

            if (Globals.GameState == GameStates.Intro || Globals.GameState == GameStates.Menu)
            {
                MenuUi = new MenuGuiBase(sMenuCanvas);
                GameUi = null;
            }
            else
            {
                GameUi = new GameInterface(sGameCanvas);
                MenuUi = null;
            }

            Globals.OnLifecycleChangeState();

            GwenInitialized = true;
        }
コード例 #31
0
ファイル: Program.cs プロジェクト: elisabethabel/CSharp
        static string Connect4Game(Game game)
        {
            if (game.GameIsOver)
            {
                Console.Clear();
                GameUi.PrintBoard(game);
                Console.WriteLine(game.Message);
            }
            else
            {
                game.SaveGameToDb(_settings.IsHumanVsComputer, _settings.WinningCondition);
                do
                {
                    Console.Clear();
                    GameUi.PrintBoard(game);
                    int posX;
                    int posY;
                    var player = game.PlayerOneMoves ? game.PlayerOneName : game.PlayerTwoName;

                    if (_settings.IsHumanVsComputer && !game.PlayerOneMoves)
                    {
                        Console.WriteLine(player + "'s turn");
                        for (int i = 0; i < 3; i++)
                        {
                            Console.Write(".");
                            Thread.Sleep(600);
                        }
                        posX = game.ComputerMove(_settings.WinningCondition);
                        posY = game.FindYIndex(posX);
                    }
                    else
                    {
                        var correctXInt = false;
                        do
                        {
                            bool userCanceled;
                            (posX, userCanceled) = GetUserIntInput($"{player} enter X coordinate (1 - {_settings.BoardWidth})",
                                                                   1, _settings.BoardWidth);
                            posX -= 1;
                            posY  = game.FindYIndex(posX);
                            if (userCanceled)
                            {
                                correctXInt     = true;
                                game.GameIsOver = true;
                            }
                            else
                            {
                                if (posY != -1)
                                {
                                    correctXInt = true;
                                }
                                else
                                {
                                    Console.WriteLine(posX + 1 + " column is already full!");
                                }
                            }
                        } while (!correctXInt);
                    }
                    if (!game.GameIsOver)
                    {
                        game.Move(posY, posX);
                        CellState playerState = game.PlayerOneMoves ? CellState.G : CellState.R;
                        if (game.IsWinning(posY, posX, _settings.WinningCondition, playerState))
                        {
                            game.GameIsOver = true;
                            game.Message    = player + " has won the game!";
                        }
                        else if (game.TableIsFull())
                        {
                            game.GameIsOver = true;
                            game.Message    = "IT'S A TIE'!";
                        }
                    }
                    game.SaveGameToDb(_settings.IsHumanVsComputer, _settings.WinningCondition);
                } while (!game.GameIsOver);
                Console.Clear();
                GameUi.PrintBoard(game);
                Console.WriteLine(game.Message);
            }
            return(game.Message);
        }