public void HandleMouse(Mouse.Button key) { Map m = Logic.CurrentParty.MainParty.MyParty[0].CurMap; int x = Mouse.GetPosition(_screen).X; int y = Mouse.GetPosition(_screen).Y; if (x >= GameGUI[0].X && x <= GameGUI[0].X + 369 && y >= GameGUI[0].Y && y <= GameGUI[0].Y + 25 && GameGUI[0].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[0].HandleMouse(key, x, y); } else if (x >= GameGUI[1].X && x <= GameGUI[1].X + 178 && y >= GameGUI[1].Y && y <= GameGUI[1].Y + 178 && GameGUI[1].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[1].HandleMouse(key, x, y); } else if (x >= GameGUI[2].X && x <= GameGUI[2].X + 140 && y >= GameGUI[2].Y && y <= GameGUI[2].Y + 200 && GameGUI[2].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[2].HandleMouse(key, x, y); } //if (x >= GameGUI[3].X && x <= GameGUI[3].X + 140 && y >= GameGUI[3].Y && y <= GameGUI[3].Y + 200) //{ // GameGUI[3].HandleMouse(key, x, y); //} else if (x >= GameGUI[4].X && x <= GameGUI[4].X + 250 && y >= GameGUI[4].Y && y <= GameGUI[4].Y + 130) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[4].HandleMouse(key, x, y); } else if (x >= GameGUI[5].X && x <= GameGUI[5].X + 178 && y >= GameGUI[5].Y && y <= GameGUI[5].Y + 140 && GameGUI[5].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[5].HandleMouse(key, x, y); } else if (x >= GameGUI[7].X && x <= GameGUI[7].X + 132 && y >= GameGUI[7].Y && y <= GameGUI[7].Y + 89 && GameGUI[7].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[7].HandleMouse(key, x, y); } else if (x >= GameGUI[8].X && x <= GameGUI[8].X + 170 && y >= GameGUI[8].Y && y <= GameGUI[8].Y + 210 && GameGUI[8].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[8].HandleMouse(key, x, y); } else if (x >= GameGUI[9].X && x <= GameGUI[9].X + 170 && y >= GameGUI[9].Y && y <= GameGUI[9].Y + 150 && GameGUI[9].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[9].HandleMouse(key, x, y); } else if (x >= GameGUI[10].X && x <= GameGUI[10].X + 170 && y >= GameGUI[10].Y && y <= GameGUI[10].Y + 210 && GameGUI[10].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[10].HandleMouse(key, x, y); } else if (x >= GameGUI[11].X && x <= GameGUI[11].X + 200 && y >= GameGUI[11].Y && y <= GameGUI[11].Y + 200 && GameGUI[11].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[11].HandleMouse(key, x, y); } else { if (key == Mouse.Button.Right) { if (ClickState > -1) { ClickState = -1; return; } GameGUI[6] = new RightClickGUI(_screen, Mouse.GetPosition(_screen).X, Mouse.GetPosition(_screen).Y, (int)(Mouse.GetPosition(_screen).X / 16 + Logic.CurrentParty.MainParty.MyParty[0].X - _screen.Size.X / 2 / 16 - 1), (int)((Mouse.GetPosition(_screen).Y + 8) / 16 + Logic.CurrentParty.MainParty.MyParty[0].Y - _screen.Size.Y / 2 / 16 - 1)); GameGUI[6].HandleMouse(key, x, y); if (Mouse.IsButtonPressed(Mouse.Button.Right) && Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[(int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Logic.CurrentParty.MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY][(int)Mouse.GetPosition(_screen).X / 16 + Logic.CurrentParty.MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX] > -1 && Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[(int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Logic.CurrentParty.MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY][(int)Mouse.GetPosition(_screen).X / 16 + Logic.CurrentParty.MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX]] is SpawnBuildable) { SpawnBuildable b = (SpawnBuildable)Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[(int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Logic.CurrentParty.MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY][(int)Mouse.GetPosition(_screen).X / 16 + Logic.CurrentParty.MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX]]; if (!b.Builded) { Logic.CurrentParty.MainParty.MyParty[0].TargetX = (int)Mouse.GetPosition(_screen).X / 16 + Logic.CurrentParty.MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1; Logic.CurrentParty.MainParty.MyParty[0].TargetY = (int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Logic.CurrentParty.MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1; Logic.CurrentParty.MainParty.MyParty[0].CurrentAction = 2; Logic.DoPathFinding(Logic.CurrentParty.MainParty.MyParty[0]); Logic.CurrentParty.MainParty.MyParty[0].ActionDir = Logic.CurrentParty.MainParty.MyParty[0].PathfindingPath[0]; Logic.CurrentParty.MainParty.MyParty[0].PathfindingPath.RemoveAt(0); GameGUI[6].Visibility = false; } else { //if (Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[(int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Logic.CurrentParty.MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY][(int)Mouse.GetPosition(_screen).X / 16 + Logic.CurrentParty.MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX] > -1 && Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[(int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Logic.CurrentParty.MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY][(int)Mouse.GetPosition(_screen).X / 16 + Logic.CurrentParty.MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX]] is SpawnBuildableFire) //{ // SpawnBuildableFire bfire = (SpawnBuildableFire)Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[(int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Logic.CurrentParty.MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY][(int)Mouse.GetPosition(_screen).X / 16 + Logic.CurrentParty.MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX]]; GameGUI[6] = new RightClickGUI(_screen, Mouse.GetPosition(_screen).X, Mouse.GetPosition(_screen).Y, (int)(Mouse.GetPosition(_screen).X / 16 + Logic.CurrentParty.MainParty.MyParty[0].X - _screen.Size.X / 2 / 16 - 1), (int)((Mouse.GetPosition(_screen).Y + 8) / 16 + Logic.CurrentParty.MainParty.MyParty[0].Y - _screen.Size.Y / 2 / 16 - 1)); GameGUI[6].HandleMouse(key, x, y); //} } } } else { switch (ClickState) { case 0: GameGUI[9].Visibility = false; Logic.BuildStuff((int)Mouse.GetPosition(_screen).X / 16 + Logic.CurrentParty.MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX, (int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Logic.CurrentParty.MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1 + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY, CurrentObjectIndex, _screen, m); ClickState = -1; break; default: if (GameGUI[6].Visibility) { GameGUI[6].HandleMouse(key, x, y); GameGUI[6].Visibility = false; if(Logic.CurrentParty.MainParty.MyParty[0].CurrentAction == 4) { } return; } else if (Mouse.IsButtonPressed(Mouse.Button.Left)) { Logic.CurrentParty.MainParty.MyParty[0].CurrentAction = 0; Logic.CurrentParty.MainParty.MyParty[0].TargetX = (int)Mouse.GetPosition(_screen).X / 16 + Logic.CurrentParty.MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1; Logic.CurrentParty.MainParty.MyParty[0].TargetY = (int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Logic.CurrentParty.MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1; Logic.Pathfinder = Logic.CurrentParty.MainParty.MyParty[0]; Logic.DoPathFinding(Logic.CurrentParty.MainParty.MyParty[0]); ConstructionGUI gc = (ConstructionGUI)GameGUI[9]; bool noitem = true; SpawnBuildable sb = null; if (Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[gc.LocY][gc.LocX] > -1) { if (Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[gc.LocY][gc.LocX]] is SpawnBuildable) sb = (SpawnBuildable)Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[gc.LocY][gc.LocX]]; } if (sb != null) { for (int bs = 0; bs < sb.Required.Count; bs++) { if (sb.Required.ElementAt(bs).Value.Count > 0 || sb.Builded) noitem = false; } if (noitem) { Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnable[Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[gc.LocY][gc.LocX]] = null; Logic.CurrentParty.MainParty.MyParty[0].CurMap.SpawnedSpawnableLocation[gc.LocY][gc.LocX] = -1; } } GameGUI[9].Visibility = false; return; } break; } } } }
public void HandleMouse(Mouse.Button key) { int x = Mouse.GetPosition(_screen).X; int y = Mouse.GetPosition(_screen).Y; if (x >= GameGUI[0].X && x <= GameGUI[0].X + 369 && y >= GameGUI[0].Y && y <= GameGUI[0].Y + 25 && GameGUI[0].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[0].HandleMouse(key, x, y); } else if (x >= GameGUI[1].X && x <= GameGUI[1].X + 178 && y >= GameGUI[1].Y && y <= GameGUI[1].Y + 178 && GameGUI[1].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[1].HandleMouse(key, x, y); } else if (x >= GameGUI[2].X && x <= GameGUI[2].X + 140 && y >= GameGUI[2].Y && y <= GameGUI[2].Y + 200 && GameGUI[2].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[2].HandleMouse(key, x, y); } //if (x >= GameGUI[3].X && x <= GameGUI[3].X + 140 && y >= GameGUI[3].Y && y <= GameGUI[3].Y + 200) //{ // GameGUI[3].HandleMouse(key, x, y); //} else if (x >= GameGUI[4].X && x <= GameGUI[4].X + 250 && y >= GameGUI[4].Y && y <= GameGUI[4].Y + 130) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[4].HandleMouse(key, x, y); } else if (x >= GameGUI[5].X && x <= GameGUI[5].X + 178 && y >= GameGUI[5].Y && y <= GameGUI[5].Y + 140 && GameGUI[5].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[5].HandleMouse(key, x, y); } else if (x >= GameGUI[7].X && x <= GameGUI[7].X + 132 && y >= GameGUI[7].Y && y <= GameGUI[7].Y + 89 && GameGUI[7].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[7].HandleMouse(key, x, y); } else if (x >= GameGUI[8].X && x <= GameGUI[8].X + 250 && y >= GameGUI[8].Y && y <= GameGUI[8].Y + 250 && GameGUI[8].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[8].HandleMouse(key, x, y); } else if (x >= GameGUI[9].X && x <= GameGUI[9].X + 170 && y >= GameGUI[9].Y && y <= GameGUI[9].Y + 150 && GameGUI[9].Visibility) { if (GameGUI[6] != null) GameGUI[6].Visibility = false; GameGUI[9].HandleMouse(key, x, y); } else { if (key == Mouse.Button.Right) { if (ClickState > -1) { ClickState = -1; return; } GameGUI[6] = new RightClickGUI(_screen, Mouse.GetPosition(_screen).X, Mouse.GetPosition(_screen).Y, (int)(Mouse.GetPosition(_screen).X / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].X - _screen.Size.X / 2 / 16 - 1), (int)((Mouse.GetPosition(_screen).Y + 8) / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].Y - _screen.Size.Y / 2 / 16 - 1)); GameGUI[6].HandleMouse(key, x, y); if (Mouse.IsButtonPressed(Mouse.Button.Right) && Program.MyMap.SpawnedSpawnableLocation[(int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1 + Program.MyMap.MinY][(int)Mouse.GetPosition(_screen).X / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1 + Program.MyMap.MinX] > -1 && Program.MyMap.SpawnedSpawnable[Program.MyMap.SpawnedSpawnableLocation[(int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1 + Program.MyMap.MinY][(int)Mouse.GetPosition(_screen).X / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1 + Program.MyMap.MinX]] is SpawnBuildable) { SpawnBuildable b = (SpawnBuildable)Program.MyMap.SpawnedSpawnable[Program.MyMap.SpawnedSpawnableLocation[(int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1 + Program.MyMap.MinY][(int)Mouse.GetPosition(_screen).X / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1 + Program.MyMap.MinX]]; if (!b.Builded) { Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].TargetX = (int)Mouse.GetPosition(_screen).X / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1; Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].TargetY = (int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1; Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].CurrentAction = 2; Logic.DoPathFinding(Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0]); Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].ActionDir = Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].PathfindingPath[0]; Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].PathfindingPath.RemoveAt(0); } } } else { switch (ClickState) { case 0: GameGUI[9].Visibility = false; Logic.BuildStuff((int)Mouse.GetPosition(_screen).X / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1 + Program.MyMap.MinX, (int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1 + Program.MyMap.MinY, CurrentObjectIndex, _screen); ClickState = -1; break; default: if (GameGUI[6].Visibility) { GameGUI[6].HandleMouse(key, x, y); GameGUI[6].Visibility = false; return; } else if (Mouse.IsButtonPressed(Mouse.Button.Left)) { Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].CurrentAction = 0; Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].TargetX = (int)Mouse.GetPosition(_screen).X / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].X - (int)_screen.Size.X / 2 / 16 - 1; Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].TargetY = (int)(Mouse.GetPosition(_screen).Y + 8) / 16 + Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0].Y - (int)_screen.Size.Y / 2 / 16 - 1; Logic.DoPathFinding(Program.Data.MyPlayerData[Program.CurrentSaveData].MainParty.MyParty[0]); GameGUI[9].Visibility = false; return; } break; } } } }