Browse Source

Fixed the character script after merge :)

master
Claire Peta 5 years ago
parent
commit
5d9a6caecf
1 changed files with 18 additions and 11 deletions
  1. +18
    -11
      Assets/Scripts/Character.cs

+ 18
- 11
Assets/Scripts/Character.cs View File

@ -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);
}
}

Loading…
Cancel
Save