Esempio n. 1
0
        //when any collider trigger the collider of this collectible
        void OnTriggerEnter(Collider col)
        {
            //only carry on if the trigger object is player
            if (col.gameObject.layer != TDS.GetLayerPlayer())
            {
                return;
            }

            //check the effect type and apply them accordingly
            if (type == _CollectType.Self)              //apply effect to player unit
            {
                ApplyEffectSelf(col.gameObject.GetComponent <UnitPlayer>());
            }
            else if (type == _CollectType.AOEHostile)           //apply effect to all surrounding hostile
            {
                ApplyEffectAOE(col);
            }
            else if (type == _CollectType.AllHostile)                   //apply effect to all hostile
            {
                ApplyEffectAll();
            }
            else if (type == _CollectType.Ability)
            {
                AbilityManager.TriggerAbility(abilityID);
            }

            GameControl.ColletibleCollected(this);

            //play the sound and show spawn the trigger effect object at current position
            AudioManager.PlaySound(triggerSFX);
            TriggeredEffect(transform.position + new Vector3(0, 0.1f, 0));

            //Destroy(gameObject);
            ObjectPoolManager.Unspawn(gameObject);
        }
Esempio n. 2
0
        //for perk that modify the ability attack effect
        public void ChangeAllAbilityEffect(int effectID)
        {
            int            effectIndex = EffectDB.GetEffectIndex(effectID);
            List <Ability> abList      = AbilityManager.GetAbilityList();

            for (int i = 0; i < abList.Count; i++)
            {
                abList[i].ChangeEffect(effectID, effectIndex);
            }
        }
Esempio n. 3
0
 //launch ability
 public void FireAbilityAlt()
 {
     if (destroyed || IsStunned())
     {
         return;
     }
     if (GameControl.EnableAltFire() && GameControl.EnableAbility())
     {
         AbilityManager.LaunchAbility();
     }
 }
Esempio n. 4
0
        void Awake()
        {
            //make sure there's only 1 instance of this
            if (instance != null)
            {
                Destroy(this);
                return;
            }

            instance = this;
        }
Esempio n. 5
0
        [HideInInspector] public Ability ability;       //the actual ability, only assigned in runtime

        //fire alternate mode
        public void FireAlt()
        {
            //if there's no ability, return
            if (ability == null || abilityID < 0)
            {
                return;
            }

            //check if the ability is ready to be activated
            string status = ability.IsReady();

            if (status != "")
            {
                //if cannot fire, fire event explaining why (for UI)
                TDS.FireAltFail(status);
                return;
            }

            //launch the ability
            AbilityManager.LaunchAbility(ability);
        }
Esempio n. 6
0
        public override void Start()
        {
            cam  = Camera.main;
            camT = cam.transform;
            //camPivot=cam.transform.parent;

            if (enableAbility && GameControl.EnableAbility())
            {
                AbilityManager.SetupAbility(abilityIDList, enableAllAbilities);
            }

            if (perk != null)
            {
                List <Ability> abList = AbilityManager.GetAbilityList();
                for (int i = 0; i < abList.Count; i++)
                {
                    abList[i].SetPlayerPerk(perk);
                }
            }

            Init();
        }
Esempio n. 7
0
        //public static string PurchasePerk(Perk perk, bool useCurrency=true){ return instance._PurchasePerk(perk, useCurrency); }
        public string PurchasePerk(Perk perk, bool useCurrency = true, bool saving = true)
        {
            string text = perk.Purchase(this, useCurrency);

            if (text != "")
            {
                Debug.Log(text);
                return(text);
            }

            for (int i = 0; i < perkList.Count; i++)
            {
                Perk perkTemp = perkList[i];
                if (perkTemp.purchased > 0 || perkTemp.prereq.Count == 0)
                {
                    continue;
                }
                perkTemp.prereq.Remove(perk.ID);
            }

            TDS.PerkPurchased(perk);

            if (player.SaveUponChange())
            {
                Save();
            }

            if (perk.type == _PerkType.ModifyGeneralStats)
            {
                hitPointCap += perk.hitPointCap;
                energyCap   += perk.energyCap;

                hitPointRegen += perk.hitPointRegen;
                energyRegen   += perk.energyRegen;

                player.GainHitPoint(perk.hitPoint);
                player.GainEnergy(perk.energy);

                moveSpeedMul += perk.moveSpeedMul;

                damageMul  += perk.dmgMul;
                critMul    += perk.critChanceMul;
                critMulMul += perk.CritMultiplierMul;

                expGainMul      += perk.expGainMul;
                creditGainMul   += perk.creditGainMul;
                scoreGainMul    += perk.scoreGainMul;
                hitPointGainMul += perk.hitPointGainMul;
                energyGainMul   += perk.energyGainMul;
            }
            else if (perk.type == _PerkType.AddWeapon && perk.newWeaponID >= 0)
            {
                Weapon newWeapon = WeaponDB.GetPrefab(perk.newWeaponID);

                if (newWeapon != null)
                {
                    if (perk.replaceExisting)
                    {
                        player.AddWeapon(newWeapon, true);
                    }
                    else if (perk.replaceWeaponID >= 0)
                    {
                        int replaceIndex = -1;
                        for (int i = 0; i < player.weaponList.Count; i++)
                        {
                            if (perk.replaceWeaponID == player.weaponList[i].ID)
                            {
                                replaceIndex = i;
                                break;
                            }
                        }

                        if (replaceIndex >= 0)
                        {
                            player.SwitchWeapon(replaceIndex);
                            player.AddWeapon(newWeapon, true);
                        }
                        else
                        {
                            player.AddWeapon(newWeapon);
                        }
                    }
                    else
                    {
                        player.AddWeapon(newWeapon);
                    }
                }

                for (int i = 0; i < perkList.Count; i++)
                {
                    if (perkList[i].purchased > 0 && perkList[i].type == _PerkType.ModifyWeapon)
                    {
                        if (perkList[i].appliedToAllWeapon || perkList[i].weaponIDList.Contains(perk.newWeaponID))
                        {
                            if (perkList[i].weapEffectID >= 0)
                            {
                                player.ChangeWeaponEffect(perk.newWeaponID, perkList[i].weapEffectID);
                            }
                            if (perkList[i].weapAbilityID >= 0)
                            {
                                player.ChangeWeaponAbility(perk.newWeaponID, perkList[i].weapAbilityID);
                            }
                        }
                    }
                }
            }
            else if (perk.type == _PerkType.AddAbility && perk.newAbilityID >= 0)
            {
                AbilityManager.AddAbility(perk.newAbilityID, perk.replaceAbilityID);

                for (int i = 0; i < perkList.Count; i++)
                {
                    if (perkList[i].purchased > 0 && perkList[i].type == _PerkType.ModifyAbility)
                    {
                        if (perkList[i].appliedToAllAbility || perkList[i].abilityIDList.Contains(perk.newAbilityID))
                        {
                            if (perkList[i].abEffectID >= 0)
                            {
                                player.ChangeAbilityEffect(perk.newAbilityID, perkList[i].abEffectID);
                            }
                        }
                    }
                }
            }
            else if (perk.type == _PerkType.ModifyWeapon)
            {
                if (perk.appliedToAllWeapon)
                {
                    weapStatG.ModifyWithPerk(perk);
                    if (perk.weapEffectID >= 0)
                    {
                        player.ChangeAllWeaponEffect(perk.weapEffectID);
                    }
                    if (perk.weapAbilityID >= 0)
                    {
                        player.ChangeAllWeaponAbility(perk.weapAbilityID);
                    }
                }
                else
                {
                    for (int i = 0; i < perk.weaponIDList.Count; i++)
                    {
                        WeaponStatMultiplier item = GetWeaponStatMul(perk.weaponIDList[i]);

                        if (item == null)
                        {
                            item          = new WeaponStatMultiplier();
                            item.prefabID = perk.weaponIDList[i];
                            weapStatList.Add(item);
                        }

                        item.ModifyWithPerk(perk);

                        if (perk.weapEffectID >= 0)
                        {
                            player.ChangeWeaponEffect(perk.weaponIDList[i], perk.weapEffectID);
                        }
                        if (perk.weapAbilityID >= 0)
                        {
                            player.ChangeWeaponAbility(perk.weaponIDList[i], perk.weapAbilityID);
                        }
                    }
                }
            }
            else if (perk.type == _PerkType.ModifyAbility)
            {
                if (perk.appliedToAllAbility)
                {
                    abilityStatG.ModifyWithPerk(perk);
                    if (perk.weapEffectID >= 0)
                    {
                        player.ChangeAllAbilityEffect(perk.weapEffectID);
                    }
                }
                else
                {
                    for (int i = 0; i < perk.abilityIDList.Count; i++)
                    {
                        AbilityStatMultiplier item = GetAbilityStatMul(perk.abilityIDList[i]);

                        if (item == null)
                        {
                            item          = new AbilityStatMultiplier();
                            item.prefabID = perk.abilityIDList[i];
                            abilityStatList.Add(item);
                        }

                        item.ModifyWithPerk(perk);

                        if (perk.abEffectID >= 0)
                        {
                            player.ChangeAbilityEffect(perk.abilityIDList[i], perk.abEffectID);
                        }
                    }
                }
            }
            else if (perk.type == _PerkType.Custom)
            {
                GameObject obj = (GameObject)Instantiate(perk.customObject);
                obj.name                    = perk.name + "_CustomObject";
                obj.transform.parent        = transform;
                obj.transform.localPosition = Vector3.zero;
                obj.transform.localRotation = Quaternion.identity;
            }

            return("");
        }
Esempio n. 8
0
        void Awake()
        {
            //make sure there's only 1 instance of this
            if(instance!=null){
                Destroy(this);
                return;
            }

            instance=this;
        }