Example #1
0
        public override void Render()
        {
            pa = pa + 3;
            px = (float)Math.Cos((double)MathHelper.DegreesToRadians(pa)) * 250;
            pz = (float)Math.Sin((double)MathHelper.DegreesToRadians(pa)) * 250;
            if (VInput.KeyIn(OpenTK.Input.Key.W))
            {
                c1.Move(new Vector3(0, 0, -1), Space.Local);
            }
            if (VInput.KeyIn(OpenTK.Input.Key.A))
            {
                c1.Move(new Vector3(-1, 0, 0), Space.Local);
            }
            if (VInput.KeyIn(OpenTK.Input.Key.D))
            {
                c1.Move(new Vector3(1, 0, 0), Space.Local);
            }
            if (VInput.KeyIn(OpenTK.Input.Key.S))
            {
                c1.Move(new Vector3(0, 0, 1), Space.Local);
            }
            if (first)
            {
                lx    = VInput.MX;
                ly    = VInput.MY;
                first = false;
            }
            x  = VInput.MX - lx;
            y  = VInput.MY - ly;
            lx = VInput.MX;
            ly = VInput.MY;
            if (Math.Abs(x) > 15)
            {
                x = 0;
            }
            if (Math.Abs(y) > 15)
            {
                y = 0;
            }
            //if (VInput.KeyIn(OpenTK.Input.Key.Space))
            // {

            //  c1.LookAt(Vector3.Zero);
            l1.Diff = new Vector3(5, 5, 5);
            e1.Turn(new Vector3(y * 0.6f, x * 0.6f, 0), Space.Local);
            // }
            //c1.Turn(new Vector3(y, x, 0), Space.Local);
            //1.Rot(new Vector3(x,y,z), Space.Local);
            l1.Pos(new Vector3(px, 80, pz), Space.Local);
            //Console.WriteLine("Render!");
            // VPen.Rect(20, 20, 200, 200);
            // sg.Render();
            //  ER.Render();

            PR.Render();
        }
Example #2
0
        public override void DrawState()
        {
            int move = 8;

            if (VInput.KeyIn(OpenTK.Input.Key.ShiftLeft))
            {
                move = 12;
            }
            if (VInput.KeyIn(OpenTK.Input.Key.W))
            {
                cam1.Move(new OpenTK.Vector3(0, 0, -move), Space.Local);
            }
            if (VInput.KeyIn(OpenTK.Input.Key.A))
            {
                cam1.Move(new OpenTK.Vector3(-move, 0, 0), Space.Local);
            }

            if (VInput.KeyIn(OpenTK.Input.Key.D))
            {
                cam1.Move(new OpenTK.Vector3(move, 0, 0), Space.Local);
            }

            if (VInput.KeyIn(OpenTK.Input.Key.S))
            {
                cam1.Move(new OpenTK.Vector3(0, 0, move), Space.Local);
            }
            if (VInput.MB[0])
            {
                light1.LocalPos = cam1.LocalPos;
            }
            int xd, yd;

            if (firstd)
            {
                lx     = VInput.MX;
                ly     = VInput.MY;
                firstd = false;
            }
            xd = VInput.MX - lx;
            yd = VInput.MY - ly;
            lx = VInput.MX;
            ly = VInput.MY;
            cam1.Turn(new OpenTK.Vector3(yd, xd, 0), Space.Local);

            scene3d.Render();

            UI.Render();
        }
Example #3
0
        public override void DrawState()
        {
            bool RenderDarkLogo()
            {
                VPen.Rect(0, 0, StarApp.W, StarApp.H, LogoTex, new OpenTK.Vector4(LogoAlpha, LogoAlpha, LogoAlpha, LogoAlpha));
                return(PresentLogo);
            }

            bool RenderPresLogo()
            {
                VPen.Rect(0, 0, StarApp.W, StarApp.H, this.PresTex, new OpenTK.Vector4(LogoAlpha, LogoAlpha, LogoAlpha, LogoAlpha));
                return(GameLogo);
            }

            bool RenderGameLogo()
            {
                //Console.WriteLine("Rendering!");

                VPen.Rect(0, 0, StarApp.W, StarApp.H, GameTex, new OpenTK.Vector4(LogoAlpha, LogoAlpha, LogoAlpha, LogoAlpha));
                return(ToMenu);
            }

            void DoMenu()
            {
                LogoAlpha = 0.0f;
                ms.Stop();

                StarApp.PushState(new MainMenuState());
            }

            bool CheckInput()
            {
                if (ToMenu)
                {
                    return(true);
                }
                if (VInput.MB[0])
                {
                    return(true);
                }
                if (VInput.KeyIn(OpenTK.Input.Key.Enter) || VInput.KeyIn(OpenTK.Input.Key.Space))
                {
                    return(true);
                }
                return(false);
            }

            //Logics.Do(TestDo);

            Graphics.When(CheckInput, DoMenu, null);

            Graphics.Flow(null, RenderDarkLogo);
            Graphics.Flow(null, RenderPresLogo);
            Graphics.Flow(null, RenderGameLogo);

            Graphics.SmartUpdate();

            return;

            void DarkLogo()
            {
                VPen.Rect(0, 0, StarApp.W, StarApp.H, LogoTex, new OpenTK.Vector4(LogoAlpha, LogoAlpha, LogoAlpha, LogoAlpha));
            }

            bool DarkLogoUntil()
            {
                return(PresentLogo);
            }

            void PresLogo()
            {
                VPen.Rect(0, 0, StarApp.W, StarApp.H, LogoTex, new OpenTK.Vector4(LogoAlpha, LogoAlpha, LogoAlpha, LogoAlpha));
            }

            bool PresentLogoUntil()
            {
                return(ReboundLogo);
            }

            void DoPresent()
            {
                Graphics.Do(PresLogo, PresentLogoUntil);
            }

            Graphics.Do(DarkLogo, DarkLogoUntil, DoPresent);

            Graphics.InternalUpdate();
        }
Example #4
0
        public virtual bool OnUpdate()
        {
            if (this.WidOpen == false)
            {
                return(false);
            }
            for (int wi = Sub.Count - 1; wi > -1; wi--)
            {
                UIWidget w = Sub[wi];

                if (w.OnUpdate())
                {
                    return(true);
                }
            }
            if (UISys.Active != null)
            {
                if (UISys.Active is UIWidgets.UIDragZone)
                {
                    UISys.ActiveWindow = UISys.Active.Top as UIWidgets.UIWindow;
                }
            }

            if (UISys.Active == null)
            {
                UISys.IsKeyIn = false;
            }

            if (UISys.Active == this)
            {
                if (VInput.AnyKey())
                {
                    if (UISys.IsKeyIn == false)
                    {
                        UISys.IsKeyIn    = true;
                        UISys.KeyIn      = VInput.KeyIn();
                        UISys.LastStroke = Environment.TickCount;
                        UISys.NextStroke = UISys.LastStroke + UISys.FirstStrokeWait;
                        UISys.Active.KeyIn(UISys.KeyIn, VInput.IsShiftIn());

                        if (UISys.KeyIn == OpenTK.Input.Key.BackSpace)
                        {
                            this.KeyBackSpace();
                        }
                        else if (UISys.KeyIn == OpenTK.Input.Key.Tab)
                        {
                            if (UISys.Active == this)
                            {
                                int ci = 0;
                                foreach (var w in UISys.Active.Top.Sub)
                                {
                                    if (w == UISys.Active)
                                    {
                                        break;
                                    }
                                    ci++;
                                }
                                UISys.Active.OnDeactivate();
                                if (ci < UISys.Active.Top.Sub.Count - 1)
                                {
                                    UISys.Active = UISys.Active.Top.Sub[ci + 1];
                                    UISys.Active.OnActivate();
                                }
                                else
                                {
                                    UISys.Active = UISys.Active.Top.Sub[0];
                                    UISys.Active.OnActivate();
                                }
                            }
                        }
                        else if (UISys.KeyIn == OpenTK.Input.Key.Delete)
                        {
                            this.KeyDel();
                        }
                        else if (UISys.KeyIn == OpenTK.Input.Key.Left)
                        {
                            this.KeyLeft();
                        }
                        else if (UISys.KeyIn == OpenTK.Input.Key.Right)
                        {
                            this.KeyRight();
                        }
                        else
                        {
                            this.KeyAdd(UISys.KeyIn, VInput.IsShiftIn());
                        }
                    }
                    else
                    {
                        if (VInput.KeyIn() == UISys.KeyIn)
                        {
                            if (Environment.TickCount >= (UISys.NextStroke))
                            {
                                UISys.LastStroke = Environment.TickCount;
                                UISys.NextStroke = UISys.LastStroke + UISys.NextStrokeWait;
                                if (UISys.KeyIn == OpenTK.Input.Key.BackSpace)
                                {
                                    KeyBackSpace();
                                }
                                else if (UISys.KeyIn == OpenTK.Input.Key.Delete)
                                {
                                    this.KeyDel();
                                }
                                else if (UISys.KeyIn == OpenTK.Input.Key.Left)
                                {
                                    this.KeyLeft();
                                }
                                else if (UISys.KeyIn == OpenTK.Input.Key.Right)
                                {
                                    this.KeyRight();
                                }
                                else
                                {
                                    if (VInput.IsShiftIn())
                                    {
                                        KeyAdd(UISys.KeyIn, true);
                                    }
                                    else
                                    {
                                        KeyAdd(UISys.KeyIn, false);
                                    }
                                }
                            }
                        }
                        else
                        {
                            this.KeyUp(UISys.KeyIn, VInput.IsShiftIn());
                            UISys.IsKeyIn    = true;
                            UISys.KeyIn      = VInput.KeyIn();
                            UISys.LastStroke = Environment.TickCount;
                            UISys.NextStroke = UISys.LastStroke + UISys.FirstStrokeWait;
                            UISys.Active.KeyIn(UISys.KeyIn, VInput.IsShiftIn());
                            if (UISys.KeyIn == OpenTK.Input.Key.BackSpace)
                            {
                                KeyDel();
                            }
                            else if (UISys.KeyIn == OpenTK.Input.Key.Left)
                            {
                                this.KeyLeft();
                            }
                            else if (UISys.KeyIn == OpenTK.Input.Key.Right)
                            {
                                this.KeyRight();
                            }
                            else
                            {
                                if (VInput.IsShiftIn())
                                {
                                    KeyAdd(UISys.KeyIn, true);
                                }
                                else
                                {
                                    KeyAdd(UISys.KeyIn, false);
                                }
                            }
                        }
                    }
                }
                else
                {
                    UISys.IsKeyIn = false;
                }
            }
            if (InBounds())
            {
                if (UISys.Over == this)
                {
                    this.OnHover();
                }
                if (UISys.Over == null)
                {
                    UISys.Over = this;
                    this.OnEnter();
                }
                if (UISys.Over != null && UISys.Over != this)
                {
                    UISys.Over.OnLeave();
                    UISys.Over = this;
                    UISys.Over.OnEnter();
                }
            }
            else
            {
                if (UISys.Over == this && UISys.Pressed != this)
                {
                    UISys.Over.OnLeave();
                    UISys.Over = null;
                }
            }
            if (VInput.MB[0] == false && UISys.Lock == true)
            {
                UISys.Lock = false;
            }
            if (VInput.MB[0] && UISys.Lock == false)
            {
                if (UISys.Over != null)
                {
                    if (UISys.Over == this)
                    {
                        if (UISys.Active != this)
                        {
                            if (UISys.Active != null)
                            {
                                if (UISys.IsKeyIn)
                                {
                                    UISys.Active.KeyUp(UISys.KeyIn, VInput.IsShiftIn());
                                    UISys.IsKeyIn = false;
                                }
                                UISys.Active.OnDeactivate();
                            }
                            UISys.IsKeyIn = false;

                            UISys.Active = this;
                            this.OnActivate();
                            UISys.Lock = true;
                            foreach (var p in Patches)
                            {
                                if (VInput.MX >= p.X)
                                {
                                    if (VInput.MY >= p.Y)
                                    {
                                        if (VInput.MX <= (p.X + p.W))
                                        {
                                            if (VInput.MY <= (p.Y + p.H))
                                            {
                                                p.Action();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                }
            }
            if (InBounds())
            {
                if (VInput.MB[0])
                {
                    if (UISys.Pressed == null)
                    {
                        OnMouseDown(UIMouseButton.Left);
                        UISys.Pressed = this;
                        foreach (var p in Patches)
                        {
                            if (VInput.MX >= p.X)
                            {
                                if (VInput.MY >= p.Y)
                                {
                                    if (VInput.MX <= (p.X + p.W))
                                    {
                                        if (VInput.MY <= (p.Y + p.H))
                                        {
                                            p.Action();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (UISys.Pressed == this)
                    {
                        OnMouseUp(UIMouseButton.Left);
                        UISys.Pressed = null;
                    }
                }
            }
            else
            {
                if (VInput.MB[0] == false)
                {
                    if (UISys.Pressed == this)
                    {
                        UISys.Pressed.OnMouseUp(UIMouseButton.Left);
                        UISys.Pressed = null;
                    }
                }
                if (UISys.Pressed != null)
                {
                    // UISys.Pressed.OnMouseUp(UIMouseButton.Left);
                    //UISys.Pressed = null;
                }
            }
            //this.Update();
            if (UISys.Over == this || UISys.Pressed == this)
            {
                return(true);
            }
            return(false);
        }