Exemplo n.º 1
0
        public override void Startup()
        {
            Matrix toScreenSpace = Matrix.Identity;
            toScreenSpace.M11 = 2 / 1024.0f;
            toScreenSpace.M22 = 2 / 768.0f;
            toScreenSpace.M41 = -1;
            toScreenSpace.M42 = -1;

            var cam = new Camera
            {
                PostWorldMatrix = toScreenSpace,
                Position = Vector3.UnitZ,
                IsPerspective = false,
                ViewportWidth = 2,
                ViewportHeight = -2
            };
            cam.Dirty();

            Root = new UI.TransformNode
            {
                Transform = cam.WorldToProjectionMatrix,
                Dispatcher = GameApp.Service<UIManager>().Root
            };

            var pageStyle = new Style.PageStyle(GameApp.Service<Styler>().GetPageStyle("Deck"));
            pageStyle.Initialize();
            TextRenderer.FontDescriptor m_msgFont = new TextRenderer.FontDescriptor("Microsoft YaHei", 16);
            m_textFormatOptions = new Graphics.TextRenderer.FormatOptions(m_msgFont);
        }
Exemplo n.º 2
0
        public override void Startup()
        {
            //Init Conversation Manager
            _convManager = new ConversationManager();
            _convManager.Scene = "init";

            Matrix toScreenSpace = Matrix.Identity;
            toScreenSpace.M11 = 2 / 1024.0f;
            toScreenSpace.M22 = 2 / 768.0f;
            toScreenSpace.M41 = -1;
            toScreenSpace.M42 = -1;

            var cam = new Camera
            {
                PostWorldMatrix = toScreenSpace,
                Position = Vector3.UnitZ,
                IsPerspective = false,
                ViewportWidth = 2,
                ViewportHeight = -2
            };
            cam.Dirty();

            Root = new UI.TransformNode
            {
                Transform = cam.WorldToProjectionMatrix,
                Dispatcher = GameApp.Service<UIManager>().Root
            };

            var pageStyle = new Style.PageStyle(GameApp.Service<Styler>().GetPageStyle("Conversation"));
            pageStyle.Initialize();
            ConversationUIPage = pageStyle.TypedTarget;

            ((Panel)pageStyle.ChildIds["ConversationPanel"].Target).MouseButton1Up += new EventHandler<MouseEventArgs>(ConversationUI_MouseButton1Up);
        }
Exemplo n.º 3
0
        public override void Startup()
        {
            Matrix toScreenSpace = Matrix.Identity;
            toScreenSpace.M11 = 2 / 1024.0f;
            toScreenSpace.M22 = 2 / 768.0f;
            toScreenSpace.M41 = -1;
            toScreenSpace.M42 = -1;

            float fov = MathUtils.PI / 4;
            float nearPlaneHeight = 2 * 0.1f * (float)Math.Tan(fov * 0.5f);
            WorldCamera = new Camera
            {
                Position = new Vector3(0, -1.2f, 2.2f),
                LookAt = new Vector3(0, -0.2f, 0.0f),
                Up = Vector3.UnitZ,
                IsPerspective = true,
                ViewportWidth = nearPlaneHeight * 1.3333f,
                ViewportHeight = nearPlaneHeight
            };
            WorldCamera.Dirty();

            UICamera = new Camera
            {
                PostWorldMatrix = toScreenSpace,
                Position = Vector3.UnitZ,
                IsPerspective = false,
                ViewportWidth = 2,
                ViewportHeight = -2
            };
            UICamera.Dirty();

            InitializeContextButton();
            CreateBindingEvaluator();

            var pageStyle = new Style.PageStyle(GameApp.Service<Styler>().GetPageStyle("InGame"));
            pageStyle.Initialize();
            pageStyle.BindingProvider = this;
            InGameUIPage = pageStyle.TypedTarget;
        }
Exemplo n.º 4
0
        public override void Startup()
        {
            #region Initialize Page
            Matrix toScreenSpace = Matrix.Identity;
            toScreenSpace.M11 = 2 / 1024.0f;
            toScreenSpace.M22 = 2 / 768.0f;
            toScreenSpace.M41 = -1;
            toScreenSpace.M42 = -1;

            var cam = new Camera
            {
                PostWorldMatrix = toScreenSpace,
                Position = Vector3.UnitZ,
                IsPerspective = false,
                ViewportWidth = 2,
                ViewportHeight = -2
            };
            cam.Dirty();

            Root = new UI.TransformNode
            {
                Transform = cam.WorldToProjectionMatrix,
                Dispatcher = GameApp.Service<UIManager>().Root
            };

            LoadPage("MainMenu");
            LoadPage("FreeMode");
            LoadPage("Network");
            LoadPage("Quit");

            #endregion

            if (m_isFirstLoaded)
            {
                #region Main Menu
                m_pages["MainMenu"].MenuClicked += (id, item) =>
                {
                    if (id == "freemode")
                    {
                        CurrentPage = m_pages["FreeMode"];
                    }
                    //else if (id == "storymode")
                    //{
                    //    //Test Conversation UI
                    //    CurrentPage = null;
                    //    Root.Dispatcher = null;
                    //    GameApp.Service<GameManager>().EnterConversation();
                    //}
                    else if (id == "makedeck")
                    {
                        CurrentPage = null;
                        Root.Dispatcher = null;
                        GameApp.Service<GameManager>().EnterDeckUI();
                    }
                    else if (id == "quit")
                    {
                        CurrentPage = m_pages["Quit"];
                    }
                };
                #endregion

                #region FreeMode Menu

                PrepareGameStartupParam();

                m_pages["FreeMode"].MenuClicked += (id, item) =>
                {
                    if (id == "vsai" || id == "hotseat")
                    {
                        CurrentPage = null;
                        // detach menu ui
                        Root.Dispatcher = null;

                        Agents.BaseAgent agent0;
                        Agents.BaseAgent agent1;

                        switch (id)
                        {
                            case "vsai":
                                if (GameApp.Instance.GetCommandLineArgValue("playback") != null)
                                {
                                    var pbAgent = new Agents.PlaybackAgent(0);
                                    param.Seed = pbAgent.RandomSeed;
                                    agent0 = pbAgent;
                                }
                                else if (GameApp.Instance.GetCommandLineArgValue("record") != null)
                                {
                                    agent0 = new Agents.LocalPlayerAgent(0, param.Seed);
                                }
                                else
                                {
                                    agent0 = new Agents.LocalPlayerAgent(0);
                                }
                                agent1 = new Agents.AIAgent(1);
                                break;
                            case "hotseat":
                                agent0 = new Agents.LocalPlayerAgent(0);
                                agent1 = new Agents.LocalPlayerAgent(1);
                                break;
                            default:
                                throw new InvalidOperationException("Invalid menu item");
                        }

                        GameApp.Service<GameManager>().StartGame(param, new Agents.BaseAgent[] { agent0, agent1 });
                    }
                    else if (id == "vsnetwork")
                    {
                        //CurrentPage = m_pages["Network"];

                        CurrentPage = null;
                        Root.Dispatcher = null;
                        GameApp.Service<GameManager>().EnterNetworkUI();
                    }
                    else if (id == "back")
                    {
                        CurrentPage = m_pages["MainMenu"];
                    }
                };
                #endregion

                #region Network Menu
                m_pages["Network"].MenuClicked += (id, item) =>
                {
                    if (id == "backtofreemode")
                    {
                        //CurrentPage = m_pages["FreeMode"];
                    }
                };
                #endregion

                #region Quit Menu
                m_pages["Quit"].MenuClicked += (id, item) =>
                {
                    if (id == "quit")
                    {
                        GameApp.Instance.Exit();
                    }
                    else if (id == "back")
                    {
                        CurrentPage = m_pages["MainMenu"];
                    }
                };
                #endregion

                //m_isFirstLoaded = false;
            }

            CurrentPage = m_pages["MainMenu"];

            var curve = GameApp.Service<ResourceManager>().Acquire<Curve>("Curves/CardMove");
            var font = new Graphics.TextRenderer.FontDescriptor("Microsoft YaHei", 16);
            var fmtOptions = new Graphics.TextRenderer.FormatOptions(font);
            var candFmtOptions = new Graphics.TextRenderer.FormatOptions(new Graphics.TextRenderer.FontDescriptor("Microsoft YaHei", 11));

            var txtBox = new UI.TextBox(250, 30, fmtOptions, candFmtOptions)
            {
                ForeColor = Color.Black,
                SelectionBackColor = new Color(0, 0, 0, 0.75f),
                SlidingCurve = curve,
                Transform = MatrixHelper.Translate(50, 200),
                Dispatcher = Root
            };

            txtBox = new UI.TextBox(250, 30, fmtOptions, candFmtOptions)
            {
                ForeColor = Color.Black,
                SelectionBackColor = new Color(0, 0, 0, 0.75f),
                SlidingCurve = curve,
                Transform = MatrixHelper.Translate(50, 250),
                Dispatcher = Root
            };

            //m_testAnimation = new Graphics.SwfInstance("germs")
            //{
            //    IsPlaying = true,
            //    TimeFactor = 2.0f,
            //    Transform = MatrixHelper.RotateZ(MathHelper.Pi / 4) * MatrixHelper.Translate(256f, 256f)
            //};

            //m_testAnimation2 = new Graphics.SwfInstance("28835")
            //{
            //    IsPlaying = true,
            //    Transform = MatrixHelper.Translate(768f, 0f)
            //};
        }