Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
        // Use this for initialization
        public override void Awake()
        {
            base.Awake();

            thisObj.layer = TDS.GetLayerPlayer();

            isPlayer = true;

            SetDestroyCallback(this.PlayerDestroyCallback);

            if (enableAllWeapons)
            {
                weaponList = new List <Weapon>(Weapon_DB.Load());
            }

            if (weaponMountPoint == null)
            {
                weaponMountPoint = thisT;
            }

            if (enableTurretRotate)
            {
                if (turretObj != null)
                {
                    turretObjParent = turretObj.parent;
                }
                else
                {
                    turretObj = thisT;
                    //faceTravelDirection=false;
                }
            }

            hitPointBase = hitPointFull;
            energyBase   = energyFull;

            InitSpawnImmunity();

            progress = thisObj.GetComponent <PlayerProgression>();
            if (progress != null)
            {
                progress.SetPlayer(this);
            }

            perk = thisObj.GetComponent <PlayerPerk>();
            if (perk != null)
            {
                perk.SetPlayer(this);
            }

            Load();
        }
Ejemplo n.º 3
0
        public static Weapon_DB Init()
        {
            if (instance != null)
            {
                return(instance);
            }
            instance = LoadDB();

                        #if UNITY_2018_3_OR_NEWER
            instance.FillObjectList();
                        #endif

            return(instance);
        }
Ejemplo n.º 4
0
        public static void LoadWeapon()
        {
            weaponDB = Weapon_DB.LoadDB();

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

            UpdateLabel_Weapon();

            TDSEditorWindow.SetWeaponDB(weaponDB, weaponIDList, weaponLabel);
            TDSEditorInspector.SetWeaponDB(weaponDB, weaponIDList, weaponLabel);
        }
Ejemplo n.º 5
0
 public static void SetWeaponDB(Weapon_DB db, List <int> IDList, string[] label)
 {
     weaponDB     = db;
     weaponIDList = IDList;
     weaponLabel  = label;
 }
Ejemplo n.º 6
0
        public override bool OnGUI()
        {
            if (!base.OnGUI())
            {
                return(true);
            }

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

            List <Weapon> weaponList = weaponDB.weaponList;

            Undo.RecordObject(this, "window");
            Undo.RecordObject(effectDB, "weaponDB");
            if (weaponList.Count > 0)
            {
                Undo.RecordObject(weaponList[selectID], "weapon");
            }

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

            if (!Weapon_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"))
                {
                    Weapon_DB.CopyFromOldDB();              Select(0);
                }
                GUI.color = Color.white;
            }


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

            EditorGUI.LabelField(new Rect(5, 7, 150, 17), "Add New Weapon:");
            Weapon newWeapon = null;

            newWeapon = (Weapon)EditorGUI.ObjectField(new Rect(115, 7, 150, 17), newWeapon, typeof(Weapon), false);
            if (newWeapon != null)
            {
                Select(NewItem(newWeapon));
            }


            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 = DrawWeaponList(startX, startY, weaponList);

            startX = v2.x + 25;

            if (weaponList.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);

            EditorGUI.BeginChangeCheck();

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

            if (EditorGUI.EndChangeCheck())
            {
                                        #if UNITY_2018_3_OR_NEWER
                //GameObject weaponObj=PrefabUtility.LoadPrefabContents(AssetDatabase.GetAssetPath(weaponList[selectID].gameObject));
                //Weapon selectedWeapon=weaponObj.GetComponent<Weapon>();
                //selectedWeapon=weaponList[selectID];
                //GameObject obj=PrefabUtility.SavePrefabAsset(selectedWeapon.gameObject);

                string assetPath = AssetDatabase.GetAssetPath(weaponList[selectID].gameObject);

                GameObject weapObj        = PrefabUtility.LoadPrefabContents(assetPath);
                Weapon     selectedWeapon = weapObj.GetComponent <Weapon>();

                EditorUtility.CopySerialized(weaponList[selectID], selectedWeapon);

                PrefabUtility.SaveAsPrefabAsset(weapObj, assetPath);
                PrefabUtility.UnloadPrefabContents(weapObj);
                                        #endif
            }

            GUI.EndScrollView();

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

            return(true);
        }
Ejemplo 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 = Weapon_DB.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("");
        }