Inheritance: UnityEngine.MonoBehaviour
 void Awake()
 {
     if (s_settings != null) {
     throw new System.InvalidProgramException("there is more than one game settings object!");
     }
     s_settings = this;
 }
示例#2
0
        private void PickPosition()
        {
            ExampleSimpleGameSettings settings = ExampleSimpleGameSettings.settings();

            m_position.x = m_rand.Next(settings.areaWidth);
            m_position.z = m_rand.Next(settings.areaHeight);
            gameObject.transform.localPosition = m_position;
        }
 void Awake()
 {
     if (s_settings != null)
     {
         throw new System.InvalidProgramException("there is more than one game settings object!");
     }
     s_settings = this;
 }
示例#4
0
        private void OnMove(MessageMove data)
        {
            ExampleSimpleGameSettings settings = ExampleSimpleGameSettings.settings();

            m_position.x = data.x * settings.areaWidth;
            m_position.z = settings.areaHeight - (data.y * settings.areaHeight) - 1; // because in 2D down is positive.

            gameObject.transform.localPosition = m_position;
        }
示例#5
0
        void StartNewPlayer(object sender, PlayerConnectMessageArgs e)
        {
            ExampleSimpleGameSettings settings = ExampleSimpleGameSettings.settings();
            Vector3 position = new Vector3(m_rand.Next(settings.areaWidth), 0, m_rand.Next(settings.areaHeight));
            // Spawn a new player then add a script to it.
            GameObject gameObject = (GameObject)Instantiate(prefabToSpawnForPlayer, position, Quaternion.identity);
            // Add the ExampleSimplePlayer script to this object. Note: We could possible add this to the prefab.
            // Not sure which is best.
            ExampleSimplePlayer player = gameObject.AddComponent <ExampleSimplePlayer>();

            player.Init(e.netPlayer);
        }
示例#6
0
        void InitializeNetPlayer(SpawnInfo spawnInfo)
        {
            // Save the netplayer object so we can use it send messages to the phone
            m_netPlayer = spawnInfo.netPlayer;

            // Register handler to call if the player disconnects from the game.
            m_netPlayer.OnDisconnect += Remove;

            // Track name changes
            m_playerNameManager = new HFTPlayerNameManager(m_netPlayer);
            m_playerNameManager.OnNameChange += ChangeName;

            // Setup events for the different messages.
            m_netPlayer.RegisterCmdHandler <MessageMove>("move", OnMove);
            m_netPlayer.RegisterCmdHandler <MessageColor>("color", OnColor);

            ExampleSimpleGameSettings settings = ExampleSimpleGameSettings.settings();

            m_position = new Vector3(UnityEngine.Random.Range(0, settings.areaWidth), 0, UnityEngine.Random.Range(0, settings.areaHeight));
            transform.localPosition = m_position;

            SetName(m_playerNameManager.Name);
        }
 void Cleanup()
 {
     s_settings = null;
 }
 void Cleanup()
 {
     s_settings = null;
 }