summaryrefslogtreecommitdiff
path: root/GameCode/SpawnedAttack.cs
blob: 8a4a09654091bbfaf715fbc3334cc3dff212ee96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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;
	}
}