public void UpdateSolar()
{
selectedhex.color = selectedcolor;
((SolarSystem3D)space).sun.color = ((SolarSystem3D)space).sun.defaultcolor;
////////mouse stuff////////
if (oldmousehex != null && !oldmousehex.Equals(selectedhex)) oldmousehex.color = oldmousehex.defaultcolor;
mousehex = ((SolarSystem3D)space).GetMouseOverHex();
if ((mousestate.LeftButton == ButtonState.Pressed) && (oldmousestate.LeftButton == ButtonState.Released) && !shipmenu.Contains(mousestate.X, mousestate.Y) && !planetmenu.Contains(mousestate.X, mousestate.Y) && !galaxybutton.Contains(mousestate.X, mousestate.Y) && mousehex != null)
{
//selecting a hex
if (clickedaction == Command.Action.None)
{
selectedhex = mousehex;
}
//selecting a target of a action
if (clickedaction != Command.Action.None && !waiting)
{
Console.WriteLine("a command");
if (selectedhex.GetGameObject() is Ship && clickedaction == Command.Action.Move)
{
if (!((Ship)(selectedhex.GetGameObject())).GetReachable().Contains(mousehex)) { return; }
((Ship)(selectedhex.GetGameObject())).SetGhost(mousehex);
}
if (selectedhex.GetGameObject() is Warship && clickedaction == Command.Action.Fire)
{
if (!((Warship)(selectedhex.GetGameObject())).GetShootable().Contains(mousehex)) { return; }
//((Ship)(selectedhex.GetGameObject())).SetGhost(mousehex);
}
if (selectedhex.GetGameObject() is Warship && clickedaction == Command.Action.Colonize)
{
if (!((Warship)(selectedhex.GetGameObject())).GetReachable().Contains(mousehex)) { return; }
//((Ship)(selectedhex.GetGameObject())).SetGhost(mousehex);
}
if (selectedhex.GetGameObject() is Ship && clickedaction == Command.Action.Jump)
{
if (!((SolarSystem3D)(space)).GetWarpable().Contains(mousehex)) {}
else if (!selectedhex.GetGameObject().hex.hexgrid.neighbors.Contains((SolarSystem3D)(space))) {}
else
{
((Ship)(selectedhex.GetGameObject())).SetGhost(mousehex);
}
Boolean vis = true;
int thresh = 0;
foreach (Hex3D h1 in ((SolarSystem3D)space).getHexes()) {
if (!h1.visible) {
vis = false;
break;
}
thresh ++;
if (thresh >= 10) {
break;
}
}
if (!vis) {
space = galaxy;
Console.WriteLine("BUMP");
}
}
middleman.AddCommand(new Command(selectedhex, mousehex, clickedaction));
clickedaction = Command.Action.None;
selectedhex = nullhex;
}
}
/////stuff to do if a ship is selected/////
GameObject selectedobject = selectedhex.GetGameObject();
if (selectedobject != null && selectedobject is Unit) { statusmenu.Update((Unit)selectedobject); statusmenu.Show(); }
else { statusmenu.Hide(); }
if (selectedhex.GetGameObject() is Ship && clickedaction == Command.Action.Jump)
{
foreach (Hex3D h in ((SolarSystem3D)space).GetWarpable())
{
h.color = Color.Blue;
}
}
if (selectedobject != null && selectedobject is Ship && ((Ship)selectedobject).getAffiliation().Equals(player)) { shipmenu.Show(); }
else { shipmenu.Hide(); }
if (selectedobject != null && selectedobject is Warship)
{
foreach (Hex3D h in ((Warship)selectedobject).GetShootable())
{
h.color = Color.Red;
}
}
if (selectedobject != null && selectedobject is Ship)
{
Ship tmpShip = (Ship)selectedobject;
if (oldShip != null && oldShip != tmpShip)
{
tmpShip.shiptype.PlaySelectSound();
}
oldShip = tmpShip;
foreach (Hex3D h in ((Ship)selectedobject).GetReachable())
{
h.color = movecolor;
}
}
////VERY REDUNDANT, handles cases where range is smaller than speed
if (selectedobject != null && selectedobject is Warship && ((Warship)selectedobject).GetRange() < ((Warship)selectedobject).getSpeed())
{
foreach (Hex3D h in ((Warship)selectedobject).GetShootable())
{
h.color = Color.Red;
}
}
//planetmenu
if (selectedobject != null && selectedobject is Planet && ((Planet)selectedobject).getAffiliation() != null && ((Planet)selectedobject).getAffiliation().Equals(player)) { planetmenu.Show(); }
else { planetmenu.Hide(); }
//Color the mousedover hex
if (mousehex != null && !mousehex.Equals(selectedhex) && !shipmenu.Contains(mousestate.X, mousestate.Y)) { mousehex.color = mousecolor; }
telescopemenu.Hide();
}