SZAND\msx_2 1 éve
szülő
commit
dfd7da902c

+ 0 - 0
ActionTowerDefense/Assets/Resources/Textures/invisiable.png → ActionTowerDefense/Assets/Resources/Textures/invisible.png


+ 0 - 0
ActionTowerDefense/Assets/Resources/Textures/invisiable.png.meta → ActionTowerDefense/Assets/Resources/Textures/invisible.png.meta


+ 4 - 0
ActionTowerDefense/Assets/Scenes/SampleScene.unity

@@ -16214,6 +16214,10 @@ MonoBehaviour:
   p1To: {fileID: 1734364483}
   p2To: {fileID: 695318508}
   uiSpeed: 0.2
+  floatHead: {fileID: 21300000, guid: c3eb7313518da2a4b951d16e791955b8, type: 3}
+  CookHead: {fileID: 21300000, guid: 46e6f86b1c70e8140826edf16bf73c75, type: 3}
+  AssassinHead: {fileID: 21300000, guid: 6c58c9f91beed454aa0bed1a9657f314, type: 3}
+  InvisibleHead: {fileID: 21300000, guid: 89f654c058be55e4c901e659ff41ff89, type: 3}
 --- !u!4 &970449925
 Transform:
   m_ObjectHideFlags: 0

+ 19 - 0
ActionTowerDefense/Assets/Scripts/PlayerController.cs

@@ -293,10 +293,14 @@ public class PlayerController : MoveCharacter
             case 0:
                 SpiritSystem.isP1Out = true;
                 SpiritSystem.isP1In = false;
+                SpiritSystem.player1 = gameObject;
+                SpiritSystem.p1Spirits = GetComponent<Spirits>();
                 break;
             case 1:
                 SpiritSystem.isP2Out = true;
                 SpiritSystem.isP2In = false;
+                SpiritSystem.player2 = gameObject;
+                SpiritSystem.p2Spirits = GetComponent<Spirits>();
                 break;
             default:
                 break;
@@ -444,6 +448,21 @@ public class PlayerController : MoveCharacter
         corpse.text = "尸体:" + corpses.ToString();
     }
 
+    void OnChooseSpirit()   //选英灵
+    {
+        switch (playerId)
+        {
+            case 0:
+                SpiritSystem.isP1CardChange = true;
+                break;
+            case 1:
+                SpiritSystem.isP2CardChange = true;
+                break;
+            default:
+                break;
+        }
+    }
+
     public bool isUltimate;     //英灵释放大招
     void OnSummonSpirit()   //法师
     {

+ 72 - 0
ActionTowerDefense/Assets/Scripts/Spirits/SpiritSystem.cs

@@ -1,9 +1,11 @@
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using UnityEngine.UI;
 
 public class SpiritSystem : MonoBehaviour
 {
+    [Header("鯤소UI貫零")]
     public Transform p1;
     public Transform p2;
     public Transform p1Orig;
@@ -12,9 +14,33 @@ public class SpiritSystem : MonoBehaviour
     public Transform p2To;
     public float uiSpeed;
 
+    [Header("鯤소1暠깃")]
+    static public GameObject player1;
+    static public Spirits p1Spirits;
+    public Image[] player1cards;
+    public GameObject choose1;
+    private int curCard1;
+    static public bool isP1CardChange;
+
+    [Header("鯤소2暠깃")]
+    static public GameObject player2;
+    static public Spirits p2Spirits;
+    public Image[] player2cards;
+    public GameObject choose2;
+    private int curCard2;
+    static public bool isP2CardChange;
+
+    [Header("亶쥣暠깃")]
+    public Sprite floatHead;
+    public Sprite CookHead;
+    public Sprite AssassinHead;
+    public Sprite InvisibleHead;
+
+    //ref醵똑
     private Vector3 re1 = Vector3.right;
     private Vector3 re2 = Vector3.left;
 
+    //ui角뤠쏵흙잼역bool
     static public bool isP1Out = false;
     static public bool isP2Out = false;
     static public bool isP1In = false;
@@ -26,6 +52,41 @@ public class SpiritSystem : MonoBehaviour
         p2.position = p2Orig.position;
     }
 
+    private void ChangeSpirit(int id)
+    {
+        switch (id)
+        {
+            case 0:
+                int man = p1Spirits.hasSpirits;
+                if (man != 0)
+                {
+                    curCard1 += 1;
+                    if (curCard1 == man)
+                    {
+                        curCard1 = 0;
+                    }
+                    choose1.transform.position = player1cards[curCard1].transform.position;
+                    p1Spirits.currentSpirit = p1Spirits.ownSpirits[curCard1];
+                }
+                break;
+            case 1:
+                int mann = p2Spirits.hasSpirits;
+                if (mann != 0)
+                {
+                    curCard2 += 1;
+                    if (curCard2 == mann)
+                    {
+                        curCard2 = 0;
+                    }
+                    choose2.transform.position = player2cards[curCard2].transform.position;
+                    p2Spirits.currentSpirit = p2Spirits.ownSpirits[curCard2];
+                }
+                break;
+            default:
+                break;
+        }
+    }
+
     private void playerUIout(int id)
     {
         switch (id)
@@ -95,5 +156,16 @@ public class SpiritSystem : MonoBehaviour
         {
             playerUIin(1);
         }
+
+        if (isP1CardChange)
+        {
+            isP1CardChange = false;
+            ChangeSpirit(0);
+        }
+        if (isP2CardChange)
+        {
+            isP2CardChange = false;
+            ChangeSpirit(1);
+        }
     }
 }

+ 2 - 1
ActionTowerDefense/Assets/Scripts/Spirits/Spirits.cs

@@ -17,8 +17,9 @@ public class Spirits : MonoBehaviour
     public GameObject floatEffect;  //漂浮特效预制体
 
     public SpiritType currentSpirit = SpiritType.Float;
-    public SpiritType[] hasSpirits;
+    public int hasSpirits;          //已有的英灵牌数量
     public int maxCards;            //最多有多少张英灵牌
+    public SpiritType[] ownSpirits; //已有的英灵牌
 
     public void RandomSpirit()
     {