예제 #1
0
    void Awake()
    {
        UI = GameObject.Find("UI(Clone)");
        UI.transform.SetParent(transform);
        dagger         = gameObject.GetComponent <dagger>();
        halberd        = gameObject.GetComponent <halberd>();
        bow            = gameObject.GetComponent <bow>();
        currencyText   = GameObject.Find("Currency").GetComponent <Text>();
        rb             = GetComponent <Rigidbody2D>();
        anim           = GetComponent <Animator>();
        cont           = GetComponent <SceneController>();
        equippedWeapon = gameObject.GetComponent <dagger>();
        cam            = Camera.main;
        storeCont      = gameObject.GetComponent <StoreController>();

        HP = maxHP;
        renderhealth();
    }
예제 #2
0
    void Awake()
    {
        UI = GameObject.Find("UI(Clone)");
        gameObject.GetComponent <halberd>().cooldownIconObject = GameObject.Find("HalberdCD");
        gameObject.GetComponent <dagger>().cooldownIconObject  = GameObject.Find("DaggerCD");
        gameObject.GetComponent <bow>().cooldownIconObject     = GameObject.Find("BowCD");
        dagger         = gameObject.GetComponent <dagger>();
        halberd        = gameObject.GetComponent <halberd>();
        bow            = gameObject.GetComponent <bow>();
        currencyText   = GameObject.Find("Currency").GetComponent <Text>();
        rb             = GetComponent <Rigidbody2D>();
        anim           = GetComponent <Animator>();
        cont           = GetComponent <SceneController>();
        equippedWeapon = gameObject.GetComponent <dagger>();
        cam            = Camera.main;
        storeCont      = gameObject.GetComponent <StoreController>();

        HP = maxHP;
        renderhealth();
    }
예제 #3
0
    public void use()
    {
        if (crossHairIsActive)
        {
            armSpawner.rotation = Camera.main.transform.rotation;
        }
        if (Input.GetMouseButtonDown(2))
        {
            activeCrossHair();
        }
        if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetButtonDown("1"))
        {
            change();
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2) || Input.GetButtonDown("2"))
        {
            changeConsumable();
        }
        if (ammo > 0 && (Input.GetKeyDown(KeyCode.Z) || Input.GetButtonDown("trow")))
        {
            if (bombActive || daggerActive)
            {
                if (bombActive)
                {
                    bombs--;
                    ammo = bombs;

                    Bomb newBomb = Instantiate(_bomb, armSpawner.position, armSpawner.rotation) as Bomb;
                    // newBomb.speed = bulletSpeed;
                }
                else
                {
                    daggers--;
                    ammo = daggers;
                    dagger newDagger = Instantiate(_DAGGER, armSpawner.position, armSpawner.rotation) as dagger;
                    // newDagger.speed = bulletSpeed;
                }
                UIManager.instance.UpdateUI();
            }
        }

        if (reserve > 0 && (Input.GetKeyDown(KeyCode.X) || Input.GetButtonDown("use")))
        {
            if (potionActive || manapotionActive)
            {
                if (potionActive)
                {
                    hppotionNumber--;
                    HealthManager.instace.HealPlayer(healingPotionPower);
                    reserve = hppotionNumber;
                }
                else
                {
                    mppotionNumber--;
                    GameManager.instace.restoreMana(manaPotionPower);
                    reserve = mppotionNumber;
                }
            }
        }
        UIManager.instance.UpdateUI();
    }