// Start is called before the first frame update void Start() { EventProcessIdx = -1; IsSimulating = false; Debug.Log("ShadowGrid is Started!!"); RecvSyncPacketQueue = new Queue <GameSynchronizeNotifyPacket>(); RecvSyncPacket = new GameSynchronizeNotifyPacket(); }
// Update is called once per frame void Update() { if (IsSimulating == true) { if (EventProcessIdx >= 6) { IsSimulating = false; RecvSyncPacket = null; return; } EVENT_TYPE recordEventType = (EVENT_TYPE)RecvSyncPacket.EventRecordArr[EventProcessIdx]; while (recordEventType == EVENT_TYPE.NONE && EventProcessIdx < 6) { EventProcessIdx++; if (EventProcessIdx >= 6) { break; } recordEventType = (EVENT_TYPE)RecvSyncPacket.EventRecordArr[EventProcessIdx]; } if (recordEventType != EVENT_TYPE.NONE && EventProcessIdx < 6) { ProcessEvent(recordEventType); EventProcessIdx++; } } else { if (RecvSyncPacketQueue != null && RecvSyncPacketQueue.Count > 0) { Debug.Log("Deque PacketSync"); RecvSyncPacket = RecvSyncPacketQueue.Dequeue(); Text RivalScore = GameObject.FindGameObjectWithTag("RivalScore").GetComponent <Text>(); RivalScore.text = "Score: " + RecvSyncPacket.Score + "\nLine: " + RecvSyncPacket.Line + "\nLevel:" + RecvSyncPacket.Level; EventProcessIdx = 0; IsSimulating = true; } } }