public MainPlaceInfo(MainPlace mainPlace) { this.MainPlace = mainPlace; this.Time = 0; this.gameState = GameState.Process; this.process = Process.GameStart; Player1 = new Player(this); Player2 = new Player(this); //MainPlace=new MainPlace() }
public Container(Size size, MainPlace main) { ContainerKind = GuiCard.Where.Place; this.MainPlace = main; base.Size = size; this.state = StateToDraw.None; this.Style = new ContainerStyle(); this.CardImage = Image.Load(".\\pic\\pic_called.jpg"); this.ContainerRect = new ContainerRect(size); Dragable = false; EasyInputAction = new EasyInputAction(this); EasyInputAction.AddEvent_MouseDownDragInside(Event_DragInside); EasyInputAction.AddEvent_OnlyInsideMouseLeftUp(Event_OnlyInsideUp); }
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"); }