示例#1
0
    public void initializeOthers(MessageBox.OtherInitializeMessage message)
    {
        Color OtherCamp = GetOtherCamp(message.Camp);

        MessageBox.Position position    = JsonUtility.FromJson <MessageBox.Position>(message.PlayerPosition);
        GameObject          otherPlayer = Instantiate(OtherPlayer, new Vector3(position.x, position.y, 0), new Quaternion());

        otherPlayer.GetComponent <OtherObjectController>().id   = message.PlayerID;
        otherPlayer.GetComponent <OtherObjectController>().type = OtherObjectController.Type.Player;
        otherPlayer.GetComponent <OtherObjectController>().SendMessage("Init", OtherCamp);
        position = JsonUtility.FromJson <MessageBox.Position>(message.HingePosition);
        GameObject otherHinge = Instantiate(OtherHinge, new Vector3(position.x, position.y, 0), new Quaternion());

        otherHinge.GetComponent <OtherObjectController>().id   = message.HingeID;
        otherHinge.GetComponent <OtherObjectController>().type = OtherObjectController.Type.Hinge;
        otherHinge.GetComponent <OtherObjectController>().SendMessage("Init", OtherCamp);
    }
示例#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");
    }