/* * void Update() { * if (!initialised) return; * * if (first) { * UConsoleObj.Deactivate(); * uConsoleGO.SetActive(false); * first = false; * } * * * if (Input.GetKeyDown(KeyCode.BackQuote)) { * //GameObject go = WorldController.Instance.uConsoleObject; * //CardboardKeep.UConsole uc = WorldController.Instance.uConsoleObject.GetComponent<CardboardKeep.UConsole>(); * if (uConsoleGO.activeSelf) { * UConsoleObj.Deactivate(); * uConsoleGO.SetActive(false); * WorldController.Instance.gameState = GAME_STATE.PLAY; * } else { * uConsoleGO.SetActive(true); * UConsoleObj.Activate(); * WorldController.Instance.gameState = GAME_STATE.PAUSE; * * } * * * } * * if (uConsoleGO.activeSelf) { * return; * } * * * * * * if (Input.GetKeyUp(KeyCode.E)) { * showingJobs = !showingJobs; * * * WorldController.Instance.jobsPanelPrefab.SetActive(showingJobs); * if (showingJobs) { * WorldController.Instance.gameState = GAME_STATE.PAUSE; * WorldController.Instance.CreateJobPanelItems(); * } else { * WorldController.Instance.gameState = GAME_STATE.PLAY; * WorldController.Instance.DestroyJobPanelItems(); * } * * * * } * * if (wcon.eventSystem.IsPointerOverGameObject()) { * return; * } * * if (Input.GetKeyUp(KeyCode.Escape) || Input.GetMouseButtonUp(1)) { * WorldController.Instance.SetBuildType_Clear(); * destroyCursors(); * selectionInfo = null; * * } * * mouseOverTile = null; * * mousePos = cam.ScreenToWorldPoint(Input.mousePosition); * mxf = mousePos.x; * myf = mousePos.y; * mx = (int)Mathf.Round(mousePos.x); * my = (int)Mathf.Round(mousePos.y); * //mp.Set(mouseX, mouseY); * cx = mx - lastX; * cy = my - lastY; * if (mx >= 0 && my >= 0) { * mouseOverTile = World.current.GetTileAt(mx, my); * if (selectionInfo != null) { * WorldController.Instance.UpdateCurrentTile(selectionInfo); * } * } * //if (mouseOverTile != null) { * // Debug.Log(mouseOverTile); * //} else { * // Debug.Log("move over nothing"); * //} * * UpdateSelected(); * * UpdateDrag(); * * * UpdateCamera(); * * * //transform.Translate(cx, cy, 0); * lastX = mx; * lastY = my; * lastFrame = cam.ScreenToWorldPoint(Input.mousePosition); * } */ private void UpdateSelected() { if (mouseOverTile != null) { if (Input.GetKeyUp(KeyCode.Escape)) { selectionInfo = null; } if (mouseMode != MOUSE_MODE.SELECT) { return; } if (Input.GetMouseButtonUp(0)) { if (selectionInfo == null || selectionInfo.tile != mouseOverTile) { selectionInfo = new SelectionInfo(); selectionInfo.tile = mouseOverTile; SetSelectionContents(); for (int i = 0; i < selectionInfo.contents.Length; i += 1) { if (selectionInfo.contents[i] != null) { selectionInfo.subSelect = i; break; } } } else { SetSelectionContents(); do { selectionInfo.subSelect = (selectionInfo.subSelect + 1) % selectionInfo.contents.Length; } while (selectionInfo.contents[selectionInfo.subSelect] == null); } } } }
public void UpdateCurrentTile(SelectionInfo info) { Text txt = currentTileText.GetComponent <Text>(); Tile t = info.tile; object o = info.contents[info.subSelect]; int pw = 38; string displayMe = ""; displayMe += Funcs.PadPair(pw, "chunk x", t.chunk.x.ToString(), '.'); displayMe += "\n" + Funcs.PadPair(pw, "chunk y", t.chunk.y.ToString(), '.'); displayMe += "\n" + Funcs.PadPair(pw, "world x", t.world_x.ToString(), '.'); displayMe += "\n" + Funcs.PadPair(pw, "world y", t.world_y.ToString(), '.'); displayMe += "\n"; if (o.GetType() == typeof(Tile)) { Tile tile = (Tile)o; displayMe += Funcs.PadPair(pw, "tile type", tile.type.name, '.'); displayMe += "\n" + tile.JobsToString(pw); } else if (o.GetType() == typeof(Entity)) { Entity to = (Entity)o; displayMe += Funcs.PadPair(pw, "type", to.typeName); displayMe += "\n" + Funcs.PadPair(pw, "name", to.name); displayMe += "\n" + Funcs.PadPair(pw, "state", to.state); //if (to.animator.valid) { // displayMe += "\n" + Funcs.PadPair(pw, "animation", to.animator.currentAnimation.name); // displayMe += "\n" + Funcs.PadPair(pw, "running", to.animator.running.ToString()); // //displayMe += "\n" + Funcs.PadPair(pw, "timer", to.animator.timer.ToString()); // //displayMe += "\n" + Funcs.PadPair(pw, "index", to.animator.index.ToString()); //} } else if (o.GetType() == typeof(InstalledItem)) { InstalledItem item = (InstalledItem)o; displayMe += Funcs.PadPair(pw, "installed item", item.niceName, '.'); if (item.itemParameters.HasProperty("socialMediaName")) { displayMe += "\n" + Funcs.PadPair(pw, "social media", item.itemParameters.GetString("socialMediaName"), '.'); } if (item.editOnClick) { this.prfInstalledItemOptionsInScene.GetComponent <prfInstalledItemScript>().Set(item); } } else if (o.GetType() == typeof(string)) { string invname = t.GetFirstInventoryItem(); if (invname != null) { string nicename = InventoryItem.GetPrototype(invname).niceName; displayMe += Funcs.PadPair(pw, nicename, t.InventoryTotal(invname).ToString()); displayMe += "\n" + Funcs.PadPair(pw, "allocated", t.InventoryTotalAllocated(invname).ToString()); } //displayMe += InventoryItem.GetPrototype(t.GetFirstInventoryItem()).niceName + ": " + t.InventoryTotal(((string)o)); } //displayMe += "\nNeighbours:" + t.neighbours.Count + ", " + t.edges.Count; //displayMe += "\nRoom:" + t.room.id; //displayMe += "\nInstalled:" + (t.installedItem == null ? "" : t.installedItem.niceName); //displayMe += "\nJobs: " + t.JobsToString(); //displayMe += "\nItems:" + t.GetContents();//(t.inventoryItem == null ? "" : t.inventoryItem.niceName + " " + t.inventoryItem.currentStack + "/" + t.inventoryItem.maxStackSize); //displayMe += "\n" + t.WhoIsHere(); txt.text = displayMe; }
void Update() { if (!initialised) { return; } switch (inputMode) { case INPUT_MODE.GAME: if (first) { UConsoleObj.Deactivate(); uConsoleGO.SetActive(false); first = false; } if (Input.GetKeyDown(KeyCode.BackQuote)) { ActivateConsole(); } else if (Input.GetKeyUp(KeyCode.E)) { ActivateJobs(); } else { if (wcon.eventSystem.IsPointerOverGameObject()) { return; } if (Input.GetKeyUp(KeyCode.Escape) || Input.GetMouseButtonUp(1)) { WorldController.Instance.SetBuildType_Clear(); destroyCursors(); selectionInfo = null; } mouseOverTile = null; mousePos = cam.ScreenToWorldPoint(Input.mousePosition); mxf = mousePos.x; myf = mousePos.y; mx = (int)Mathf.Round(mousePos.x); my = (int)Mathf.Round(mousePos.y); //mp.Set(mouseX, mouseY); cx = mx - lastX; cy = my - lastY; if (mx >= 0 && my >= 0) { mouseOverTile = World.current.GetTileAt(mx, my); if (selectionInfo != null) { WorldController.Instance.UpdateCurrentTile(selectionInfo); } } //if (mouseOverTile != null) { // Debug.Log(mouseOverTile); //} else { // Debug.Log("move over nothing"); //} UpdateSelected(); UpdateDrag(); UpdateCamera(); //transform.Translate(cx, cy, 0); lastX = mx; lastY = my; lastFrame = cam.ScreenToWorldPoint(Input.mousePosition); } break; case INPUT_MODE.CONSOLE: if (Input.GetKeyDown(KeyCode.BackQuote)) { DeactivateConsole(); } break; case INPUT_MODE.SHOWING_JOBS: if (Input.GetKeyUp(KeyCode.E)) { DeactivateJobs(); } break; case INPUT_MODE.SHOWING_DIALOGUE: selectionInfo = null; break; default: break; } }