/// <summary> /// 發生於目前獲得焦點的UI變更 /// </summary> protected virtual void OnFocusObjectUIChanged(ObjectUI oldValue, ObjectUI newValue) { if (oldValue != null) { oldValue.OnLostFocus(); } if (newValue != null) { newValue.OnGetFocus(); if (newValue.HasClickEnevt) { Cursor = Cursors.Hand; } else { Cursor = DefaultCursor; } } else { Cursor = DefaultCursor; } if (FocusObjectUIChanged != null) { FocusObjectUIChanged(this, oldValue, newValue); } }
public SceneGaming() { SceneTimeFix = 1.4F; MenuCooldownCounter = new CounterObject(Sec(2)); EndDelay = new CounterObject(Global.DefaultEndDelayLimit); IntervalOfWave = Global.DefaultIntervalOfWave; WaveNo = new CounterObject(0); Waves = new List <WaveLine>(); WaveEvents = new Dictionary <string, WaveEventHandle>(); _UIPlayName = new ObjectUI(75, 20, 150, 25, new DrawUIText(Color.Black, Color.WhiteSmoke, Color.Empty, Color.Empty, 0, 0, GlobalPlayer.PlayerName, new Font("微軟正黑體", 11), GlobalFormat.MiddleLeft)); _UIEnergyBar = new ObjectUI(80, 45, 150, 15, new DrawUICounterBar(GlobalColors.EnergyBar, Color.Black, Color.AliceBlue, 2, false)); _UISkillIcon1 = new ObjectUI(250, 10, 50, 50, _DrawSkill1); _UISkillIcon2 = new ObjectUI(320, 10, 50, 50, _DrawSkill2); Skill1 = GlobalScenes.ChoiceSkill1; Skill2 = GlobalScenes.ChoiceSkill2; UIObjects.Add(_UISkillIcon1); UIObjects.Add(_UISkillIcon2); UIObjects.Add(_UIPlayName); UIObjects.Add(_UIEnergyBar); GameObjects.ObjectDead += OnObjectDead; ShowMenu = false; }
protected override void OnLoadComplete() { _UITopbar = new ObjectUI(0, 0, 0, 90, new DrawUIFrame(Color.Wheat, Color.DarkSlateBlue, 1, 0)); _UIInfo = new ObjectUIPlayerInfo(DirectionType.TopLeft, 5, 5, MoveNull.Value); _UIInfo.Click += (x, e) => { PlayerInfoShow(); }; _UISceneChoice = new ObjectUISceneChoice(0, 90, Width, Height - _UITopbar.Layout.Height); _UISceneChoice.SceneChoice += (x, i, l) => { GlobalScenes.ChoiceScene = i; GlobalScenes.ChoiceLevel = l; OnGoScene(new SceneSkill()); }; _UISceneChoice.SceneHightScoreClick += (x, i, l) => { HightScoreShow(i); }; _UISceneChoice.Mode = GlobalScenes.ChoiceScene == null ? 0 : 1; UIObjects.Add(_UITopbar); UIObjects.Add(_UISceneChoice); UIObjects.Add(_UIInfo); if (string.IsNullOrWhiteSpace(GlobalPlayer.PlayerName)) { PlayerInfoShow(); } base.OnLoadComplete(); }
/// <summary> /// 鎖定場景 /// </summary> /// <param name="coverColor">遮罩顏色</param> /// <param name="fadeSpeed">遮罩出現速度</param> public void LockScene(Color coverColor, float fadeSpeed) { DrawBrush drawCover = new DrawBrush(coverColor, ShapeType.Rectangle); ObjectUI newCover = new ObjectUI(0, 0, Width, Height, drawCover); if (fadeSpeed > 0) { drawCover.Colors.Opacity = 0; newCover.Propertys.Add(new PropertyOpacityFix(1, fadeSpeed, true)); } _UIObjects.Add(newCover); _LockCover.Push(newCover); SearchFocusObjectUI(); }
/// <summary> /// 新增場景資訊畫面 /// </summary> /// <param name="anchor">訂位位置</param> /// <param name="x">X座標</param> /// <param name="y">Y座標</param> /// <param name="moveObject">移動物件</param> public ObjectUISceneInfo(DirectionType anchor, int x, int y, MoveBase moveObject) : base(anchor, x, y, 220, 150, new DrawUIFrame(Color.AliceBlue, Color.DarkSlateBlue, 2, 20), moveObject) { _DrawCommandHighScore = new DrawUIText(Color.SteelBlue, Color.RoyalBlue, Color.FromArgb(220, 255, 255), Color.SteelBlue, 2, 8, "排行榜", new Font("微軟正黑體", 12), GlobalFormat.MiddleCenter); _DrawCommandHighScoreHover = new DrawUIText(Color.SteelBlue, Color.RoyalBlue, Color.FromArgb(100, 220, 255, 255), Color.SteelBlue, 2, 8, "排行榜", new Font("微軟正黑體", 12), GlobalFormat.MiddleCenter); _CommandHighScore = new ObjectUI(160, 10, 50, 25, _DrawCommandHighScore); _CommandHighScore.DrawObjectHover = _DrawCommandHighScoreHover; _CommandHighScore.Propertys.Add(new PropertyShadow(2, 2)); _CommandHighScore.Layout.Depend.SetObject(this); _CommandHighScore.Layout.Depend.Anchor = DirectionType.Left | DirectionType.Top; _CommandHighScore.Click += (s, e) => { OnHightScoreClick(); }; }
public override void Action() { if (MoveObject == MoveNull.Value) { base.Action(); } else { ObjectUI inRect = InRectangle(Scene.TrackPoint); base.Action(); if (inRect != InRectangle(Scene.TrackPoint)) { Scene.SearchFocusObjectUI(); } } }
/// <summary> /// 重新搜尋目前獲得焦點的UI /// </summary> public void SearchFocusObjectUI() { ObjectUI fidUI = null; for (int i = UIObjects.Count - 1; i >= 0; i--) // 由後往前找 { ObjectUI item = UIObjects[i] as ObjectUI; if (item != null && item.Visible) { ObjectUI hoverUI = item.InRectangle(TrackPoint); if (hoverUI != null) { fidUI = hoverUI.Enabled ? hoverUI : null; break; } } } FocusObjectUI = fidUI; }
/// <summary> /// 取消鎖定場景 /// </summary> /// <param name="fadeSpeed">遮罩消失速度</param> public void UnlockScene(float fadeSpeed) { if (_LockCover.Count == 0) { return; } ObjectUI cover = _LockCover.Pop(); if (fadeSpeed > 0) { PropertyOpacityFix fadeout = new PropertyOpacityFix(0, fadeSpeed, true); fadeout.End += (x, e) => { cover.Kill(null, ObjectDeadType.Clear); }; cover.Propertys.Add(fadeout); } }
/// <summary> /// 檢查座標是否在此物件內 /// </summary> /// <param name="point">檢查座標</param> public override ObjectUI InRectangle(Point point) { ObjectUI result = base.InRectangle(point); if (result == null) { return(null); } for (int i = UIObjects.Count - 1; i >= 0; i--) { ObjectUI child = UIObjects[i] as ObjectUI; if (child != null && child.Visible) { ObjectUI chileFocus = child.InRectangle(point); if (chileFocus != null) { return(chileFocus.Enabled ? chileFocus : result); } } } return(result); }
public SceneSkill() { InitializeComponent(); _Skills = new SkillBase[] { new SkillSprint(3000, Sec(0.7F), 0, 6000, true), new SkillShield(1, 6000, 0, Sec(2F), Sec(3F)), new SkillShockwave(6000, 0, Sec(1.5F), Sec(2.5F), Sec(0.1F), 4000, 300), new SkillBulletTime(2000, 9000, -1, Sec(3), 1), new SkillBait(6000, Sec(2F), Sec(2F), 400), new SkillShotgun(5, 1, 60, 5000, Sec(1F)) //new SkillSleep(3000,Sec(0.5F),Sec(0.5F)) }; if (DeveloperOptions.Player_NoCast) { foreach (SkillBase skill in _Skills) { skill.CostEnergy = 0; skill.CostEnergyPerSec = 0; } } if (DeveloperOptions.Player_NoCooldown) { foreach (SkillBase skill in _Skills) { skill.Cooldown.Limit = 0; } } int len = _Skills.Length; _UISkillIcons = new ObjectUI[len]; _UISkillInfos = new ObjectUI[len]; for (int i = 0; i < len; i++) { int left = i % 2 * 270 + 30; int top = i / 2 * 100 + 120; DrawBase skillDraw = _Skills[i].GetDrawObject(Color.FromArgb(120, 60, 0)); DrawUISkillFrame drawFrame = new DrawUISkillFrame(Color.White, Color.FromArgb(210, 180, 50), 2, 10, SkillKeyType.None, skillDraw) { StaticMode = true }; _UISkillIcons[i] = new ObjectUI(left, top, 75, 75, drawFrame); _UISkillIcons[i].GetFocus += (s, e) => { (s as ObjectUI).DrawObject.Colors.SetColor("Border", Color.Chocolate); (s as ObjectUI).DrawObject.Scale = 1.1F; }; _UISkillIcons[i].LostFocus += (s, e) => { (s as ObjectUI).DrawObject.Colors.SetColor("Border", Color.FromArgb(210, 180, 50)); (s as ObjectUI).DrawObject.Scale = 1F; }; _UISkillIcons[i].Click += IconClick; DrawBase infoDraw = _Skills[i].GetInfoObject(Color.Chocolate, Color.Cornsilk, Color.FromArgb(180, 210, 180, 50)); _UISkillInfos[i] = new ObjectUI(left + 85, top + 6, 170, 75, infoDraw); _UISkillIcons[i].Propertys.Add(new PropertyShadow(4, 6, 1, 1, 0.2F) { RFix = -0.3F, GFix = -0.3F, BFix = -0.3F }); if (GlobalScenes.ChoiceSkill1 != null && _Skills[i].ID == GlobalScenes.ChoiceSkill1.ID) { Skill1 = drawFrame; drawFrame.DrawButton = SkillKeyType.MouseButtonLeft; } else if (GlobalScenes.ChoiceSkill2 != null && _Skills[i].ID == GlobalScenes.ChoiceSkill2.ID) { Skill2 = drawFrame; drawFrame.DrawButton = SkillKeyType.MouseButtonRight; } UIObjects.Add(_UISkillIcons[i]); UIObjects.Add(_UISkillInfos[i]); } DrawUIText drawCommandOK = new DrawUIText(Color.Black, Color.WhiteSmoke, Color.FromArgb(150, 255, 255, 255), Color.Black, 2, 10, "繼續", Global.CommandFont, GlobalFormat.MiddleCenter); DrawUIText drawCommandCancel = new DrawUIText(Color.Black, Color.WhiteSmoke, Color.FromArgb(150, 255, 255, 255), Color.Black, 2, 10, "返回", Global.CommandFont, GlobalFormat.MiddleCenter); DrawUIText drawCommandOKHover = new DrawUIText(Color.Black, Color.WhiteSmoke, Color.FromArgb(200, 255, 255, 220), Color.Black, 2, 10, "繼續", Global.CommandFont, GlobalFormat.MiddleCenter); DrawUIText drawCommandCancelHover = new DrawUIText(Color.Black, Color.WhiteSmoke, Color.FromArgb(200, 255, 255, 220), Color.Black, 2, 10, "返回", Global.CommandFont, GlobalFormat.MiddleCenter); _UICommandOK = new ObjectUI(0, 0, 150, 50, drawCommandOK); _UICommandCancel = new ObjectUI(0, 0, 150, 50, drawCommandCancel); _UICommandOK.DrawObjectHover = drawCommandOKHover; _UICommandCancel.DrawObjectHover = drawCommandCancelHover; _UICommandOK.Propertys.Add(new PropertyShadow(-4, 4) { RFix = 0, GFix = 0, BFix = 0 }); _UICommandCancel.Propertys.Add(new PropertyShadow(4, 4) { RFix = 0, GFix = 0, BFix = 0 }); UIObjects.Add(_UICommandOK); UIObjects.Add(_UICommandCancel); _UICommandOK.Click += (x, e) => { GlobalScenes.ChoiceSkill1 = Skill1 == null ? null : (Skill1.DrawObjectInside as DrawSkillBase).BindingSkill; GlobalScenes.ChoiceSkill2 = Skill2 == null ? null : (Skill2.DrawObjectInside as DrawSkillBase).BindingSkill; SceneGaming scene = GlobalScenes.ChoiceScene.CreateScene(GlobalScenes.ChoiceLevel); OnGoScene(scene); }; _UICommandCancel.Click += (x, e) => { OnGoScene(new SceneMain() { }); }; }
public ObjectUISceneChoice(int x, int y, int width, int height) : base(x, y, width, height, new DrawBrush(Color.White, ShapeType.Rectangle)) { BackObjects = new ObjectCollection(); var ScenesItems = GlobalScenes.Scenes.GetItems(); int group1Idx = 0; int group1Cot = ScenesItems.Count; _UIScenes = new ObjectUISceneInfo[group1Cot]; _UIScenesLocation = new PointF[group1Cot]; foreach (ISceneInfo sceneInfo in ScenesItems) { _UIScenes[group1Idx] = new ObjectUISceneInfo(DirectionType.TopLeft, 0, 0, new MoveStraight(this, 1, 3000, 1, 100, 1F)); _UIScenes[group1Idx].MoveObject.Target.Anchor = DirectionType.TopLeft; _UIScenes[group1Idx].MoveObject.Anchor = DirectionType.TopLeft; _UIScenes[group1Idx].Layout.Depend.Anchor = DirectionType.TopLeft; _UIScenes[group1Idx].Layout.Depend.SetObject(this); _UIScenes[group1Idx].BindingScene = sceneInfo; _UIScenes[group1Idx].SceneChoice += (s, i, l) => { OnSceneChoice(i, l); }; _UIScenes[group1Idx].HightScoreClick += (s, i) => { OnSceneHightScoreClick(sceneInfo); }; UIObjects.Add(_UIScenes[group1Idx]); group1Idx++; } if (group1Cot > 0) { int maxH = (int)((width - _PaddingX * 2 + _ItemPaddingX) / (_UIScenes[0].Layout.RectWidth + _ItemPaddingX)); // 橫向最多項目數 int cotX = group1Cot > maxH ? maxH : group1Cot; // 橫向數量 int cotY = (group1Cot - 1) / maxH + 1; // 縱向數量 float baseX = (width - (_UIScenes[0].Layout.RectWidth * cotX) - (_ItemPaddingX * (cotX - 1))) / 2; float baseY = _PaddingY + (height - (_UIScenes[0].Layout.RectWidth * cotY) - (_ItemPaddingY * (cotY - 1))) / 2; baseY = Math.Max(_ItemMinY, baseY); float originX = baseX; for (int i = 0; i < _UIScenes.Length; i++) { _UIScenesLocation[i] = new PointF(baseX, baseY); _UIScenes[i].Layout.X = baseX; _UIScenes[i].Layout.Y = baseY + height; _UIScenes[i].MoveObject.Target.SetOffsetByXY(baseX, baseY + height); if (i > 0 && i - 1 % cotX == 0) { baseX = originX; baseY += _UIScenes[0].Layout.RectHeight + _ItemPaddingY; } else { baseX += _UIScenes[i].Layout.RectWidth + _ItemPaddingX; } } } _DrawGroup1 = new DrawUIText(Color.DarkSlateBlue, Color.White, Color.AliceBlue, Color.DarkSlateBlue, 2, 12, "生存100秒", new Font("標楷體", 18, FontStyle.Bold), GlobalFormat.BottomCenter); _DrawGroup1.DrawObjectInside = new DrawSceneTypeA(Color.LightSteelBlue); _UIGroup1 = new ObjectUI(DirectionType.Center, -200, height / 2, 200, 200, _DrawGroup1, new MoveStraight(this, 1, 3000, 1, 100, 1F)); _UIGroup1.Propertys.Add(new PropertyShadow(3, 4)); _UIGroup1.Layout.Depend.Anchor = DirectionType.TopLeft; _UIGroup1.Layout.Depend.SetObject(this); _UIGroup1.GetFocus += (s, e) => { _DrawGroup1.Colors.SetColor("Back", Color.FromArgb(255, 255, 220)); _DrawGroup1.DrawObjectInside.Colors.SetColor("Player", Color.Black); _DrawGroup1.DrawObjectInside.Colors.SetColor("Ememy", Color.Red); }; _UIGroup1.LostFocus += (s, e) => { _DrawGroup1.Colors.SetColor("Back", Color.AliceBlue); _DrawGroup1.DrawObjectInside.Colors.SetColor("Player", Color.LightSteelBlue); _DrawGroup1.DrawObjectInside.Colors.SetColor("Ememy", Color.LightSteelBlue); }; _UIGroup1.Click += (s, e) => { Mode = 1; }; _DrawGroup2 = new DrawUIText(Color.DarkSlateBlue, Color.White, Color.WhiteSmoke, Color.DarkSlateBlue, 2, 12, "", new Font("標楷體", 18), GlobalFormat.BottomCenter); _UIGroup2 = new ObjectUI(DirectionType.Center, width + 200, height / 2, 200, 200, _DrawGroup2, new MoveStraight(this, 1, 3000, 1, 100, 1F)); _UIGroup2.Propertys.Add(new PropertyShadow(-3, 4)); _UIGroup2.Layout.Depend.Anchor = DirectionType.TopLeft; _UIGroup2.Layout.Depend.SetObject(this); _CommandBack = new ObjectUI(20, 20, 80, 40, new DrawUIText(Color.Black, Color.Gray, Color.FromArgb(255, 255, 255, 220), Color.Black, 1, 8, "返回", new Font("微軟正黑體", 18), GlobalFormat.MiddleCenter)); _CommandBack.Propertys.Add(new PropertyShadow(5, 4) { RFix = 0F, GFix = 0F, BFix = 0F }); _CommandBack.Layout.Depend.Anchor = DirectionType.TopLeft; _CommandBack.Layout.Depend.SetObject(this); _CommandBack.Visible = false; _CommandBack.Click += (s, e) => { Mode = 0; }; UIObjects.Add(_CommandBack); UIObjects.Add(_UIGroup1); UIObjects.Add(_UIGroup2); Mode = 0; }
public ObjectUIHighScore(DirectionType anchor, int x, int y, MoveBase moveObject, ISceneInfo sceneInfo) : base(anchor, x, y, 380, 390, new DrawUIFrame(Color.AliceBlue, Color.CornflowerBlue, 2, 20), moveObject) { Propertys.Add(new PropertyShadow(0, 6, 0.95F, 1)); DrawUIText drawCommandClose = new DrawUIText(Color.RoyalBlue, Color.Gray, Color.FromArgb(175, 220, 230, 255), Color.FromArgb(100, 140, 255), 1, 10, "關 閉", new Font("微軟正黑體", 14), GlobalFormat.MiddleCenter); DrawUIText drawCommandCloseHover = new DrawUIText(Color.RoyalBlue, Color.Gray, Color.FromArgb(220, 255, 250, 235), Color.FromArgb(100, 140, 255), 1, 10, "關 閉", new Font("微軟正黑體", 14), GlobalFormat.MiddleCenter); _CommandClose = new ObjectUI(285, 10, 75, 30, drawCommandClose) { DrawObjectHover = drawCommandCloseHover }; _CommandClose.Propertys.Add(new PropertyShadow(2, 2) { RFix = -0.5F, GFix = -0.5F, BFix = -0.5F, Opacity = 0.2F }); _CommandClose.Layout.Depend.Anchor = DirectionType.TopLeft; _CommandClose.Layout.Depend.SetObject(this); _CommandClose.Click += (s, e) => { OnClose(); }; UIObjects.Add(_CommandClose); if (sceneInfo == null) { return; } _SceneInfo = sceneInfo; int itemWidth = 40; int itemHeight = 25; int left = 15; int top = 15; _SceneButtons = new ObjectUI[sceneInfo.MaxLevel]; for (int i = 0; i < sceneInfo.MaxLevel; i++) { int idx = i + 1; DrawUIFrame drawObject = new DrawUIFrame(Color.FromArgb(175, 255, 255, 255), Color.FromArgb(100, 140, 255), 1, 8) { Scale = 0.8F }; ObjectUI newObject = new ObjectUI(left, top, itemWidth, itemHeight, drawObject); newObject.Layout.Depend.SetObject(this); newObject.Layout.Depend.Anchor = DirectionType.TopLeft; newObject.Propertys.Add(new PropertyShadow(3, 3) { Opacity = 0.2F, ScaleX = 0.95F, ScaleY = 0.95F }); UIObjects.Add(newObject); left += itemWidth; drawObject.AfterDraw += (s, g, r) => { g.DrawString(idx.ToString(), _ItemFont, Brushes.RoyalBlue, r, GlobalFormat.MiddleCenter); }; newObject.GetFocus += (s, e) => { (s as ObjectUI).DrawObject.Colors.SetColor("Border", Color.Red); _HoverLevel = idx; }; newObject.LostFocus += (s, e) => { (s as ObjectUI).DrawObject.Colors.SetColor("Border", Color.FromArgb(100, 140, 255)); _HoverLevel = 0; }; newObject.Click += (s, e) => { SelectedIndex = _HoverLevel; }; _SceneButtons[i] = newObject; } SelectedIndex = 1; DrawUIFrame drawPanel = new DrawUIFrame(Color.FromArgb(180, 220, 240, 250), Color.Empty, 0, 0); ObjectUI panel = new ObjectUI(10, 50, Layout.Width - 20, Layout.Height - 60, drawPanel); panel.Propertys.Add(new PropertyShadow(-2, -2)); panel.Layout.Depend.SetObject(this); panel.Layout.Depend.Anchor = DirectionType.Left | DirectionType.Top; UIObjects.Add(panel); _DrawRects = new DrawUIText[3, 10]; _DrawInfos = new string[3, 10]; int rectLeft = 5, rectTop = 5; int rectHeight = 27; for (int i = 0; i < 10; i++) { _DrawRects[0, i] = new DrawUIText(Color.RoyalBlue, Color.Empty, Color.AliceBlue, Color.Empty, 0, 0, "", _ItemFont2, GlobalFormat.MiddleCenter); _DrawRects[1, i] = new DrawUIText(Color.RoyalBlue, Color.Empty, Color.WhiteSmoke, Color.Empty, 0, 0, "", _ItemFont2, GlobalFormat.MiddleLeft); _DrawRects[2, i] = new DrawUIText(Color.RoyalBlue, Color.Empty, Color.WhiteSmoke, Color.Empty, 0, 0, "", _ItemFont2, GlobalFormat.MiddleRight); ObjectUI object1 = new ObjectUI(rectLeft, rectTop, 35, rectHeight, _DrawRects[0, i]); ObjectUI object2 = new ObjectUI(rectLeft + 40, rectTop, 210, rectHeight, _DrawRects[1, i]); ObjectUI object3 = new ObjectUI(rectLeft + 255, rectTop, 90, rectHeight, _DrawRects[2, i]); object1.Propertys.Add(new PropertyShadow(2, 2)); object2.Propertys.Add(new PropertyShadow(2, 2)); object3.Propertys.Add(new PropertyShadow(2, 2)); object1.Layout.Depend.SetObject(panel); object2.Layout.Depend.SetObject(panel); object3.Layout.Depend.SetObject(panel); object1.Layout.Depend.Anchor = DirectionType.Left | DirectionType.Top; object2.Layout.Depend.Anchor = DirectionType.Left | DirectionType.Top; object3.Layout.Depend.Anchor = DirectionType.Left | DirectionType.Top; UIObjects.Add(object1); UIObjects.Add(object2); UIObjects.Add(object3); rectTop += rectHeight + 5; } _DrawCommandMessage = new DrawUIText(Color.Red, Color.Gray, Color.LightYellow, Color.Black, 1, 0, "連線中...", new Font("微軟正黑體", 20), GlobalFormat.MiddleCenter); _CommandMessage = new ObjectUI(DirectionType.Center, 0, 0, 200, 60, _DrawCommandMessage); _CommandMessage.Layout.Depend.SetObject(this); _CommandMessage.Layout.Depend.Anchor = DirectionType.Center; _CommandMessage.Propertys.Add(new PropertyShadow(2, 4)); UIObjects.Add(_CommandMessage); LoadData(); }
public ObjectUIGameMenu(DirectionType anchor, int x, int y, MoveBase moveObject, ScenePlayingInfo playingInfo, int mode) : base(anchor, x, y, 380, 240 + playingInfo.ScoreDetail.Count * _DetailHeight, new DrawUIFrame(Color.Empty, Color.DarkSlateBlue, 2, 20), moveObject) { _DrawCommandAction = new DrawUIText(Color.Black, Color.White, Color.FromArgb(150, 255, 255, 255), Color.Black, 2, 10, "", Global.CommandFont, GlobalFormat.MiddleCenter); _DrawCommandActionHover = new DrawUIText(Color.Black, Color.White, Color.FromArgb(200, 255, 255, 220), Color.Black, 2, 10, "", Global.CommandFont, GlobalFormat.MiddleCenter); _UICommandAction = new ObjectUI(210, Layout.Height - 75, 150, 50, _DrawCommandAction); _UICommandAction.DrawObjectHover = _DrawCommandActionHover; _UICommandAction.Layout.Depend.SetObject(this); _UICommandAction.Layout.Depend.Anchor = DirectionType.TopLeft; _UICommandAction.Propertys.Add(new PropertyShadow(-4, 4) { RFix = 0, GFix = 0, BFix = 0 }); _UICommandAction.Click += (s, e) => { OnActionButtonClick(_ActionCommand); }; _DrawCommandBack = new DrawUIText(Color.Black, Color.White, Color.FromArgb(150, 255, 255, 255), Color.Black, 2, 10, "回選單", Global.CommandFont, GlobalFormat.MiddleCenter); _DrawCommandBackHover = new DrawUIText(Color.Black, Color.White, Color.FromArgb(200, 255, 255, 220), Color.Black, 2, 10, "回選單", Global.CommandFont, GlobalFormat.MiddleCenter); _UICommandBack = new ObjectUI(20, Layout.Height - 75, 150, 50, _DrawCommandBack); _UICommandBack.DrawObjectHover = _DrawCommandBackHover; _UICommandBack.Layout.Depend.SetObject(this); _UICommandBack.Layout.Depend.Anchor = DirectionType.TopLeft; _UICommandBack.Propertys.Add(new PropertyShadow(4, 4) { RFix = 0, GFix = 0, BFix = 0 }); _UICommandBack.Click += (s, e) => { OnBackButtonClick(); }; _DrawCommandUpdate = new DrawUIText(Color.Black, Color.White, Color.FromArgb(150, 225, 255, 225), Color.Black, 2, 10, "上傳分數", _UpdateFont, GlobalFormat.MiddleCenter); _DrawCommandUpdateHover = new DrawUIText(Color.Black, Color.White, Color.FromArgb(200, 255, 235, 220), Color.Black, 2, 10, "上傳分數", _UpdateFont, GlobalFormat.MiddleCenter); _UICommandUpdate = new ObjectUI(270, 10, 90, 25, _DrawCommandUpdate); _UICommandUpdate.DrawObjectHover = _DrawCommandUpdateHover; _UICommandUpdate.Layout.Depend.SetObject(this); _UICommandUpdate.Layout.Depend.Anchor = DirectionType.TopLeft; _UICommandUpdate.Propertys.Add(new PropertyShadow(4, 4) { RFix = 0, GFix = 0, BFix = 0 }); _UICommandUpdate.Click += (s, e) => { if (Global.Online) { Global.SQL.AddParameter("@SceneID", PlayingInfo.SceneID); Global.SQL.AddParameter("@Level", PlayingInfo.Level); Global.SQL.AddParameter("@PlayerName", GlobalPlayer.PlayerName); Global.SQL.AddParameter("@Score", PlayingInfo.Score); if (Global.SQL.Run(@"set time_zone = '+8:00'; insert into Score (SceneID,Level,PlayerName,Score,UpdateTime) values (@SceneID,@Level,@PlayerName,@Score,now())")) { _DrawCommandUpdate.Text = "上傳成功"; _DrawCommandUpdateHover.Text = "上傳成功"; _UICommandUpdate.Enabled = false; } else { _DrawCommandUpdate.Text = "上傳失敗"; _DrawCommandUpdateHover.Text = "上傳失敗"; } } else { _DrawCommandUpdate.Text = "不可用"; _DrawCommandUpdateHover.Text = "不可用"; _UICommandUpdate.Enabled = false; } }; UIObjects.Add(_UICommandBack); UIObjects.Add(_UICommandAction); UIObjects.Add(_UICommandUpdate); PlayingInfo = playingInfo; Mode = mode; }
public ObjectUINameSetting(DirectionType anchor, int x, int y, MoveBase moveObject) : base(anchor, x, y, 310, 125, new DrawUIFrame(Color.AliceBlue, Color.CornflowerBlue, 2, 20), moveObject) { Propertys.Add(new PropertyShadow(0, 6, 0.95F, 1)); // 玩家姓名 _DrawPlayerName = new DrawUITextScroll(Color.Maroon, Color.LightGray, Color.FromArgb(230, 255, 245), Color.CornflowerBlue, 1, 10, GlobalPlayer.PlayerName, new Font("細明體", 12), GlobalFormat.MiddleLeft, 120) { TextPadding = new Padding(10, 10, 0, 5) }; ObjectUI uiPlayerName = new ObjectUI(20, 60, 270, 40, _DrawPlayerName); // 重新選取 DrawUIText drawCommandBuildName = new DrawUIText(Color.CornflowerBlue, Color.Empty, Color.Empty, Color.Empty, 0, 0, "↻", new Font("標楷體", 22, FontStyle.Bold), GlobalFormat.MiddleCenter) { TextPadding = new Padding(0, 10, 0, 0) }; DrawUIText drawCommandBuildNameHover = new DrawUIText(Color.Orange, Color.Empty, Color.Empty, Color.Empty, 0, 0, "↻", new Font("標楷體", 22, FontStyle.Bold), GlobalFormat.MiddleCenter) { TextPadding = new Padding(0, 10, 0, 0) }; ObjectUI uiCommandBuildName = new ObjectUI(250, 60, 40, 40, drawCommandBuildName) { DrawObjectHover = drawCommandBuildNameHover }; DrawUIText drawCommandOK = new DrawUIText(Color.FromArgb(100, 220, 100), Color.Empty, Color.Empty, Color.Empty, 0, 0, "✔", new Font("微軟正黑體", 16, FontStyle.Bold), GlobalFormat.MiddleCenter); DrawUIText drawCommandOKHover = new DrawUIText(Color.FromArgb(0, 180, 0), Color.Empty, Color.Empty, Color.Empty, 0, 0, "✔", new Font("微軟正黑體", 16, FontStyle.Bold), GlobalFormat.MiddleCenter); _CommandOK = new ObjectUI(230, 15, 30, 30, drawCommandOK) { Visible = false, DrawObjectHover = drawCommandOKHover }; _CommandOK.Propertys.Add(new PropertyShadow(2, 2) { RFix = -0.5F, GFix = -0.5F, BFix = -0.5F, Opacity = 0.2F }); DrawUIText drawCommandClose = new DrawUIText(Color.FromArgb(255, 150, 150), Color.Empty, Color.Empty, Color.Empty, 0, 0, "✘", new Font("微軟正黑體", 16, FontStyle.Bold), GlobalFormat.MiddleCenter); DrawUIText drawCommandCloseHover = new DrawUIText(Color.FromArgb(255, 70, 70), Color.Empty, Color.Empty, Color.Empty, 0, 0, "✘", new Font("微軟正黑體", 16, FontStyle.Bold), GlobalFormat.MiddleCenter); _CommandClose = new ObjectUI(260, 15, 30, 30, drawCommandClose) { Visible = !string.IsNullOrWhiteSpace(GlobalPlayer.PlayerName), DrawObjectHover = drawCommandCloseHover }; _CommandClose.Propertys.Add(new PropertyShadow(2, 2) { RFix = -0.5F, GFix = -0.5F, BFix = -0.5F, Opacity = 0.2F }); uiPlayerName.Layout.Depend.Anchor = DirectionType.TopLeft; uiCommandBuildName.Layout.Depend.Anchor = DirectionType.TopLeft; _CommandOK.Layout.Depend.Anchor = DirectionType.TopLeft; _CommandClose.Layout.Depend.Anchor = DirectionType.TopLeft; uiCommandBuildName.Layout.Depend.SetObject(this); uiPlayerName.Layout.Depend.SetObject(this); _CommandOK.Layout.Depend.SetObject(this); _CommandClose.Layout.Depend.SetObject(this); uiCommandBuildName.Click += (s, e) => { _DrawPlayerName.Text = Function.GetRandName(); _CommandOK.Visible = true; }; _CommandOK.Click += (s, e) => { GlobalPlayer.PlayerName = _DrawPlayerName.Text; GlobalPlayer.WriteRegistry(); OnClose(); }; _CommandClose.Click += (s, e) => { OnClose(); }; UIObjects.Add(uiPlayerName); UIObjects.Add(uiCommandBuildName); UIObjects.Add(_CommandOK); UIObjects.Add(_CommandClose); }