/// <summary>
        /// 更新
        /// </summary>
        public void Update()
        {
#if UNITY_EDITOR
            if (isDisposed == true)
            {
                Debug.LogWarning("すでにDisposeが呼ばれている。");
                return;
            }
#endif
            if (stateObject.IsBegan == false)
            {
                stateObject.OnBegin();
            }

            if (stateObject.IsStart == false)
            {
                stateObject.OnStart();
            }

            stateObject.OnUpdate();

            if (isRequestState == true)
            {
                CurrentTrigger = requestState;
                stateObject.OnStop();
                stateObject    = GetStateObject(CurrentTrigger);
                isRequestState = false;

                if (OnChangeState != null)
                {
                    OnChangeState.Invoke();
                }
            }
        }
        private void OnStartState(STATE_ID stateID)
        {
            if (_debug)
            {
                Debug.Log($"{_owner.name}.FSM.OnStartState.Entry current:{CurrentStateID}, new:{stateID}, wait:{_waitQueue.ToStringCollection()}", _owner);
            }

            if (_stateInstance.TryGetValue(stateID, out TSTATE state) == false)
            {
                Debug.LogError($"{_owner.name}.FSM.OnStartState(StateWithParam:'{stateID}') state is not found", _owner);
                return;
            }

            if (state.Equals(CurrentState))
            {
                return;
            }

            if (_debug)
            {
                Debug.Log($"{_owner.name}.FSM.OnStartState.Execute current:{CurrentStateID}, new:{stateID}, wait:{_waitQueue.ToStringCollection()}", _owner);
            }

            CurrentState?.OnChangeState(state);
            state.OnAwake();
            CurrentState      = state;
            _currentStateID   = stateID;
            _currentCoroutine = _owner.StartCoroutine(StateCoroutine());
            OnChangeState?.Invoke(stateID, CurrentState);
        }
Beispiel #3
0
        // Update is called once per frame
        void Update()
        {
            if (Lights == null)
            {
                return;
            }

            //Browse the list of lights
            for (int i = 0; i < Lights.Count; ++i)
            {
                IsOnShadow = !IsOnLight(Lights[i]);
                if (!IsOnShadow)
                {
                    break;
                }
            }

            //Call Events
            if (_lastValue != IsOnShadow)
            {
                OnChangeState.Invoke(IsOnShadow);
            }
            if (IsOnShadow)
            {
                OnEnterShadow.Invoke();
            }
            else
            {
                OnExitShadow.Invoke();
            }

            _lastValue = IsOnShadow;
        }
    /// <summary>
    /// Method responsible for changing to a specific state
    /// </summary>
    /// <param name="wantedState">Specific state to change to</param>
    public void ChangeToState(short wantedState)
    {
        //if (isPlaying) return;
        firstStateChange = true;

        State = wantedState;
        PlayAnimation();
        OnChangeState?.Invoke(this, State);
    }
        public void ChangeClientState(ClientState newState)
        {
            if (PlayerTransformSync.LocalInstance == null || QSBPlayerManager.LocalPlayer.State == newState)
            {
                return;
            }

            QSBPlayerManager.LocalPlayer.State = newState;
            OnChangeState?.Invoke(newState);
        }
Beispiel #6
0
        public void ChangeServerState(ServerState newState)
        {
            if (_currentState == newState)
            {
                return;
            }

            _currentState = newState;
            OnChangeState?.Invoke(newState);
        }
Beispiel #7
0
        public void EnableBuffParam(BuffParamKind _kind, Dictionary <BasePartsData, int> _value, bool _enable, UnitCtrl _source, bool _isBuff, bool _additional)
        {
            eStateIconType      bufficon;
            BuffDebuffConstData buffDebuffConstData = new BuffDebuffConstData(0, 0);

            if (BUFF_DEBUFF_ICON_DIC.TryGetValue(_kind, out BuffDebuffConstData buffDebuffConstData1))
            {
                buffDebuffConstData = buffDebuffConstData1;
            }
            else
            {
                string word = UnitName + "的BUFF图标种类出错,未找到种类为" + _kind.GetDescription() + "的图标!";
                BattleUIManager.Instance.LogMessage(word, eLogMessageType.ERROR, IsOther);
            }
            if (_isBuff)
            {
                bufficon = buffDebuffConstData.BuffIcon;
            }
            else
            {
                bufficon = buffDebuffConstData.DebuffIcon;
            }
            OnChangeState?.Invoke(this, bufficon, _enable);
            if (bufficon != eStateIconType.NONE)
            {
                if (_enable)
                {
                    if (_isBuff)
                    {
                        buffCounter++;
                    }
                    else
                    {
                        debuffCounter++;
                    }
                }
                else
                {
                    if (_isBuff)
                    {
                        buffCounter--;
                    }
                    else
                    {
                        debuffCounter--;
                    }
                }
            }
            foreach (BasePartsData a in _value.Keys)
            {
                a.SetBuffDebuff(_enable, _value[a], _kind, _source, null, _additional);
            }
        }
Beispiel #8
0
        public override void SetState(State newState)
        {
            if (gameObject.activeInHierarchy == false)
            {
                return;
            }

            try
            {
                base.SetState(newState);
                CurrentPlayerState = newState;
                OnChangeState?.Invoke(_state);
            }
            catch (MissingReferenceException err)
            {
                print(err);
                return;
            }
        }
Beispiel #9
0
 public void CureAllAbnormalState()
 {
     for (int i = 1; i <= 48; i++)
     {
         if (IsAbnormalState((eAbnormalState)i))
         {
             EnableAbnormalState((eAbnormalState)i, false);
         }
     }
     for (int i = LifeStealQueueList.Count - 1; i >= 0; i--)
     {
         LifeStealQueueList[i].Dequeue();
         if (LifeStealQueueList[i].Count == 0)
         {
             LifeStealQueueList.RemoveAt(i);
             OnChangeState?.Invoke(this, eStateIconType.BUFF_ADD_LIFE_STEAL, false);
         }
     }
     //处理反击字典
     //处理knightGuardDatas
     DamageSealDataDictionary.Clear();
     DamageOnceOwnerSealDateDictionary.Clear();
     DamageOwnerSealDataDictionary.Clear();
 }
Beispiel #10
0
        public TemperatureDevice()
        {
            IsReading = true;

            ModbusDeviceStates = new StateMachine <TemperatureDeviceState, TemperatureDeviceEdge>(TemperatureDeviceState.Idle);
            ModbusDeviceStates.Configure(TemperatureDeviceState.CheckConnection)
            .OnEntry(() => Task.Run(() => OnChangeState?.Invoke(this, TemperatureDeviceState.CheckConnection)))
            .OnEntry(Connect)
            .Permit(TemperatureDeviceEdge.ConnectionInvalid, TemperatureDeviceState.FindPortName)
            .Permit(TemperatureDeviceEdge.ReadStart, TemperatureDeviceState.FindPortName)
            .Permit(TemperatureDeviceEdge.ConnectionValid, TemperatureDeviceState.Read)
            .Permit(TemperatureDeviceEdge.ReadStop, TemperatureDeviceState.StopRead)
            .Permit(TemperatureDeviceEdge.ToIdle, TemperatureDeviceState.Idle);
            ModbusDeviceStates.Configure(TemperatureDeviceState.FindPortName)
            .OnEntry(() => Task.Run(() => OnChangeState?.Invoke(this, TemperatureDeviceState.FindPortName)))
            .OnEntry(async() => await FindPortNameAsync())
            .PermitReentry(TemperatureDeviceEdge.PortNameNotFounded)
            .Permit(TemperatureDeviceEdge.PortNameFounded, TemperatureDeviceState.CheckConnection)
            .Permit(TemperatureDeviceEdge.ReadStop, TemperatureDeviceState.StopRead)
            .Permit(TemperatureDeviceEdge.ToIdle, TemperatureDeviceState.Idle);
            ModbusDeviceStates.Configure(TemperatureDeviceState.Read)
            .OnEntry(() => Task.Run(() => OnChangeState?.Invoke(this, TemperatureDeviceState.Read)))
            .OnEntry(async() => await ReadAsync())
            .PermitReentry(TemperatureDeviceEdge.ReadSuccess)
            .Permit(TemperatureDeviceEdge.ReadError, TemperatureDeviceState.CheckConnection)
            .Permit(TemperatureDeviceEdge.ReadStop, TemperatureDeviceState.StopRead)
            .Permit(TemperatureDeviceEdge.ToIdle, TemperatureDeviceState.Idle);
            ModbusDeviceStates.Configure(TemperatureDeviceState.StopRead)
            .OnEntry(() => Task.Run(() => OnChangeState?.Invoke(this, TemperatureDeviceState.StopRead)))
            .Permit(TemperatureDeviceEdge.ReadStart, TemperatureDeviceState.Read)
            .Permit(TemperatureDeviceEdge.ToIdle, TemperatureDeviceState.Idle);
            ModbusDeviceStates.Configure(TemperatureDeviceState.Idle)
            .OnEntry(() => Task.Run(() => OnChangeState?.Invoke(this, TemperatureDeviceState.Idle)))
            .Permit(TemperatureDeviceEdge.ReadStart, TemperatureDeviceState.Read)
            .PermitReentry(TemperatureDeviceEdge.ToIdle);
        }
Beispiel #11
0
        private void EnableAbnormalState(eAbnormalState abnormalState, bool enable, bool reduceEnergy = false, bool _switch = false)
        {
            eAbnormalStateCategory    category     = GetAbnormalStateCategory(abnormalState);
            AbnormalStateCategoryData categoryData = abnormalStateCategoryDataDictionary[category];

            if (!enable)
            {
                //销毁特效
                categoryData.MainValue = 0;
                categoryData.Time      = 0;
                categoryData.Duration  = 0;
            }
            categoryData.enable            = enable;
            m_abnormalState[abnormalState] = enable;
            switch (abnormalState)
            {
            case eAbnormalState.HASTE:
                if (enable)
                {
                    if (actionState == eActionState.IDLE)
                    {
                        spineController.SetTimeScale(timeScale * 2.0f);
                        break;
                    }
                }
                else if (!IsUnableActionState() && !isPause)
                {
                    spineController.Resume();
                }
                break;

            case eAbnormalState.POISON:
            case eAbnormalState.BURN:
            case eAbnormalState.CURSE:
            case eAbnormalState.NO_EFFECT_SLIP_DAMAGE:
            case eAbnormalState.VENOM:
            case eAbnormalState.HEX:
            case eAbnormalState.COMPENSATION:
                if (enable)
                {
                    slipDamageIdDictionary[category]++;
                    StartCoroutine(UpdateSlipDamage(category, slipDamageIdDictionary[category]));
                }
                break;

            case eAbnormalState.SLOW:
                if (enable)
                {
                    //改变颜色
                    if (actionState == eActionState.IDLE)
                    {
                        spineController.SetTimeScale(timeScale * 0.5f);
                    }
                }
                else
                {
                    //改变颜色
                    if (!IsUnableActionState())
                    {
                        spineController.Resume();
                    }
                }
                break;

            case eAbnormalState.PARALYSIS:
            case eAbnormalState.FREEZE:
            case eAbnormalState.CHAINED:
            case eAbnormalState.SLEEP:
            case eAbnormalState.STUN:
            case eAbnormalState.DETAIN:
            case eAbnormalState.FAINT:
                if (enable)
                {
                    if (actionState != eActionState.DAMAGE)
                    {
                        SetState(eActionState.DAMAGE, 0);
                        break;
                    }
                }
                else if (!IsUnableActionState() && !_switch)
                {
                    SetMotionResume();
                }
                break;

            case eAbnormalState.CONVERT:
            case eAbnormalState.CONFUSION:
                SetLeftDirection(IsNearestEnemyLeft());
                if (actionState == eActionState.ATK || actionState == eActionState.IDLE || actionState == eActionState.SKILL1 || actionState == eActionState.SKILL)
                {
                    cancalByCovert          = true;
                    idleStartAfterWaitFrame = m_fCastTimer <= DeltaTimeForPause;
                }
                if (Hp >= 1 && !IsUnableActionState() && actionState != eActionState.DAMAGE)
                {
                    SetState(eActionState.IDLE, 0);
                }
                break;

            case eAbnormalState.CONTINUOUS_ATTACK_NEARBY:
                Debug.LogError("咕咕咕!");
                break;

            case eAbnormalState.DECOY:
                Debug.LogError("咕咕咕!");
                break;

            case eAbnormalState.STONE:
                if (enable)
                {
                    if (actionState != eActionState.DAMAGE)
                    {
                        SetState(eActionState.DAMAGE, 0);
                    }
                    //设置石化颜色
                }
                else
                {
                    if (!IsUnableActionState() && !_switch)
                    {
                        SetMotionResume();
                    }
                    //设置石化颜色
                }
                break;

            case eAbnormalState.REGENERATION:
                if (enable)
                {
                    currentHpRegeneId++;
                    StartCoroutine(UpdateHpRegeneration(currentHpRegeneId));
                }
                break;

            case eAbnormalState.TP_REGENERATION:
                if (enable)
                {
                    currentTpRegeneId++;
                    StartCoroutine(UpdateTpRegeneration(currentHpRegeneId));
                }
                break;

            default:
                break;
            }
            OnChangeState?.Invoke(this, ABNORMAL_CONST_DATA[abnormalState].IconType, enable);
            if (!enable && !_switch)
            {
                //Elements_Battle_BattleManager__RestartAbnormalStateField(v43, this, abnormalState, 0LL)
            }
        }
Beispiel #12
0
        private void _FixedUpdate()
        {
            if (Lights == null || targets == null || targets.Count == 0)
            {
                return;
            }
            ShadowTarget current_st;
            int          nbTargetOnShadow = 0;

            //Browse the list of target
            for (int i = 0; i < targets.Count; ++i)
            {
                current_st            = targets[i];
                current_st.IsOnShadow = !IsOnLight(Lights, current_st.Target.position);

                //Call Events
                if (current_st.LastIsOnShadowEstado != current_st.IsOnShadowEstado)
                {
                    current_st.OnChangeState.Invoke(current_st.IsOnShadow);
                    if (current_st.IsOnShadow)
                    {
                        current_st.OnEnterShadow.Invoke();
                    }
                    else
                    {
                        current_st.OnExitShadow.Invoke();
                    }
                }
                if (current_st.IsOnShadow)
                {
                    current_st.OnShadow.Invoke();
                }
                else
                {
                    current_st.OutShadow.Invoke();
                }

                current_st.Last_IsOnShadow = current_st.IsOnShadow;

                if (current_st.IsOnShadow)
                {
                    nbTargetOnShadow++;
                }
            }

            IsOnShadow = (nbTargetOnShadow >= minimumNbTargetOnShadow);
            //Call Events
            if (LastIsOnShadowEstado != IsOnShadowEstado)
            {
                OnChangeState.Invoke(IsOnShadow);
                if (IsOnShadow)
                {
                    OnEnterShadow.Invoke();
                }
                else
                {
                    OnExitShadow.Invoke();
                }
            }
            if (IsOnShadow)
            {
                OnShadow.Invoke();
            }
            else
            {
                OutShadow.Invoke();
            }

            Last_IsOnShadow = IsOnShadow;
        }
        public bool Download()
        {
            try
            {
                string torrent = DownloadTorrentFile(Settings.ServerId);

                if (torrent != null)
                {
                    MonoTorrent.Common.Torrent decoded = null;

                    try
                    {
                        decoded = MonoTorrent.Common.Torrent.Load(torrent);
                    }
                    catch (Exception decEx)
                    {
                        decEx.ToLog(LogLevel.Error);

                        Stop();

                        return(false);
                    }

                    External.AppendManager(decoded, Settings.DownloadPath, new TorrentSettings(5, 100, Settings.MaxDownloadSpeed, Settings.MaxUploadSpeed));
                    if (External.TryGetFastResume(Settings.GetResumeFile()))
                    {
                        if (External.FastResume.ContainsKey(decoded.InfoHash.ToHex()))
                        {
                            External.Manager.LoadFastResume(new FastResume((BEncodedDictionary)External.FastResume[decoded.InfoHash.ToHex()]));
                        }
                    }

                    External.Engine.Register(External.Manager);
                    External.Manager.PeersFound += OnPeersFounded;

                    External.Manager.StartAsync().Wait();

                    var thread = new Thread(() =>
                    {
                        while (External.Manager.State != TorrentState.Stopped)
                        {
                            var data = new TorrentData();
                            data.Build(
                                FileUtils.FormatByte(External.Engine.TotalDownloadSpeed),
                                FileUtils.FormatByte(External.Engine.DiskManager.TotalRead),
                                FileUtils.FormatByte(External.Engine.DiskManager.TotalWritten),
                                FileUtils.FormatByte(External.Engine.DiskManager.WriteRate),
                                (int)External.Manager.Progress);

                            OnChangeState?.Invoke(data);

                            if (data.Progress == 100)
                            {
                                break;
                            }

                            Thread.Sleep(500);
                        }

                        DownloadStopped();
                    });

                    thread.Start();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                ex.ToLog(LogLevel.Error);

                return(false);
            }

            return(false);
        }