void HandleKeyboard() { if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Space)) { InventoryPanel.instance.visible = false; CharstatPanel.instance.visible = false; } if (!CommandPrompt.instance.visible) { if (Input.GetKeyDown(KeyCode.Return)) { CommandPrompt.instance.visible = true; } if (Input.GetKeyDown(KeyCode.I)) { InventoryPanel.instance.visible ^= true; } if (Input.GetKeyDown(KeyCode.C)) { CharstatPanel.instance.visible ^= true; } if (Input.GetKeyDown(KeyCode.R)) { run ^= true; } // following section serves debugging purposes only if (Input.GetKeyDown(KeyCode.T)) { for (int i = 0; i < 1; ++i) { var tc = TreasureClass.sheet[Random.Range(0, TreasureClass.sheet.Count)]; if (tc.name == null) { continue; } int itemLevel = Random.Range(50, 100); ItemDrop.Drop(tc.name, Iso.MapToWorld(IsoInput.mouseTile), itemLevel); } } } else { if (Input.GetKeyDown(KeyCode.Return)) { CommandPrompt.instance.visible = false; CommandPrompt.instance.Execute(); } if (Input.GetKeyDown(KeyCode.Escape)) { CommandPrompt.instance.visible = false; } } }
public static void DebugDrawPath(Vector2 from, List <Step> path) { if (path.Count > 0) { Debug.DrawLine(Iso.MapToWorld(from), Iso.MapToWorld(path[0].pos), Color.grey); } for (int i = 0; i < path.Count - 1; ++i) { Debug.DrawLine(Iso.MapToWorld(path[i].pos), Iso.MapToWorld(path[i + 1].pos)); } if (path.Count > 0) { var center = Iso.MapToWorld(path[path.Count - 1].pos); Debug.DrawLine(center + Iso.MapToWorld(new Vector2(0, 0.15f)), center + Iso.MapToWorld(new Vector2(0, -0.15f))); Debug.DrawLine(center + Iso.MapToWorld(new Vector2(-0.15f, 0)), center + Iso.MapToWorld(new Vector2(0.15f, 0))); } }
public void Use(MiscInfo itemInfo) { Debug.Log("Use item " + itemInfo.name + ", function: " + itemInfo.useFunction); switch (itemInfo.useFunction) { case MiscInfo.UseFunction.None: break; case MiscInfo.UseFunction.IdentifyItem: break; case MiscInfo.UseFunction.TownPortal: var pos = Iso.MapToWorld(iso.pos); var teleport = WorldBuilder.SpawnObject("TP", pos, fit: true); teleport.modeName = "OP"; var sound = SoundInfo.Find("player_townportal_cast"); AudioManager.instance.Play(sound, pos); break; case MiscInfo.UseFunction.Potion: if (itemInfo.stat1 == "hpregen") { character.health += itemInfo.calc1; } if (itemInfo.stat1 == "manarecovery") { character.mana += itemInfo.calc1; } break; case MiscInfo.UseFunction.RejuvPotion: if (itemInfo.stat1 == "hitpoints") { character.health += (int)(itemInfo.calc1 / 100.0f * character.maxHealth); } if (itemInfo.stat1 == "mana") { character.mana += (int)(itemInfo.calc1 / 100.0f * character.maxMana); } if (itemInfo.stat2 == "hitpoints") { character.health += (int)(itemInfo.calc2 / 100.0f * character.maxHealth); } if (itemInfo.stat2 == "mana") { character.mana += (int)(itemInfo.calc2 / 100.0f * character.maxMana); } break; case MiscInfo.UseFunction.TemporaryPotion: break; case MiscInfo.UseFunction.HoradricCube: break; case MiscInfo.UseFunction.Elixir: break; case MiscInfo.UseFunction.StaminaPotion: break; } }