Beispiel #1
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);
            }
        }
Beispiel #2
0
 public void Completed()
 {
     cleared = true;
     GameControl.GainCredits(creditGain);
     GameControl.GainScore(scoreGain);
 }