Ejemplo n.º 1
0
    public void initialize(MessageBox.InitializeMessage message)
    {
        _camp = GetOtherCamp(message.Camp);
        Debug.Log("Camp:" + _camp);
        MessageBox.Position position = JsonUtility.FromJson <MessageBox.Position>(message.PlayerPosition);
        GameObject          player   = Instantiate(Player, new Vector3(position.x, position.y, 0), new Quaternion());

        player.name = "Player";
        player.GetComponent <PlayerController>().id   = message.PlayerID;
        player.GetComponentInChildren <StateBar>().id = message.PlayerID;
        Collector.Others.Add(new Collector.KeyValuePair
        {
            key   = message.PlayerID,
            value = player
        });
        position = JsonUtility.FromJson <MessageBox.Position>(message.HingePosition);
        GameObject hinge = Instantiate(Hinge, new Vector3(position.x, position.y, 0), new Quaternion());

        hinge.name = "Hinge";
        hinge.GetComponent <HingeController>().id    = message.HingeID;
        hinge.GetComponentInChildren <StateBar>().id = message.HingeID;
        Collector.Others.Add(new Collector.KeyValuePair
        {
            key   = message.HingeID,
            value = hinge
        });
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Awake()
    {
        MessageBase            = new MessageBox.MessageBase();
        InitializeMessage      = new MessageBox.InitializeMessage();
        OtherInitializeMessage = new MessageBox.OtherInitializeMessage();
        PlayerPosition         = new MessageBox.PlayerPosition();
        BulletMessage          = new MessageBox.BulletMessage();
        ChangeStateBar         = new MessageBox.ChangeStateBar();
        BuildMessage           = new MessageBox.BuildMessage();
        Collector  = GameObject.Find("Collector").GetComponent <Collector>();
        Initialize = GameObject.Find("InitializeController").GetComponent <Initialize>();
        Debug.Log("start connect");
        SocketConnect("ws://192.168.0.106:2222");
        Debug.Log("connect done");

        Bullet = Resources.Load <GameObject>("Prefabs/OtherBullet");
    }