using UnityEngine; using System.Collections.Generic; using NeonTea.Quakeball.Networking.Instances; using NeonTea.Quakeball.Networking; using NeonTea.Quakeball.TeaNet.Packets; namespace NeonTea.Quakeball.Game { public class GameMaster { private NetInstance Instance; public GameMode GameMode; public Dictionary> Players = new Dictionary>(); public GameMaster() { Instance = Net.Singleton.Instance; GameMode = GameMode.TeamPlay; Players[Team.FreeForAll] = new List(); Players[Team.Sun] = new List(); Players[Team.Moon] = new List(); } public void PlayerJoined(NetPlayer player) { Team team = Team.FreeForAll; if (GameMode == GameMode.TeamPlay) { if (Players[Team.Sun].Count > Players[Team.Moon].Count) { team = Team.Sun; } else { team = Team.Moon; } } Players[Team.Sun].Add(player.Id); player.Team = team; } public void PlayerLeft(NetPlayer player) { Players[player.Team].Remove(player.Id); } public Vector3 GetSpawn(NetPlayer player) { string Tag = "Respawn"; switch (player.Team) { case Team.Sun: Tag = "SunRespawn"; break; case Team.Moon: Tag = "MoonRespawn"; break; } GameObject[] spawnPoints = GameObject.FindGameObjectsWithTag(Tag); return spawnPoints[Random.Range(0, spawnPoints.Length)].transform.position; } } public enum GameMode { TeamPlay = 0, FreeForAll = 1, } public enum Team { FreeForAll = 0, Sun = 1, Moon = 2, } }