Ejemplo n.º 1
0
    IEnumerator Start()
    {
        var onlineDetails = FindObjectOfType <OnlineDetails>();

        if (onlineDetails != null)
        {
            if (onlineDetails.IsClient)
            {
                if (channelID < 1)
                {
                    channelID = TNManager.lastChannelID;
                }

                while (TNManager.isJoiningChannel || !TNManager.IsInChannel(channelID))
                {
                    yield return(null);
                }

                TNManager.Instantiate(channelID, "CreateAtPosition", prefabPath, persistent, transform.position, transform.rotation);
                Destroy(gameObject);
            }
        }
        else
        {
            Debug.LogWarning("No online details found");
        }
    }
Ejemplo n.º 2
0
    public void SpawnPlayer(int channelID)
    {
        var          index = Random.Range(0, SpawnPoints.Length);
        var          sp    = SpawnPoints[index];
        var          p     = GameObject.FindGameObjectsWithTag("Player");
        BattlePlayer found = null;

        foreach (var player in p)
        {
            var bp = player.GetComponent <BattlePlayer>();
            if (bp.tno.isMine)
            {
                found = bp;
            }
        }
        if (!found)
        {
            TNManager.Instantiate(channelID, "CreateBattlePlayer", "Prefabs/Player/Battle Network Player - swat", false, sp.transform.position, sp.transform.rotation);
        }
        else
        {
            found.transform.position = sp.transform.position;
            found.transform.rotation = sp.transform.rotation;
            found.GetComponent <Rigidbody>().isKinematic = false;
            found.Respawn();
        }
    }
Ejemplo n.º 3
0
    void RFC_SyncPlayersPosInfoAndCreatePlayer(string playersPosInfoDicStr)
    {
        Debug.Log(playersPosInfoDicStr);

        _playersOnCellDic = null;
        //var players = playersPosInfoDicStr.Split (',');
        //for (int i = 0; i < players.Length; i++) {
        //	var pinfo = players [i].Split (':');
        //	_playersPosInfoDic.Add(int.Parse(pinfo[0]), int.Parse(pinfo[1]));
        //}
        _playersOnCellDic = playersPosInfoDicStr.ToNoramDic();

        //foreach (var kvp in _playersOnCellDic)
        //{
        //	_mapCells [kvp.Value].SetPlayer (TNManager.GetPlayer(kvp.Key));
        //}
        _playerGos = new TNet.List <PlayerGo> ();

        var pos = _mapCells [_playersOnCellDic [TNManager.player.id]].GetPlayerStandPos();

        Color color = new Color(Random.value, Random.value, Random.value, 1f);

        TNManager.Instantiate(GameCtr.Instance.ChannelID, "RCC_SpawnPlayer", _playerPrefabName, true, pos, Quaternion.identity, color, TNManager.playerID);

        UICtr.Instance.HideReadyButton();
        GameCtr.Instance.SetStateTo(GameState.PLAYING);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Create a new object above the clicked position
    /// </summary>

    public void CreateMapByHost()
    {
        // Let's not try to create objects unless we are in this channel
        if (TNManager.isConnected && !TNManager.IsInChannel(GameCtr.Instance.ChannelID))
        {
            return;
        }
        if (!TNManager.isHosting)
        {
            return;
        }

        TNManager.Instantiate(GameCtr.Instance.ChannelID, "RCC_CreateMap", prefabName, true, Vector3.zero, Quaternion.identity);

//		var halfX = mapSizeX / 2;
//		var halfY = mapSizeY / 2;
//		for (int i = -1*halfX; i < halfX; i++)
//		{
//			for (int j = -1*halfY; j < halfY; j++)
//			{
//				// Object's position will be up in the air so that it can fall down
//				Vector3 pos = new Vector3(i + .5f, 0, j + 0.5f);
//
//				// Object's rotation is completely random
//				Quaternion rot = Quaternion.identity;
//
//				// Object's color is completely random
//				Color color = new Color(Random.value, Random.value, Random.value, 1f);
//
//				// Create the object using a custom creation function defined below.
//				// Note that passing "channelID" is optional. If you don't pass anything, TNet will pick one for you.
//				TNManager.Instantiate(GameCtr.Instance.ChannelID, "RCC_CreateMap", prefabName, true, pos, rot, color);
//			}
//		}
    }
Ejemplo n.º 5
0
 protected override void Spawn(int channelID)
 {
     if (transform.childCount > 0)
     {
         return;
     }
     TNManager.Instantiate(channelID, mSpawnFunction, prefab.PathInResources, Persistent, Index, transform.position, transform.rotation, Contents, Value);
 }
 IEnumerator Start()
 {
     while (TNManager.isJoiningChannel)
     {
         yield return(null);
     }
     if (channelID < 1)
     {
         channelID = TNManager.lastChannelID;
     }
     TNManager.Instantiate(channelID, "CreateAtPosition", prefabPath, persistent, transform.position, transform.rotation);
     Destroy(gameObject);
 }
Ejemplo n.º 7
0
 private IEnumerator coSpawn(int step)
 {
     while (TNManager.isJoiningChannel)
     {
         yield return(null);
     }
     if (channelID < 1)
     {
         channelID = TNManager.lastChannelID;
     }
     TNManager.Instantiate(channelID, "CreateAtPosition", prefabPath, persistent, position, rotation);
     //Destroy(gameObject);
 }
Ejemplo n.º 8
0
        void PlaceObstacle(PrefabPath p, Obstacle obs, Transform obsPosition)
        {
            if (ObstacleCooldown.IsRunning)
            {
                return;
            }
            if (Resources < obs.Cost)
            {
                return;
            }

            Resources -= obs.Cost;
            TNManager.Instantiate(tno.channelID, "CreateObstacle", p.PathInResources, false, obsPosition.position, obsPosition.rotation);
        }
Ejemplo n.º 9
0
    /// <summary>
    /// Create a new object above the clicked position
    /// </summary>

    void OnClick()
    {
        // Let's not try to create objects unless we are in this channel
        if (TNManager.isConnected && !TNManager.IsInChannel(channelID))
        {
            return;
        }

        // Object's position will be up in the air so that it can fall down
        Vector3 pos = TouchHandler.worldPos + Vector3.up * 3f;

        // Object's rotation is completely random
        Quaternion rot = Quaternion.Euler(Random.value * 180f, Random.value * 180f, Random.value * 180f);

        // Object's color is completely random
        Color color = new Color(Random.value, Random.value, Random.value, 1f);

        // Create the object using a custom creation function defined below.
        // Note that passing "channelID" is optional. If you don't pass anything, TNet will pick one for you.
        TNManager.Instantiate(channelID, "ColoredObject", prefabName, true, pos, rot, color, autoDestroyDelay);
    }
Ejemplo n.º 10
0
 public void FireProjectile(Vector3 targetPoint)
 {
     TNManager.Instantiate(tno.channelID, "FireProjectile", baseWeapon.ProjectilePrefab.PathInResources, false, raycastOrigin.position, (targetPoint - raycastOrigin.position).normalized);
 }
Ejemplo n.º 11
0
 void CreateBall()
 {
     Debug.Log(TNManager.lastChannelID);
     TNManager.Instantiate(TNManager.lastChannelID, "CreatePuck", "Puck", true, Vector3.zero);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Convenience method mirroring TNManager.Instantiate.
        /// Instantiate a new game object in the behaviour's channel on all connected players.
        /// </summary>

        public void Instantiate(string funcName, string path, bool persistent, params object[] objs)
        {
            TNManager.Instantiate(tno.channelID, 0, funcName, path, persistent, objs);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Convenience method mirroring TNManager.Instantiate.
        /// Instantiate a new game object in the behaviour's channel on all connected players.
        /// </summary>

        public void Instantiate(int rccID, string path, bool persistent, params object[] objs)
        {
            TNManager.Instantiate(tno.channelID, rccID, null, path, persistent, objs);
        }