public void Awake() { Debug.Log("GAME START"); GlobalUnitEntityDictionary.LoadCombatData("Unit Entities"); Game = new GameMaster(world); Game.OnUnitSpawn += CreateUnitEntityController; GUIState = new GUIStateManager(cityGUI, mapHUD); }
public AbilityCastTargeter(Ability ability, GUIStateManager gui, World world, PlayerUnitEntityController unit, UnitEntityConfig config) { this.ability = ability; this.gui = gui; this.world = world; this.unit = unit; this.config = config; range = ability.GetWithinRange(unit.Unit, world); area = new HashSet <Vector3Int>(); }
private void Awake() { manager = (GUIStateManager)target; guiFolder = manager.transform.FindChild("GUI"); if(guiFolder == null) { GameObject guiFolderObj = new GameObject("GUI"); guiFolder = guiFolderObj.transform; guiFolder.parent = manager.transform; } for(int i = 0; i < guiFolder.childCount; ++i) { Transform currChild = guiFolder.GetChild(i); GUIState state = currChild.GetComponent<GUIState>(); if(state != null) { guiStates.Add(new EditorData<GUIState>(state, currChild.name)); } } }
void Start() { instance = this; DontDestroyOnLoad(gameObject); }
private IEnumerator WaitForPlacement(City city, World world, ConstructedTileProject project, GUIStateManager state) { state.SetState(GUIStateManager.GHOST_TILE); char sepChar = System.IO.Path.DirectorySeparatorChar; spriteRenderer.sprite = Resources.Load <Sprite>("Projects" + sepChar + "Constructed Tiles" + sepChar + project.ID); spriteRenderer.color = new Color(0.5f, 0.5f, 0.5f); Vector3Int gridPos = world.WorldToCell(Camera.main.ScreenToWorldPoint(Input.mousePosition)); HashSet <Vector3Int> range = city.GetCityRange(world); UnityEngine.Tilemaps.Tile green = Resources.Load <UnityEngine.Tilemaps.Tile>(System.IO.Path.Combine("Tiles", "Green")); foreach (Vector3Int pos in range) { if (IsValidTile(pos, city, world, project)) { world.SetMovementTile(pos, green); } } yield return(new WaitForSeconds(0.1f)); bool click = Input.GetMouseButtonUp(0); while (!click || !IsValidTile(gridPos, city, world, project)) { gridPos = world.WorldToCell(Camera.main.ScreenToWorldPoint(Input.mousePosition)); transform.position = world.CellToWorld(gridPos); string text = project.GetTooltipText(gridPos, world); if (text != null) { if (!canvas.gameObject.activeSelf) { canvas.gameObject.SetActive(true); } tooltipText.text = text; } else { if (canvas.gameObject.activeSelf) { canvas.gameObject.SetActive(false); } } if (!IsValidTile(gridPos, city, world, project)) { spriteRenderer.color = new Color(0, 0, 0); } else { spriteRenderer.color = new Color(0.5f, 0.5f, 0.5f); } click = Input.GetMouseButtonUp(0); yield return(null); } ConstructedTile tile = Resources.Load <ConstructedTile>("Projects" + sepChar + "Constructed Tiles" + sepChar + project.ID); if (world.GetConstructedTile(gridPos) != null) { project.OnPlacement(gridPos, (world.GetConstructedTile(gridPos)).Project); } else { project.OnPlacement(gridPos); } world.StartConstructionOfCityTile(tile, gridPos); foreach (Vector3Int pos in range) { world.SetMovementTile(pos, null); } Debug.Log("Tile Selected"); state.SetState(GUIStateManager.CITY); yield break; }
public Coroutine Place(City city, World world, ConstructedTileProject project, GUIStateManager state) { gameObject.SetActive(true); return(StartCoroutine(WaitForPlacement(city, world, project, state))); }