public override void destroy()
    {
        // temp fix... TODO
        _gameManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();

        // add score to game manager
        _gameManager.addScore(score);

        // show score popup text
        PopupTextManager popupManager = GameObject.FindWithTag("PopupTextManager").GetComponent <PopupTextManager>();

        if (popupManager)
        {
            popupManager.showMessage(score.ToString(), transform.position);
        }
        else
        {
            Debug.LogError("Can't find the PopupTextManager.");
        }

        // fire weapon on destroy
        if (weaponOnDestroy)
        {
            weaponOnDestroy.fire();
        }

        // explosion, destroy gameobject
        base.destroy();
    }
    public void addWeaponExp(int exp)
    {
        // weapon is not max
        if (!_currentWeapon.isMaxLevel())
        {
            // add exp to current weapon
            bool isUpgraded = _currentWeapon.addExperience(exp);

            // update UI
            if (isUpgraded)
            {
                weaponCircle.switchWeapon(_currentWeapon);

                // Show popup text
                PopupTextManager popupManager = GameObject.FindWithTag("PopupTextManager").GetComponent <PopupTextManager>();
                if (popupManager)
                {
                    popupManager.showMessage("LEVEL UP", transform.position);
                }
            }
            else
            {
                weaponCircle.update(_currentWeapon);
            }
        }
        else
        {
            // exceeding exp would transfer to health
            applyHealing((int)(exp * rateExpToHp));
        }
    }
示例#3
0
    public override void doPowerup(PlayerController player)
    {
        player.addLife(life);

        // show popup text
        PopupTextManager popupManager = GameObject.FindWithTag("PopupTextManager").GetComponent <PopupTextManager>();

        if (popupManager)
        {
            popupManager.showMessage("+" + life + " LIFE", player.transform.position);
        }
        else
        {
            Debug.LogError("Can't find the PopupTextManager.");
        }
    }
    private void die()
    {
        // explosion vfx
        Instantiate(vfxExplosion, transform.position, transform.rotation);

        // Sfx
        if (Clip_OnDestroy)
        {
            Audio.PlaySfx(Clip_OnDestroy);
        }

        // drop experience as penalty
        if (!_currentWeapon.isMaxLevel())
        {
            int expDrop = _currentWeapon.experience;
            _currentWeapon.experience = 0;
            expDrop = (int)(expDrop * proportionExpDrop);
            weaponCircle.update(_currentWeapon);

            if (GameMgr == null)
            {
                Debug.LogError("Can't find the GameManager.");
            }
            else
            {
                Vector3 pos    = transform.position;
                float   radius = GetComponent <Collider>().bounds.extents.x + extendRangeExpDrop;
                GameMgr.dropExperience(pos, radius, expDrop);
            }

            // Show popup text for experience dropped
            PopupTextManager popupManager = GameObject.FindWithTag("PopupTextManager").GetComponent <PopupTextManager>();
            if (popupManager)
            {
                popupManager.showMessage("LOSE " + (proportionExpDrop * 100).ToString() + "% EXP", transform.position);
            }
            else
            {
                Debug.LogError("Can't find the PopupTextManager.");
            }
        }

        // turn off renderer and collider
        setVisible(false);
        GetComponent <Collider>().enabled = false;
        transform.position = new Vector3(0.0f, 10.0f, 0.0f); // place outside
    }
示例#5
0
    public override void doPowerup(PlayerController player)
    {
        // heal the player
        player.applyHealing(healing);

        // show popup text
        PopupTextManager popupManager = GameObject.FindWithTag("PopupTextManager").GetComponent <PopupTextManager>();

        if (popupManager)
        {
            popupManager.showMessage("+" + healing + " HP", player.transform.position);
        }
        else
        {
            Debug.LogError("Can't find the PopupTextManager.");
        }
    }
    public override void doPowerup(PlayerController player)
    {
        // add experience to player
        player.addWeaponExp(experience);

        // show popup text
        PopupTextManager popupManager = GameObject.FindWithTag("PopupTextManager").GetComponent <PopupTextManager>();

        if (popupManager)
        {
            popupManager.showMessage("+" + experience + " EXP", player.transform.position);
        }
        else
        {
            Debug.LogError("Can't find the PopupTextManager.");
        }
    }