コード例 #1
0
 public void Setup(bool is_host)
 {
     this.is_host = is_host;
     GameObject.Find("Join/Host").SetActive(false);
     SetupVariables();
     if(is_host) {
         socket = Host_Actions.Host();
         //			Debug_View_Mediator.Setup_Debug();
         socket.connected += delegate {
             ServerWaiting();
         };
         socket.playerConnected += delegate {
             ServerWaiting();
         };
     } else {
         socket = Client_Actions.Connect();
         //			Debug_View_Mediator.Setup_Debug();
         socket.connected += delegate {
             socket.AddCustomDataReadEvent(EventHelper.GetEventId("ALL_CLIENTS_JOINED"), delegate (NetworkingPlayer arg1, NetworkingStream arg2) {
                 Debug_Console.i.add("All clients have joined");
                 Turn_Controller.instance.server_players = (Server_Player_Model) EasySerialization.EasyDeserialize<Server_Player_Model>(ref arg2);
                 state = 1;
             });
             manager.SetActive(true);
         };
     }
 }
コード例 #2
0
    public override void Setup(ref NetWorker socket)
    {
        base.Setup(ref socket);

        socket.AddCustomDataReadEvent(EventHelper.GetEventId("SERVER_REQUEST"), delegate {
            Debug_Console.i.add("sending server request");
        });

        //		socket.AddCustomDataReadEvent ("COMBAT_REGISTER", delegate {
        //			Debug_View_Mediator.i.add("sending combat register");
        //		});
        Debug_Console.i.add("Client controller setup");
    }
コード例 #3
0
    public override void Setup(ref NetWorker socket)
    {
        base.Setup(ref socket);
        socket.AddCustomDataReadEvent(EventHelper.GetEventId("SERVER_REQUEST"), ReadRequest);
        //		socket.AddCustomDataReadEvent ("COMBAT_REGISTER", ReadCombatRegister);

        SmartObject obj = new SmartObject();
        SmartObject add = new SmartObject();
        Client_Model[] players = Turn_Controller.instance.server_players.players.ToArray();
        int entity_count = 0;
        for(int i = 0; i < players.Length; i++) {
            Entity_Model_Army army = Entity_Model_Army.GenerateRandomArmy(ref players[i], 2);
            for(int i2 = 0; i2 < army.entity_army.Length; i2++) {
                add.AddEntity("Entity_" + entity_count, army.entity_army[i2]);
                entity_count++;
            }
        }
        Debug_Console.i.add("Host controller setup");
        add.AddInt("length", entity_count);
        obj.AddSmartObject("Additions", add);
        BMSByte bms_byte = EasySerialization.EasySerialize(obj);
        StartCoroutine("Delayed", bms_byte);
    }