Beispiel #1
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();
            }
        }
Beispiel #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);
                }
            }
        }
Beispiel #3
0
 public static void AddNewWeapon(FPSWeapon weaponPrefab)
 {
     if (instance != null)
     {
         instance._AddNewWeapon(weaponPrefab);
     }
 }
Beispiel #4
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;
         }
     }
 }
Beispiel #5
0
        public static void RemoveWeapon(int listID)
        {
            FPSWeapon removedWeapon = weaponList[listID];

            weaponIDList.Remove(weaponList[listID].prefabID);
            weaponList.RemoveAt(listID);
            UpdateWeaponNameList();
            SetDirtyFPSWeapon();
            RefreshFPSWeapon_Remove(removedWeapon);
        }
Beispiel #6
0
 public static void StartReload(FPSWeapon weap)
 {
     if (instance.currentWeapon == weap)
     {
         if (onFPSReloadE != null)
         {
             onFPSReloadE(true);
         }
     }
 }
Beispiel #7
0
 public static void ReloadComplete(FPSWeapon weap)
 {
     if (instance.currentWeapon == weap)
     {
         if (onFPSReloadE != null)
         {
             onFPSReloadE(false);
         }
     }
 }
Beispiel #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>());
        }
Beispiel #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);
        }
Beispiel #10
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);
        }
Beispiel #11
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);
            }
        }