Пример #1
0
    void OnTriggerEnter(Collider coll)
    {
        GameObject object_collided_with = coll.gameObject;

        if (object_collided_with.tag == "rupee")
        {
            if (inventory != null)
            {
                inventory.AddRupees(1);
            }
            Destroy(object_collided_with);

            AudioSource.PlayClipAtPoint(rupee_collection_sound_clip, Camera.main.transform.position);
        }

        if (object_collided_with.tag == "key")
        {
            if (inventory != null)
            {
                inventory.AddKeys(1);
            }
            Destroy(object_collided_with);

            AudioSource.PlayClipAtPoint(key_collection_sound_clip, Camera.main.transform.position);
        }

        if (object_collided_with.tag == "BombIcon")
        {
            if (inventory != null)
            {
                inventory.AddBombs(5);
                inventory.WeaponBomb();
            }
            Destroy(object_collided_with);

            AudioSource.PlayClipAtPoint(bomb_collection_sound_clip, Camera.main.transform.position);
        }

        if (object_collided_with.tag == "bow")
        {
            if (inventory != null)
            {
                inventory.WeaponBow();
            }
            Destroy(object_collided_with);

            AudioSource.PlayClipAtPoint(bow_collection_sound_clip, Camera.main.transform.position);
        }

        if (object_collided_with.tag == "boomerangeicon")
        {
            if (inventory != null)
            {
                inventory.WeaponBoomerange();
            }
            Destroy(object_collided_with);

            AudioSource.PlayClipAtPoint(bow_collection_sound_clip, Camera.main.transform.position);
        }
    }
Пример #2
0
    private void OnTriggerEnter(Collider coll)
    {
        GameObject object_collided_with = coll.gameObject;

        if (object_collided_with.tag == "rupee")
        {
            if (inventory != null)
            {
                inventory.AddRupees(1);
            }
            Destroy(object_collided_with);

            AudioSource.PlayClipAtPoint(rupee_collection_sound_clip, Camera.main.transform.position);
        }

        if (object_collided_with.tag == "key")
        {
            if (inventory != null)
            {
                inventory.AddKeys(1);
            }
            Destroy(object_collided_with);

            AudioSource.PlayClipAtPoint(rupee_collection_sound_clip, Camera.main.transform.position);
        }

        if (object_collided_with.tag == "bomb")
        {
            if (inventory != null)
            {
                inventory.AddBombs(1);
            }
            Destroy(object_collided_with);

            AudioSource.PlayClipAtPoint(rupee_collection_sound_clip, Camera.main.transform.position);
        }

        if (object_collided_with.tag == "door" || object_collided_with.tag == "door2" || object_collided_with.tag == "door3")
        {
            if (inventory != null && inventory.GetKeys() > 0)
            {
                inventory.AddKeys(-1);
                object_collided_with.GetComponent <BoxCollider>().enabled = false;
                sr = object_collided_with.GetComponentsInChildren <SpriteRenderer>();
                if (object_collided_with.tag == "door")
                {
                    sr[0].sprite = d0;
                    sr[1].sprite = d1;
                }
                if (object_collided_with.tag == "door2")
                {
                    sr[1].sprite = d2;
                }
                if (object_collided_with.tag == "door3")
                {
                    sr[1].sprite = d3;
                }
            }
        }
    }
Пример #3
0
    protected virtual void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "rupee")
        {
            Debug.Log("Collected rupee!");
            if (inventory)
            {
                inventory.AddRupees(1);
            }
            Destroy(other.gameObject);

            AudioSource.PlayClipAtPoint(rupee_collection_sound_clip, Camera.main.transform.position);
        }
        if (other.gameObject.tag == "key")
        {
            Debug.Log("Collected key!");
            if (inventory)
            {
                inventory.AddKeys(1);
            }
            Destroy(other.gameObject);

            AudioSource.PlayClipAtPoint(rupee_collection_sound_clip, Camera.main.transform.position);
        }
        if (other.gameObject.tag == "bomb")
        {
            Debug.Log("Collected bomb!");
            if (inventory)
            {
                inventory.AddBombs(1);
            }
            Destroy(other.gameObject);

            AudioSource.PlayClipAtPoint(rupee_collection_sound_clip, Camera.main.transform.position);
        }
        if (other.gameObject.tag == "res_heart")
        {
            Debug.Log("Collected restoration heart!");
            if (GetComponent <Health>())
            {
                GetComponent <Health>().AlterHealth(2);
            }
            Destroy(other.gameObject);

            AudioSource.PlayClipAtPoint(rupee_collection_sound_clip, Camera.main.transform.position);
        }
    }
Пример #4
0
    public void PickupItem(string item, int value = 0)
    {
        switch (item)
        {
        case "Bow(Clone)":
            inventory.SetBowAquired();
            break;

        case "Door Key(Clone)":
            SetHasDoorKey(true);
            inventory.SetKeyAquired();
            break;

        case "Chest Key(Clone)":
            SetHasChestKey(true);
            break;

        case "Heart(Clone)":
            if (!healed)
            {
                AddHealth(25);
            }
            break;

        case "Coin(Clone)":
            Debug.Log(value);
            cashDisplay.AddMoney(value);
            break;

        case "BombItem(Clone)":
            inventory.SetBombAquired();
            inventory.AddBombs(1);
            break;

        default:
            Debug.Log("PickupItem() was called with no/no known item.");
            break;
        }
    }
Пример #5
0
 public void CollectBomb()
 {
     inventory.AddBombs(1);
 }
Пример #6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.X) && !arm.camera_moving && !arm.gold && !weapon_using && !special_using)
        {
            weapon_using   = true;
            weapon_holding = true;
            weaponPosition();
            Instantiate <Weapons>(weapon1, pos, Quaternion.identity);
            AudioSource.PlayClipAtPoint(useSword_soundClip, Camera.main.transform.position);
        }

        if (Input.GetKeyDown(KeyCode.Z) && !arm.camera_moving && !arm.gold && !weapon_using && !special_using)
        {
            if (weapon2.type == WeaponType.bow && inventory.GetRupees() > 0)
            {
                weapon_using   = true;
                weapon_holding = true;
                weaponPosition();
                Instantiate <Weapons>(weapon2, pos, Quaternion.identity);
                inventory.AddRupees(-1);
            }
            else if (weapon2.type == WeaponType.boomerang)
            {
                weapon_using   = true;
                weapon_holding = true;
                weaponPosition();
                Instantiate <Weapons>(weapon2, pos, Quaternion.identity);
                AudioSource.PlayClipAtPoint(boomerang_soundClip, Camera.main.transform.position);
                special_using = true;
            }
            else if (weapon2.type == WeaponType.bomb && inventory.GetBombs() > 0)
            {
                weapon_using   = true;
                weapon_holding = true;
                weaponPosition();
                Instantiate <Weapons>(weapon2, pos, Quaternion.identity);
                inventory.AddBombs(-1);
            }
        }

        if (Input.GetKeyDown(KeyCode.C) && !arm.camera_moving && !weapon_using && !special_using)
        {
            counter++;
            if (counter == 4)
            {
                if (has_bow)
                {
                    counter = 1;
                }
                else if (!has_bow && has_boomerang)
                {
                    counter = 2;
                }
                else
                {
                    counter = 3;
                }
            }
            weapon2 = weapons[counter];
        }
    }
Пример #7
0
    // Update is called once per frame
    void Update()
    {
        if (is_catched == false)
        {
            //Move current player
            Vector2 current_input = GetInput();
            inputVelocity = current_input * movement_speed;

            rb.velocity = inputVelocity + knockbackVelocity;

            //make every movement half tile
            if (current_input.x == 0 && current_input.y == 0)
            {
                correct_position_x = Mathf.Round(tf.position.x * 2);
                correct_position_y = Mathf.Round(tf.position.y * 2);
                tf.position        = new Vector3(correct_position_x / 2, correct_position_y / 2, 0);
            }
        }


        //Game Over
        if (Input.GetKeyDown(KeyCode.Space))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }

        //Invincibility/ Infinite Keys/ Bomb/ Rupees Cheat
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            it.AddBombs(99);
            it.AddKeys(99);
            it.AddRupees(99);
        }

        //use sword
        if (Input.GetKeyDown(KeyCode.X))
        {
            if (it.GetHearts() >= 6)
            {
                var sword = GameObject.Find("/Sword(Clone)");
                if (sword == null)
                {
                    Shot(swordPrefab);
                }
            }
            else
            {
                StartCoroutine(Draw());
            }
        }
        //draw back sword if go away
        if (rb.velocity != new Vector3(0.0f, 0.0f, 0.0f))
        {
            sword.SetActive(false);
        }

        //use bow
        if (Input.GetKeyDown(KeyCode.Z))
        {
            if (weapon_nums == 0)
            {
                if (it.GetRupees() != 0)
                {
                    Shot(bowPrefab);
                    it.SubtractRupees(1);
                }
            }
            if (weapon_nums == 1)
            {
                Shot(boomrangPrefab);
            }
            if (weapon_nums == 2)
            {
                if (it.GetBombs() != 0)
                {
                    GameObject item = Instantiate(bombPrefab, tf.position, Quaternion.identity);
                    it.SubtractBombs(1);
                }
            }
        }

        //change weapons
        if (Input.GetKeyDown(KeyCode.C))
        {
            if (weapon_nums < 2)
            {
                weapon_nums += 1;
            }
            else
            {
                weapon_nums = 0;
            }
        }

        //change weapons
    }
Пример #8
0
    private void OnTriggerEnter(Collider other)
    {
        GameObject object_collided_with = other.gameObject;

        if (object_collided_with.tag == "rupee")
        {
            if (inventory != null)
            {
                inventory.AddRupees(1);
            }
            Destroy(object_collided_with);

            AudioSource.PlayClipAtPoint(rupee_collection_sound_clip, Camera.main.transform.position);
            AudioSource.PlayClipAtPoint(countingAudio, Camera.main.transform.position);
        }

        if (object_collided_with.tag == "rupeeB")
        {
            if (inventory != null)
            {
                inventory.AddRupees(5);
            }
            Destroy(object_collided_with);

            StartCoroutine(GetComponent <playerSounds>().MultipleCollected(5));
            AudioSource.PlayClipAtPoint(rupee_collection_sound_clip, Camera.main.transform.position);
        }

        if (object_collided_with.tag == "heartR")
        {
            if (inventory != null)
            {
                player.heal(2);
            }
            Destroy(object_collided_with);

            AudioSource.PlayClipAtPoint(heartR_collection_sound_clip, Camera.main.transform.position);
            AudioSource.PlayClipAtPoint(countingAudio, Camera.main.transform.position);
        }

        if (object_collided_with.tag == "key")
        {
            if (inventory != null)
            {
                inventory.AddKeys(1);
            }
            Destroy(object_collided_with);

            AudioSource.PlayClipAtPoint(heartR_collection_sound_clip, Camera.main.transform.position);
            AudioSource.PlayClipAtPoint(countingAudio, Camera.main.transform.position);
        }

        if (object_collided_with.tag == "bombPickup")
        {
            if (inventory != null)
            {
                inventory.AddBombs(4);
            }
            Destroy(object_collided_with);

            AudioSource.PlayClipAtPoint(heartR_collection_sound_clip, Camera.main.transform.position);
            AudioSource.PlayClipAtPoint(countingAudio, Camera.main.transform.position);
        }
    }
Пример #9
0
    private void Update()
    {
        if (count_0 == 5)
        {
            if (Input.GetKeyDown(KeyCode.Q))
            {
                player.full_health     += 3;
                player.current_health  += 3;
                player.health_text.text = "Health: " + player.current_health.ToString() + " / " + player.full_health.ToString();
                coroutine = StartGame();
                StartCoroutine(coroutine);
                count_0 = 0;
            }
            else if (Input.GetKeyDown(KeyCode.W))
            {
                player_inventory.AddBombs(3);
                coroutine = StartGame();
                StartCoroutine(coroutine);
                count_0 = 0;
            }
            else if (Input.GetKeyDown(KeyCode.E))
            {
                iori.GetComponent <MotionControl>().damaged++;
                coroutine = StartGame();
                StartCoroutine(coroutine);
                count_0 = 0;
            }
            t0   = false;
            next = false;
        }

        while (t0 && next && count_0 < 5)
        {
            text.text = "";
            coroutine = SetConversation(conversations0[count_0], 0.1f, true);
            StartCoroutine(coroutine);
            next = false;
        }

        if (t1 && next)
        {
            text.text = "Iori: ";
            coroutine = SetConversation(conversation_11, 0.1f, true);
            StartCoroutine(coroutine);
            next = false;
            t1   = false;
            Invoke("Text0", 7.5f);
        }

        if (t2 && next)
        {
            text.text = "Iori: ";
            coroutine = SetConversation(conversation_21, 0.1f, false);
            StartCoroutine(coroutine);
            next = false;
            t2   = false;
        }

        if (t3 && next)
        {
            text.text = "Iori: ";
            coroutine = SetConversation(conversation_31, 0.1f, true);
            StartCoroutine(coroutine);
            next = false;
            t3   = false;
            Invoke("Text0", 7.5f);
        }

        if (t4 && next)
        {
            text.text = "Iori: ";
            coroutine = SetConversation(conversation_41, 0.1f, false);
            StartCoroutine(coroutine);
            next = false;
            t4   = false;
        }
    }
Пример #10
0
    // Update is called once per frame
    void Update()
    {
        //TODO: add throw mechanic when player with full health
        if (playerController.state == PlayerController.PlayerStates.Idle && GameController.instance.gameState == GameController.GameStates.Play)
        {
            if (Input.GetButtonDown("Switch"))
            {
                // Debug.Log("Switching Weapon.");
                for (int i = 1; i < 5; i++)
                {
                    int newWeaponIndex = ((int)weaponSpecies + i) % 4;
                    if (obtainBWeapon[newWeaponIndex])
                    {
                        Debug.Log(newWeaponIndex);
                        weaponSpecies = (WeaponSpecies)newWeaponIndex;
                        break;
                    }
                }
            }

            if (Input.GetButtonDown("Fire1"))
            {
                GameController.Direction direction = movement.GetDirection();
                if (!SwordThrowing && playerController.hp == playerController.maxHp)
                {
                    //Throw sword
                    //Debug.Log("Sword throwing!");
                    SwordThrowing = true;
                    //ThrowingSword.instance.Attack(direction);
                    StartCoroutine(animatorInput.AnimateSwordAttack(true, direction));
                }
                else if (!SwordAttacking)
                {
                    //Attack sword
                    //Debug.Log("Sword attacking!");
                    Sword.instance.Attack(direction);
                    StartCoroutine(animatorInput.AnimateSwordAttack(false, direction));
                }
            }
            else if (!BWeaponAttacking && Input.GetButtonDown("Fire2"))
            {
                GameController.Direction direction = movement.GetDirection();
                switch (weaponSpecies)
                {
                case WeaponSpecies.Bow:
                    if (inventory.GetRupees() <= 0 && !inventory.isGodMode)
                    {
                        return;
                    }
                    BWeaponAttacking = true;
                    if (!inventory.isGodMode)
                    {
                        inventory.AddRupees(-1);
                    }
                    //Debug.Log("Arrow attacking!");
                    AudioSource.PlayClipAtPoint(bow_sound_clip, Camera.main.transform.position);
                    StartCoroutine(animatorInput.AnimateBWeaponAttack(direction, WeaponSpecies.Bow));
                    break;

                case WeaponSpecies.Boomerang:
                    //Debug.Log("Boomerang attacking!");
                    BWeaponAttacking = true;
                    AudioSource.PlayClipAtPoint(bow_sound_clip, Camera.main.transform.position);
                    StartCoroutine(animatorInput.AnimateBWeaponAttack(direction, WeaponSpecies.Boomerang));
                    break;

                // Mark
                case WeaponSpecies.PortalGun:
                    if (!portalGunAcquired)
                    {
                        return;
                    }
                    BWeaponAttacking = true;
                    StartCoroutine(animatorInput.AnimateBWeaponAttack(direction, WeaponSpecies.PortalGun));
                    break;
                }
            }
            else if (!BombAttacking && Input.GetButtonDown("Fire3"))
            {
                if (inventory.GetBombs() <= 0 && !inventory.isGodMode)
                {
                    return;
                }
                BombAttacking = true;
                if (!inventory.isGodMode)
                {
                    inventory.AddBombs(-1);
                }
                GameController.Direction direction = movement.GetDirection();
                StartCoroutine(animatorInput.AnimateBombAttack(direction));
            }
        }
    }