/// <summary> /// Creates the player empire. /// </summary> void StartPlayerEmpire() { var player = EmpireManager.CreateNewEmpire(); player.EmpireColor = Spritemanager.Colors["LGREEN"]; InitCursor(TileToWorld(player.Colonies[0].Location)); MenuManager.Cursor.PlayerEmpire = player; var curmov = Cursor.GetComponent <Movement>(); curmov.StarSystem = this; curmov.Move(player.Colonies[0].Location); MenuManager.Cursor.Movement = curmov; MenuManager.Cursor.SetCamPos(); Logger.PingLocation = player.Colonies[0].Location; player.OnBuildShip += (Vector3Int location, Attributes attributes) => { Logger.Log($"New Ship of type {attributes.Type} built at {location.ToString()}", location); }; player.OnColonize += (Vector3Int location, ColonyAttributes atr) => { Logger.Log($"New Colony founded at {location.ToString()}", location); }; }
/// <summary> /// Loads the selected menu. /// </summary> /// <param name="attributes"></param> public void LoadSelectedMenu(BaseAttributes attributes) { CloseMenu("select"); var pageo = Instantiate(menuObj, Canvas.transform); var menu = pageo.GetComponentInChildren <MenuController>(); menu.AddText("selectobj", attributes.name); var colony = attributes as ColonyAttributes; var entity = attributes as Attributes; if (colony != null) { var colonyControl = colony.GetComponent <ColonyControl>(); menu.AddText("status", "", () => { return(colonyControl.ColonyAction.ToString()); }); } else if (entity != null) { var brain = entity.GetComponent <EntityBrain>(); menu.AddText("status", "", () => { return(brain.Action); }); } Cursor.SetMovement(true, menu); menu.AddButton("deselect", "Backspace - Back", () => { CloseMenu("select"); }, KeyCode.Backspace); menu.AddButton("goto", "G - Goto", () => { Cursor.SetPosition(attributes.Location); }, KeyCode.G); if (colony != null) { var colonyControl = colony.GetComponent <ColonyControl>(); menu.AddButton("build", "B - Build", () => { if (colonyControl == null) { CloseMenu("select"); return; } if (colonyControl.ColonyAction == ColonyAction.Building) { Logger.Log("Colony is building!", colonyControl.Location); return; } LoadBuildMenu(colonyControl); }, KeyCode.B); SetAllInactive(); Menus.Add("select", menu); return; } if (entity != null) { var brain = entity.GetComponent <EntityBrain>(); menu.AddButton("moveentity", "M - MoveToCursor", () => { if (brain == null) { Logger.Log("Ship is Dead!", Cursor.Movement.Location); CloseMenu("select"); return; } brain.SetState(new MoveState(brain, Cursor.Movement.Location)); CloseMenu("select"); return; }, KeyCode.M); if (entity.CanColonize) { menu.AddButton("colonize", "O - Colonize", () => { if (brain == null) { Logger.Log("Ship is Dead!", Cursor.Movement.Location); CloseMenu("select"); return; } if (StarSystem.EntityManager.GetAllUncolonized().Contains(Cursor.Movement.Location)) { brain.SetState(new ColonizeState(brain, Cursor.Movement.Location)); CloseMenu("select"); return; } Logger.Log("Not Valid for colonization", Cursor.Movement.Location); }, KeyCode.O); } SetAllInactive(); Menus.Add("select", menu); return; } }