|
|
@ -305,21 +305,28 @@ public class Character : MonoBehaviour |
|
|
|
void OnTriggerEnter(Collider other) |
|
|
|
{ |
|
|
|
Collectable collectable = other.GetComponentInChildren<Collectable>(); |
|
|
|
blockSpawn spawn = GetComponent<blockSpawn>(); |
|
|
|
|
|
|
|
if (collectable != null) |
|
|
|
{ |
|
|
|
collectable.OnCollect(this); |
|
|
|
} |
|
|
|
if (other.gameObject.name == "collect_sphere") |
|
|
|
{ |
|
|
|
other.gameObject.SetActive(false); |
|
|
|
//player.collected +=1;
|
|
|
|
//get position from average;
|
|
|
|
ClientList list = spawn.clientDataList; |
|
|
|
float average = 0; |
|
|
|
int livePlayerCount = 0; |
|
|
|
foreach (ClientData data in list.ConnectedClients) |
|
|
|
{ |
|
|
|
if (data.Lives > 0) |
|
|
|
{ |
|
|
|
average += data.playerCharacter.transform.position.x; |
|
|
|
livePlayerCount++; |
|
|
|
} |
|
|
|
} |
|
|
|
average /= livePlayerCount; |
|
|
|
float tosend = lives + (transform.position.x - average); |
|
|
|
|
|
|
|
} |
|
|
|
if (other.gameObject.name == "End Portal") |
|
|
|
{ |
|
|
|
other.GetComponent<Collider>().enabled = false; |
|
|
|
SceneManager.LoadScene(nextScene); |
|
|
|
spawn.assignLogicBlock(collectable.gameObject, tosend); |
|
|
|
|
|
|
|
collectable.OnCollect(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|