Pārlūkot izejas kodu

增加随机系统中

SZAND\msx_2 1 gadu atpakaļ
vecāks
revīzija
54f12257a9

+ 1 - 0
ActionTowerDefense/Assets/Resources/Prefab/Player.prefab

@@ -1051,6 +1051,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 01b7616677d36984185e7836d04c5b0b, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  types: 4
   floatEffect: {fileID: 417478504669294145, guid: 243eb0eff66414445990654286d861d1, type: 3}
   currentSpirit: 0
 --- !u!1 &3571941039716665622

+ 10 - 40
ActionTowerDefense/Assets/Scripts/Spirits/Spirits.cs

@@ -4,53 +4,23 @@ using UnityEngine;
 
 public class Spirits : MonoBehaviour
 {
-    public enum SpiritType  //英灵种类
+    public enum SpiritType          //英灵种类
     {
-        Float = 0,       //漂浮
-        Assassin = 1,      //冲刺
-        Cook = 2,      //烤串
-        Invisible = 3,  //隐身
+        Float = 0,                  //漂浮
+        Assassin = 1,               //冲刺
+        Cook = 2,                   //烤串
+        Invisible = 3,              //隐身
     }
 
+    public int types;               //英灵数量
+
     public GameObject floatEffect;  //漂浮特效预制体
 
     public SpiritType currentSpirit = SpiritType.Float;
 
-    /*
-    public void SummonSpirit(SpiritType st)
+    public void RandomSpirit()
     {
-        switch (st)
-        {
-            case SpiritType.Float:
-                //特效用预制体做
-                
-                break;
-            case SpiritType.Assassin:
-                break;
-            case SpiritType.Invisible:
-                break;
-            case SpiritType.Cook:
-                break;
-        }
+        int a = Random.Range(0, types);
+        currentSpirit = (SpiritType)a;
     }
-
-    
-    private void Update()
-    {
-        if (Input.GetKeyDown(KeyCode.P))
-        {
-            currentSpirit = SpiritType.Float;
-            SummonSpirit(currentSpirit);
-        }
-        if (Input.GetKeyDown(KeyCode.O))
-        {
-            currentSpirit = SpiritType.Invisible;
-            SummonSpirit(currentSpirit);
-        }
-        if (Input.GetKeyDown(KeyCode.I))
-        {
-            currentSpirit = SpiritType.Invisible;
-            SummonSpirit(currentSpirit);
-        }
-    }*/
 }