Пример #1
0
    public RangedFloatState(float initialValue, float minValue, float maxValue)
    {
        _max   = new FloatState(maxValue);
        _min   = new FloatState(minValue);
        _value = new FloatState(Clamp(initialValue, _min.Value, _max.Value));

        Init();
    }
Пример #2
0
    private void Awake()
    {
        desScript = GetComponent <DesScript>();

        floatState       = new FloatState(this);
        lightBulbState   = new LightBulbAttackState(this);
        dieState         = new DieAttackState(this);
        createLevelState = new CreateLevelAttackState(this);
    }
Пример #3
0
    private IEnumerator Wait()
    {
        floatState = FloatState.idle;

        float waitTime = Random.Range(minWaitTime, maxWaitTime);

        yield return(new WaitForSeconds(waitTime));

        SetTargetPosition();
    }
Пример #4
0
        private void Init()
        {
            state = State.Head1;
            val   = 0f;
            pow   = 1;
            fSt   = FloatState.Integer;

            temp   = 0f;
            hum    = 0f;
            coVal  = 0f;
            co2Val = 0f;
        }
Пример #5
0
    private void SetTargetPosition()
    {
        targetPosition = new Vector3(
            originPosition.x + Random.Range(-maxFloatDistance, maxFloatDistance),
            originPosition.y + Random.Range(-maxFloatDistance, maxFloatDistance),
            originPosition.z + Random.Range(-maxFloatDistance, maxFloatDistance)
            );

        SetupSingleAxisMovement();

        RestrainAxes();

        floatState = FloatState.floating;
    }
Пример #6
0
 private void OnTriggerEnter(Collider other)
 {
     Debug.Log("Trigger for whispers and chilling!");
     stayCount = 0f;
     if (!whispered)
     {
         audioData.Play(0);
         mystate = FloatState.WHISPERING;
     }
     else if (!chilled)
     {
         audioData.PlayOneShot(chill);
         mystate = FloatState.CHILLING;
     }
 }
Пример #7
0
 void InitPercentage()
 {
     if (_percentageInited)
     {
         return;
     }
     _percentageInited = true;
     if (_percentage == null)
     {
         _percentage = new FloatState(0);
     }
     _min.OnChange.Register(UpdatePercentage);
     _max.OnChange.Register(UpdatePercentage);
     _value.OnChange.Register(UpdatePercentage);
     UpdatePercentage();
 }
Пример #8
0
        private void Temperature(string buffer)
        {
            state = State.Temp;

            bool done = ParseFloat(buffer);

            if (done)
            {
                fSt  = FloatState.Integer;
                temp = val;
                val  = 0f;
                pow  = 1;

                pos++;
                Humidity(buffer);
            }
        }
Пример #9
0
        private void Humidity(string buffer)
        {
            state = State.Hum;

            bool done = ParseFloat(buffer);

            if (done)
            {
                fSt = FloatState.Integer;
                hum = val;
                val = 0f;
                pow = 1;

                pos++;
                CO(buffer);
            }
        }
Пример #10
0
        private void CO(string buffer)
        {
            state = State.CO;

            bool done = ParseFloat(buffer);

            if (done)
            {
                fSt   = FloatState.Integer;
                coVal = val;
                val   = 0f;
                pow   = 1;

                pos++;
                CO2(buffer);
            }
        }
Пример #11
0
        private void CO2(string buffer)
        {
            state = State.CO2;

            bool done = ParseFloat(buffer);

            if (done)
            {
                fSt    = FloatState.Integer;
                co2Val = val;
                val    = 0f;
                pow    = 1;

                current = new Reading(temp, hum, coVal, co2Val);
                pos++;
                S(buffer);
            }
        }
Пример #12
0
        private void CO2(string buffer)
        {
            state = State.CO2;

            bool done = ParseFloat(buffer);

            if (done)
            {
                fSt = FloatState.Integer;
                co2Val = val;
                val = 0f;
                pow = 1;

                current = new Reading(temp, hum, coVal, co2Val);
                pos++;
                S(buffer);
            }
        }
Пример #13
0
 private void OnTriggerExit(Collider other)
 {
     audioData.Stop();
     mystate = FloatState.NONE;
 }
Пример #14
0
 // Start is called before the first frame update
 void Start()
 {
     audioData = GetComponent <AudioSource>();
     mystate   = FloatState.NONE;
 }
Пример #15
0
        private void CO(string buffer)
        {
            state = State.CO;

            bool done = ParseFloat(buffer);

            if (done)
            {
                fSt = FloatState.Integer;
                coVal = val;
                val = 0f;
                pow = 1;

                pos++;
                CO2(buffer);
            }
        }
Пример #16
0
        private void Temperature(string buffer)
        {
            state = State.Temp;

            bool done = ParseFloat(buffer);

            if (done)
            {
                fSt = FloatState.Integer;
                temp = val;
                val = 0f;
                pow = 1;

                pos++;
                Humidity(buffer);
            }
        }
Пример #17
0
        private bool ParseFloat(string buffer)
        {
            if (pos == buffer.Length)
                return false;

            //In case the next string begins with # ending the previous data string
            if (buffer[pos] == '#')
            {
                pos++;
                return true;
            }

            bool neg = false;

            if (buffer[pos] == '-')
            {
                neg = true;
                pos++;
            }

            if (fSt == FloatState.Integer)
            {
                while (buffer[pos] != '.')
                {
                    val = val * 10 + int.Parse(buffer[pos].ToString());

                    pos++;
                    if (pos == buffer.Length)
                        return false;
                }
            }

            fSt = FloatState.Decimal;

            pos++;
            if (pos == buffer.Length)
                return false;

            while (buffer[pos] != '#')
            {
                val = val + (float)(int.Parse(buffer[pos].ToString()) * Math.Pow(10, -pow));

                pow++;

                pos++;
                if (pos == buffer.Length)
                    return false;
            }

            if (neg)
                val *= -1;

            return true;
        }
Пример #18
0
        private void Init()
        {
            state = State.Head1;
            val = 0f;
            pow = 1;
            fSt = FloatState.Integer;

            temp = 0f;
            hum = 0f;
            coVal = 0f;
            co2Val = 0f;
        }
Пример #19
0
        private void Humidity(string buffer)
        {
            state = State.Hum;

            bool done = ParseFloat(buffer);

            if (done)
            {
                fSt = FloatState.Integer;
                hum = val;
                val = 0f;
                pow = 1;

                pos++;
                CO(buffer);
            }
        }
Пример #20
0
        private bool ParseFloat(string buffer)
        {
            if (pos == buffer.Length)
            {
                return(false);
            }

            //In case the next string begins with # ending the previous data string
            if (buffer[pos] == '#')
            {
                pos++;
                return(true);
            }

            bool neg = false;

            if (buffer[pos] == '-')
            {
                neg = true;
                pos++;
            }

            if (fSt == FloatState.Integer)
            {
                while (buffer[pos] != '.')
                {
                    val = val * 10 + int.Parse(buffer[pos].ToString());

                    pos++;
                    if (pos == buffer.Length)
                    {
                        return(false);
                    }
                }
            }

            fSt = FloatState.Decimal;

            pos++;
            if (pos == buffer.Length)
            {
                return(false);
            }

            while (buffer[pos] != '#')
            {
                val = val + (float)(int.Parse(buffer[pos].ToString()) * Math.Pow(10, -pow));

                pow++;

                pos++;
                if (pos == buffer.Length)
                {
                    return(false);
                }
            }

            if (neg)
            {
                val *= -1;
            }

            return(true);
        }