Ejemplo n.º 1
0
        static void Finish(GUnit unit, ObjectStateProcessData stateProcessData, ObjectStateData stateData = null)
        {
            var currentState = stateData == null ? stateProcessData.currentState : stateData;

            if (currentState == null)
            {
                return;
            }

            if (currentState is IndependentObjectStateData)
            {
                if (currentState.stateTypeProperty.Value == ObjectStateType.Start)
                {
                    currentState.stateTypeProperty.Value = ObjectStateType.Finish;
                    stateProcessData.currentState        = null;

                    var newStateData = GetHighestPriorityState(unit, stateProcessData);
                    Start(stateProcessData, newStateData);
                }
                else if (currentState.stateTypeProperty.Value == ObjectStateType.Stop)
                {
                    currentState.stateTypeProperty.Value = ObjectStateType.Finish;
                }
            }
            else
            {
                currentState.stateTypeProperty.Value = ObjectStateType.Finish;
            }
        }
Ejemplo n.º 2
0
        public void Init(GUnit unit, ObjectStateData stateData)
        {
            var unitData = unit.GetData <UnitData>();

            stateData.stateTypeProperty.Subscribe(_ => {
                if (_ == ObjectStateType.Start)
                {
                    OnStart(unit, stateData);
                }
                else if (_ == ObjectStateType.Stop)
                {
                    OnStop(unit, stateData);
                }
                else if (_ == ObjectStateType.Finish)
                {
                    OnFinish(unit, stateData);
                    stateData.stateTypeProperty.Value = ObjectStateType.None;
                }
            }).AddTo(unitData.disposable);

            OnInit(unit, stateData);

            var independentStateData = stateData as IndependentObjectStateData;

            if (independentStateData != null && independentStateData.isDefault)
            {
                ObjectStateProcess.Start(unit, independentStateData.id, independentStateData.param, false);
            }
        }
Ejemplo n.º 3
0
        protected override void OnStop(GUnit unit, ObjectStateData stateData)
        {
            var assetData = unit.GetData <AssetData>();
            var animator  = assetData.GetComponent <Animator>();

            animator.SetBool(ObjectTestConstant.ANIMATOR_PARAM_IDLE, false);
        }
Ejemplo n.º 4
0
        public void Release(GUnit unit, ObjectStateData stateData)
        {
            if (stateData.stateTypeProperty.Value == ObjectStateType.None ||
                stateData.stateTypeProperty.Value == ObjectStateType.Finish)
            {
                return;
            }

            stateData.stateTypeProperty.Value = ObjectStateType.Finish;

            OnRelease(unit, stateData);
        }
Ejemplo n.º 5
0
        protected override void OnStop(GUnit unit, ObjectStateData stateData)
        {
            var moveParamData = unit.GetData <ObjectMoveParamData>();

            moveParamData.moveDispose?.Dispose();
            moveParamData.moveDispose = null;

            var assetData = unit.GetData <AssetData>();
            var animator  = assetData.GetComponent <Animator>();

            animator.SetBool(ObjectTestConstant.ANIMATOR_PARAM_MOVE, false);
        }
    //save current item states
    public void SaveItemStates()
    {
        while (itemsStateData.Count < items.Count)
        {
            itemsStateData.Add(null);
        }

        for (int i = 0; i < items.Count; i++)
        {
            if (itemsStateData[i] == null)
            {
                itemsStateData[i] = new ObjectStateData(items[i]);
            }
            itemsStateData[i].SetObject(items[i]);
        }
    }
 public override void Deserialize(NetworkReader reader)
 {
     objectCount = reader.ReadInt32();
     try
     {
         for (int i = 0; i < objectCount; i++)
         {
             ObjectStateData obj = new ObjectStateData();
             obj.id    = reader.ReadInt32();
             obj.state = reader.ReadInt32();
             Data.Add(obj);
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 8
0
        static void Start(ObjectStateProcessData stateProcessData, ObjectStateData stateData)
        {
            if (stateData is IndependentObjectStateData)
            {
                if (stateProcessData.currentState != null)
                {
                    Stop(stateProcessData);
                }

                stateData.stateTypeProperty.Value = ObjectStateType.Start;
                stateProcessData.currentState     = stateData as IndependentObjectStateData;
            }
            else
            {
                stateData.stateTypeProperty.SetValueAndForceNotify(ObjectStateType.Start);
            }
        }
Ejemplo n.º 9
0
 public void world_updateEntityState(ObjectStateData ent)
 {
     foreach (EntityData obj in EntityList)
     {
         if (ent.id == obj.uniqueID && obj.Object != null)
         {
             BaseInteractable interactHandler = obj.Object.GetComponent <BaseInteractable>();
             if (interactHandler != null)
             {
                 if (interactHandler.getState() != ent.state)
                 {
                     interactHandler.onInteractStart();
                 }
             }
             break;
         }
     }
 }
Ejemplo n.º 10
0
        protected override void OnStart(GUnit unit, ObjectStateData stateData)
        {
            var moveSpeedData = unit.GetData <ObjectMoveSpeedData>();
            var assetData     = unit.GetData <AssetData>();
            var animator      = assetData.GetComponent <Animator>();
            var rigidbody     = assetData.GetComponent <Rigidbody2D>();

            animator.SetBool(ObjectTestConstant.ANIMATOR_PARAM_MOVE, true);

            var moveParamData = unit.GetData <ObjectMoveParamData>();

            moveParamData.moveDispose = ObjectSyncServer.EverySyncUpdate().Subscribe(_ =>
            {
                var deltaX = stateData.param.x * moveSpeedData.allValue * ObjectTestConstant.OBJECTTEST_FIXED_MSECOND;
                deltaX    /= ObjectTestConstant.MSECOND_TO_SECOND * ObjectTestConstant.MSECOND_TO_SECOND;

                _movePosition.x = deltaX;
                rigidbody.MovePosition(rigidbody.position + _movePosition);
            });
        }
Ejemplo n.º 11
0
 public virtual bool CanFinish(GUnit unit, ObjectStateProcessData processData, ObjectStateData stateData)
 {
     return(true);
 }
Ejemplo n.º 12
0
        public virtual bool CanStart(GUnit unit, ObjectStateProcessData stateProcessData, ObjectStateData stateData, Vector3 param)
        {
            if (stateData is IndependentObjectStateData)
            {
                var currentState = stateProcessData.currentState;
                if (currentState == null)
                {
                    return(true);
                }

                var independentState    = stateData as IndependentObjectStateData;
                var isSameState         = currentState == independentState;
                var containExcludeState = ContainExcludeState(currentState.objectState.ExcludeIdList, stateData.id);
                var higherPriority      = independentState.priority >= currentState.priority;
                return(isSameState && independentState.param != param ||
                       !isSameState && !containExcludeState && higherPriority);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 13
0
 protected virtual void OnRelease(GUnit unit, ObjectStateData stateData)
 {
 }
Ejemplo n.º 14
0
 protected virtual void OnFinish(GUnit unit, ObjectStateData stateData)
 {
 }
Ejemplo n.º 15
0
 protected virtual void OnStop(GUnit unit, ObjectStateData stateData)
 {
 }
Ejemplo n.º 16
0
 protected override void OnFinish(GUnit unit, ObjectStateData stateData)
 {
     OnStop(unit, stateData);
 }
Ejemplo n.º 17
0
 public virtual bool CanUpdate(GUnit unit, ObjectStateProcessData processData, ObjectStateData stateData, Vector3 param)
 {
     return(true);
 }