コード例 #1
0
ファイル: ObjectStateProcess.cs プロジェクト: nottvlike/EGP
        public static void Start(GUnit unit, int id, Vector3 param, bool sync = true)
        {
            var stateProcessData = unit.GetData <ObjectStateProcessData>();
            var stateData        = ObjectStateDataDict.Get(unit, id);

            if (!stateData.objectState.CanStart(unit, stateProcessData, stateData, param))
            {
                return;
            }

            if (sync && unit.GetData <ObjectSyncData>() == null)
            {
                sync = false;
            }

            if (sync)
            {
                ObjectSyncServer.AddState(unit, id, param, ObjectStateType.Start);
            }
            else
            {
                stateData.param = param;
                Start(stateProcessData, stateData);
            }
        }
コード例 #2
0
ファイル: ObjectSync.cs プロジェクト: nottvlike/EGP
        protected override void OnAdd(GUnit unit)
        {
            var unitData       = unit.GetData <UnitData>();
            var objectSyncData = unit.GetData <ObjectSyncData>();

            objectSyncData.stateSyncInfoList.ObserveAdd().Subscribe(_ =>
            {
                if (objectSyncData.checkSyncDispose != null)
                {
                    return;
                }

                objectSyncData.checkSyncDispose = ObjectSyncServer.EverySyncUpdate().Subscribe(frameInfo =>
                {
                    if (objectSyncData.stateSyncInfoList.Count == 0)
                    {
                        objectSyncData.checkSyncDispose.Dispose();
                        objectSyncData.checkSyncDispose = null;
                        return;
                    }

                    var stateSyncInfoList = objectSyncData.stateSyncInfoList;
                    for (var i = 0; i < stateSyncInfoList.Count;)
                    {
                        var syncInfo = objectSyncData.stateSyncInfoList[i];
#if DEBUG
                        if (syncInfo.serverKeyFrame < frameInfo.Item1 ||
                            (syncInfo.serverKeyFrame == frameInfo.Item1 && syncInfo.internalFrame < frameInfo.Item2))
                        {
                            Log.W("Sync {0} state {1} {2} failed!", syncInfo.stateType,
                                  syncInfo.stateId, syncInfo.stateParam);
                            objectSyncData.stateSyncInfoList.RemoveAt(i);
                            return;
                        }
#endif
                        if (syncInfo.serverKeyFrame == frameInfo.Item1 && syncInfo.internalFrame == frameInfo.Item2)
                        {
                            DoState(unit, syncInfo);
                            objectSyncData.stateSyncInfoList.RemoveAt(i);
                        }
                        else
                        {
                            i++;
                        }
                    }
                });
            }).AddTo(unitData.disposable);
        }
コード例 #3
0
ファイル: ObjectStateProcess.cs プロジェクト: nottvlike/EGP
        public static void Finish(GUnit unit, int id, bool sync = true)
        {
            var stateProcessData = unit.GetData <ObjectStateProcessData>();
            var stateData        = ObjectStateDataDict.Get(unit, id);

            if (!stateData.objectState.CanFinish(unit, stateProcessData, stateData))
            {
                return;
            }

            if (sync && unit.GetData <ObjectSyncData>() == null)
            {
                sync = false;
            }

            if (sync)
            {
                ObjectSyncServer.AddState(unit, id, Vector3.zero, ObjectStateType.Finish);
            }
            else
            {
                Finish(unit, stateProcessData, stateData);
            }
        }