예제 #1
0
        public NameCreation(CharacterCreation parent, CharacterCreationOutput output)
        {
            myParent = parent;
            myOutput = output;

            var label = new UILabel(Font.Large, new Vector2(4, 24))
            {
                Text = "Name:"
            };

            AddChild(label);

            myTextbox = new UITextBox(new Vector2(200 - 70 - 2, 20), new Vector2(70, 20))
            {
                Text = "Player"
            };
            AddChild(myTextbox);

            var button = new UIButton(new Vector2(100, 20), new Vector2(100 - 4, 80 - 4))
            {
                Text       = "Next",
                CentreText = true
            };

            button.Click += new MouseButtonEventHandler(button_Click);
            AddChild(button);

            CanResize = true;
            SetSize(200, 100);

            myTextbox.Focus();
        }
예제 #2
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            if (myHostingLocal && !myJoinedLocalServer && GameServer.Running)
            {
                OnLocalServerReady();
            }

            if (!myViewingOverworld && GameClient.IsViewingOverworld)
            {
                OnJoinGame();
            }

            if (!myInGame && GameClient.IsPlaying)
            {
                OnEnterMap();
            }

            if (GameClient.CreateCharacter)
            {
                GameClient.CreateCharacter = false;

                myCreation = new CharacterCreation();
                AddChild(myCreation);
                myCreation.Show();
                myCreation.Focus();
                myCreation.Centre();
            }

            if (!GameClient.Connected || !GameClient.IsPlaying)
            {
                return;
            }

            if (!myCreation.IsVisible && !myChatBox.IsFocused && !myMainMenu.IsVisible && myInventoryView == null)
            {
                WalkDirection newDir = WalkDirection.Still;

                if (IsKeyPressed(LewtKey.WalkLeft))
                {
                    newDir = WalkDirection.Left;
                }
                else if (IsKeyPressed(LewtKey.WalkUp))
                {
                    newDir = WalkDirection.Up;
                }
                else if (IsKeyPressed(LewtKey.WalkRight))
                {
                    newDir = WalkDirection.Right;
                }
                else if (IsKeyPressed(LewtKey.WalkDown))
                {
                    newDir = WalkDirection.Down;
                }

                if (newDir != GameClient.PlayerEntity.WalkDirection)
                {
                    if (newDir == WalkDirection.Still)
                    {
                        GameClient.PlayerEntity.StopWalking();
                        GameClient.SendPlayerStopMoving();
                    }
                    else
                    {
                        GameClient.PlayerEntity.StartWalking(newDir);
                        GameClient.SendPlayerStartMoving(newDir);
                    }
                }

                if (IsKeyPressed(LewtKey.Cast) && GameClient.PlayerEntity.CanCast)
                {
                    GameClient.PlayerEntity.Cast();
                    GameClient.SendPlayerCast(GameClient.PlayerEntity.CastAngle);
                }

                if (IsKeyPressed(LewtKey.Use))
                {
                    if (!myUseBtnPressed)
                    {
                        myUseBtnPressed = true;
                        Entity closest = GameClient.PlayerEntity.GetNearestUseableEntity();

                        if (closest != null)
                        {
                            GameClient.SendPlayerUse(closest);
                        }
                    }
                }
                else
                {
                    myUseBtnPressed = false;
                }

                if (IsKeyPressed(LewtKey.Menu))
                {
                    if (!myMenuBtnPressed)
                    {
                        myMenuBtnPressed = true;
                        myMainMenu.Show();
                    }
                }
                else
                {
                    myMenuBtnPressed = false;
                }

                if (IsKeyPressed(LewtKey.Inventory) && !myWaitingForInventory)
                {
                    myWaitingForInventory = true;
                    GameClient.SendPlayerViewInventory();
                }

                if (IsKeyPressed(LewtKey.Chat) && !Lewt.Server.Networking.GameServer.SinglePlayer)
                {
                    myChatBox.StartTyping();
                }
            }
            else if (IsKeyPressed(LewtKey.Menu))
            {
                if (!myMenuBtnPressed)
                {
                    myMenuBtnPressed = true;

                    if (myChatBox.IsFocused)
                    {
                        myChatBox.UnFocus();
                    }
                    else if (myMainMenu.IsVisible)
                    {
                        myMainMenu.Hide();
                    }
                    else if (myInventoryView != null)
                    {
                        myInventoryView.Close();
                    }
                }
            }
            else
            {
                myMenuBtnPressed = false;
            }

#if DEBUG
            if ((DateTime.Now - myLastFPSShow).TotalSeconds >= 0.5)
            {
                myFPSDisplay.Text = "Map Render Time: " + myMapRenderTime.ToString("F") + "ms\nSprite Render Time: " + mySprRenderTime.ToString("F") + "ms\nEntities: " + GameClient.Map.Entities.Length.ToString();
                myLastFPSShow     = DateTime.Now;
            }

            myTimeDisplay.Text = "Client time: " + GameClient.Map.TimeSeconds.ToString("F");
#endif

            GameClient.Map.Think(e.Time);
        }
예제 #3
0
        public AttributeCreation(CharacterCreation parent, CharacterCreationOutput output)
        {
            myParent = parent;
            myOutput = output;



            float y = 4;

            myPointsLabel = new UILabel(Font.Large, new Vector2(4, y));
            AddChild(myPointsLabel);
            UnusedPoints = GameClient.CharacterUnusedAttribPoints;

            y += 30;

            foreach (CharAttribute attrib in CharAttribute.GetAll())
            {
                var row = new AttribRow(this, attrib, myOutput);
                row.Top  = y;
                row.Left = 4;
                y       += 30;
                AddChild(row);
            }

            y += 20;

            var skills = CharSkill.GetAll();

            skillRows = new SkillRow[skills.Length];

            int i = 0;

            foreach (CharSkill skill in skills)
            {
                var row = new SkillRow(new Vector2(4, y), skill, myOutput);
                y           += 25;
                skillRows[i] = row;
                i++;
                AddChild(row);
            }

            var button = new UIButton(new Vector2(150, 20), new Vector2(300 - 150 - 4, y))
            {
                Text       = "Create Character",
                CentreText = true
            };

            AddChild(button);
            button.Click += new MouseButtonEventHandler(button_Click);

            var back = new UIButton(new Vector2(50, 20), new Vector2(4, y))
            {
                Text       = "Back",
                CentreText = true
            };

            back.Click += new MouseButtonEventHandler(back_Click);
            AddChild(back);

            y += 20;

            Width  = 300;
            Height = y + 4 + PaddingTop + PaddingBottom;
        }