예제 #1
0
        private bool CanCollideWith(CollisionAbility other)
        {
            if (!HasInit || other == null)
            {
                return(false);
            }

            bool passTypeTest = UseTypeTest ?
                                GamePlay.instance.collisionManager.CanPassTypeTest(this, other) : true;

            if (passTypeTest)
            {
                bool passExclusiveTest = UseExclusiveTest ?
                                         GamePlay.instance.collisionManager.CanPassExclusiveTest(this, other) : true;

                if (passExclusiveTest)
                {
                    return(true);
                }
                else
                {
                    ZLog.log(owner.name, "fails Exclusive Test with:", other.owner.name);
                }
            }
            else
            {
                ZLog.log(owner.name, "fails Type Test with type:", other.Type);
            }
            return(false);
        }
        private void FinishOne()
        {
            //ZLog.log("finishOne, rest action =", _actionSequence.Count.ToString());
            ZLog.log($"[{GetInstanceID().ToString()}] finishOne, rest action = { _actionSequence.Count.ToString()}");

            DoNextAction();
        }
예제 #3
0
        public BaseSerializableData load(string tag, DataLocation location)
        {
            BaseSerializableData data = null;

            if (location == DataLocation.memory)
            {
                if (!readCache(tag, out data))
                {
                    ZLog.log("TODO: cache miss, read from file");
                }
            }
            else if (location == DataLocation.local)
            {
                if (!readFile(_persistPath, tag, out data))
                {
                    ZLog.warn("TODO: file miss, read from net");
                }
            }
            else if (location == DataLocation.remote)
            {
                ZLog.error("not yet");
            }

            return(data);
        }
예제 #4
0
        public override void OnInspectorGUI()
        {
            CollisionConfig config = target as CollisionConfig;

            GUILayout.Label("Back To Empty state");
            if (GUILayout.Button("init/reset"))
            {
                config.init();
                ZLog.log(config.ToString());
            }

            GUILayout.Space(20);
            GUILayout.Label("Sync if you change ColliderType");
            if (GUILayout.Button("Refresh"))
            {
                config.Refresh();
                ZLog.log(config.ToString());
                valueChange = true;
            }

            GUILayout.Space(20);
            if (valueChange)
            {
                if (GUILayout.Button("Value changed, Click or Press Ctrl + S", GUILayout.Height(50)))
                {
                    valueChange = false;
                    AssetDatabase.SaveAssets();
                }
            }

            show(config);

            EditorUtility.SetDirty(config); //This is very important
        }
        private void Enqueue(ActionItem item)
        {
            IsFinshed = false;

            ZLog.log($"[{GetInstanceID().ToString()}] dequeue:{item.ToString()}");

            _actionSequence.Enqueue(item);
        }
        private void DoNextAction()
        {
            if (_actionSequence.Count > 0)
            {
                ActionItem item = _actionSequence.Peek();
                _actionSequence.Dequeue();

                ZLog.log($"[{GetInstanceID().ToString()}] dequeue:{item.ToString()}");

                // exceptions may raise, but ActionSequence should keep operating.
                try
                {
                    if (item.funcWithParamAndCallBack != null)
                    {
                        item.funcWithParamAndCallBack(item.param, item.func);
                        FinishOne();
                    }
                    else if (item.funcWithParam != null)
                    {
                        item.funcWithParam(item.param);
                        FinishOne();
                    }
                    else if (item.func != null)
                    {
                        item.func();
                        FinishOne();
                    }
                    else if (item.coroutine != null)
                    {
                        StartCoroutine(DoItemCoroutine(item));
                    }
                    else if (item.yieldInstruction != null)
                    {
                        StartCoroutine(DoItemYieldInstruction(item));
                    }
                    else if (item.customYield != null)
                    {
                        StartCoroutine(DoItemCustomYieldInstruction(item));
                    }
                }
                catch (Exception e)
                {
                    ZLog.warn(e.ToString());
                    OnFinished?.Invoke(this);
                }
            }
            else
            {
                OnFinished?.Invoke(this);
            }
        }
예제 #7
0
        /// <summary>
        /// change state immediately with some data
        /// </summary>
        public void ChangeState(BaseState <T, M> newState, object param = null)
        {
            if (!IsRunning)
            {
                ZLog.error("Cannot change state, FSM is not runnning");
                return;
            }

            if (newState == null)
            {
                ZLog.error(_owner, "cannot change state to null");
                return;
            }
            if (_lastSate == null || _curState == null)
            {
                ZLog.error(_owner, "Fatal error: _lastSate || _curState = null, newState=", newState);
                return;
            }

            if (newState.GetType().Equals(_curState.GetType()))
            {
                ZLog.warn(_owner, "cannot change to the same state:", _curState);
                return;
            }

            if (_owner == null)
            {
                ZLog.error("_owner = null");
                return;
            }

            _lastSate = _curState;
            _curState = newState;

            ZLog.log(_owner, _lastSate, _curState);

            _lastSate.Exit(_owner);
            _curState.Enter(_owner, param);
        }