Пример #1
0
 public static PlayerSpawns GetInstance()
 {
     if (h_instance == null)
     {
         GameObject playerSpawnsObject = GameObject.Find("Spawners");
         PlayerSpawns instance = playerSpawnsObject.GetComponent<PlayerSpawns>();
         h_instance = instance;
     }
     return h_instance;
 }
Пример #2
0
 public static PlayerSpawns GetInstance()
 {
     if (h_instance == null)
     {
         GameObject   playerSpawnsObject = GameObject.Find("Spawners");
         PlayerSpawns instance           = playerSpawnsObject.GetComponent <PlayerSpawns>();
         h_instance = instance;
     }
     return(h_instance);
 }
Пример #3
0
        public MapSpawns GetMapSpawns(int mapId)
        {
            var mapName           = $"Map{mapId}";
            var contentType       = "Maps";
            var toReturnMapSpawns = new MapSpawns();


            if (!_content.ContainsKey(contentType) || !_content[contentType].ContainsKey(mapName))
            {
                return(null);
            }

            var fileName = $"{mapName}/{mapName}";
            var filePath = $"{GetContentTypePath(contentType)}/{fileName}.json";

            JToken mapSpawnInformation;

            try
            {
                var mapData = JObject.Parse(File.ReadAllText(filePath));

                mapSpawnInformation = mapData.SelectToken("spawns");
            }
            catch (JsonReaderException)
            {
                return(null);
            }

            foreach (JProperty teamSpawn in mapSpawnInformation)
            {
                var team = teamSpawn.Name;
                var spawnsByPlayerCount = (JArray)teamSpawn.Value;
                for (var i = 0; i < spawnsByPlayerCount.Count; i++)
                {
                    var playerSpawns = new PlayerSpawns((JArray)spawnsByPlayerCount[i]);
                    toReturnMapSpawns.SetSpawns(team, playerSpawns, i);
                }
            }

            return(toReturnMapSpawns);
        }
Пример #4
0
        /// <summary>
        /// Creates a new playerObject and fully initiates it, spawns it on an open spawn field, returns the object
        /// </summary>
        /// <param name="player"></param>
        public PlayerController SpawnPlayer_Single(PhotonPlayer player)
        {
            PlayerController newPlayerObject = null;

            // new object creation
            if (PlayerObject_Exists(player) == false)
            {
                // allow the CLIENT to create its own player
                if (player.isLocal)
                {
                    GameObject newObject = PhotonNetwork.Instantiate(PlayerObjectPrefab.name, Vector3.zero, Quaternion.identity, 0);
                    newPlayerObject = newObject.GetComponent <PlayerController>();
                    newPlayerObject.Photonplayer = player;               // important!
                    newPlayerObject.transform.SetParent(this.transform);
                    AssignPlayerObjectToPlayer(newPlayerObject, player); // VERY important!
                }
                else
                {
                    return(null); // Exit, because I don't own this player
                }
            }
            else
            {
                newPlayerObject = GetPlayerObject(player);
            }


            // object initialisation & position
            //Position
            int     playerSlotIndex = GetPlayerSlot(player);
            Vector3 spawnPosition   = PlayerSpawns.GetInstance().SpawnList[playerSlotIndex].position;

            newPlayerObject.transform.position = spawnPosition;


            //DEBUG:
            newPlayerObject.GetComponentInChildren <Renderer>().material.color = m_SlotColorList[GetPlayerSlot(player)];

            return(newPlayerObject);
        }
Пример #5
0
	// Use this for initialization
	void Start () {
        h_instance = this;
    }
Пример #6
0
 // Use this for initialization
 void Start()
 {
     h_instance = this;
 }