void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Player" || collision.gameObject.tag == "Ice") { if (collision.gameObject.tag == "Ice") { statusCounter.score += enemyScorePoint; } ItemDrop script = GetComponent <ItemDrop>(); if (script != null) // 敵がitemを保持しているとき { script.Drop(); //そのアイテムを落とす } if (collision.transform.position.x > transform.position.x) { damagedEnemy.blowAwayDirection = -1; } else { damagedEnemy.blowAwayDirection = 1; } Instantiate(damaged, transform.position, Quaternion.identity); Destroy(gameObject); } }
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 void Kill() { IsDead = true; Destroy(gameObject, 1.5f); audio.PlayOneShot(deathSound); animation.CrossFade(deathAnimation.name); aiFollow.canMove = false; itemDrop.Drop(); }
public virtual void Die() { int randomDrop = Random.Range(1, 10); if (randomDrop > 7) { Instantiate(drop.Drop(), transform.position, Quaternion.identity); } FindObjectOfType <MoonBehaviour>().ComboBoost(); var scoreUI = FindObjectOfType <UIController>(); scoreUI.score += scoreValue; scoreUI.UpdateScore(); Destroy(gameObject); }
void Update() { ControlUI(); if (flush && (Input.GetMouseButton(0) || Input.GetMouseButton(1))) { return; } flush = false; if (EventSystem.current.IsPointerOverGameObject()) { return; } ControlCharacter(); 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); } } if (Input.GetKeyDown(KeyCode.F8)) { var pos = Iso.MapToWorld(IsoInput.mousePosition); var teleport = World.SpawnObject("TP", pos); teleport.modeName = "OP"; } #if UNITY_EDITOR if (Input.GetKeyDown(KeyCode.Space) && Input.GetKey(KeyCode.LeftShift)) { UnityEditor.EditorWindow.focusedWindow.maximized ^= true; } #endif }
void Update() { HandleKeyboard(); UpdateCamera(); if (flush && (Input.GetMouseButton(0) || Input.GetMouseButton(1))) { return; } flush = false; if (EventSystem.current.IsPointerOverGameObject()) { return; } ControlCharacter(); // 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); } } #if UNITY_EDITOR if (Input.GetKeyDown(KeyCode.Space) && Input.GetKey(KeyCode.LeftShift)) { UnityEditor.EditorWindow.focusedWindow.maximized ^= true; } #endif }
public override void Operate(Character character) { Debug.Log(character.name + " use " + name + " (operateFn " + objectInfo.operateFn + ")"); if (objectInfo.operateFn == 1 || // bed, caskets objectInfo.operateFn == 3 || // urns objectInfo.operateFn == 4 || // chests objectInfo.operateFn == 5 || // barrels objectInfo.operateFn == 14 || // crates objectInfo.operateFn == 51 // jungle objects ) { AudioManager.instance.Play("object_chest_large"); var levelInfo = LevelInfo.sheet[85]; // todo determine current level string tc = "Act " + (levelInfo.act + 1); var actLevels = LevelInfo.byAct[levelInfo.act]; int lowest = actLevels[0].id; int highest = actLevels[actLevels.Count - 1].id; int letterIndex = (levelInfo.id - lowest) / ((highest - lowest + 1) / 3); string letter = treasureClassLetters[letterIndex]; tc += " Chest " + letter; Debug.Log(tc); ItemDrop.Drop(tc, transform.position, levelInfo.id); SetMode("OP"); } else if (objectInfo.operateFn == 23) { // waypoint if (COF.ModeNames[2][mode] != "OP") { AudioManager.instance.Play("object_waypoint_open"); SetMode("OP"); } } else { SetMode("OP"); } }
private void Operate(StaticObject staticObject, Unit unit) { Debug.Log(unit.name + " operate " + staticObject.name + " (operateFn " + staticObject.info.operateFn + ")"); if (staticObject.info.operateFn == 1 || // bed, caskets staticObject.info.operateFn == 3 || // urns staticObject.info.operateFn == 4 || // chests staticObject.info.operateFn == 5 || // barrels staticObject.info.operateFn == 14 || // crates staticObject.info.operateFn == 51 // jungle objects ) { AudioManager.instance.Play("object_chest_large"); var levelInfo = LevelInfo.sheet[85]; // todo determine current level string tc = "Act " + (levelInfo.act + 1); var actLevels = LevelInfo.byAct[levelInfo.act]; int lowest = actLevels[0].id; int highest = actLevels[actLevels.Count - 1].id; int letterIndex = (levelInfo.id - lowest) / ((highest - lowest + 1) / 3); string letter = TreasureClassLetters[letterIndex]; tc += " Chest " + letter; Debug.Log(tc); ItemDrop.Drop(tc, transform.position, levelInfo.id); staticObject.SetMode("OP"); } else if (staticObject.info.operateFn == 23) { // waypoint if (COF.ModeNames[2][staticObject.ModeIndex] != "OP") { AudioManager.instance.Play("object_waypoint_open"); staticObject.SetMode("OP"); } } else { staticObject.SetMode("OP"); } }
void Process(string input) { if (input == "") { return; } if (history.Count == 0 || history[history.Count - 1] != input) { history.Add(input); } string[] parts = input.Split(' '); if (parts.Length >= 2 && parts[0] == "/spawn") { var pos = Iso.MapToWorld(IsoInput.mouseTile); if (parts[1] == "pickup") { string flippyFile = @"data\global\items\flp" + parts[2] + ".dc6"; Pickup.Create(pos, flippyFile, flippyFile); return; } if (parts[1] == "item") { string code = parts[2]; ItemDrop.Drop(code, pos, 100); return; } if (parts[1] == "itemset") { string subname = parts[2]; var set = ItemSet.sheet.Find(s => s.id.ToLower().Contains(subname)); if (set != null) { foreach (var setItem in set.items) { var item = Item.Create(setItem.itemCode); item.quality = Item.Quality.Set; item.level = setItem.level; item.identified = false; ItemDrop.GenerateSetItem(item); Pickup.Create(pos, item); } } return; } var id = parts[1]; var objectInfo = ObjectInfo.Find(id); if (objectInfo != null) { var obj = World.SpawnObject(objectInfo, pos, fit: true); if (obj != null && parts.Length > 2) { obj.modeName = parts[2]; } return; } World.SpawnMonster(id, pos); } else { Debug.LogWarning(input); } }
void Execute(string input) { if (input == "") { return; } if (history.Count == 0 || history[history.Count - 1] != input) { history.Add(input); } string[] parts = input.Split(' '); if (parts.Length >= 2 && parts[0] == "/spawn") { var pos = Iso.MapToWorld(IsoInput.mouseTile); if (parts[1] == "pickup") { string flippyFile = @"data\global\items\flp" + parts[2] + ".dc6"; Pickup.Create(pos, flippyFile, flippyFile); return; } if (parts[1] == "item") { string subname = parts[2].ToLower(); var uniqueItem = UniqueItem.sheet.Find(s => s.nameStr.ToLower().Contains(subname)); if (uniqueItem != null) { ItemDrop.Drop(uniqueItem, pos); } else { string code = parts[2]; ItemDrop.Drop(code, pos, 100); } return; } if (parts[1] == "itemset") { string subname = parts[2].ToLower(); var set = ItemSet.sheet.Find(s => s.id.ToLower().Contains(subname)); if (set != null) { foreach (var setItem in set.items) { ItemDrop.Drop(setItem, pos); } } return; } var id = parts[1]; var objectInfo = ObjectInfo.Find(id); if (objectInfo != null) { var obj = WorldBuilder.SpawnObject(objectInfo, pos, fit: true); if (obj != null && parts.Length > 2) { obj.modeName = parts[2]; } } else { int monsterCount = parts.Length > 2 ? int.Parse(parts[2]) : 1; for (int i = 0; i < monsterCount; ++i) { WorldBuilder.SpawnMonster(id, pos); } } } else if (parts.Length == 2 && parts[0] == "/act") { if (int.TryParse(parts[1], out int actNumber)) { WorldBuilder.GoToAct(actNumber); } } else if (parts.Length == 2 && parts[0] == "/addstate") { string stateCode = parts[1]; var stateInfo = StateInfo.FindByCode(stateCode); if (stateInfo != null) { var player = WorldState.instance.Player.gameObject; Overlay.Create(player, stateInfo.castoverlay, loop: false); Overlay.Create(player, stateInfo.overlay1, loop: true); Overlay.Create(player, stateInfo.overlay2, loop: true); Overlay.Create(player, stateInfo.overlay3, loop: true); Overlay.Create(player, stateInfo.overlay4, loop: true); } } else { Debug.LogWarning(input); } }