summaryrefslogtreecommitdiff
path: root/GameCode/SpawnedAttack.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-10-27 11:05:14 +0800
committerchai <215380520@qq.com>2023-10-27 11:05:14 +0800
commit766cdff5ffa72b65d7f106658d1603f47739b2ba (patch)
tree34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/SpawnedAttack.cs
+ init
Diffstat (limited to 'GameCode/SpawnedAttack.cs')
-rw-r--r--GameCode/SpawnedAttack.cs63
1 files changed, 63 insertions, 0 deletions
diff --git a/GameCode/SpawnedAttack.cs b/GameCode/SpawnedAttack.cs
new file mode 100644
index 0000000..8a4a096
--- /dev/null
+++ b/GameCode/SpawnedAttack.cs
@@ -0,0 +1,63 @@
+using Photon.Pun;
+using UnityEngine;
+
+public class SpawnedAttack : MonoBehaviour
+{
+ public Player spawner;
+
+ public int attackLevel;
+
+ public int attackID;
+
+ public PhotonView view;
+
+ private void Awake()
+ {
+ view = GetComponent<PhotonView>();
+ }
+
+ [PunRPC]
+ public void RPCA_SetSpawner(int spawnerID)
+ {
+ spawner = PhotonNetwork.GetPhotonView(spawnerID).GetComponent<Player>();
+ }
+
+ public void CopySpawnedAttackTo(GameObject to)
+ {
+ SpawnedAttack spawnedAttack = to.GetComponent<SpawnedAttack>();
+ if (!spawnedAttack)
+ {
+ spawnedAttack = to.AddComponent<SpawnedAttack>();
+ }
+ spawnedAttack.spawner = spawner;
+ spawnedAttack.attackLevel = attackLevel;
+ }
+
+ public void SetColor(Color color)
+ {
+ TrailRenderer[] componentsInChildren = GetComponentsInChildren<TrailRenderer>();
+ for (int i = 0; i < componentsInChildren.Length; i++)
+ {
+ componentsInChildren[i].startColor = color;
+ componentsInChildren[i].endColor = color;
+ }
+ ProjectileHit component = GetComponent<ProjectileHit>();
+ if ((bool)component)
+ {
+ component.projectileColor = color;
+ }
+ }
+
+ public bool IsMine()
+ {
+ if ((bool)view)
+ {
+ return view.IsMine;
+ }
+ if ((bool)spawner)
+ {
+ return spawner.data.view.IsMine;
+ }
+ return false;
+ }
+}