public void CreateMessageAndSend() { MessageBox.MessageBase MB = new MessageBox.MessageBase(); MB.Type = "ChangeStateBar"; MessageBox.ChangeStateBar CSB = new MessageBox.ChangeStateBar { id = id, Health = _CurrentHealth, Energy = _CurrentEnergy, Shield = _CurrentShield }; MB.Message = JsonUtility.ToJson(CSB); WS.Send(JsonUtility.ToJson(MB)); }
// 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"); }
public void ChangeInfoByMessage(MessageBox.ChangeStateBar CSB) { CurrentEnergy = CSB.Energy; CurrentHealth = CSB.Health; CurrentShield = CSB.Shield; }