コード例 #1
0
    // Use this for initialization
    void Start()
    {
        //initialize things that will be the same regardless of role
        NetworkView net = this.GetComponent <NetworkView>();

        ice = (GameObject)Instantiate(rink, new Vector3(0, 0, 0), Quaternion.identity);
        int localPlayers = PlayerPrefs.GetInt("numPlayers");

        if (PlayerPrefs.GetString("multiplayerType") == "online")
        {
            if (PlayerPrefs.GetString("onlineRole") == "host")
            {
                //create serverBehavior
                gameObject.AddComponent <ServerBehavior>();
                ServerBehavior serv = gameObject.GetComponent <ServerBehavior>();
                serv.InitServerBehavior(net, prefab, localPlayers);
                action = serv;
            }
            else
            {
                //create clientBehavior
                gameObject.AddComponent <ClientBehavior>();
                ClientBehavior cli = gameObject.GetComponent <ClientBehavior>();
                cli.InitClientBehavior(net, prefab, localPlayers);
                action = cli;
            }
        }
        else
        {
            //create localBehavior
            gameObject.AddComponent <LocalBehavior>();
            LocalBehavior loc = gameObject.GetComponent <LocalBehavior>();
            loc.InitLocalBehavior(prefab, localPlayers);
            action = loc;
        }
    }
コード例 #2
0
ファイル: OnError.cs プロジェクト: chrisbaglieri/nServer
 /// <summary>
 /// Constructs the attribute with an end point and behavior.
 /// </summary>
 /// <param name="endPoint">end point</param>
 /// <param name="behavior">server behavior</param>
 public OnErrorAttribute(ExceptionEndPoint endPoint, ServerBehavior behavior)
 {
     this.EndPoint = endPoint;
     this.Behavior = behavior;
 }
コード例 #3
0
ファイル: OnError.cs プロジェクト: chrisbaglieri/nServer
 /// <summary>
 /// Empty default constructor.  Assumes logging the exception
 /// and keeping the server active.
 /// </summary>
 public OnErrorAttribute()
 {
     EndPoint = ExceptionEndPoint.Log;
     Behavior = ServerBehavior.RemainActive;
 }