示例#1
0
        void Awake()
        {
            gameObject.GetComponent <Collider>().isTrigger = true;
            gameObject.layer = TDS.GetLayerCollectible();

            if (type == _CollectType.Self)
            {
                //initiate the weapon list to contain all weapon if the condition is checked
                if (gainWeapon && randomWeapon && enableAllWeapon)
                {
                    weaponList = new List <Weapon>(Weapon_DB.Load());
                }

                //make sure none of the element in weaponList is null
                for (int i = 0; i < weaponList.Count; i++)
                {
                    if (weaponList[i] == null)
                    {
                        weaponList.RemoveAt(i); i -= 1;
                    }
                }
            }

            //effect=EffectDB.CloneItem(effectID);
            effectIdx = Effect_DB.GetEffectIndex(effectID);

            if (triggerEffectObj != null)
            {
                ObjectPoolManager.New(triggerEffectObj, 1);
            }
        }
示例#2
0
        //for perk that modify the weapon attack effect
        public void ChangeAllWeaponEffect(int effectID)
        {
            int effectIndex = Effect_DB.GetEffectIndex(effectID);

            for (int i = 0; i < weaponList.Count; i++)
            {
                weaponList[i].ChangeEffect(effectID, effectIndex);
            }
        }
示例#3
0
 public static Effect_DB Init()
 {
     if (instance != null)
     {
         return(instance);
     }
     instance = LoadDB();
     return(instance);
 }
示例#4
0
        //for perk that modify the ability attack effect
        public void ChangeAllAbilityEffect(int effectID)
        {
            int            effectIndex = Effect_DB.GetEffectIndex(effectID);
            List <Ability> abList      = AbilityManager.GetAbilityList();

            for (int i = 0; i < abList.Count; i++)
            {
                abList[i].ChangeEffect(effectID, effectIndex);
            }
        }
示例#5
0
        public void ChangeWeaponEffect(int weaponID, int effectID)
        {
            int effectIndex = Effect_DB.GetEffectIndex(effectID);

            for (int i = 0; i < weaponList.Count; i++)
            {
                if (weaponList[i].ID == weaponID)
                {
                    weaponList[i].ChangeEffect(effectID, effectIndex);
                    break;
                }
            }
        }
示例#6
0
        public static void LoadEffect()
        {
            effectDB = Effect_DB.LoadDB();

            for (int i = 0; i < effectDB.effectList.Count; i++)
            {
                if (effectDB.effectList[i] != null)
                {
                    //effectDB.effectList[i].ID=i;
                    effectIDList.Add(effectDB.effectList[i].ID);
                }
                else
                {
                    effectDB.effectList.RemoveAt(i);
                    i -= 1;
                }
            }

            UpdateLabel_Effect();

            TDSEditorWindow.SetEffectDB(effectDB, effectIDList, effectLabel);
            TDSEditorInspector.SetEffectDB(effectDB, effectIDList, effectLabel);
        }
示例#7
0
 public static void SetEffectDB(Effect_DB db, List <int> IDList, string[] label)
 {
     effectDB     = db;
     effectIDList = IDList;
     effectLabel  = label;
 }
示例#8
0
        //applies the effect of an attack
        public void ApplyAttack(AttackInstance attInstance)
        {
            if (immunityCounter > 0)
            {
                return;
            }

            //if unit is invincible, do nothing
            if (IsInvincible())
            {
                Debug.Log("Immuned");
                Vector3 osPos = new Vector3(0, Random.value + 0.5f, 0);
                new TextOverlay(thisT.position + osPos, "Immuned");
                return;
            }

            AttackStats aStats = attInstance.aStats;

            //check if the attack is an aoe and modify the damage value is dimishingAOE is enabled
            float damage = Random.Range(aStats.damageMin, aStats.damageMax);

            if (attInstance.isAOE && aStats.diminishingAOE)
            {
                damage *= Mathf.Clamp(1 - attInstance.aoeDistance / aStats.aoeRadius, 0, 1);
            }


            //check for cirtical and modify the damage based on critical multiplier
            bool critical = Random.value < aStats.critChance;

            if (critical)
            {
                damage *= aStats.critMultiplier;
            }

            //modify the damage based on damage and armor type
            damage *= DamageTable.GetModifier(armorType, aStats.damageType);

            //if damage is valid, modify the hit point
            if (damage > 0)
            {
                //show the overlay (for UI)
                Vector3 offsetPos = new Vector3(0, Random.value + 0.5f, 0);
                if (!critical)
                {
                    new TextOverlay(thisT.position + offsetPos, damage.ToString("f0"));
                }
                else
                {
                    new TextOverlay(thisT.position + offsetPos, damage.ToString("f0"), new Color(1f, 0.9f, 0.9f, 1f), 1.5f);
                }

                //if the unit is player, fire event to inform UI
                if (thisObj.layer == TDS.GetLayerPlayer())
                {
                    TDS.PlayerDamaged(damage);
                }

                //register the stagger
                hpRegenStaggerCounter = hpRegenStagger;

                hitPoint -= damage;                     //damage the hitpoint
                if (hitPoint <= 0)
                {
                    Destroyed(attInstance.GetSrcPlayer());
                }

                if (hitPoint > 0 && uAnimation != null)
                {
                    uAnimation.Hit();
                }
            }

            //apply effect if there's any
            //if(aStats.effect!=null) ApplyEffect(aStats.effect);
            if (hitPoint > 0 && aStats.effectIdx >= 0)
            {
                ApplyEffect(Effect_DB.CloneItem(aStats.effectIdx));
            }
        }
示例#9
0
        public int effectIdx = -1;              //effect'sindex to effectlist in DB during runtime
        //[HideInInspector] public Effect effect=null;


        public void Init()
        {
            //clone the effect so the original in DB wont get modified
            //effect=EffectDB.CloneItem(effectID);
            effectIdx = Effect_DB.GetEffectIndex(effectID);
        }
示例#10
0
        public override bool OnGUI()
        {
            if (!base.OnGUI())
            {
                return(true);
            }

            if (window == null)
            {
                Init();
            }

            List <Effect> effectList = effectDB.effectList;

            Undo.RecordObject(this, "window");
            Undo.RecordObject(effectDB, "EffectDB");

            if (GUI.Button(new Rect(Math.Max(260, window.position.width - 120), 5, 100, 25), "Save"))
            {
                SetDirtyTDS();
            }

            if (!Effect_DB.UpdatedToPost_2018_3())
            {
                GUI.color = new Color(0, 1f, 1f, 1f);
                if (GUI.Button(new Rect(Math.Max(260, window.position.width - 230), 5, 100, 25), "Copy Old DB"))
                {
                    Effect_DB.CopyFromOldDB();              Select(0);
                }
                GUI.color = Color.white;
            }


            if (GUI.Button(new Rect(5, 5, 120, 25), "Create New"))
            {
                Select(NewItem());
            }
            if (effectList.Count > 0 && GUI.Button(new Rect(130, 5, 100, 25), "Clone Selected"))
            {
                Select(NewItem(selectID));
            }

            float startX = 5; float startY = 55;

            if (minimiseList)
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), ">>"))
                {
                    minimiseList = false;
                }
            }
            else
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), "<<"))
                {
                    minimiseList = true;
                }
            }

            Vector2 v2 = DrawEffectList(startX, startY, effectList);

            startX = v2.x + 25;

            if (effectList.Count == 0)
            {
                return(true);
            }


            Rect visibleRect = new Rect(startX, startY, window.position.width - startX - 10, window.position.height - startY - 5);
            Rect contentRect = new Rect(startX, startY, contentWidth - startY, contentHeight);

            scrollPos = GUI.BeginScrollView(visibleRect, scrollPos, contentRect);

            //float cachedX=startX;
            v2            = DrawEffectConfigurator(startX, startY, effectList[selectID]);
            contentWidth  = v2.x + 35;
            contentHeight = v2.y - 55;

            GUI.EndScrollView();

            if (GUI.changed)
            {
                SetDirtyTDS();
            }

            return(true);
        }
示例#11
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(Effect_DB.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);
            }
        }