void Update() { if (Input.GetKeyDown(KeyCode.Keypad1) || Input.GetKeyDown(KeyCode.Alpha1)) { inventory.AddRupees(99); inventory.AddKeys(99); inventory.AddBomb(99); } }
public void PickItems() { MapGenerator.Coord myPosition = MapGenerator.ConvertWorldToIndex(transform.position); int myActualPosition = GetTile(myPosition.i, myPosition.j); Vector2 spawnPos = MapGenerator.initialPos + new Vector2(TILE_SIZE * myPosition.i, -TILE_SIZE * myPosition.j); if ((myActualPosition == (int)MapGenerator.KeyTile) && (Input.GetKeyDown(KeyCode.Space))) { int itemindex = GetTile(myPosition.i, myPosition.j); m_Inventory.AddKey(new Key()); MapGenerator.m_PlayerPos[myPosition.i, myPosition.j] = MapGenerator.WalkableTile; GameObject blank = Instantiate(m_BlankPrefab); blank.transform.position = spawnPos; } else if ((myActualPosition == (int)MapGenerator.RupeeTile) && (Input.GetKeyDown(KeyCode.Space))) { int itemindex = GetTile(myPosition.i, myPosition.j); m_Inventory.AddRupee(new Rupee()); MapGenerator.m_PlayerPos[myPosition.i, myPosition.j] = MapGenerator.WalkableTile; GameObject blank = Instantiate(m_BlankPrefab); blank.transform.position = spawnPos; } else if ((myActualPosition == (int)MapGenerator.BombTile) && (Input.GetKeyDown(KeyCode.Space))) { int itemindex = GetTile(myPosition.i, myPosition.j); m_Inventory.AddBomb(m_SpawnedBomb); MapGenerator.m_PlayerPos[myPosition.i, myPosition.j] = MapGenerator.WalkableTile; GameObject blank = Instantiate(m_BlankPrefab); blank.transform.position = spawnPos; } }
private void OnTriggerEnter(Collider other) { if (!utility.isCustom && attMovement.isAttacking) { return; } GameObject thing = other.gameObject; if (thing.tag == "rupee") { if (inventory) { inventory.AddRupee(1); } Debug.Log(inventory.GetRupees()); Destroy(thing); AudioSource.PlayClipAtPoint(rupee_collecting_sound, Camera.main.transform.position); } else if (thing.tag == "heart") { if (inventory) { inventory.AddHealth(1); } Destroy(thing); AudioSource.PlayClipAtPoint(heart_collecting_sound, Camera.main.transform.position); } else if (thing.tag == "key") { if (inventory) { inventory.AddKey(1); } Destroy(thing); AudioSource.PlayClipAtPoint(heart_collecting_sound, Camera.main.transform.position); } else if (thing.tag == "bomb") { if (inventory) { inventory.AddBomb(); } Destroy(thing); AudioSource.PlayClipAtPoint(heart_collecting_sound, Camera.main.transform.position); } }
// Update is called once per frame void Update() { if (!is_Froze) { Vector2 current_input = GetInput(); rb.velocity = current_input * movement_speed; if (Input.GetKeyDown(KeyCode.Alpha1)) { Debug.Log("God mode ran"); if (god_Mode) { god_Mode = false; } else { god_Mode = true; } } if (Input.GetButtonDown("Swing")) { weapon.GetSwing(); animationManager.Attack(); } if (Input.GetButtonDown("Arrow/Boomerang")) { if (!isArrow) { isArrow = true; } else { isArrow = false; } } if (Input.GetButtonDown("Bomb_Activate")) { if (bombActive) { bombActive = false; } else { bombActive = true; } } if (Input.GetButtonDown("Shoot")) { if (inventory.GetRupees() > 0 && isArrow) { inventory.AddRupee(-1); weapon.ShootArrow(); } else if (inventory.GetBombs() > 0 && bombActive) { inventory.AddBomb(-1); weapon.ShootBomb(); } else { weapon.ShootBoomerang(); } animationManager.Attack(); } } }
void OnTriggerEnter(Collider other) { GameObject object_collided_with = other.gameObject; if (object_collided_with.tag == "rupee") { if (inventory != null) { inventory.AddRupee(1); } Destroy(object_collided_with); AudioManager.Instance.RupeeEffect(); } else if (object_collided_with.tag == "Restoring_Heart") { if (HPManager != null) { HPManager.HealHP(1); } Destroy(object_collided_with); AudioManager.Instance.RestroingHeartEffect(); } else if (object_collided_with.tag == "Key") { if (inventory != null) { inventory.AddKey(1); } Destroy(object_collided_with); AudioManager.Instance.KeyEffect(); } else if (object_collided_with.tag == "Bomb") { if (inventory != null) { inventory.AddBomb(1); } Destroy(object_collided_with); AudioManager.Instance.KeyEffect(); } else if (object_collided_with.tag == "ImportantItem") { if (object_collided_with.name == "HPStone(Clone)") { if (HPManager != null) { HPManager.AddHP(); } } if (object_collided_with.name == "Boomerang_item(Clone)") { gameObject.GetComponent <Weapon_System>().gotBoomerang(); } if (object_collided_with.name == "Bow") { gameObject.GetComponent <Weapon_System>().gotBow(); GetComponent <AnimationManager>().ObtainItem(); } Destroy(object_collided_with); AudioManager.Instance.ObtainItem(); if (object_collided_with.name == "Triforce") { AudioManager.Instance.BeatTheDungeon(); GetComponent <AnimationManager>().ObtainItem(); } } }