2020-07-13 02:36:50 -04:00

32 lines
958 B
C#

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using Random = UnityEngine.Random;
public class Lobby : MonoBehaviour {
[SerializeField] List<Player> players;
void Awake() => players = new List<Player>();
public void OnPlayerJoined(PlayerInput playerInput) {
playerInput.transform.parent = transform;
players.Add(playerInput.GetComponent<Player>());
playerInput.gameObject.name = "Player " + players.Count;
Debug.Log(playerInput.gameObject.name + " joined!");
var color = Random.ColorHSV(0, 1, 0.8f, 1, 0.8f, 1);
playerInput.GetComponent<Renderer>().material
.color = color;
float h, s, v;
Color.RGBToHSV(color, out h, out s, out v);
playerInput.transform.GetChild(0).GetComponent<Renderer>().material
.color = Color.HSVToRGB((h - 0.05f) % 1f, s + 0.05f, v - 0.1f);
}
public void OnPlayerLeft(PlayerInput playerInput)
=> Debug.Log(playerInput.gameObject.name + " left :O");
}