Ejemplo n.º 1
0
    public void SpawnRobotsForPlayer(int playerId, int robotCnt)
    {
        NetworkPlayerInfo player = netPlayers[playerId];

//		Debug.Log("SpawnRobotsForPlayer - playerIdx: " + playerIdx + ", player.color: " + player.color);



//		Vector3 spawnPos = Tools.AddHalf(new Vector3((int)player.initPos.x, (int)player.initPos.y, 0));
        Vector3 spawnPos = new Vector3(-100, -100, 0);

        Color clr = PlayerHelper.IDToColor(playerId);

        for (int i = 0; i < robotCnt; i++)
        {
            Robot robot = ((Transform)Network.Instantiate(robotPrefab, spawnPos, Quaternion.identity, (int)NetGroup.DEFAULT)).GetComponent <Robot>();
            robot.ServerInit(player.robotIDIncr++, clr, playerId, playersIDToGUID[playerId]);

            gameCtrl.AddPlayerRobot(robot, player.netView.owner.guid);
        }


//		SpawnedRobotForPlayer(robot, player);

//		StartCoroutine(SendSpawnedRobotForPlayer(robot, player));

//		netView.RPC("RPCSpawnedRobotForPlayer", RPCMode.AllBuffered, robot.netView.viewID, player.netView.owner);
    }