/// <summary> /// 加入button并且为button准备其该出现的位置(Matrix) /// </summary> /// <param name="bt"></param> public void AddButton(MyGuiButton bt) { Buttons.Add(bt); var temp = FatherCard.Transform.Matrix; //给出出现位置 temp.Translation = new System.Numerics.Vector3(temp.Translation.X + FatherCard.Size.Width, temp.Translation.Y + (Buttons.Count - 1) * bt.Size.Height, 0); AimTrans.Add(temp); }
private static void LoadMainPlace() { //决斗盘加载 MainPlace mainPlace = new MainPlace("MainPlace"); MainPlace = mainPlace; MainPlaceInfo mainPlaceInfo = new MainPlaceInfo(mainPlace); Player thisPlayer = mainPlaceInfo.Player1; Player OpPlayer = mainPlaceInfo.Player2; thisPlayer.Name = "测试用户"; OpPlayer.Name = "测试对手"; thisPlayer.CardGroup.GetCardGroup(CardGroup.TestCardGroup); List <GuiCard> HandCard = new List <GuiCard>(); List <Container> monPlace1 = new List <Container>(); List <Container> monPlace2 = new List <Container>(); List <Container> mgcPitPlace1 = new List <Container>(); List <Container> mgcPitPlace2 = new List <Container>(); //建议先创建图层的整个列表,新添加的图层将显示在之前图层的前方。 mainPlace.LayerController.AddNewLayer("Place"); //放置卡牌的场地 mainPlace.LayerController.AddNewLayer("DuelTool"); //决斗盘的手臂部分 mainPlace.LayerController.AddNewLayer("HandCard"); //手牌展示区 mainPlace.LayerController.AddNewLayer("Select"); //被鼠标选中的卡牌会被移到比较上方的图层 mainPlace.LayerController.AddNewLayer("UI"); //其他UI //我方场地怪兽区 for (int i = 0; i < 5; i++) { Container container = new Container(new Size(Program.placeWidth * 2 / 16, Program.totalHeight * 4 / 18), mainPlace); EasyTranform.Offset(container.Transform, new Point2f((Program.totalWidth - Program.placeWidth) + Program.placeWidth * 3 / 16 + i * Program.placeWidth * 2 / 16, Program.totalHeight * 8 / 18)); mainPlace.LayerController.AddElementToLayer(container, "Place"); monPlace1.Add(container); } //对方场地怪兽区 for (int i = 0; i < 5; i++) { Container container = new Container(new Size(Program.placeWidth * 2 / 16, Program.totalHeight * 4 / 18), mainPlace); EasyTranform.Offset(container.Transform, new Point2f((Program.totalWidth - Program.placeWidth) + Program.placeWidth * 3 / 16 + i * Program.placeWidth * 2 / 16, Program.totalHeight * 4 / 18)); mainPlace.LayerController.AddElementToLayer(container, "Place"); monPlace2.Add(container); } //我方场地魔法陷阱区 for (int i = 0; i < 5; i++) { Container container = new Container(new Size(Program.placeWidth * 2 / 16, Program.totalHeight * 4 / 18), mainPlace); EasyTranform.Offset(container.Transform, new Point2f((Program.totalWidth - Program.placeWidth) + Program.placeWidth * 3 / 16 + i * Program.placeWidth * 2 / 16, Program.totalHeight * 12 / 18)); mgcPitPlace1.Add(container); mainPlace.LayerController.AddElementToLayer(mgcPitPlace1[i], "Place"); } //对方场地魔法陷阱区 for (int i = 0; i < 5; i++) { Container container = new Container(new Size(Program.placeWidth * 2 / 16, Program.totalHeight * 4 / 18), mainPlace); EasyTranform.Offset(container.Transform, new Point2f((Program.totalWidth - Program.placeWidth) + Program.placeWidth * 3 / 16 + i * Program.placeWidth * 2 / 16, Program.totalHeight * 0 / 18)); mgcPitPlace2.Add(container); mainPlace.LayerController.AddElementToLayer(mgcPitPlace2[i], "Place"); } //我方场地魔法区 Container placeMpc1 = new Container(new Size(Program.placeWidth * 2 / 16, Program.totalHeight * 4 / 18), mainPlace); EasyTranform.Offset(placeMpc1.Transform, new Point2f((Program.totalWidth - Program.placeWidth) + Program.placeWidth * 13 / 16, Program.totalHeight * 10 / 18)); mainPlace.LayerController.AddElementToLayer(placeMpc1, "Place"); //对方场地魔法区 Container placeMpc2 = new Container(new Size(Program.placeWidth * 2 / 16, Program.totalHeight * 4 / 18), mainPlace); EasyTranform.Offset(placeMpc2.Transform, new Point2f((Program.totalWidth - Program.placeWidth) + Program.placeWidth / 16, Program.totalHeight * 2 / 18)); mainPlace.LayerController.AddElementToLayer(placeMpc2, "Place"); //-----------------决斗盘手臂部分------- //卡组区 mainPlace.LayerController.AddElementToLayer(thisPlayer.CardGroupContainer, "DuelTool"); thisPlayer.CardGroup.GetCardGroup(CardGroup.TestCardGroup); for (int i = 0; i < 6; i++) { thisPlayer.CardGroup.Front_ShowAGuiCard(CardGroup.TestCardGroup[i]); } //手牌区 mainPlace.LayerController.AddElementToLayer(thisPlayer.HandCardPlaceContainer, "HandCard");//加入元素 //-----------测试(关于如何使用一个MyGuiButton) //设置文字,设置大小 MyGuiButton button = new MyGuiButton("测试", 50, new Size(100, 100)); //设置图片 button.Image = Image.Load(".\\pic\\button.jpg"); //利用EsayDoing中提供的方法进行简单的矩阵变换 //平移 EasyTranform.Offset(button.Transform, new Point2f(0, 800)); //为button添加鼠标抬起时候触发的方法 button.AddEvent_InsideMouseLeftUp(() => { var temp = thisPlayer.CardGroup.cardList.Count; for (int i = 0; i < temp - 1; i++) { thisPlayer.HandCardPlaceContainer.AddContainer_Auto(thisPlayer.CardGroup.Front_GiveAGuiCardOut()); } }); //把定义完的Button加入到图层 mainPlace.LayerController.AddElementToLayer(button, "UI"); MyGuiButton button1 = new MyGuiButton(".", 15, new Size(200, 100)) { Image = Image.Load(".\\pic\\rectbutton_null.png"), }; EasyTranform.Offset(button1.Transform, new Point2f(400, 0)); button1.AddEvent_InsideMouseLeftUp(() => { foreach (var item in MainPlace.Elements) { if (item is GuiCard) { var temp = (GuiCard)item; Console.WriteLine(temp.Card.Name); } else { Console.WriteLine(item); } } Console.WriteLine(); }); mainPlace.LayerController.AddElementToLayer(button1, "UI"); MyGuiButton ChangeButton = new MyGuiButton("切换场景", 30, new Size(200, 100)); ChangeButton.Image = Image.Load(".\\pic\\rectbutton_null.png"); //ChangeButton.Dragable = true; EasyTranform.Offset(ChangeButton.Transform, new Point2f(20, 0)); ChangeButton.AddEvent_InsideMouseLeftUp(() => { Gui.Remove(AllSceneToTakeIn.MainPlace); Gui.Add(AllSceneToTakeIn.ClientWindow); }); //MainPlace.LayerController.AddElementToLayer(ChangeButton, "UI"); }
private static void LoadClientWindow() { //联网与大厅场景 ClientWindow ClientWindow = new ClientWindow("ClientWindow"); AllSceneToTakeIn.ClientWindow = ClientWindow; //---------------------------------- var steam = MusicAndSounds.PreStar; var steam1 = MusicAndSounds.Huolang; AudioQueue audioQueue = new AudioQueue(); audioQueue.Add(steam, 0, steam.Length); AudioSource audioSource = new AudioSource(steam.WaveFormat); audioSource.SubmitAudioQueue(audioQueue); audioSource.Start(); MyGuiButton ChangeButton = new MyGuiButton("切换场景", 30, new Size(200, 100)); ChangeButton.Image = Image.Load(".\\pic\\rectbutton_null.png"); //ChangeButton.Dragable = true; EasyTranform.Offset(ChangeButton.Transform, new Point2f(0, 0)); ChangeButton.AddEvent_InsideMouseLeftUp(() => { Gui.Remove(AllSceneToTakeIn.ClientWindow); Gui.Add(AllSceneToTakeIn.MainPlace); new EasyAudio(MusicAndSounds.ChangeButtonClick).Start(); audioSource.Stop(); audioQueue.Remove(0); audioQueue.Add(steam1, 0, steam1.Length); audioSource.SubmitAudioQueue(audioQueue); audioSource.Start(); }); ClientWindow.AddElement(ChangeButton); MyGuiButton button1 = new MyGuiButton(".", 15, new Size(200, 100)) { Image = Image.Load(".\\pic\\rectbutton_null.png"), }; EasyTranform.Offset(button1.Transform, new Point2f(400, 0)); button1.AddEvent_InsideMouseLeftUp(() => { new EasyAudio(MusicAndSounds.NormalButtonClick).Start(); }); ClientWindow.AddElement(button1); //button1.Dragable = true; //MyGuiButton button2 = new MyGuiButton(".",15, new Size(200, 100)); //button2.Image = Image.Load(".\\pic\\rectbutton_null.png"); //button2.Dragable = true; //MyGuiButton button3 = new MyGuiButton(".", 15, new Size(200, 100)); //button3.Image = Image.Load(".\\pic\\rectbutton_null.png"); //button3.Dragable = true; //MyGuiButton button4 = new MyGuiButton(".", 15, new Size(200, 100)); //button4.Image = Image.Load(".\\pic\\rectbutton_null.png"); //button4.Dragable = true; //MyGuiButton button5 = new MyGuiButton(".", 15, new Size(200, 100)); //button5.Image = Image.Load(".\\pic\\rectbutton_null.png"); //button5.Dragable = true; //ClientWindow.AddElement(button1); //ClientWindow.AddElement(button2); //ClientWindow.AddElement(button3); //ClientWindow.AddElement(button4); //ClientWindow.AddElement(button5); }