public override void OnEvent(SetPlayerPersonalizationEvent evnt) // assign the state of each user color to the chosen player color. { if (evnt.PlayerEntity != null && evnt.PlayerEntity.IsOwner) { Debug.LogWarning(evnt.PlayerColor); evnt.PlayerEntity.GetState <IMasterPlayerState>().UserColor = evnt.PlayerColor; // changes the state only on the owner's screen } //evnt.PlayerEntity.transform.Find("PlayerGFX").GetComponent<MeshRenderer>().material = Player_Colors.GetColor(evnt.PlayerColor); }
public override void OnEvent(GetPlayerPersonalizationEvent evnt) // HANDLE ALL COSMETICS HERE!! { var playermat = Player_Colors.PlayerMaterials; if (playermat.Count == 0) // no materials assigned. Get a list of all the possible colors. Remove them as you go. { playermat.Add(Color_Tags.BLUE); playermat.Add(Color_Tags.GREEN); playermat.Add(Color_Tags.GREY); playermat.Add(Color_Tags.LIGHTBLUE); playermat.Add(Color_Tags.LIGHTGREEN); playermat.Add(Color_Tags.ORANGE); playermat.Add(Color_Tags.PURPLE); playermat.Add(Color_Tags.RED); playermat.Add(Color_Tags.WHITE); playermat.Add(Color_Tags.YELLOW); } int chosenIndex = Random.Range(0, playermat.Count); string chosenColor = playermat[chosenIndex]; // if its a problem, use the delete function in player_materials. playermat.RemoveAt(chosenIndex); // index has been chosen. var Set_Evnt = SetPlayerPersonalizationEvent.Create(); Set_Evnt.PlayerEntity = evnt.PlayerEntity; Set_Evnt.PlayerColor = chosenColor; Set_Evnt.Send(); }