コード例 #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
ファイル: DesStateMachine.cs プロジェクト: yazici/Glitched
    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
ファイル: Interpreter.cs プロジェクト: 9vag/Libelium
        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
ファイル: Interpreter.cs プロジェクト: 9vag/Libelium
        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
ファイル: Interpreter.cs プロジェクト: 9vag/Libelium
        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
ファイル: Interpreter.cs プロジェクト: 9vag/Libelium
        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
ファイル: Interpreter.cs プロジェクト: 9vag/Libelium
        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
ファイル: Interpreter.cs プロジェクト: kicasta/Libelium
        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
ファイル: Interpreter.cs プロジェクト: kicasta/Libelium
        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
ファイル: Interpreter.cs プロジェクト: kicasta/Libelium
        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
ファイル: Interpreter.cs プロジェクト: kicasta/Libelium
        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
ファイル: Interpreter.cs プロジェクト: kicasta/Libelium
        private void Init()
        {
            state = State.Head1;
            val = 0f;
            pow = 1;
            fSt = FloatState.Integer;

            temp = 0f;
            hum = 0f;
            coVal = 0f;
            co2Val = 0f;
        }
コード例 #19
0
ファイル: Interpreter.cs プロジェクト: kicasta/Libelium
        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
ファイル: Interpreter.cs プロジェクト: 9vag/Libelium
        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);
        }