blob: 8f00c7a31258feee756328ed9ec4ee35309dc49c (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
using System;
using Photon.Pun;
using UnityEngine;
public class SpawnObjects : MonoBehaviour
{
public enum SpawnRot
{
Identity,
TransformRotation
}
public GameObject[] objectToSpawn;
public SpawnRot spawnRot;
public bool inheritScale;
public bool destroyObject;
public bool destroyRoot;
private PhotonView view;
public Action<GameObject> SpawnedAction;
[HideInInspector]
public GameObject mostRecentlySpawnedObject;
private void ConfigureObject(GameObject go)
{
SpawnedAttack spawnedAttack = go.GetComponent<SpawnedAttack>();
if (!spawnedAttack)
{
spawnedAttack = go.AddComponent<SpawnedAttack>();
}
spawnedAttack.spawner = base.transform.root.GetComponent<Player>();
if (!spawnedAttack.spawner)
{
SpawnedAttack componentInParent = base.transform.GetComponentInParent<SpawnedAttack>();
if ((bool)componentInParent)
{
componentInParent.CopySpawnedAttackTo(go);
}
}
AttackLevel componentInParent2 = GetComponentInParent<AttackLevel>();
if ((bool)componentInParent2)
{
spawnedAttack.attackLevel = componentInParent2.attackLevel;
}
if (inheritScale)
{
go.transform.localScale *= base.transform.localScale.x;
}
if (SpawnedAction != null)
{
SpawnedAction(go);
}
}
public void Spawn()
{
for (int i = 0; i < objectToSpawn.Length; i++)
{
Quaternion rotation = Quaternion.identity;
if (spawnRot == SpawnRot.TransformRotation)
{
rotation = base.transform.rotation;
}
GameObject go = UnityEngine.Object.Instantiate(objectToSpawn[i], base.transform.position, rotation);
ConfigureObject(go);
mostRecentlySpawnedObject = go;
}
if (destroyObject)
{
UnityEngine.Object.Destroy(base.gameObject);
}
if (destroyRoot)
{
UnityEngine.Object.Destroy(base.transform.root.gameObject);
}
}
}
|