示例#1
0
        public OneState GetProportionState()
        {
            if (((IReadOnlyList <OneState>) this.nextState).IsNullOrEmpty <OneState>())
            {
                return(new OneState());
            }
            float num1 = 0.0f;

            this.nextStateTemp.Clear();
            this.nextStateTemp.AddRange((IEnumerable <OneState>) this.nextState);
            for (int index = 0; index < this.nextStateTemp.Count; ++index)
            {
                num1 += this.nextStateTemp[index].proportion;
                OneState oneState = this.nextStateTemp[index];
                oneState.proportion       = num1;
                this.nextStateTemp[index] = oneState;
            }
            float num2 = Random.Range(0.0f, num1);

            for (int index = 0; index < this.nextStateTemp.Count; ++index)
            {
                if ((double)num2 <= (double)this.nextStateTemp[index].proportion)
                {
                    return(this.nextStateTemp[index]);
                }
            }
            return(new OneState());
        }
示例#2
0
        public OneState GetNonOverlapState()
        {
            if (((IReadOnlyList <OneState>) this.nextState).IsNullOrEmpty <OneState>())
            {
                return(new OneState());
            }
            int      index    = Random.Range(0, this.Count);
            OneState oneState = this.nextState[index];

            this.nextState.RemoveAt(index);
            return(oneState);
        }
示例#3
0
        public void AddNextState(OneState _state)
        {
            if (_state.state == AnimalState.None)
            {
                return;
            }
            OneState oneState = this.nextState.Find((Predicate <OneState>)(x => x.state == _state.state));

            if (oneState.state == AnimalState.None)
            {
                this.nextState.Add(_state);
            }
            else
            {
                this.nextState[this.nextState.IndexOf(oneState)] = _state;
            }
        }
示例#4
0
 public void RemoveNextState(OneState _state)
 {
     this.nextState.RemoveAll((Predicate <OneState>)(x => x.Equal(_state)));
 }
示例#5
0
 protected bool SetCurrentState(OneState _state)
 {
     return(this.SetCurrentState(_state.state));
 }