예제 #1
0
 public VaultData(NetworkMessageT t, string d)
 {
     this.iden = t;
     this.size = d.Length;
     this.data = d;
     this.hash = NetworkScript.CalculateHash(d);
 }
예제 #2
0
 // Use this for initialization
 void Start()
 {
     currentTurnState = (int)States.Menu;
     engine           = GameObject.Find("Engine").GetComponent("Engine") as Engine;
     networkScript    = GameObject.Find("NetworkManager").GetComponent("NetworkScript") as NetworkScript;
     //Debug.Log ("currentTurnState set to States.Menu");
 }
예제 #3
0
 protected void NetworkDestroy(NetworkScript instance)
 {
     if (instance)
     {
         instance.Destroy();
     }
 }
예제 #4
0
	void Start(){
		ApplicationDOA.getInstance ().set_age (24);
		ApplicationDOA.getInstance ().set_weight (65);
		MC = GameObject.FindGameObjectWithTag("Network").GetComponent<NetworkScript>();
		speed = 0;
		count = 0;
	}
예제 #5
0
    //Setup the singleton
    public void Awake()
    {
        if (NetworkScript.instance == null)
        {
            NetworkScript.instance = this;
        }
        else if (NetworkScript.instance != this)
        {
            DestroyObject(this);
        }

        this.registered     = new Dictionary <String, NetworkObject> ();
        this.recentMessages = new Dictionary <String, String> ();

        Debug.Log("Starting server");
        Debug.Log("Enum Values: " + (int)VaultData.NetworkMessageT.HANDSHAKE);
        try     {
            tcp_socket              = new TcpClient(host, port);
            net_stream              = tcp_socket.GetStream();
            socket_writer           = new StreamWriter(net_stream);
            socket_reader           = new StreamReader(net_stream);
            socket_ready            = true;
            socket_writer.AutoFlush = true;
            connected = true;
            //SETUP HANDSHAKE:
            toServerQueue.Enqueue(new VaultData(VaultData.NetworkMessageT.HANDSHAKE, 0));
            flushQueue();
        }
        catch (Exception e)     {
            // Something went wrong
            Debug.Log("Socket error: " + e);
        }
    }
예제 #6
0
 // Use this for initialization
 void Start()
 {
     turn          = GameObject.Find("TurnState").GetComponent("TurnState") as TurnState;
     networkScript = GameObject.Find("NetworkManager").GetComponent("NetworkScript") as NetworkScript;
     p1Wins        = 0; p2Wins = 0; draws = 0;
     menuLeft      = Screen.width / 2 + 5;
     menuTop       = Screen.height / 2 - 220;
 }
예제 #7
0
 void Start()
 {
     StudentCodeInput = GameObject.Find("StudentCodeInput").GetComponent <InputField>();
     remember         = GameObject.Find("RememberCheckBox").GetComponent <Toggle>();
     photoObject      = GameObject.Find("TakePicButton").GetComponent <CameraScript>();
     network          = gameObject.GetComponent <NetworkScript>();
     location         = gameObject.GetComponent <LocationScript>();
     informations     = new Informations();
 }
    void Start()
    {
        //Manager객체를 계속 유지하도록 만들기
        GameObject Manager = GameObject.Find("Manager");

        networkscript = Manager.GetComponentInChildren <NetworkScript>();
        manager       = Manager.GetComponentInChildren <ManagerScript>();
        DontDestroyOnLoad(Manager);
    }
예제 #9
0
    void Start()
    {
        net    = new NetworkScript();
        parser = new ParsingScript();

        parser.CreateDico();
        net.setupSocket();
        net.writeSocket("GRAPHIC");
    }
예제 #10
0
    //Create the header and payload for a string
    public void createMessage(string data)
    {
        string    hash    = NetworkScript.CalculateHash(data);
        VaultData payload = new VaultData(VaultData.NetworkMessageT.PAYLOAD, data);
        VaultData header  = new VaultData(VaultData.NetworkMessageT.INFO, data.Length, hash);

        toServerQueue.Enqueue(header);
        toServerQueue.Enqueue(payload);
        this.recentMessages.Add(hash, data);
    }
예제 #11
0
 //Ensure Singleton status
 private void Start()
 {
     if (NetworkScript.instance == null)
     {
         NetworkScript.instance = this;
     }
     else if (NetworkScript.instance != this)
     {
         DestroyObject(this);
     }
 }
예제 #12
0
	void Start () {
		originalRotation = transform.rotation;
		MC = GameObject.FindGameObjectWithTag("Network").GetComponent<NetworkScript>();
		speed = 0;
		count = 0;

		Interface = GameObject.Find ("Interface");
		PauseCanvas = GameObject.Find ("PausedMenu");
		AdjustCanvas = GameObject.Find ("AdjustCanvas");
		FinishCanvas = GameObject.Find ("FinishCanvas");
	}
예제 #13
0
 public void RegisterSignaller(NetworkScript signaller)
 {
     try
     {
         signallersByID.Add(signaller.networkID, signaller);
     }
     catch(ArgumentException)
     {
         signallersByID[signaller.networkID] = signaller;
         Debug.Log("NID " + signaller.networkID + " already exist.");
     }
 }
예제 #14
0
 public void RegisterSignaller(NetworkScript signaller)
 {
     try
     {
         signallersByID.Add(signaller.networkID, signaller);
     }
     catch (ArgumentException)
     {
         signallersByID[signaller.networkID] = signaller;
         Debug.Log("NID " + signaller.networkID + " already exist.");
     }
 }
예제 #15
0
 private void Awake()
 {
     if (Insance == null)
     {
         DontDestroyOnLoad(gameObject);
         Insance = this;
     }
     else if (Insance != this)
     {
         Destroy(gameObject);
     }
 }
예제 #16
0
    void Start()
    {
        network = NetworkScript.Insance;

        if (network.host)
        {
            Debug.Log("This is the Host!");
        }
        else
        {
            Debug.Log("This is the remote player flipping Camera");

            transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, 180);
        }
    }
예제 #17
0
 void Start()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
     //string uriSend = uri + "?user="******"&score=" + score + "&token=" + access_token;
     //Debug.Log(uriSend);
     StartCoroutine(GetText());
     DontDestroyOnLoad(gameObject);
 }
예제 #18
0
    // Start is called before the first frame update
    void Start()
    {
        myRigidbody = GetComponent <Rigidbody>();
        network     = NetworkScript.Insance;

        if ((remote & network.host) || (!remote & !network.host))
        {
            gameObject.AddComponent <RemoteController>();
            localController = false;
        }
        else
        {
            gameObject.AddComponent <LocalController>();
            localController = true;
        }
    }
    void Start()
    {
        //종료 메뉴는 안보이는 상태로 시작
        QuitMenuPrefab.SetActive(false);
        networkScript = GetComponentInChildren <NetworkScript>();
        //팝업 텍스트도 안보이는 상태로 시작
        PopupMessage.SetActive(false);

        if (Application.platform == RuntimePlatform.Android)
        {
            isServer = false;
        }
        else
        {
            isServer = true;
        }
    }
예제 #20
0
 public void NewGame(NetworkScript network)
 {
     playerCounter = Count;
     blindIndex    = (blindIndex + 1) % Count;
     this[blindIndex].SmallBlind();
     this[(blindIndex + 1) % Count].BigBlind();
     network.SetPlayersMoney(this[blindIndex], this[blindIndex].MoneyInString());
     network.SetPlayersBet(this[blindIndex], this[blindIndex].BetInString());
     network.SetPlayersMoney(this[(blindIndex + 1) % Count], this[(blindIndex + 1) % Count].MoneyInString());
     network.SetPlayersBet(this[(blindIndex + 1) % Count], this[(blindIndex + 1) % Count].BetInString());
     foreach (Player player in this)
     {
         player.NewGame();
     }
     first        = this[blindIndex];
     actual       = this[blindIndex];
     readyCounter = 0;
 }
예제 #21
0
 // Use this for initialization
 void Start()
 {
     Network.isMessageQueueRunning = true;
     network             = gameObject.GetComponent <NetworkScript>();
     counter             = TimerOff;
     changeBlueprints[0] = new Change(1);
     changeBlueprints[1] = new Change(5);
     changeBlueprints[2] = new Change(10);
     changeBlueprints[3] = new Change(25);
     changeBlueprints[4] = new Change(100);
     if (Network.isServer)
     {
         mainPile = new Money("Empty", this.ChangeBlueprints);
         players.Add(new Player(Network.player));
         players[0].Name = PlayerPrefs.GetString("Nickname");
         network.RPCSetPlayersMoney(Network.player, players.GetPlayer(Network.player).MoneyInString());
     }
 }
예제 #22
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject ManagerObj = GameObject.Find("Manager");

        Manager                = ManagerObj.GetComponent <ManagerScript>();
        networkScript          = ManagerObj.GetComponentInChildren <NetworkScript>();
        BettingSlider.maxValue = PlayerMoney > MAXIMUMBETTING ? MAXIMUMBETTING : PlayerMoney;
        MainCamera             = Camera.main;
        StartCoroutine("CameraZoomIn");
        if (Manager.IsServer())
        {
            SceneText.GetComponent <Text>().text = "Waiting Client...";
            InvokeRepeating("CheckConnection", 0f, 1f);
        }
        else
        {
            SceneText.GetComponent <Text>().text = "Game Start!";
            //클라이언트는 서버의 턴 선택 결과를 기다린다.
            CurrentState = GameState.Wait;
        }
    }
예제 #23
0
    void Awake()
    {
        //Manager객체를 계속 유지하도록 만들기
        GameObject Manager = GameObject.Find("Manager");

        networkscript = Manager.GetComponentInChildren <NetworkScript>();
        PopupMenu     = Manager.GetComponentInChildren <ManagerScript>();

        //서버 주소(일단 하드 코딩해놓고 실제 서버 사용시엔 DNS로 알아오는 방식으로 적용할 것)
        serverAddress = "121.181.137.193";  //고정 ip가 아니기 때문에 바뀔 수 있다.

        /*  DNS로 알아오는 방식
         * // 호스트명을 가져옵니다.
         *      string hostname = Dns.GetHostName();
         *      // 호스트명에서 IP주소를 가져옵니다.
         *      IPAddress[] adrList = Dns.GetHostAddresses(hostname);
         *      serverAddress = adrList[0].ToString();
         */

        currentMode = Mode.None;
    }
예제 #24
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("Init login script");
        network = GameObject.Find("Network").GetComponent <NetworkScript>();

        url           = GameObject.Find("ServerInput").GetComponent <InputField>();
        usernameInput = GameObject.Find("UsernameInput").GetComponent <InputField>();
        passwordInput = GameObject.Find("PasswordInput").GetComponent <InputField>();


        Button b = GameObject.Find("ServerConnectBtn").GetComponent <Button>();

        b.onClick.AddListener(Connect);

        Button l = GameObject.Find("LoginBtn").GetComponent <Button>();

        l.onClick.AddListener(Login);

        Button j = GameObject.Find("JoinBtn").GetComponent <Button>();

        j.onClick.AddListener(Join);

        charDropdown = GameObject.Find("CharDropDown").GetComponent <Dropdown>();
    }
예제 #25
0
 void Start()
 {
     NetworkingScript = gameObject.GetComponent <NetworkScript>();
 }
예제 #26
0
 // Use this for initialization
 void Start()
 {
     network = GameObject.Find("Network").GetComponent <NetworkScript>();
 }
예제 #27
0
	// Use this for initialization
	void Start () {
		MC = GameObject.Find("Network").GetComponent<NetworkScript>();
	}
예제 #28
0
    /**
     * Accept a received string of information from the server,
     * and do something with it
     */
    void ProcessReceivedData(string receivedJson)
    {
        if (receivedJson == "")
        {
            return;
        }

        Debug.Log("Received data: " + receivedJson);
        //Convert json into object
        VaultData fromNetworkData = JsonUtility.FromJson <VaultData>(receivedJson);

        /*
         * Handle the data:
         */
        switch (fromNetworkData.iden)
        {
        //INIITIAL SETUP HANDSHAKE:
        case VaultData.NetworkMessageT.HANDSHAKE:
            Debug.Log("Network Handshake Complete");
            //Update the connection UI:
            text.text = "Connected";
            //Send some information
            foreach (var obj in this.registered.Values)
            {
                this.createMessage(obj.GetComponent <ActorAIStub> ().toPythonString());
            }
            break;

        //INSTRUCTION TO CHANGE THE GAME WORLD:
        case VaultData.NetworkMessageT.ACTION:
            Debug.Log("Got an Action Header");
            Debug.Log(String.Format("Payload: {0}", fromNetworkData.data));
            Debug.Assert(fromNetworkData.hash == NetworkScript.CalculateHash(fromNetworkData.data));
            this.fromServerQueue.Enqueue(fromNetworkData.data);
            break;

        //NOTIFICATION OF AI CYCLE / TURN COMPLETION:
        case VaultData.NetworkMessageT.AI_COMPLETE:
            Debug.Log("AI Finished, time to trigger actions");
            break;

        //INSTRUCTION TO RESEND CORRUPTED DATA
        case VaultData.NetworkMessageT.RESEND:
            Debug.Log("Hash Mismatch, Resend Data: " + fromNetworkData.hash);
            break;

        //MESSAGES THAT SHOULD ONLY BE SENT, NOT RECEIVED:
        case VaultData.NetworkMessageT.INFO:
        case VaultData.NetworkMessageT.AI_GO:
            throw new Exception("Data or command passed in the wrong direction");
            break;

        //UPON QUIT OF GAME, SIGNAL SHUTDOWN OF SERVER
        case VaultData.NetworkMessageT.QUIT:
            text.text = "Disconnected";
            closeSocket();
            break;

        default:
            closeSocket();
            break;
        }
    }
예제 #29
0
 public void NetworkInstantiate(NetworkScript prefab, IAutoSerializable callbackArg, string callback)
 {
     var ni = new NetworkInstantiate(prefab.name, callbackArg, callback);
     Send(ni);
 }
예제 #30
0
 protected void NetworkDestroy(NetworkScript instance)
 {
     if (instance)
         instance.Destroy();
 }
예제 #31
0
 public void NetworkInstantiate(NetworkScript prefab)
 {
     var ni = new NetworkInstantiate(prefab.name, new NullPacket(), "");
     Send(ni);
 }
예제 #32
0
 public void Start()
 {
     network = NetworkScript.Insance;
 }
예제 #33
0
 public void NetworkInstantiate(NetworkScript prefab, IAutoSerializable callbackArg)
 {
     var ni = new NetworkInstantiate(prefab.name, callbackArg, "");
     NetworkProgramUnity.currentInstance.Send(ni);
 }
예제 #34
0
 public void NetworkInstantiate(NetworkScript prefab, string callback)
 {
     var ni = new NetworkInstantiate(prefab.name, new NullPacket(), callback);
     Send(ni);
 }
예제 #35
0
    public void NetworkInstantiate(NetworkScript prefab)
    {
        var ni = new NetworkInstantiate(prefab.name, new NullPacket(), "");

        Send(ni);
    }
예제 #36
0
    public void NetworkInstantiate(NetworkScript prefab, string callback)
    {
        var ni = new NetworkInstantiate(prefab.name, new NullPacket(), callback);

        Send(ni);
    }
예제 #37
0
    public void NetworkInstantiate(NetworkScript prefab, IAutoSerializable callbackArg, string callback)
    {
        var ni = new NetworkInstantiate(prefab.name, callbackArg, callback);

        Send(ni);
    }
예제 #38
0
    // Use this for initialization
    void Start()
    {
        nets = GetComponent<NetworkScript>();
        stateScene = LANConnexionState.LOADING;

        hitNet = new Dictionary<GameObject, NetworkPlayer>();

        hitNetClient = new Dictionary<GameObject, CublastPlayer>();
        previousLenghtConnected = 0;

        networkStarted = false;
        actualColor = 0f;
        sens = 1f;
        time = 0f;
        alphaDescription = 0f;

        locked = false;
        somethingSelected = false;
        isReady = false;
        countForTimeEnd = 0f;
        tex = new Dictionary<string, Texture2D>();
        tex.Add("mode0", (Texture2D) Resources.Load("LANFFA"));
        tex.Add("mode1", (Texture2D) Resources.Load("LANScoreTournament"));
        tex.Add("mode2", (Texture2D) Resources.Load("LANPointTournament"));
        tex.Add("mode3", (Texture2D) Resources.Load("LANElimination"));
        tex.Add("black", (Texture2D) Resources.Load("black"));

        if(LANManager.Instance.isCreator)
        {
            profileAlreadyGetted.Add(cubePlayers.transform.GetChild(0).gameObject);
        }

        fm = GetComponent<FadeManager>();
    }
예제 #39
0
 void Start()
 {
     movement = GetComponent <Movement>();
     network  = NetworkScript.Insance;
     network.handlePlayerPacket += UpdatePosistion;
 }
예제 #40
0
 public void UnregisterSignaller(NetworkScript signaller)
 {
     signallersByID.Remove(signaller.networkID);
 }
예제 #41
0
 void Start()
 {
     movement = GetComponent <Movement>() as Movement;
     network  = NetworkScript.Insance;
 }