Example #1
0
 public void Initialize()
 {
     instance = this;
     _openParameterId = Animator.StringToHash(_openTransitionName);
     OpenUI(_uiMain);
     _lastTouched = Time.time;
 }
        /// <summary>
        /// Create an instance of an UI element renderer.
        /// </summary>
        /// <param name="services">The list of registered services</param>
        public ElementRenderer(IServiceRegistry services)
        {
            Content = services.GetSafeServiceAs<IContentManager>();
            GraphicsDeviceService = services.GetSafeServiceAs<IGraphicsDeviceService>();

            UI = services.GetServiceAs<UISystem>();
            if (UI == null)
            {
                UI = new UISystem(services);
                var gameSystems = services.GetServiceAs<IGameSystemCollection>();
                gameSystems?.Add(UI);
            }
        }
 private static void term()
 {
     graphics.Dispose();
     UISystem.Terminate();
     client.Disconnect();
 }
 public virtual void Init(UISystem manager)
 {
     this.manager = manager;
 }
Example #5
0
 public void BackStartWindow()
 {
     UISystem.Get().HideAllWindow();
     UISystem.Get().ShowWindow("StartWindow");
 }
Example #6
0
    private void UIInitialize()
    {
        _uiSystem = FindObjectOfType <UISystem>();

        // 시간관련 초기화.
        _timeText = Instantiate(Resources.Load("GUI/TimeText") as GameObject).GetComponent <Text>();
        var timePosition = (new Vector3(Screen.width / 2, Screen.height * 0.95f, 0));

        timePosition.z = 0;
        _timeText.transform.position = timePosition;
        _uiSystem.AttachUI(_timeText.gameObject);

        _gameTimer = Instantiate(Resources.Load("Prefabs/GameTimer") as GameObject).GetComponent <GameTimer>();
        _gameTimer.SetText(_timeText);
        _gameTimer.OnTurnAutoEnd += OnTurnAutoEnd;

        // 플레이어 체력바 초기화.
        _playerHealthBar = Instantiate(Resources.Load("GUI/HorizontalBoxWithShadow") as GameObject);
        _playerHealthBar.transform.position = new Vector3(Screen.width * 0.2f, Screen.height * 0.88f, 0);
        _uiSystem.AttachUI(_playerHealthBar);

        _player.SetHealthBar(_playerHealthBar);

        // 적군 체력바 초기화.
        _enemyHealthBar = Instantiate(Resources.Load("GUI/HorizontalBoxWithShadow") as GameObject);
        _enemyHealthBar.transform.position = new Vector3(Screen.width * 0.8f, Screen.height * 0.88f, 0);
        _uiSystem.AttachUI(_enemyHealthBar);

        _enemy.SetHealthBar(_enemyHealthBar);

        // 플레이어 정보 초기화.
        _playerNameText = Instantiate(Resources.Load("GUI/PlayerNameText") as GameObject).GetComponent <Text>();
        _playerNameText.GetComponent <Text>().text = _dataContainer._playerId;
        _playerNameText.transform.position         = new Vector3(Screen.width * 0.128f, Screen.height * 0.95f, 0);
        _uiSystem.AttachUI(_playerNameText.gameObject);

        _playerText = Instantiate(Resources.Load("GUI/PlayerText") as GameObject).GetComponent <Text>();
        _uiSystem.AttachUI(_playerText.gameObject);

        _playerScoreText = Instantiate(Resources.Load("GUI/PlayerScoreText") as GameObject).GetComponent <Text>();
        _playerScoreText.GetComponent <Text>().text = "Wins : " + _dataContainer._playerWins.ToString() + "\n Loses : " + _dataContainer._playerLoses.ToString();
        _playerScoreText.transform.position         = new Vector3(Screen.width * 0.40f, Screen.height * 0.95f, 0);
        _uiSystem.AttachUI(_playerScoreText.gameObject);

        // 적군 정보 초기화.
        _enemyNameText = Instantiate(Resources.Load("GUI/EnemyNameText") as GameObject).GetComponent <Text>();
        _enemyNameText.GetComponent <Text>().text = _dataContainer._enemyId;
        _enemyNameText.transform.position         = new Vector3(Screen.width * 0.872f, Screen.height * 0.95f, 0);
        _uiSystem.AttachUI(_enemyNameText.gameObject);

        _enemyText = Instantiate(Resources.Load("GUI/PlayerText") as GameObject).GetComponent <Text>();
        _uiSystem.AttachUI(_enemyText.gameObject);

        _enemyScoreText = Instantiate(Resources.Load("GUI/EnemyScoreText") as GameObject).GetComponent <Text>();
        _enemyScoreText.GetComponent <Text>().text = _dataContainer._enemyWins.ToString() + " : Wins \n" + _dataContainer._enemyLoses.ToString() + " : Loses";
        _enemyScoreText.transform.position         = new Vector3(Screen.width * 0.60f, Screen.height * 0.95f, 0);
        _uiSystem.AttachUI(_enemyScoreText.gameObject);

        // 턴 텍스트 초기화.
        _turnText = Instantiate(Resources.Load("GUI/TurnText") as GameObject).GetComponent <Text>();
        _turnText.GetComponent <Text>().text = "PLAYER TURN";
        _turnText.transform.position         = new Vector3(Screen.width * 0.5f, Screen.height * 0f - 50f, 0);
        _uiSystem.AttachUI(_turnText.gameObject);

        // 트윈 초기화.
        DOTween.Init(false, true, LogBehaviour.ErrorsOnly);
    }
Example #7
0
        public HighScoreScene(int highscore)
        {
            m_highscore = highscore;

            this.Camera.SetViewFromViewport();
            Sce.PlayStation.HighLevel.UI.Panel dialog = new Panel();
            dialog.Width  = Director.Instance.GL.Context.GetViewport().Width;
            dialog.Height = Director.Instance.GL.Context.GetViewport().Height;

            ImageBox ib = new ImageBox();

            ib.Width  = dialog.Width;
            ib.Image  = new ImageAsset("/Application/images/title.png", false);
            ib.Height = dialog.Height;
            ib.SetPosition(0.0f, 0.0f);

            // editable text box parameters
            editTextBox.Name   = "editText";
            editTextBox.Text   = "You got a new high score, Enter your name (do not enter ',' or spaces)";
            editTextBox.Width  = 400;
            editTextBox.Height = 100;
            editTextBox.SetPosition(dialog.Width / 2.0f - editTextBox.Width / 2.0f, 220.0f);

            // retrieve highscores
            // retrieve highscore from server
            Client m_client = new Client(new string[1] {
                "Highscorers1234567890"
            });

            string[] highScorers     = new string[10];
            string[] sectionsMessage = m_client.responseMessage.Split(' ');
            highScorers = sectionsMessage[sectionsMessage.Length - 1].Split(',');

            string labelText = "Highscores" + Environment.NewLine +
                               highScorers[0] + ": " + highScorers[1] + Environment.NewLine +
                               highScorers[2] + ": " + highScorers[3] + Environment.NewLine +
                               highScorers[4] + ": " + highScorers[5] + Environment.NewLine +
                               highScorers[6] + ": " + highScorers[7] + Environment.NewLine +
                               highScorers[8] + ": " + highScorers[9] + Environment.NewLine;

            lb.Label highscores = new lb.Label();
            highscores.Name   = "highscores";
            highscores.Text   = labelText;
            highscores.Width  = 300;
            highscores.Height = 400;
            highscores.Alpha  = 0.8f;
            highscores.SetPosition(50, 220.0f);

            // when text box changed - fire event ( change player name and replace scene )
            editTextBox.TextChanged += OnTextEdit;

            dialog.AddChildLast(ib);
            dialog.AddChildLast(editTextBox);
            dialog.AddChildLast(highscores);

            m_uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
            m_uiScene.RootWidget.AddChildLast(dialog);
            m_uiScene.RootWidget.AddChildLast(highscores);

            UISystem.SetScene(m_uiScene);
            Scheduler.Instance.ScheduleUpdateForTarget(this, 0, false);
        }
Example #8
0
 public override void Update(float dt)
 {
     base.Update(dt);
     UISystem.Update(Touch.GetData(0));
 }
Example #9
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            SceneSystem.GraphicsCompositor = Content.Load <GraphicsCompositor>("GraphicsCompositor");

            StopOnFrameCount = -1;

            Scene = new Scene();

            UIRoot = new Entity("Root entity of camera UI")
            {
                new UIComponent()
            };
            UIComponent.IsFullScreen      = true;
            UIComponent.Resolution        = new Vector3(1000, 600, 500);
            UIComponent.ResolutionStretch = ResolutionStretch.FixedWidthFixedHeight;
            Scene.Entities.Add(UIRoot);

            UI = Services.GetService <UISystem>();
            if (UI == null)
            {
                UI = new UISystem(Services);
                Services.AddService(UI);
                GameSystems.Add(UI);
            }

            Camera = new Entity("Scene camera")
            {
                new CameraComponent {
                    Slot = SceneSystem.GraphicsCompositor.Cameras[0].ToSlotId()
                }
            };
            Camera.Transform.Position = new Vector3(0, 0, 1000);
            Scene.Entities.Add(Camera);

            // Default styles
            // Note: this is temporary and should be replaced with default template of UI elements
            textBlockTextColor = Color.LightGray;

            scrollingTextTextColor = Color.LightGray;

            var buttonPressedTexture    = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ButtonPressed);
            var buttonNotPressedTexture = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ButtonNotPressed);
            var buttonOverredTexture    = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ButtonOverred);

            buttonPressedImage = (SpriteFromTexture) new Sprite("Test button pressed design", buttonPressedTexture)
            {
                Borders = 8 * Vector4.One
            };
            buttonNotPressedImage = (SpriteFromTexture) new Sprite("Test button not pressed design", buttonNotPressedTexture)
            {
                Borders = 8 * Vector4.One
            };
            buttonMouseOverImage = (SpriteFromTexture) new Sprite("Test button overred design", buttonOverredTexture)
            {
                Borders = 8 * Vector4.One
            };

            var editActiveTexture   = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.EditTextActive);
            var editInactiveTexture = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.EditTextInactive);
            var editOverredTexture  = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.EditTextOverred);

            editTextTextColor      = Color.LightGray;
            editTextSelectionColor = Color.FromAbgr(0x623574FF);
            editTextCaretColor     = Color.FromAbgr(0xF0F0F0FF);
            editTextActiveImage    = (SpriteFromTexture) new Sprite("Test edit active design", editActiveTexture)
            {
                Borders = 12 * Vector4.One
            };
            editTextInactiveImage = (SpriteFromTexture) new Sprite("Test edit inactive design", editInactiveTexture)
            {
                Borders = 12 * Vector4.One
            };
            editTextMouseOverImage = (SpriteFromTexture) new Sprite("Test edit overred design", editOverredTexture)
            {
                Borders = 12 * Vector4.One
            };

            var toggleButtonChecked       = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ToggleButtonChecked);
            var toggleButtonUnchecked     = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ToggleButtonUnchecked);
            var toggleButtonIndeterminate = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ToggleButtonIndeterminate);

            toggleButtonCheckedImage = (SpriteFromTexture) new Sprite("Test toggle button checked design", toggleButtonChecked)
            {
                Borders = 8 * Vector4.One
            };
            toggleButtonUncheckedImage = (SpriteFromTexture) new Sprite("Test toggle button unchecked design", toggleButtonUnchecked)
            {
                Borders = 8 * Vector4.One
            };
            toggleButtonIndeterminateImage = (SpriteFromTexture) new Sprite("Test toggle button indeterminate design", toggleButtonIndeterminate)
            {
                Borders = 8 * Vector4.One
            };

            var designsTexture = TextureExtensions.FromFileData(GraphicsDevice, DefaultDesigns.Designs);

            sliderTrackBackgroundImage = (SpriteFromTexture) new Sprite("Default slider track background design", designsTexture)
            {
                Borders = 14 * Vector4.One, Region = new RectangleF(207, 3, 32, 32)
            };
            sliderTrackForegroundImage = (SpriteFromTexture) new Sprite("Default slider track foreground design", designsTexture)
            {
                Borders = 0 * Vector4.One, Region = new RectangleF(3, 37, 32, 32)
            };
            sliderThumbImage = (SpriteFromTexture) new Sprite("Default slider thumb design", designsTexture)
            {
                Borders = 4 * Vector4.One, Region = new RectangleF(37, 37, 16, 32)
            };
            sliderMouseOverThumbImage = (SpriteFromTexture) new Sprite("Default slider thumb overred design", designsTexture)
            {
                Borders = 4 * Vector4.One, Region = new RectangleF(71, 37, 16, 32)
            };
            sliderTickImage = (SpriteFromTexture) new Sprite("Default slider track foreground design", designsTexture)
            {
                Region = new RectangleF(245, 3, 3, 6)
            };
            sliderTickOffset           = 13f;
            sliderTrackStartingOffsets = new Vector2(3);

            Window.IsMouseVisible = true;

            SceneSystem.SceneInstance = new SceneInstance(Services, Scene);
        }
Example #10
0
        /// <summary>
        /// Checks for user input and executes corresponding command if input is present
        /// </summary>
        /// <param name="gameTime"></param>
        /// <returns>wether input/command is available</returns>
        public bool CheckInput(GameTime gameTime)
        {
            KeyboardState curKeyState = Keyboard.GetState();

            if (curKeyState == prevKeyState)
            {
                if (curKeyState == noKeyPressed)
                {
                    return(false);
                }

                keyHeldDownFor += gameTime.ElapsedGameTime.Milliseconds;

                if (keyHeldDownFor < keyHoldDelay)
                {
                    return(false);
                }
                else
                {
                    keyHeldDownFor = keyHoldDelay - heldDownInputDelay;
                }
            }
            else
            {
                prevKeyState   = curKeyState;
                keyHeldDownFor = 0;

                shift = curKeyState.IsKeyDown(Keys.LeftShift) || curKeyState.IsKeyDown(Keys.RightShift);
                ctrl  = curKeyState.IsKeyDown(Keys.LeftControl) || curKeyState.IsKeyDown(Keys.RightControl);
                alt   = curKeyState.IsKeyDown(Keys.LeftAlt);

                //Console.WriteLine("Mods (shift|ctrl|alt): " + shift + "|" + ctrl + "|" + alt);
            }

            if (curKeyState == noKeyPressed)
            {
                return(false);
            }

            CommandDomain curDomain = domainHistory.Peek();

            if (!keyToCommand.ContainsKey(curDomain))
            {
                Log.Error("Command domain not present: " + curDomain);
                return(false);
            }

            var keyBindings = keyToCommand[curDomain];

            if (keyBindings == null)
            {
                Log.Error("Key bindings missing for " + curDomain);
                return(false);
            }

            Command command = Command.None;

            //StringBuilder sb = new StringBuilder();

            //foreach (var keyPressed in curKeyState.GetPressedKeys())
            //{
            //    sb.AppendFormat("{0}, ", keyPressed);
            //}

            //Log.Message(sb.ToString());

            foreach (var keyPressed in curKeyState.GetPressedKeys())
            {
                if (keyPressed == Keys.F1)
                {
                    EntityManager.Dump();
                    continue;
                }

                // TODO: implement modifiers
                if (keyBindings.ContainsKey(keyPressed))
                {
                    command = keyBindings[keyPressed];
                    break;
                }
            }



            if (command == Command.None)
            {
                UISystem.Message("Unkown Command!");
                return(false);
            }

            //ExecuteCommand(command);
            curCommand = command;
            return(true);
        }
	void OnApplicationQuit() {
		if (m_UISystem != null)
		{
			if(UISystemDestroying != null) {
				UISystemDestroying();
			}

			m_SystemListener.Dispose();
			m_UISystem.Uninitialize();
			m_UISystem.Dispose();
			m_UISystem = null;
		}
	}
Example #12
0
 private void ShowSelectMap(GameObject go)
 {
     selectTab.transform.SetParent(go.transform, false);
     UISystem.Get().HideAllWindow();
     UISystem.Get().ShowWindow("SelectMapWindow");
 }
Example #13
0
 /// <summary>
 /// Create an instance of an UI element renderer.
 /// </summary>
 /// <param name="services">The list of registered services</param>
 public ElementRenderer(IServiceRegistry services)
 {
     Asset = services.GetSafeServiceAs<IAssetManager>();
     GraphicsDeviceService = services.GetSafeServiceAs<IGraphicsDeviceService>();
     UI = services.GetServiceAs<UISystem>();
 }
        /// <summary>
        /// Create an instance of the game test
        /// </summary>
        public UITestGameBase()
        {
            StopOnFrameCount = -1;

            graphicsCompositor = new SceneGraphicsCompositorLayers
            {
                Cameras = { Camera.Get<CameraComponent>() },
                Master =
                {
                    Renderers =
                    {
                        new ClearRenderFrameRenderer { Color = Color.Green, Name = "Clear frame" },

                        new SceneDelegateRenderer(SpecificDrawBeforeUI) { Name = "Delegate before main UI" },

                        new SceneCameraRenderer { Mode = SceneCameraRenderer },
                    }
                }
            };
            Scene = new Scene { Settings = { GraphicsCompositor = graphicsCompositor } };

            Scene.Entities.Add(UIRoot);
            Scene.Entities.Add(Camera);

            Camera.Transform.Position = new Vector3(0, 0, 1000);

            UIComponent.IsFullScreen = true;
            UIComponent.Resolution = new Vector3(1000, 500, 500);
            UIComponent.ResolutionStretch = ResolutionStretch.FixedWidthFixedHeight;

            UI = (UISystem)Services.GetService(typeof(UISystem));
            if (UI == null)
            {
                UI = new UISystem(Services);
                GameSystems.Add(UI);
            }
        }
	// Use this for initialization
	void Start () {
		if (SystemInfo.graphicsDeviceVersion.StartsWith("Direct3D 11")
				|| SystemInfo.operatingSystem.Contains("Mac"))
		{
			DeviceSupportsSharedTextures = true;
		}

		if (m_UISystem == null)
		{
			m_SystemListener = (SystemListenerFactoryFunc != null)? SystemListenerFactoryFunc(this.OnSystemReady) : new SystemListener(this.OnSystemReady);
			m_LogHandler = new UnityLogHandler();
			if (FileHandlerFactoryFunc != null)
			{
				m_FileHandler = FileHandlerFactoryFunc();
			}
			#if !UNITY_ANDROID || UNITY_EDITOR

			if (m_FileHandler == null)
			{
				Debug.LogWarning("Unable to create file handler using factory function! Falling back to default handler.");
				m_FileHandler = new UnityFileHandler();
			}
			#endif

			#if COHERENT_UNITY_STANDALONE || COHERENT_UNITY_UNSUPPORTED_PLATFORM
			SystemSettings settings = new SystemSettings() {
				HostDirectory = Path.Combine(Application.dataPath, this.HostDirectory),
				EnableProxy = this.EnableProxy,
				AllowCookies = this.AllowCookies,
				CookiesResource = "file:///" + Application.persistentDataPath + '/' + this.CookiesResource,
				CachePath = Path.Combine(Application.temporaryCachePath, this.CachePath),
				HTML5LocalStoragePath = Path.Combine(Application.temporaryCachePath, this.HTML5LocalStoragePath),
				ForceDisablePluginFullscreen = this.ForceDisablePluginFullscreen,
				DisableWebSecurity = this.DisableWebSecutiry,
				DebuggerPort = this.DebuggerPort,
			};
			int sdkVersion = Coherent.UI.Versioning.SDKVersion;
			#elif UNITY_IPHONE || UNITY_ANDROID
			SystemSettings settings = new SystemSettings() {
				iOS_UseURLCache = m_UseURLCache,
				iOS_URLMemoryCacheSize = (uint)m_MemoryCacheSize,
				iOS_URLDiskCacheSize = (uint)m_DiskCacheSize,
			};
			int sdkVersion = Coherent.UI.Mobile.Versioning.SDKVersion;
			#endif

			m_UISystem = CoherentUI_Native.InitializeUISystem(sdkVersion, Coherent.UI.License.COHERENT_KEY, settings, m_SystemListener, Severity.Info, m_LogHandler, m_FileHandler);
			if (m_UISystem == null)
			{
				throw new System.ApplicationException("UI System initialization failed!");
			}
			Debug.Log ("Coherent UI system initialized..");
			#if COHERENT_UNITY_STANDALONE
			CoherentUIViewRenderer.WakeRenderer();
			#endif
		}
		m_StartTime = Time.realtimeSinceStartup;

		DontDestroyOnLoad(this.gameObject);
	}
        public static void Initialize()
        {
            // Set up the graphics system
            graphics = new GraphicsContext();
            UISystem.Initialize(graphics);

            // Initiliaze a new scene
            scene = new Scene();

            // Build a play button
            Button play_btn = new Button();

            play_btn.X             = 50f;
            play_btn.Y             = 50f;
            play_btn.Width         = 50f;
            play_btn.Height        = 50f;
            play_btn.ButtonAction += HandlePlay_btnButtonAction;
            CustomButtonImageSettings play_btn_bg = new CustomButtonImageSettings();
            ImageAsset play_image = new ImageAsset("play.png");

            play_btn_bg.BackgroundNormalImage   = play_image;
            play_btn_bg.BackgroundDisabledImage = play_image;
            play_btn_bg.BackgroundPressedImage  = play_image;
            play_btn.CustomImage = play_btn_bg;
            play_btn.Style       = ButtonStyle.Custom;
            // Add the button to the scene
            scene.RootWidget.AddChildFirst(play_btn);


            // Build a Pause button
            Button pause_btn = new Button();

            pause_btn.X             = 120f;
            pause_btn.Y             = 50f;
            pause_btn.Width         = 50f;
            pause_btn.Height        = 50f;
            pause_btn.ButtonAction += HandlePause_btnButtonAction;
            CustomButtonImageSettings pause_btn_bg = new CustomButtonImageSettings();
            ImageAsset pause_image = new ImageAsset("pause.png");

            pause_btn_bg.BackgroundNormalImage   = pause_image;
            pause_btn_bg.BackgroundDisabledImage = pause_image;
            pause_btn_bg.BackgroundPressedImage  = pause_image;
            pause_btn.CustomImage = pause_btn_bg;
            pause_btn.Style       = ButtonStyle.Custom;
            // Add the button to the scene
            scene.RootWidget.AddChildFirst(pause_btn);


            // Build a Stop button
            Button stop_btn = new Button();

            stop_btn.X             = 190f;
            stop_btn.Y             = 50f;
            stop_btn.Width         = 50f;
            stop_btn.Height        = 50f;
            stop_btn.ButtonAction += HandleStop_btnButtonAction;
            CustomButtonImageSettings stop_btn_bg = new CustomButtonImageSettings();
            ImageAsset stop_image = new ImageAsset("stop.png");

            stop_btn_bg.BackgroundNormalImage   = stop_image;
            stop_btn_bg.BackgroundDisabledImage = stop_image;
            stop_btn_bg.BackgroundPressedImage  = stop_image;
            stop_btn.CustomImage = stop_btn_bg;
            stop_btn.Style       = ButtonStyle.Custom;
            // Add the button to the scene
            scene.RootWidget.AddChildFirst(stop_btn);

            // Set the scene
            UISystem.SetScene(scene, null);
        }
Example #17
0
 public static void Show()
 {
     instance = UISystem.InstantiateUI("DeleteWorldUI").GetComponent <DeleteWorldUI>();
 }
Example #18
0
 // 打开或关闭时,最后调用
 void Open_End(UISystem uiSystem)
 {
     uiSystem.gameObject.SetActive(true);
     ResetToFront(uiSystem);
 }
Example #19
0
 private void OnDestroy()
 {
     instance = null;
 }
Example #20
0
    // 打开界面,每次都调
    public GameObject Open(string uiName)
    {
        // 是否存在,交给存在的界面处理
        UISystem uiSystem = null;

        if (_UIListByName.TryGetValue(uiName, out uiSystem))
        {
            OnOpen(uiSystem);
            return(uiSystem.gameObject);
        }

        // 超过最大数量,析构最老的那个
        if (_UIList.Count >= UI_MAXCOUNT)
        {
            for (int i = 0; i < _UIList.Count; i++)
            {
                // 子界面堆栈中的界面不删除
                if (_UIList[i].autoDestroy && !_ChildUIStack.Contains(_UIList[i]))
                {
                    GameObject.Destroy(_UIList[i].gameObject);
                    break;
                }
            }
        }

        // 优先读取关联的assetbundle
        string abname = "_ab_ui_" + uiName.ToLower();

        if (ResourceManager.LoadAssetBundle(abname) != null)
        {
            LogUtil.GetInstance().WriteGame("UI loadAssetBundle :" + abname);
        }


        // 读prefab资源
        GameObject obj = ResourceManager.LoadPrefab(uiName);

        if (obj == null)
        {
            Debug.LogError("Can't Find UI:" + uiName);
            return(null);
        }

        obj.SetActive(false);
        GameObject go = GameObject.Instantiate <GameObject>(obj);

        obj.SetActive(true);
        go.name  = uiName;
        uiSystem = go.GetComponent <UISystem>();
        if (uiSystem == null)
        {
            Destroy(obj);
            Debug.LogError(uiName + "is not a UI!");
            return(null);
        }

        go.transform.SetParent(_Layers[(int)uiSystem.layer]);
        go.transform.localScale = Vector3.one;
        go.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
        go.GetComponent <RectTransform>().sizeDelta        = Vector2.zero;

        _UIList.Add(uiSystem);
        _UIListByName.Add(uiName, uiSystem);
        //uiSystem.gameObject.SetActive( false );
        OnOpen(uiSystem);
        return(go);
    }
Example #21
0
 public override void Draw()
 {
     base.Draw();
     UISystem.Render();
 }
Example #22
0
 public override void OnHide()
 {
     UISystem.Get().HideWindow("FriendMembersWindow");
 }
Example #23
0
 public override void Init(UISystem manager)
 {
     base.Init(manager);
 }
Example #24
0
    public override void OnUIEventHandler(EventId eventId, params object[] args)
    {
        if (eventId == EventId.OnMatchInit)
        {
            // room init
            matchId = (string)args [0];
            roomId  = (string)args [1];
            IList <NetMessage.UserData> userList = (IList <NetMessage.UserData>)args [2];
            IList <int> userIndexList            = (IList <int>)args [3];
            hostId    = (int)args [4];
            playerNum = (int)args[5];

            // format data
            int nPlayerCount = 0;
            for (int i = 0; i < userList.Count; ++i)
            {
                PlayerData pd = new PlayerData();
                if (pd.userId > 0)
                {
                    nPlayerCount++;
                }
                pd.Init(userList [i]);
                int index = userIndexList [i];
                allPlayers [index] = pd;
            }

            SetModelPage();
            SetPage();
            Flurry.Instance.FlurryPVPBattleMatchEvent("1", matchId, "0", nPlayerCount.ToString(), roomId);
        }
        else if (eventId == EventId.OnMatchUpdate)
        {
            // room update

            IList <NetMessage.UserData> userAddList = (IList <NetMessage.UserData>)args [0];
            IList <int>  userIndexAddList           = (IList <int>)args [1];
            IList <int>  userIndexDeleteList        = (IList <int>)args [2];
            IList <bool> userKickList       = (IList <bool>)args [3];
            IList <int>  userChangeFromList = (IList <int>)args [4];
            IList <int>  userChangeToList   = (IList <int>)args [5];
            if (args.Length == 7)
            {
                hostId = (int)args [6];
            }

            for (int i = 0; i < userIndexDeleteList.Count; ++i)
            {
                int index = userIndexDeleteList [i];

                if (allPlayers [index] != null && allPlayers [index].userId == LocalPlayer.Get().playerData.userId)
                {
                    // 自己退出,则关闭页面
                    UISystem.Instance.HideWindow("RoomWaitWindow");
                    UISystem.Instance.ShowWindow("CreateRoomWindow");

                    if (userKickList [i])
                    {
                        // 被踢
                        Tips.Make(Tips.TipsType.FlowUp, LanguageDataProvider.GetValue(909), 1.0f);
                    }
                }

                allPlayers [index] = null;
            }
            // add
            for (int i = 0; i < userAddList.Count; ++i)
            {
                PlayerData pd = new PlayerData();
                pd.Init(userAddList [i]);
                int index = userIndexAddList [i];
                allPlayers [index] = pd;
            }
            // change pos
            for (int i = 0; i < userChangeFromList.Count; ++i)
            {
                AudioManger.Get().PlayEffect("onOpen");
                int from = userChangeFromList [i];
                int to   = userChangeToList [i];

                PlayerData temp = allPlayers [from];
                allPlayers [from] = allPlayers [to];
                allPlayers [to]   = temp;
            }

            SetPage();
        }
        else if (eventId == EventId.OnMatchQuit)
        {
            // quit , 谁触发的quit,谁收到quit,
            NetMessage.ErrCode code = (NetMessage.ErrCode)args [0];
            if (code == NetMessage.ErrCode.EC_NotMaster)
            {
                Tips.Make(Tips.TipsType.FlowUp, LanguageDataProvider.GetValue(905), 1.0f);
            }
            else if (code != NetMessage.ErrCode.EC_Ok)
            {
                Tips.Make(Tips.TipsType.FlowUp, LanguageDataProvider.Format(901, code), 1.0f);
            }
            else if (code == NetMessage.ErrCode.EC_Ok)
            {
                UISystem.Get().HideAllWindow();
                UISystem.Get().ShowWindow("CreateRoomWindow");
            }
        }
    }
Example #25
0
 // Use this for initialization
 void Awake()
 {
     // 检查事件是否存在
     CheckEventSystem();
     CurrentUI = null;
 }
Example #26
0
        public static void Initialize()
        {
            //Set up director and UISystem.
            Director.Initialize();
            UISystem.Initialize(Director.Instance.GL.Context);

            //Set game scene
            gameScene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            gameScene.Camera.SetViewFromViewport();

            //Set the ui scene.
            uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
            Panel panel = new Panel();

            panel.Width  = Director.Instance.GL.Context.GetViewport().Width;
            panel.Height = Director.Instance.GL.Context.GetViewport().Height;
            uiScene.RootWidget.AddChildLast(panel);

            //Set the highscores scene.
            highscoresManager = new HighScoreManager(gameScene);
            highscoresScene   = new Sce.PlayStation.HighLevel.UI.Scene();
            Panel highscoresPanel = new Panel();

            highscoresPanel.Width  = Director.Instance.GL.Context.GetViewport().Width;
            highscoresPanel.Height = Director.Instance.GL.Context.GetViewport().Height;
            highscoresScene.RootWidget.AddChildLast(highscoresPanel);

            // Setup highscores label
            highscoresLabel        = new Sce.PlayStation.HighLevel.UI.Label();
            highscoresLabel.Height = 200.0f;
            highscoresLabel.Text   = "Retrieving Data";
            highscoresPanel.AddChildLast(highscoresLabel);
            highscoresScene.RootWidget.AddChildLast(highscoresPanel);

            // Setup ui scene labels
            scoreLabel = new Sce.PlayStation.HighLevel.UI.Label();
            scoreLabel.SetPosition(10, 8);
            int roundedScore = (int)FMath.Floor(score / 100) * 100;

            scoreLabel.Text = "Score: " + roundedScore.ToString("N0");
            panel.AddChildLast(scoreLabel);

            gameSpeedLabel = new Sce.PlayStation.HighLevel.UI.Label();
            gameSpeedLabel.SetPosition(770, 8);
            float speed = FMath.Round(moveSpeed * 10) / 10;             // round to 1dp

            gameSpeedLabel.Text = "Game Speed: " + moveSpeed.ToString("N1");
            panel.AddChildLast(gameSpeedLabel);

            soundManager = new SoundManager();

            //Create Sprite
            rTextureInfo     = new TextureInfo("/Application/textures/reset.png");
            rSprite          = new SpriteUV();
            rSprite          = new SpriteUV(rTextureInfo);
            rSprite.Quad.S   = rTextureInfo.TextureSizef;
            rSprite.Scale    = new Vector2(1.0f, 1.0f);
            rSprite.Position = new Vector2(0.0f, 0.0f);
            rSprite.CenterSprite();

            //Run the scene.
            Director.Instance.RunWithScene(gameScene, true);
            screenManager = new ScreenManager(gameScene);
        }
Example #27
0
 public static void Show()
 {
     instance = UISystem.InstantiateUI("ItemSelectPanel").GetComponent <ItemSelectPanel>();
 }
Example #28
0
        } //create whatever's needed to start a new game

        void CreateUI()
        {
            //NOTE: CREATE BUTTON VARIANTS
            mainUI = new UISystem(new List <Button>()
            {
                new Button("startGame", new Rectangle(220, 42, 32, 16),
                           SpriteSheetCollection.GetTex("idle", "buttons", "play"),
                           SpriteSheetCollection.GetTex("pressed", "buttons", "play"),
                           SpriteSheetCollection.GetTex("hovered", "buttons", "play")
                           ),
                new Button("tutorial", new Rectangle(220, 82, 32, 16),
                           SpriteSheetCollection.GetTex("idle", "buttons", "square"),
                           SpriteSheetCollection.GetTex("pressed", "buttons", "square"),
                           SpriteSheetCollection.GetTex("hovered", "buttons", "square")
                           ),
                new Button("exitGame", new Rectangle(220, 122, 32, 16),
                           SpriteSheetCollection.GetTex("idle", "buttons", "quit"),
                           SpriteSheetCollection.GetTex("pressed", "buttons", "quit"),
                           SpriteSheetCollection.GetTex("hovered", "buttons", "quit")
                           )
            }
                                  );

            endgameUI = new UISystem(new List <Button>()
            {
                new Button("mainMenu", new Rectangle(144, 140, 32, 16),
                           SpriteSheetCollection.GetTex("idle", "buttons", "menu"),
                           SpriteSheetCollection.GetTex("pressed", "buttons", "menu"),
                           SpriteSheetCollection.GetTex("hovered", "buttons", "menu")
                           ),
                new Button("restartGame", new Rectangle(68, 140, 32, 16),
                           SpriteSheetCollection.GetTex("idle", "buttons", "restart"),
                           SpriteSheetCollection.GetTex("pressed", "buttons", "restart"),
                           SpriteSheetCollection.GetTex("hovered", "buttons", "restart")
                           ),
                new Button("exitGame", new Rectangle(220, 140, 32, 16),
                           SpriteSheetCollection.GetTex("idle", "buttons", "quit"),
                           SpriteSheetCollection.GetTex("pressed", "buttons", "quit"),
                           SpriteSheetCollection.GetTex("hovered", "buttons", "quit")
                           ),
            }
                                     );

            tutorialUI = new UISystem(new List <Button>()
            {
                new Button("startGame", new Rectangle(64, 160, 32, 16),
                           SpriteSheetCollection.GetTex("idle", "buttons", "play"),
                           SpriteSheetCollection.GetTex("pressed", "buttons", "play"),
                           SpriteSheetCollection.GetTex("hovered", "buttons", "play")
                           ),
                new Button("mainMenu", new Rectangle(224, 160, 32, 16),
                           SpriteSheetCollection.GetTex("idle", "buttons", "menu"),
                           SpriteSheetCollection.GetTex("pressed", "buttons", "menu"),
                           SpriteSheetCollection.GetTex("hovered", "buttons", "menu")
                           )
            }
                                      );

            pauseUI = new UISystem(new List <Button>()
            {
                new Button("resumeGame", new Rectangle(60, 120, 32, 16),
                           SpriteSheetCollection.GetTex("idle", "buttons", "play"),
                           SpriteSheetCollection.GetTex("pressed", "buttons", "play"),
                           SpriteSheetCollection.GetTex("hovered", "buttons", "play")
                           ),
                new Button("mainMenu", new Rectangle(144, 120, 32, 16),
                           SpriteSheetCollection.GetTex("idle", "buttons", "menu"),
                           SpriteSheetCollection.GetTex("pressed", "buttons", "menu"),
                           SpriteSheetCollection.GetTex("hovered", "buttons", "menu")
                           ),
                new Button("restartGame", new Rectangle(228, 120, 32, 16),
                           SpriteSheetCollection.GetTex("idle", "buttons", "restart"),
                           SpriteSheetCollection.GetTex("pressed", "buttons", "restart"),
                           SpriteSheetCollection.GetTex("hovered", "buttons", "restart")
                           )
            }
                                   );

            gameUI = new UISystem(new List <Button>()
            {
                new Button("pauseGame", new Rectangle(288, 0, 32, 16),
                           SpriteSheetCollection.GetTex("idle", "buttons", "pause"),
                           SpriteSheetCollection.GetTex("pressed", "buttons", "pause"),
                           SpriteSheetCollection.GetTex("hovered", "buttons", "pause")
                           )
            }
                                  );
        }
Example #29
0
 /// <summary>
 /// Create an instance of an UI element renderer.
 /// </summary>
 /// <param name="services">The list of registered services</param>
 public ElementRenderer(IServiceRegistry services)
 {
     Asset = services.GetSafeServiceAs <IAssetManager>();
     GraphicsDeviceService = services.GetSafeServiceAs <IGraphicsDeviceService>();
     UI = services.GetServiceAs <UISystem>();
 }
Example #30
0
        } //set the next state and substate to the current one at the start of the update

        void StateChangeSwitch()
        {
            switch (currentState)
            {
            case GameState.Game:
                SoundManager.QueueSong("game", true);
                switch (currentSubState)
                {
                case GameSubState.Game:         //GAME-GAME
                    currentUI = gameUI;
                    currentBG = gameBg;
                    break;

                case GameSubState.Pause:         //GAME-MAIN
                    currentUI = pauseUI;

                    break;
                }
                break;

            case GameState.Menu:
                SoundManager.QueueSong("main", true);
                switch (currentSubState)
                {
                case GameSubState.Main:         //MENU-MAIN
                    currentUI = mainUI;
                    currentBG = mainMenuBG;
                    break;

                case GameSubState.Tutorial:         //MENU-TUT
                    currentUI = tutorialUI;
                    currentBG = tutorialBG;
                    break;

                case GameSubState.End:         //MENU-MAIN
                    currentUI            = endgameUI;
                    transitionTimer.time = 2f;
                    switch (ending)
                    {
                    case GameEnding.churchWins:
                        currentBG = goodEnding;
                        break;

                    case GameEnding.revolt:
                        currentBG = revoltEnding;
                        break;

                    case GameEnding.villageDestroyed:
                        currentBG = destructionEnding;
                        break;

                    case GameEnding.starvation:
                        currentBG = starvationEnding;
                        break;

                    case GameEnding.cult:
                        currentBG = cultEnding;
                        break;

                    default:
                        currentBG = endBG;
                        break;
                    }
                    break;
                }
                break;
            }
        }
        public LoadingScreen(Sce.PlayStation.HighLevel.GameEngine2D.Scene scene, Sce.PlayStation.HighLevel.UI.Scene uiScene) : base(scene)
        {
//			loadingTexture0     = new TextureInfo("/Application/textures/LoadingScreens/Level0Load.png");
//			loadingTexture1     = new TextureInfo("/Application/textures/LoadingScreens/Level1Load.png");
//			loadingTexture2     = new TextureInfo("/Application/textures/LoadingScreens/Level2Load.png");
//			loadingTexture3     = new TextureInfo("/Application/textures/LoadingScreens/Level3Load.png");
//			loadingTexture4     = new TextureInfo("/Application/textures/LoadingScreens/Level4Load.png");
//			loadingTexture5     = new TextureInfo("/Application/textures/LoadingScreens/Level5Load.png");
//			loadingTexture6     = new TextureInfo("/Application/textures/LoadingScreens/Level6Load.png");
//			loadingTexture7     = new TextureInfo("/Application/textures/LoadingScreens/Level7Load.png");
//			loadingTexture8     = new TextureInfo("/Application/textures/LoadingScreens/Level8Load.png");
//			loadingTexture9     = new TextureInfo("/Application/textures/LoadingScreens/Level9Load.png");
//			loadingTexture10    = new TextureInfo("/Application/textures/LoadingScreens/Level10Load.png");
//			loadingTexture11    = new TextureInfo("/Application/textures/LoadingScreens/Level11Load.png");
//			loadingTexture12    = new TextureInfo("/Application/textures/LoadingScreens/Level12Load.png");
//			loadingTexture13    = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture14  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture15  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture16  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture17  = new TextureInfo("/Application/textures/LoadingScreens/Level0Load.png");
//			//loadingTexture18	= new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture19  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture20  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture21  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture22  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture23  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture24  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture25  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture26  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");

            textureInfo     = AppMain.loadingTexture0;
            sprite          = new SpriteUV();
            sprite          = new SpriteUV(textureInfo);
            sprite.Quad.S   = textureInfo.TextureSizef;
            sprite.Position = new Vector2(-5000.0f, -5000.0f);
            sprite.CenterSprite(new Vector2(0.5f, 0.5f));

            loadingLabel           = new Sce.PlayStation.HighLevel.UI.Label();
            loadingLabel.X         = 804.0f;
            loadingLabel.Y         = 503.0f;
            loadingLabel.Text      = "Loading...";
            loadingLabel.TextColor = new UIColor(0.0f, 0.0f, 0.0f, 1.0f);
            uiScene.RootWidget.AddChildLast(loadingLabel);

            levelLabel           = new Sce.PlayStation.HighLevel.UI.Label();
            levelLabel.X         = 15.0f;
            levelLabel.Y         = 503.0f;
            levelLabel.Text      = "";
            levelLabel.TextColor = new UIColor(1.0f, 1.0f, 1.0f, 1.0f);
            //levelLabel.Font = new UIFont(FontAlias.System, 32, FontStyle.Regular);
            uiScene.RootWidget.AddChildLast(levelLabel);

            loadingSymbol = new BusyIndicator(true);
            loadingSymbol.SetPosition(910, 495);
            loadingSymbol.SetSize(48, 48);
            loadingSymbol.Anchors = Anchors.Height | Anchors.Width;
            uiScene.RootWidget.AddChildLast(loadingSymbol);
            loadingSymbol.Start();

            readyButton = new Button();
            readyButton.SetPosition(860, 490);
            readyButton.Text = "PLAY";
            readyButton.SetSize(88, 48);
            readyButton.BackgroundFilterColor = new UIColor(255.0f, 255.0f, 0.0f, 1.0f);
            readyButton.ButtonAction         += HandleButtonAction;
            readyButton.Visible = false;
            uiScene.RootWidget.AddChildLast(readyButton);

            readyButton2 = new Button();
            readyButton2.SetPosition(190, 450);
            readyButton2.Text = "JOIN X";
            readyButton2.SetSize(88, 48);
            readyButton2.BackgroundFilterColor = new UIColor(255.0f, 255.0f, 0.0f, 1.0f);
            readyButton2.ButtonAction         += HandleButtonAction;
            readyButton2.Visible = false;
            uiScene.RootWidget.AddChildLast(readyButton2);

            scene.AddChild(sprite);
            UISystem.SetScene(uiScene);

            startBox.Min = new Vector2(sprite.Position.X + loadingLabel.X - 500, sprite.Position.Y + loadingLabel.Y - 500);
            startBox.Max = new Vector2(sprite.Position.X + loadingLabel.X + 500, sprite.Position.Y + loadingLabel.Y + 500);
        }
Example #32
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Button button = new Button("goToGame", new Rectangle(119, 196, 162, 48), new TextureDrawer(Content.Load <Texture2D>("button")));

            UIs = new UISystem[] { new UISystem(new List <Button>(1)
                {
                    button
                }, "Menu"), new UISystem(SetupGameButtons(), "Game") };
            currentUI = UIs[0];
            //LOAD ALL XML
            ElementCollection.ReadDocument(XDocument.Load("Content/Entities.xml"));
            ElementCollection.ReadDocument(XDocument.Load("Content/TurretSheet.xml"));
            XElement e = ElementCollection.GetSpritesheetRef("turrets");

            SpriteSheetCollection.LoadSheet(ElementCollection.GetSpritesheetRef("turrets"), Content);

            FontDrawer drawer = new FontDrawer();

            TextureDrawer[] letters = GetLettersFromSource();
            drawer.fonts.Add(new DrawerCollection(letters, "aaa"));
            handler = new TextHandler(drawer, virtualDims);

            SoundManager.AddEffect(Content.Load <SoundEffect>("classic_hurt"), "shoot");
            SoundManager.AddSong(Content.Load <Song>("ld41tracktest2"), "song");

            ChangeToQueue(0);

            //LOAD MAP AND ENTS
            gameMap = new Map(
                new Vector2[] {
                new Vector2(150, 0),
                new Vector2(153, 142),
                new Vector2(222, 142),
                new Vector2(222, 190),
                new Vector2(108, 190),
                new Vector2(108, 104),
                new Vector2(-30, 104)
            },
                new TextureDrawer(Content.Load <Texture2D>("envtest3")),
                new FRectangle[] {
                new FRectangle(0, 0, 141, 81),
                new FRectangle(119, 82, 26, 58),
                new FRectangle(135, 144, 78, 23),
                new FRectangle(162, 0, 79, 123),
                new FRectangle(230, 123, 9, 67),
                new FRectangle(102, 191, 138, 49),
                new FRectangle(0, 104, 100, 138)
            });

            availableTurrets = new List <Entity>();
            availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("machinegun 1"), new Vector2(24, 16), Content, ebuilder, false));
            availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("sniper 1"), new Vector2(24, 16), Content, ebuilder, false));
            availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("artillery 1"), new Vector2(24, 16), Content, ebuilder, false));
            availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("ring"), new Vector2(24, 16), Content, ebuilder, false));

            //availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("machinegun 2"), new Vector2(24, 16), Content, ebuilder, false));
            //availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("sniper 2"), new Vector2(24, 16), Content, ebuilder, false));
            //availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("artillery 2"), new Vector2(24, 16), Content, ebuilder, false));

            //availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("machinegun 3"), new Vector2(24, 16), Content, ebuilder, false));
            //availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("sniper 3"), new Vector2(24, 16), Content, ebuilder, false));
            //availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("artillery 3"), new Vector2(24, 16), Content, ebuilder, false));
            status = new TextureDrawer(Content.Load <Texture2D>("statusbar"));

            cursor        = new TextureDrawer(Content.Load <Texture2D>("cursor"), new TextureFrame(new Rectangle(0, 0, 8, 8), new Point(4, 4)));
            transitiontex = new TextureDrawer(Content.Load <Texture2D>("loading"));
            menutex       = new TextureDrawer(Content.Load <Texture2D>("start"));
            dedtex        = new TextureDrawer(Content.Load <Texture2D>("gameover"));
            textframe     = new TextureDrawer(Content.Load <Texture2D>("ui2"));
            loader        = new TextureDrawer(Content.Load <Texture2D>("loadanim"), new TextureFrame[] {
                new TextureFrame(new Rectangle(0, 0, 162, 48), Point.Zero),
                new TextureFrame(new Rectangle(0, 48, 162, 48), Point.Zero),
                new TextureFrame(new Rectangle(0, 96, 162, 48), Point.Zero),
                new TextureFrame(new Rectangle(0, 144, 162, 48), Point.Zero)
            });
        }
Example #33
0
        public static void Initialize()
        {
            //Set up director and UISystem.
            Director.Initialize();
            UISystem.Initialize(Director.Instance.GL.Context);

            //Set game scene
            gameScene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            gameScene.Camera.SetViewFromViewport();

            //Set the ui scene.
            uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
            Panel panel = new Panel();

            panel.Width  = Director.Instance.GL.Context.GetViewport().Width;
            panel.Height = Director.Instance.GL.Context.GetViewport().Height;

            scoreLabel = new Sce.PlayStation.HighLevel.UI.Label();
            scoreLabel.HorizontalAlignment = HorizontalAlignment.Left;
            scoreLabel.VerticalAlignment   = VerticalAlignment.Top;

            scoreLabel.TextShadow                  = new TextShadowSettings();
            scoreLabel.TextShadow.Color            = new UIColor(0.0f, 0.0f, 0.0f, 1.0f);
            scoreLabel.TextShadow.HorizontalOffset = 2.0f;
            scoreLabel.TextShadow.VerticalOffset   = 2.0f;

            scoreLabel.SetPosition(
                Director.Instance.GL.Context.GetViewport().Width / 2 - scoreLabel.Width / 2,
                Director.Instance.GL.Context.GetViewport().Width *0.1f - scoreLabel.Height / 2);

            scoreLabel.Text = "Score: " + score.ToString();

            airLabel = new Sce.PlayStation.HighLevel.UI.Label();
            airLabel.HorizontalAlignment = HorizontalAlignment.Right;
            airLabel.VerticalAlignment   = VerticalAlignment.Top;

            airLabel.TextShadow                  = new TextShadowSettings();
            airLabel.TextShadow.Color            = new UIColor(0.0f, 0.0f, 0.0f, 1.0f);
            airLabel.TextShadow.HorizontalOffset = 2.0f;
            airLabel.TextShadow.VerticalOffset   = 2.0f;

            airLabel.SetPosition(
                Director.Instance.GL.Context.GetViewport().Width / 2 - airLabel.Width / 2,
                Director.Instance.GL.Context.GetViewport().Width *0.1f - airLabel.Height / 2);
            airLabel.Text = "Air: " + air.ToString();

            windowWidth  = Director.Instance.GL.Context.GetViewport().Width;
            windowHeight = Director.Instance.GL.Context.GetViewport().Height;

            panel.AddChildLast(scoreLabel);
            panel.AddChildLast(airLabel);
            uiScene.RootWidget.AddChildLast(panel);
            UISystem.SetScene(uiScene);

            //Create the background.
            background = new Background(gameScene);

            //Create the flappy guy
            bird = new Bird(gameScene);

            //Create some chains.
            chain    = new Chain[OBSTACLE_COUNT];
            chain[0] = new Chain(windowWidth * 0.5f, gameScene);
            chain[1] = new Chain(windowWidth, gameScene);

            //Create seamines and attach to chain
            seamine    = new Mine[OBSTACLE_COUNT];
            seamine[0] = new Mine((X = chain[0].GetX + chain[0].GetMaxX) - 80, Y = chain[0].GetY + chain[0].GetMaxY, gameScene);
            seamine[1] = new Mine((X = chain[1].GetX + chain[1].GetMaxX) - 80, Y = chain[1].GetY + chain[1].GetMaxY, gameScene);

            //Create Bubbles
            bubble = new List <Bubble>();
            bubble.Add(new Bubble(windowWidth / 4, -70.0f, 0.75f, gameScene));
            bubble.Add(new Bubble(windowWidth / 2, -42.0f, 0.25f, gameScene));
            bubble.Add(new Bubble((windowWidth / 4) * 3, -103.0f, 0.5f, gameScene));
            bubble.Add(new Bubble(windowWidth, -129.0f, 0.5f, gameScene));

            //Run the scene.
            Director.Instance.RunWithScene(gameScene, true);
        }
Example #34
0
 public void OnCloseButton()
 {
     UISystem.CloseDialog(Define.DialogType.ShopDialog);
 }
Example #35
0
 public static void Show()
 {
     UISystem.InstantiateUI("DisconnectedUI");
 }
Example #36
0
//		//ammo stuff
//		public void UpdateAmmo(int ammoCount)
//		{
//			ammoText.Text = "ammo: "+ ammoCount;
//		}

//		//Clean up Location text
//		public void ClearLocation()
//		{
//			foreach (Label l in characterLocation)
//				l.Text = "";
//			instructionText.Text = "";
//		}

        public void Render()
        {
            UISystem.Render();
        }
Example #37
0
	// Use this for initialization
	void Start () {
		
		if(SystemInfo.graphicsDeviceVersion.StartsWith("Direct3D 11") || SystemInfo.operatingSystem.Contains("Mac"))
		{
			DeviceSupportsSharedTextures = true;
		}
		
		if (m_UISystem == null)
		{
			m_SystemListener = (SystemListenerFactoryFunc != null)? SystemListenerFactoryFunc(this.OnSystemReady) : new SystemListener(this.OnSystemReady);
			m_LogHandler = new UnityLogHandler();
			if (FileHandlerFactoryFunc != null)
			{
				m_FileHandler = FileHandlerFactoryFunc();
			}
			if (m_FileHandler == null)
			{
				Debug.LogWarning("Unable to create file handler using factory function! Falling back to default handler.");
				m_FileHandler = new UnityFileHandler();
			}
			
			#if UNITY_EDITOR || COHERENT_UNITY_STANDALONE
			SystemSettings settings = new SystemSettings() { 
				HostDirectory = Path.Combine(Application.dataPath, this.HostDirectory),
				EnableProxy = this.EnableProxy,
				AllowCookies = this.AllowCookies,
				CookiesResource = "file:///" + Application.persistentDataPath + '/' + this.CookiesResource,
				CachePath = Path.Combine(Application.temporaryCachePath, this.CachePath),
				HTML5LocalStoragePath = Path.Combine(Application.temporaryCachePath, this.HTML5LocalStoragePath),
				ForceDisablePluginFullscreen = this.ForceDisablePluginFullscreen,
				DisableWebSecurity = this.DisableWebSecutiry,
				DebuggerPort = this.DebuggerPort,
			};
			#elif UNITY_IPHONE
			SystemSettings settings = new SystemSettings() {
				
			};
			#endif
			if (string.IsNullOrEmpty(Coherent.UI.License.COHERENT_KEY))
			{
				throw new System.ApplicationException("You must supply a license key to start Coherent UI! Follow the instructions in the manual for editing the License.cs file.");
			}
			m_UISystem = CoherentUI_Native.InitializeUISystem(Coherent.UI.License.COHERENT_KEY, settings, m_SystemListener, Severity.Warning, m_LogHandler, m_FileHandler);
			if (m_UISystem == null)
			{
				throw new System.ApplicationException("UI System initialization failed!");
			}
			Debug.Log ("Coherent UI system initialized..");
		}
		
		DontDestroyOnLoad(this.gameObject);
	}
Example #38
0
        public HUD(GraphicsContext graphics, int totalPlayerNum)
        {
            UISystem.Initialize(graphics);

            //decarations
            Scene scene = new Scene();
            Label lblName, lblScore, lblLocation, lblHP;

            characterName     = new List <Label>();
            characterHP       = new List <Label>();
            characterScore    = new List <Label>();
            characterLocation = new List <Label>();
            float colorRed = 1, colorGreen = 1, colorBlue = 1;
            int   labelSpacing = graphics.Screen.Rectangle.Width / Math.Max(totalPlayerNum, 1);

            //Loop to create a list of labels.
            for (int characterNum = 0; characterNum < totalPlayerNum; characterNum++)
            {
                if (characterNum == 0)
                {
                    colorRed   = 1;
                    colorGreen = 0;
                    colorBlue  = 0;
                }
                if (characterNum == 1)
                {
                    colorRed   = 0;
                    colorGreen = 1;
                    colorBlue  = 0;
                }
                if (characterNum == 2)
                {
                    colorRed   = 0;
                    colorGreen = 0;
                    colorBlue  = 1;
                }
                if (characterNum == 3)
                {
                    colorRed   = 1;
                    colorGreen = 1;
                    colorBlue  = 0;
                }

                //Name
                lblName                     = new Label();
                lblName.X                   = 0 + labelSpacing * (characterNum);
                lblName.Y                   = 10;
                lblName.Width               = graphics.Screen.Rectangle.Width / Math.Max(totalPlayerNum, 1);
                lblName.Text                = "Name: ";
                lblName.TextColor           = new UIColor(colorRed, colorGreen, colorBlue, 1);
                lblName.HorizontalAlignment = HorizontalAlignment.Center;
                scene.RootWidget.AddChildLast(lblName);
                characterName.Add(lblName);

                //HP
                lblHP                     = new Label();
                lblHP.X                   = 0 + labelSpacing * (characterNum);
                lblHP.Y                   = characterName[characterNum].Y + characterName[characterNum].Height;
                lblHP.Width               = graphics.Screen.Rectangle.Width / Math.Max(totalPlayerNum, 1);
                lblHP.Text                = "HP: X";
                lblHP.TextColor           = new UIColor(colorRed, colorGreen, colorBlue, 1);
                lblHP.HorizontalAlignment = HorizontalAlignment.Center;
                scene.RootWidget.AddChildLast(lblHP);
                characterHP.Add(lblHP);

                //Score
                lblScore                     = new Label();
                lblScore.X                   = 0 + labelSpacing * (characterNum);
                lblScore.Y                   = characterHP[characterNum].Y + characterHP[characterNum].Height;
                lblScore.Width               = graphics.Screen.Rectangle.Width / Math.Max(totalPlayerNum, 1);
                lblScore.Text                = "Score: 0";
                lblScore.TextColor           = new UIColor(colorRed, colorGreen, colorBlue, 1);
                lblScore.HorizontalAlignment = HorizontalAlignment.Center;
                scene.RootWidget.AddChildLast(lblScore);
                characterScore.Add(lblScore);

//				//where am I? (I now can show you where everyone is)
//				lblLocation = new Label();
//				lblLocation.X = 0 + labelSpacing * (characterNum);
//				lblLocation.Y = characterScore[characterNum].Y + characterScore[characterNum].Height;
//				lblLocation.Width = graphics.Screen.Rectangle.Width / Math.Max(totalPlayerNum,1);
//				lblLocation.Text = "";
//				lblLocation.TextColor = new UIColor (colorRed, colorGreen, colorBlue, 1);
//				lblLocation.HorizontalAlignment = HorizontalAlignment.Center;
//				scene.RootWidget.AddChildLast(lblLocation);
//				characterLocation.Add(lblLocation);
            }

            //where am I? (This is outside the loop because it should only render once.)
            pausedText       = new Label();
            pausedText.Width = 600;
            pausedText.X     = graphics.Screen.Rectangle.Width / 2 - pausedText.Width / 2;
            pausedText.Y     = graphics.Screen.Rectangle.Height / 2 - pausedText.Height / 2;
            pausedText.HorizontalAlignment = HorizontalAlignment.Center;
            pausedText.Text      = "";
            pausedText.TextColor = new UIColor(1, 0, 0, 1);
            scene.RootWidget.AddChildLast(pausedText);

            //			//where am I? (This is outside the loop because it should only render once.)
//			instructionText = new Label();
//			instructionText.X = 10;
//			instructionText.Y = graphics.Screen.Rectangle.Height - instructionText.Height - 10;
//			instructionText.Width = 800;
//			instructionText.Text = "Press 'Start' (keyboard X) to show location.";
//			instructionText.TextColor = new UIColor (1, 1, 1, 1);
//			scene.RootWidget.AddChildLast(instructionText);

//			//ammo on the screen count
//			ammoText = new Label();
//			ammoText.X = 10;
//			ammoText.Y = graphics.Screen.Rectangle.Height - instructionText.Height - 20;
//			ammoText.Width = 800;
//			ammoText.Text = "ammo: ";
//			ammoText.TextColor = new UIColor (1, 1, 1, 1);
//			scene.RootWidget.AddChildLast(ammoText);

            //set scene
            UISystem.SetScene(scene, null);
        }