Пример #1
0
 public static void AddNewWeapon(FPSWeapon weaponPrefab)
 {
     if (instance != null)
     {
         instance._AddNewWeapon(weaponPrefab);
     }
 }
Пример #2
0
        public void SetAnchorTower(UnitTower tower)
        {
            if (!useTowerWeapon)
            {
                return;
            }

            anchorTower = tower;
            if (currentWeapon != null)
            {
                currentWeapon.gameObject.SetActive(false);
            }
            currentWeapon = null;

            if (anchorTower.FPSWeaponID < 0)
            {
                return;
            }

            for (int i = 0; i < weaponList.Count; i++)
            {
                if (weaponList[i].prefabID == tower.FPSWeaponID)
                {
                    currentWeapon = weaponList[i];
                    currentWeapon.gameObject.SetActive(true);
                }
            }
        }
Пример #3
0
 public static void StartReload(FPSWeapon weap)
 {
     if (instance.currentWeapon == weap)
     {
         //if(onFPSReloadE!=null) onFPSReloadE(true);
         TDTK.OnFPSReload(true);
     }
 }
Пример #4
0
 public static void ReloadComplete(FPSWeapon weap)
 {
     if (instance.currentWeapon == weap)
     {
         //if(onFPSReloadE!=null) onFPSReloadE(false);
         TDTK.OnFPSReload(false);
     }
 }
Пример #5
0
        void ShiftItem(int dir)
        {
            FPSWeapon weapon = fpsWeaponDB.weaponList[selectID];

            fpsWeaponDB.weaponList[selectID]       = fpsWeaponDB.weaponList[selectID + dir];
            fpsWeaponDB.weaponList[selectID + dir] = weapon;
            selectID += dir;
        }
Пример #6
0
 private static void RefreshFPSWeapon_Remove(FPSWeapon weapon)
 {
     for (int i = 0; i < towerList.Count; i++)
     {
         if (towerList[i].FPSWeaponID == weapon.prefabID)
         {
             towerList[i].FPSWeaponID = -1;
         }
     }
 }
Пример #7
0
        public static void RemoveWeapon(int listID)
        {
            FPSWeapon removedWeapon = weaponList[listID];

            weaponIDList.Remove(weaponList[listID].prefabID);
            weaponList.RemoveAt(listID);
            UpdateWeaponNameList();
            SetDirtyFPSWeapon();
            RefreshFPSWeapon_Remove(removedWeapon);
        }
Пример #8
0
        public void _AddNewWeapon(FPSWeapon weaponPrefab)
        {
            for (int i = 0; i < weaponList.Count; i++)
            {
                if (weaponList[i].prefabID == weaponPrefab.prefabID)
                {
                    return;
                }
            }

            Transform weapT = CreateWeaponInstance(weaponPrefab.transform);

            weaponList.Add(weapT.GetComponent <FPSWeapon>());
        }
Пример #9
0
		void Start(){
			//weapon initiation goes here, wait for PerkManager to initiate the perk
			if(weaponList.Count>0){
				for(int i=0; i<weaponList.Count; i++){
					Transform weapT=CreateWeaponInstance(weaponList[i].transform);
					weaponList[i]=weapT.GetComponent<FPSWeapon>();
				}
				
				currentWeapon=weaponList[currentWeaponID];
				currentWeapon.gameObject.SetActive(true);
			}
			
			thisObj.SetActive(false);
		}
Пример #10
0
        int _NewItem(FPSWeapon weapon)
        {
            if (fpsWeaponDB.weaponList.Contains(weapon))
            {
                return(selectID);
            }

            weapon.prefabID = GenerateNewID(fpsWeaponIDList);
            fpsWeaponIDList.Add(weapon.prefabID);

            fpsWeaponDB.weaponList.Add(weapon);

            UpdateLabel_FPSWeapon();

            return(fpsWeaponDB.weaponList.Count - 1);
        }
Пример #11
0
        void Start()
        {
            //weapon initiation goes here, wait for PerkManager to initiate the perk
            if (weaponList.Count > 0)
            {
                for (int i = 0; i < weaponList.Count; i++)
                {
                    Transform weapT = CreateWeaponInstance(weaponList[i].transform);
                    weaponList[i] = weapT.GetComponent <FPSWeapon>();
                }

                currentWeapon = weaponList[currentWeaponID];
                currentWeapon.gameObject.SetActive(true);
            }

            thisObj.SetActive(false);
        }
Пример #12
0
        public void SelectWeapon(int val)
        {
            if (useTowerWeapon)
            {
                return;
            }

            currentWeapon.gameObject.SetActive(false);
            currentWeaponID += val;
            if (currentWeaponID < 0)
            {
                currentWeaponID = weaponList.Count - 1;
            }
            else if (currentWeaponID >= weaponList.Count)
            {
                currentWeaponID = 0;
            }

            currentWeapon = weaponList[currentWeaponID];
            currentWeapon.gameObject.SetActive(true);

            //if(onSwitchWeaponE!=null) onSwitchWeaponE();
            TDTK.OnFPSSwitchWeapon();
        }
Пример #13
0
        public static int AddNewFPSWeapon(FPSWeapon newWeapon)
        {
            if (weaponList.Contains(newWeapon))
            {
                return(-1);
            }

            int ID = GenerateNewID(weaponIDList);

            newWeapon.prefabID = ID;
            weaponIDList.Add(ID);
            weaponList.Add(newWeapon);

            UpdateWeaponNameList();

            if (newWeapon.stats.Count == 0)
            {
                newWeapon.stats.Add(new UnitStat());
            }

            SetDirtyFPSWeapon();

            return(weaponList.Count - 1);
        }
Пример #14
0
 public static void AddNewWeapon(FPSWeapon weaponPrefab)
 {
     if(instance!=null) instance._AddNewWeapon(weaponPrefab);
 }
Пример #15
0
        public void _SetAnchorTower(UnitTower tower)
        {
            if(!useTowerWeapon) return;

            anchorTower=tower;
            if(currentWeapon!=null) currentWeapon.gameObject.SetActive(false);
            currentWeapon=null;

            if(anchorTower.FPSWeaponID<0) return;

            for(int i=0; i<weaponList.Count; i++){
                if(weaponList[i].prefabID==tower.FPSWeaponID){
                    currentWeapon=weaponList[i];
                    currentWeapon.gameObject.SetActive(true);
                }
            }
        }
Пример #16
0
        public void _AddNewWeapon(FPSWeapon weaponPrefab)
        {
            for(int i=0; i<weaponList.Count; i++){ if(weaponList[i].prefabID==weaponPrefab.prefabID) return; }

            Transform weapT=CreateWeaponInstance(weaponPrefab.transform);
            weaponList.Add(weapT.GetComponent<FPSWeapon>());
        }
Пример #17
0
        public void SelectWeapon(int val)
        {
            if(useTowerWeapon) return;

            currentWeapon.gameObject.SetActive(false);
            currentWeaponID+=val;
            if(currentWeaponID<0) currentWeaponID=weaponList.Count-1;
            else if(currentWeaponID>=weaponList.Count) currentWeaponID=0;

            currentWeapon=weaponList[currentWeaponID];
            currentWeapon.gameObject.SetActive(true);

            if(onSwitchWeaponE!=null) onSwitchWeaponE();
        }
Пример #18
0
 public static void StartReload(FPSWeapon weap)
 {
     if(instance.currentWeapon==weap){
         if(onFPSReloadE!=null) onFPSReloadE(true);
     }
 }
Пример #19
0
		private static void RefreshFPSWeapon_Remove(FPSWeapon weapon){
			for(int i=0; i<towerList.Count; i++){
				if(towerList[i].FPSWeaponID==weapon.prefabID){
					towerList[i].FPSWeaponID=-1;
				}
			}
		}
Пример #20
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            EditorGUILayout.Space();
            cont = new GUIContent("Use Tower Weapon:", "Check to have use the assigned weapon of the selected tower. When this is enabled, player cannot switch weapon.");
            instance.useTowerWeapon = EditorGUILayout.Toggle(cont, instance.useTowerWeapon);


            cont = new GUIContent("Aim Sensitivity:", "Mouse sensitivity when aiming in fps mode");
            instance.aimSensitivity = EditorGUILayout.FloatField(cont, instance.aimSensitivity);

            cont  = new GUIContent("Recoil Mode:", "The way shoot recoil works");
            contL = new GUIContent[recoilModeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(recoilModeLabel[i], recoilModeTooltip[i]);
            }
            instance.recoilMode = EditorGUILayout.Popup(cont, instance.recoilMode, contL);

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showPivotTransform = EditorGUILayout.Foldout(showPivotTransform, "Show Pivot Transforms & Camera");
            EditorGUILayout.EndHorizontal();
            if (showPivotTransform)
            {
                cont = new GUIContent("Weapon Pivot:", "The pivot transform of the weapon object.");
                instance.weaponPivot = (Transform)EditorGUILayout.ObjectField(cont, instance.weaponPivot, typeof(Transform), true);

                cont = new GUIContent("Camera Pivot:", "The pivot transform of the camera");
                instance.cameraPivot = (Transform)EditorGUILayout.ObjectField(cont, instance.cameraPivot, typeof(Transform), true);

                cont          = new GUIContent("Camera Transform:", "The transform which contains the fps camera component");
                instance.camT = (Transform)EditorGUILayout.ObjectField(cont, instance.camT, typeof(Transform), true);
            }


            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showWeaponList = EditorGUILayout.Foldout(showWeaponList, "Show Weapon List");
            EditorGUILayout.EndHorizontal();
            if (showWeaponList)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailableIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailableIDList = new List <int>();
                    for (int i = 0; i < weaponList.Count; i++)
                    {
                        instance.unavailableIDList.Add(weaponList[i].prefabID);
                    }
                }
                EditorGUILayout.EndHorizontal();

                //scrollPosition = GUILayout.BeginScrollView (scrollPosition);

                for (int i = 0; i < weaponList.Count; i++)
                {
                    FPSWeapon weapon = weaponList[i];

                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    EditorUtilities.DrawSprite(rect, weapon.icon, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(weapon.name, GUILayout.ExpandWidth(false));

                    bool flag = !instance.unavailableIDList.Contains(weapon.prefabID) ? true : false;
                    if (Application.isPlaying)
                    {
                        flag = !flag;                                                           //switch it around in runtime
                    }
                    flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the weapon in this level"), flag);

                    if (!Application.isPlaying)
                    {
                        if (flag)
                        {
                            instance.unavailableIDList.Remove(weapon.prefabID);
                        }
                        else
                        {
                            if (!instance.unavailableIDList.Contains(weapon.prefabID))
                            {
                                instance.unavailableIDList.Add(weapon.prefabID);
                            }
                        }
                    }

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }


            EditorGUILayout.Space();


            if (GUILayout.Button("Open FPSWeaponEditor"))
            {
                FPSWeaponEditorWindow.Init();
            }
            EditorGUILayout.Space();



            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showDefaultFlag = EditorGUILayout.Foldout(showDefaultFlag, "Show default editor");
            EditorGUILayout.EndHorizontal();
            if (showDefaultFlag)
            {
                DrawDefaultInspector();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Пример #21
0
 void Awake()
 {
     instance = (FPSWeapon)target;
     LoadDB();
 }
Пример #22
0
 public static bool ExistInDB(FPSWeapon weapon)
 {
     return(fpsWeaponDB.weaponList.Contains(weapon));
 }
Пример #23
0
        void Start()
        {
            if(weaponList.Count>0){
                for(int i=0; i<weaponList.Count; i++){
                    Transform weapT=CreateWeaponInstance(weaponList[i].transform);
                    weaponList[i]=weapT.GetComponent<FPSWeapon>();
                }

                currentWeapon=weaponList[currentWeaponID];
                currentWeapon.gameObject.SetActive(true);
            }

            thisObj.SetActive(false);
        }
Пример #24
0
 public static int NewItem(FPSWeapon weapon)
 {
     return(window._NewItem(weapon));
 }
Пример #25
0
        public override bool OnGUI()
        {
            if (!base.OnGUI())
            {
                return(true);
            }

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

            List <FPSWeapon> weaponList = fpsWeaponDB.weaponList;

            Undo.RecordObject(this, "window");
            Undo.RecordObject(fpsWeaponDB, "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"))
            {
                SetDirtyTD();
            }

            //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:");
            FPSWeapon newWeapon = null;

            newWeapon = (FPSWeapon)EditorGUI.ObjectField(new Rect(115, 7, 150, 17), newWeapon, typeof(FPSWeapon), 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);

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

            GUI.EndScrollView();

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

            return(true);
        }
Пример #26
0
        Vector2 DrawWeaponConfigurator(float startX, float startY, FPSWeapon weapon)
        {
            TDEditor.DrawSprite(new Rect(startX, startY, 60, 60), weapon.icon);
            startX += 65;

            cont = new GUIContent("Name:", "The ability name to be displayed in game");
            EditorGUI.LabelField(new Rect(startX, startY += 5, width, height), cont);
            weapon.weaponName = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), weapon.weaponName);

            cont = new GUIContent("Icon:", "The ability icon to be displayed in game, must be a sprite");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), weapon.icon, typeof(Sprite), false);

            cont = new GUIContent("Prefab:", "The prefab object of the unit\nClick this to highlight it in the ProjectTab");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), weapon.gameObject, typeof(GameObject), false);

            startX -= 65;
            startY += spaceY;           //cachedY=startY;


            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Basic Setting", headerStyle);
            startX += 15;

            cont = new GUIContent("Damage Type:", "The damage type of the weapon\nDamage type can be configured in Damage Armor Table Editor");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.damageType = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), weapon.damageType, damageTypeLabel);

            cont = new GUIContent("Recoil:", "The recoil force of the weapon");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.recoil = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), weapon.recoil);

            cont = new GUIContent("ShootPoint:", "The transform which indicate the position where the shootObject will be fired from (Optional)\nEach shootPoint assigned will fire a shootObject instance in each attack\nIf left empty, the unit transform itself will be use as the shootPoint\nThe orientation of the shootPoint matter as they dictate the orientation of the shootObject starting orientation.\n");
            shootPointFoldout = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), shootPointFoldout, cont);
            int shootPointCount = weapon.shootPoints.Count;

            shootPointCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), shootPointCount);

            if (shootPointCount != weapon.shootPoints.Count)
            {
                while (weapon.shootPoints.Count < shootPointCount)
                {
                    weapon.shootPoints.Add(null);
                }
                while (weapon.shootPoints.Count > shootPointCount)
                {
                    weapon.shootPoints.RemoveAt(weapon.shootPoints.Count - 1);
                }
            }

            if (shootPointFoldout)
            {
                for (int i = 0; i < weapon.shootPoints.Count; i++)
                {
                    int objID = GetObjectIDFromHList(weapon.shootPoints[i], objHList);
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "    - Element " + (i + 1));
                    objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                    weapon.shootPoints[i] = (objHList[objID] == null) ? null : objHList[objID].transform;
                }
            }

            startY += 10;

            cont = new GUIContent("ShootObject:", "The shootObject used by the unit.\nUnit that intended to shoot at the target will not function correctly if this is left unassigned.");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.stats[0].shootObject = (ShootObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), weapon.stats[0].shootObject, typeof(ShootObject), false);

            startY += 5;

            cont = new GUIContent("ReloadSound:", "The audio-clip to be played when the weapon reloads (optional)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            weapon.reloadSound = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), weapon.reloadSound, typeof(AudioClip), false);


            startX -= 15;
            startY += 35;

            if (weapon.stats.Count == 0)
            {
                weapon.stats.Add(new UnitStat());
            }

            string text = "Weapon Stats " + (!foldStats ? "(show)" : "(hide)");

            foldStats = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldStats, text, foldoutStyle);
            if (foldStats)
            {
                startX += 15;

                startY = DrawWeaponStat(weapon.stats[0], startX + 15, startY += spaceY);

                //for(int i=0; i<weapon.stats.Count; i++){
                //	startY=DrawWeaponStat(weapon.stats[i], startX+15, startY+=spaceY);
                //}

                startX -= 15;
            }


            startY += 25;

            GUIStyle style = new GUIStyle("TextArea");

            style.wordWrap = true;
            cont           = new GUIContent("Weapon description (to be used in runtime): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            weapon.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), weapon.desp, style);


            return(new Vector2(startX, startY + 170));
        }
        Vector2 DrawWeaponConfigurator(float startX, float startY, FPSWeapon weapon)
        {
            float maxWidth=0;

            float cachedY=startY;
            float cachedX=startX;

            EditorUtilities.DrawSprite(new Rect(startX, startY, 60, 60), weapon.icon);
            startX+=65;

            cont=new GUIContent("Name:", "The unit name to be displayed in game");
            EditorGUI.LabelField(new Rect(startX, startY+=spaceY-8, width, height), cont);
            weapon.weaponName=EditorGUI.TextField(new Rect(startX+spaceX-65, startY, width-5, height), weapon.weaponName);

            cont=new GUIContent("Icon:", "The unit icon to be displayed in game, must be a sprite");
            EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            weapon.icon=(Sprite)EditorGUI.ObjectField(new Rect(startX+spaceX-65, startY, width-5, height), weapon.icon, typeof(Sprite), false);

            startX=cachedX;
            startY+=spaceY+8;

            string[] damageTypeLabel=EditorDBManager.GetDamageTypeLabel();
            cont=new GUIContent("Damage Type:", "The damage type of the weapon\nDamage type can be configured in Damage Armor Table Editor");
            EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            weapon.damageType=EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), weapon.damageType, damageTypeLabel);

            cont=new GUIContent("Recoil:", "The recoil force of the weapon");
            EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            weapon.recoil=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), weapon.recoil);

            cont=new GUIContent("ShootPoint:", "The transform which indicate the position where the shootObject will be fired from (Optional)\nEach shootPoint assigned will fire a shootObject instance in each attack\nIf left empty, the unit transform itself will be use as the shootPoint\nThe orientation of the shootPoint matter as they dictate the orientation of the shootObject starting orientation.\n");
            shootPointFoldout=EditorGUI.Foldout(new Rect(startX, startY+=spaceY, spaceX, height), shootPointFoldout, cont);
            int shootPointCount=weapon.shootPoints.Count;
            shootPointCount=EditorGUI.IntField(new Rect(startX+spaceX, startY, 40, height), shootPointCount);

            if(shootPointCount!=weapon.shootPoints.Count){
                while(weapon.shootPoints.Count<shootPointCount) weapon.shootPoints.Add(null);
                while(weapon.shootPoints.Count>shootPointCount) weapon.shootPoints.RemoveAt(weapon.shootPoints.Count-1);
            }

            if(shootPointFoldout){
                for(int i=0; i<weapon.shootPoints.Count; i++){
                    int objID=GetObjectIDFromHList(weapon.shootPoints[i], objHList);
                    EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), "    - Element "+(i+1));
                    objID = EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), objID, objHLabelList);
                    weapon.shootPoints[i] = (objHList[objID]==null) ? null : objHList[objID].transform;
                }
            }

            startX=cachedX;
            startY+=10;

            GUIStyle style=new GUIStyle("TextArea");
            style.wordWrap=true;
            cont=new GUIContent("Weapon description: ", "");
            EditorGUI.LabelField(new Rect(startX, startY+=spaceY, 400, 20), cont);
            weapon.desp=EditorGUI.TextArea(new Rect(startX, startY+spaceY-3, 280, 200), weapon.desp, style);

            startX+=330;
            startY=cachedY;

            if(weapon.stats.Count==0) weapon.stats.Add(new UnitStat());
            for(int i=0; i<weapon.stats.Count; i++){
                v3=DrawWeaponStat(weapon.stats[i], startX, startY, statContentHeight);
                statContentHeight=v3.z;
                startX=v3.x+10;
                if(startX>maxWidth) maxWidth=startX;
            }
            startY=v3.y+spaceY-cachedY;

            startX=maxWidth-cachedX+80;

            return new Vector2(startX, startY);
        }
Пример #28
0
 public static void ReloadComplete(FPSWeapon weap)
 {
     if(instance.currentWeapon==weap){
         if(onFPSReloadE!=null) onFPSReloadE(false);
     }
 }
Пример #29
0
        public string _PurchasePerk(Perk perk, bool useRsc = true)
        {
            string text = perk.Purchase(useRsc);

            if (text != "")
            {
                return(text);
            }

            if (!purchasedIDList.Contains(perk.ID))
            {
                purchasedIDList.Add(perk.ID);
            }
            SavePurchasedPerk();

            TDTK.OnPerkPurchased(perk);

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


            perkPoint += 1;
            TDTK.OnPerkPoint();

            if (perk.type == _PerkType.NewTower)
            {
                UnitTower tower = TDTK.GetDBTower(perk.itemIDList[0]);
                unlockedTowerList.Add(tower);
                BuildManager.AddNewTower(tower);
            }
            else if (perk.type == _PerkType.NewAbility)
            {
                Ability ability = TDTK.GetDBAbility(perk.itemIDList[0]);
                unlockedAbilityList.Add(ability);
                AbilityManager.AddNewAbility(ability);
            }
            else if (perk.type == _PerkType.NewFPSWeapon)
            {
                FPSWeapon weapon = TDTK.GetDBFpsWeapon(perk.itemIDList[0]);
                unlockedWeaponList.Add(weapon);
                FPSControl.AddNewWeapon(weapon);
            }

            else if (perk.type == _PerkType.GainLife)
            {
                GameControl.GainLife((int)Random.Range(perk.value, perk.valueAlt));
            }
            else if (perk.type == _PerkType.LifeCap)
            {
                lifeCap += (int)perk.value; GameControl.GainLife(0);
            }
            else if (perk.type == _PerkType.LifeRegen)
            {
                lifeRegen += perk.value;
            }
            else if (perk.type == _PerkType.LifeWaveClearedBonus)
            {
                lifeWaveClearedBonus += (int)perk.value;
            }

            else if (perk.type == _PerkType.GainRsc)
            {
                List <int> valueList = new List <int>();
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    valueList.Add((int)perk.valueRscList[i]);
                }
                ResourceManager.GainResource(valueList, null, false);                   //dont pass multiplier and dont use multiplier
            }
            else if (perk.type == _PerkType.RscRegen)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscRegen[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscCreepKilledGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscCreepKilledGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscWaveClearedGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscWaveClearedGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscResourceTowerGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscRscTowerGain[i] += perk.valueRscList[i];
                }
            }

            else if (perk.type == _PerkType.Tower)
            {
                ModifyTowerModifier(globalTowerModifier, perk);
            }
            else if (perk.type == _PerkType.TowerSpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = TowerModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkTowerModifier towerModifier = new PerkTowerModifier();
                        towerModifier.prefabID = perk.itemIDList[i];
                        towerModifierList.Add(towerModifier);
                        ID = towerModifierList.Count - 1;
                    }
                    ModifyTowerModifierInList(ID, perk);
                }
            }
            else if (perk.type == _PerkType.Ability)
            {
                ModifyAbilityModifier(globalAbilityModifier, perk);
            }
            else if (perk.type == _PerkType.AbilitySpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = AbilityModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkAbilityModifier abilityModifier = new PerkAbilityModifier();
                        abilityModifier.abilityID = perk.itemIDList[i];
                        abilityModifierList.Add(abilityModifier);
                        ID = abilityModifierList.Count - 1;
                    }
                    ModifyAbilityModifierInList(ID, perk);
                }
            }
            else if (perk.type == _PerkType.FPSWeapon)
            {
                ModifyFPSWeaponModifier(globalFPSWeaponModifier, perk);
            }
            else if (perk.type == _PerkType.FPSWeaponSpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = FPSWeaponModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkFPSWeaponModifier weaponModifier = new PerkFPSWeaponModifier();
                        weaponModifier.prefabID = perk.itemIDList[i];
                        FPSWeaponModifierList.Add(weaponModifier);
                        ID = FPSWeaponModifierList.Count - 1;
                    }
                    ModifyFPSWeaponModifierInList(ID, perk);
                }
            }

            else if (perk.type == _PerkType.EnergyRegen)
            {
                energyRegen += perk.value;
            }
            else if (perk.type == _PerkType.EnergyIncreaseCap)
            {
                energyCap += perk.value;
            }
            else if (perk.type == _PerkType.EnergyCreepKilledBonus)
            {
                energyCreepKilledBonus += perk.value;
            }
            else if (perk.type == _PerkType.EnergyWaveClearedBonus)
            {
                energyWaveClearedBonus += perk.value;
            }

            return("");
        }
Пример #30
0
		public static int AddNewFPSWeapon(FPSWeapon newWeapon){
			if(weaponList.Contains(newWeapon)) return -1;
			
			int ID=GenerateNewID(weaponIDList);
			newWeapon.prefabID=ID;
			weaponIDList.Add(ID);
			weaponList.Add(newWeapon);
			
			UpdateWeaponNameList();
			
			if(newWeapon.stats.Count==0) newWeapon.stats.Add(new UnitStat());
			
			SetDirtyFPSWeapon();
			
			return weaponList.Count-1;
		}