Ver código fonte

新增【DisplayOnly】 ;

SZAND\msx_2 7 meses atrás
pai
commit
2318528c38

+ 22 - 0
ActionTowerDefense/Assets/Editor/ReadOnlyDrawer.cs

@@ -0,0 +1,22 @@
+using UnityEditor;
+
+namespace UnityEngine
+{
+    /// <summary>
+    /// ÉèÖÃÊôÐÔÖ»¶Á
+    /// </summary>
+    [CustomPropertyDrawer(typeof(DisplayOnly))]
+    public class ReadOnlyDrawer : PropertyDrawer
+    {
+        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+        {
+            return EditorGUI.GetPropertyHeight(property, label, true);
+        }
+        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+        {
+            GUI.enabled = false;
+            EditorGUI.PropertyField(position, property, label, true);
+            GUI.enabled = true;
+        }
+    }
+}

+ 11 - 0
ActionTowerDefense/Assets/Editor/ReadOnlyDrawer.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 29bb7d847689157499532b727bdb63bc
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 2
ActionTowerDefense/Assets/Scripts/Characters/AttackController.cs

@@ -54,9 +54,9 @@ public class AttackController : MonoBehaviour
     public bool isNonAttack = false;            //ÎÞÆÕ¹¥
     [HideInInspector]
     public GameObject addAttackEffect;
-    [HideInInspector]
+    [DisplayOnly]
     public int[] curDamage1;
-    [HideInInspector]
+    [DisplayOnly]
     public int[] curDamage2;
 
     [Header("¹¥»÷¶¯»­")]

+ 10 - 26
ActionTowerDefense/Assets/Scripts/Characters/Character.cs

@@ -22,7 +22,6 @@ public enum CharacterState
     Die = 11,
     Weak = 12,
 
-    Spirits = 14,           //召唤英灵
     Float = 15,             //空中漂浮
 
     Coma = 21,              //昏迷
@@ -32,14 +31,6 @@ public enum CharacterState
     SpecialStatus,
 }
 
-//血量上限增加类型
-public enum HpUpType
-{
-    Degree = 0,     //按一定比例加血
-    Add = 1,        //直接加血
-    Fixed = 2,      //加固定血量
-}
-
 public class Character : MonoBehaviour
 {
     [Header("骨骼")]
@@ -76,10 +67,13 @@ public class Character : MonoBehaviour
     public Character attackTarget;
 
     [Header("角色状态")]
+    [DisplayOnly]
     public CharacterState state;
     public int totalHp = 100;
     public int hp;
+    [DisplayOnly]
     public bool isDie = false;      //已死亡
+    [DisplayOnly]
     public bool isRevive;           //从虚弱状态恢复中
     public bool canNotAddForce;     //不会被打飞
     public bool canNotChangeHurt;   //不会被打虚弱
@@ -96,10 +90,8 @@ public class Character : MonoBehaviour
     public LockSoul ls;
     public bool isInSoulTower;      //在锁魂塔范围内
 
-    [Header("血量上限增加类型")]
-    public HpUpType hptp;
-
     [Header("体型增大")]
+    [HideInInspector]
     public bool beLarger = false;
     public float toLargeSize = 0;                   //变大程度
     private Vector3 speed = new Vector3(1, 1, 0);   //变大速度
@@ -137,7 +129,10 @@ public class Character : MonoBehaviour
         uiHp.Show(hp, totalHp);
         ChangeState(CharacterState.Idle);
 
-        attackController = GetComponent<AttackController>();
+        if (attackController == null)
+        {
+            attackController = GetComponent<AttackController>();
+        }
         attackController.Init();
         attackTarget = attackController.attackTarget;
         targetCharacter = attackController.targetCharacter;
@@ -220,19 +215,8 @@ public class Character : MonoBehaviour
     {
         cookEffect.transform.GetChild(0).gameObject.SetActive(true);
         int add = 0;
-        switch (hptp)
-        {
-            case HpUpType.Degree:
-                value = value / 100;
-                add = (int)(totalHp * value);
-                break;
-            case HpUpType.Add:
-                add = (int)value;
-                break;
-            case HpUpType.Fixed:
-                add = (int)(totalHp - value);
-                break;
-        }
+        value = value / 100;
+        add = (int)(totalHp * value);
         totalHp += add;
         hp += add;
         uiHp.Show(hp, totalHp);

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tool.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 0dc8c3ee78ab0814bbcfbeacd6c1e097
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 6 - 0
ActionTowerDefense/Assets/Scripts/Tool/DisplayOnly.cs

@@ -0,0 +1,6 @@
+using UnityEngine;
+
+public class DisplayOnly : PropertyAttribute
+{
+
+}

+ 11 - 0
ActionTowerDefense/Assets/Scripts/Tool/DisplayOnly.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 9adf7d8a01bf9d74b9b80c7db404030a
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: