Пример #1
0
        //public static void LevelUp(){ instance._LevelUp(); }
        public void _LevelUp()
        {
            PlayerPerk perk = player.GetPlayerPerk();

            if (perk != null)
            {
                for (int i = 0; i < stats.perkUnlockingAtLevelList.Count; i++)
                {
                    if (level + 1 == stats.perkUnlockingAtLevelList[i].level)
                    {
                        for (int n = 0; n < stats.perkUnlockingAtLevelList[i].perkIDList.Count; n++)
                        {
                            perk.PurchasePerk(stats.perkUnlockingAtLevelList[i].perkIDList[n], false);
                        }

                        break;
                    }
                }
            }

            level += 1;

            if (level > 1)
            {
                player.GainHitPoint(stats.hitPointGain);
                player.GainEnergy(stats.energyGain);

                player.GainPerkCurrency(stats.perkCurrencyGain);

                TDS.PlayerLevelUp(player);
                TDS.OnGameMessage("level Up!");
            }

            GainExp();                  //call the function to make sure if we under level
        }
Пример #2
0
        //apply the effect to player
        void ApplyEffectSelf(UnitPlayer player)
        {
            //gain life
            if (life > 0)
            {
                GameControl.GainLife();
            }

            //gain hit-point
            if (hitPoint > 0)
            {
                float hitPointGained = player.GainHitPoint(hitPoint);

                Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0);
                new TextOverlay(transform.position + offsetPos, "+" + hitPointGained.ToString("f0"), new Color(0.3f, 1f, 0.3f, 1));
            }

            //gain energy
            if (energy > 0)
            {
                float energyGained = player.GainEnergy(energy);

                Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0);
                new TextOverlay(transform.position + offsetPos, "+" + energyGained.ToString("f0"), new Color(.3f, .3f, 1f, 1));
            }

            //not in used
            if (credit > 0)
            {
                GameControl.GainCredits(credit);

                Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0);
                new TextOverlay(transform.position + offsetPos, "+$" + credit.ToString("f0"), new Color(.5f, .75f, 1, 1));
            }

            //gain score
            if (score > 0)
            {
                GameControl.GainScore(score);

                Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0);
                new TextOverlay(transform.position + offsetPos, "+" + score.ToString("f0"), new Color(.1f, 1f, 1, 1));
            }

            //gain ammo
            if (ammo != 0)
            {
                player.GainAmmo(ammoID, ammo);

                Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0);
                new TextOverlay(transform.position + offsetPos, "+ammo");
            }

            //gain exp
            if (exp != 0)
            {
                player.GainExp(exp);

                Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0);
                new TextOverlay(transform.position + offsetPos, "+exp", new Color(1f, 1f, 1, 1));
            }

            //gain perk currency
            if (perkCurrency != 0)
            {
                player.GainPerkCurrency(perkCurrency);

                Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0);
                new TextOverlay(transform.position + offsetPos, "+perk points", new Color(1f, 1f, 1, 1));
            }


            //effects
            if (effectIdx >= 0)
            {
                player.ApplyEffect(EffectDB.CloneItem(effectIdx));
            }
            //if(effect!=null && effect.duration>0) player.ApplyEffect(effect);

            //gain weapon
            if (gainWeapon && weaponList.Count > 0)
            {
                int playerWeaponID = player.weaponList[player.weaponID].ID;
                int rand           = randomWeapon ? Random.Range(0, weaponList.Count) : 0;
                if (randomWeapon && weaponList.Count > 1)
                {
                    int count = 0;
                    while (weaponList[rand].ID == playerWeaponID)
                    {
                        rand   = Random.Range(0, weaponList.Count);
                        count += 1;
                        if (count > 50)
                        {
                            break;
                        }
                    }
                }

                bool replaceWeapon   = weaponType == _WeaponType.Replacement;
                bool temporaryWeapon = weaponType == _WeaponType.Temporary;
                player.AddWeapon(weaponList[rand], replaceWeapon, temporaryWeapon, tempWeapDuration);
            }
        }
Пример #3
0
        //for when the unit is destroy by game mechanic
        public void Destroyed(UnitPlayer player = null)
        {
            if (destroyed)
            {
                return;
            }

            //if(player==null) Debug.LogWarning("unit destroyed by not source player has been detected", null);

            destroyed = true;

            //spawn a unit if spawnUponDestroy is assigned
            if (spawnUponDestroy != null)
            {
                //loop as many as required
                for (int i = 0; i < spawnUponDestroyCount; i++)
                {
                    //instantiate the unit
                    //GameObject unitObj=(GameObject)Instantiate(spawnUponDestroy.gameObject, thisT.position, thisT.rotation);
                    GameObject unitObj = ObjectPoolManager.Spawn(spawnUponDestroy.gameObject, thisT.position, thisT.rotation);
                    unitObj.layer = thisObj.layer;

                    //pass on the wave info
                    Unit unitInstance = unitObj.GetComponent <Unit>();
                    if (waveID >= 0)
                    {
                        unitInstance.SetWaveID(spawner, waveID);
                        spawner.AddUnitToWave(unitInstance);
                    }
                    else if (spawner != null)
                    {
                        spawner.AddUnit(unitInstance);
                    }
                }
            }

            //check if the unit is going to drop any collectible
            if (useDropManager)                 //if useDropManager is enabled, inform CollectibleDropManager
            {
                CollectibleDropManager.UnitDestroyed(thisT.position);
            }
            else
            {
                //check chance and spawn the item
                if (dropObject != null && Random.value < dropChance)
                {
                    ObjectPoolManager.Spawn(dropObject.gameObject, thisT.position, Quaternion.identity);
                }
            }


            if (player != null)
            {
                //applies the bonus value for when the unit is destroyed.
                //if(valueCredits>0) GameControl.GainCredits(valueCredits);
                if (valueScore > 0)
                {
                    GameControl.GainScore(valueScore);
                }

                if (valuePerkC > 0)
                {
                    player.GainPerkCurrency(valuePerkC);
                }
                if (valueExp > 0)
                {
                    player.GainExp(valueExp);
                }
                if (valueHitPoint > 0)
                {
                    player.GainHitPoint(valueHitPoint);
                }
                if (valueEnergy > 0)
                {
                    player.GainEnergy(valueEnergy);
                }
            }

            //if(isPlayer) GetUnitPlayer().DeleteSave();

            //shake camera
            TDS.CameraShake(destroyCamShake);

            float delay = uAnimation != null?uAnimation.Destroyed() : 0;

            ClearUnit(true, delay);
        }