コード例 #1
0
            public override void UpdateDelta(float delta)
            {
                switch (State)
                {
                case (BreathState.Start):
                    StartTime -= delta;
                    if (StartTime < 0)
                    {
                        State = BreathState.Breath;
                    }
                    break;

                case (BreathState.Breath):
                    BiteTime -= delta;
                    if (BiteTime < 0)
                    {
                        State = BreathState.End;
                    }
                    break;

                case (BreathState.End):
                    EndTime -= delta;
                    if (EndTime < 0)
                    {
                        Snake.ResetState();
                    }
                    break;
                }
            }
コード例 #2
0
        public Player()
        {
            _breathState        = BreathState.Breathing;
            _breathTimer        = new Timer();
            _kevlarMax          = 3;
            _kevlar             = 0;
            _healthMax          = 100;
            _health             = _healthMax;
            _scoreMultiplier    = 1;
            _comboHeadshot      = 0;
            _stats              = new SessionStats();
            contracts           = new List <Contract>();
            _weapon             = new Weapon("P250", 10);
            _heartbeat          = Resources.heartbeat.CreateInstance();
            _heartbeat.Volume   = Options.Config.SoundVolume;
            _heartbeat.IsLooped = true;

            _breathTimer.addAction(TimerDirection.Forward, 2501, TimeoutBehaviour.None, () =>
            {
                Resources.outbreath.Play(Options.Config.SoundVolume, 0f, 0f);
                _breathState = BreathState.ForceRecovery;
                GameMain.hud.crosshair.setSway(true);
                _breathTimer.setDuration(2500);
                _breathTimer.Reverse();
            });
            _breathTimer.addAction(TimerDirection.Backward, -1, TimeoutBehaviour.Reset, () =>
            {
                _breathState = BreathState.Breathing;
                _breathTimer.Reverse();
            });
        }
コード例 #3
0
        private IEnumerator Breathe(float duration, BreathState state)
        {
            SetState(state);

            for (float i = 0; i <= 1.0F; i += Time.deltaTime / duration)
            {
                SetPositionValue(i, state);
                yield return(null);
            }

            SetPositionValue(1, state);
        }
コード例 #4
0
        private void OnSolverStateChanged(BreathState state)
        {
            switch (state)
            {
            case BreathState.Inhale:
                _curve = CurveIn;
                break;

            case BreathState.Exahle:
                _curve = CurveOut;
                break;
            }
        }
コード例 #5
0
        /// The position is measured from 0 to 1, where 0 to 1 is Inhaling and 1 > 0 is Exhaling
        private void SetPositionValue(float value, BreathState state)
        {
            switch (state)
            {
            case BreathState.Exahle:
                _currentPositionValue = Mathf.Lerp(1, 0, value);
                break;

            case BreathState.Inhale:
                _currentPositionValue = value;
                break;
            }

            OnValueChanged.InvokeSafe(_currentPositionValue);
        }
コード例 #6
0
    void setBreathValue()
    {
        if (points.Count > 0 && breathPoints.Count > 1)
        {
            BreathPoint p  = breathPoints [breathPoints.Count - 1];
            BreathPoint pp = breathPoints [breathPoints.Count - 2];

            float breathDiff = points [points.Count - 1].y - p.value;
            float timeDiff   = p.time - pp.time;

            float prevPointY = points [points.Count - breathLineDistance].y;
            float curPointY  = points [points.Count - 1].y;
            float lineDiff   = curPointY - prevPointY;

            if (Mathf.Abs(breathDiff) < movementTreshold && Mathf.Abs(timeDiff) > timeTreshold)
            {
                if (lineDiff > 0 && Mathf.Abs(lineDiff) > breathLineTreshold)
                {
                    breathState = BreathState.BreathIn;
                    isBreathIn  = true;
                }
                else if (Mathf.Abs(lineDiff) > breathLineTreshold)
                {
                    breathState = BreathState.BreathOut;
                    isBreathIn  = false;
                }
                else if (isUp)
                {
                    breathState = BreathState.BreathInHold;
                    isBreathIn  = true;
                }
                else
                {
                    breathState = BreathState.BreathOutHold;
                    isBreathIn  = false;
                }
                breathValue = (1 - smoothBreathValue) * breathDiff + smoothBreathValue * breathValue;
            }
            else
            {
                // movement
                breathState = BreathState.Move;
            }

            UpdateBreathStateChange();
        }
    }
コード例 #7
0
 void UpdateBreathStateChange()
 {
     if (breathStatePrev != breathState)
     {
         onBreathStateEvent.Invoke(breathState);
     }
     if (isBreathInPrev != isBreathIn)
     {
         if (breathState == BreathState.BreathIn || breathState == BreathState.BreathInHold)
         {
             onBreathInEvent.Invoke();
         }
         else
         {
             onBreathOutEvent.Invoke();
         }
     }
     breathStatePrev = breathState;
     isBreathInPrev  = isBreathIn;
 }
コード例 #8
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("HP: {0}\r\n", HP);
            sb.AppendFormat("MP: {0}\r\n", MP);
            sb.AppendFormat("EXP Percentage: {0}%\r\n", EXPPercentage.ToString("N2"));
            sb.AppendFormat("Alert HP: {0}\r\n", AlertHP);
            sb.AppendFormat("Alert MP: {0}\r\n", AlertMP);
            sb.AppendFormat("Position: X: {0} Y: {1}\r\n", Position.X, Position.Y);
            sb.AppendFormat("Teleport: {0}\r\n", Teleport);
            sb.AppendFormat("Teleport Position: X: {0} Y: {1}\r\n", TeleportPosition.X, TeleportPosition.Y);
            sb.AppendFormat("Mouse Animation: {0}\r\n", MouseAnimation);
            sb.AppendFormat("Mouse Location: X: {0} Y: {1}\r\n", MouseLocation.X, MouseLocation.Y);
            sb.AppendFormat("Watched ItemID: {0}\r\n", WatchedItemID);
            sb.AppendFormat("Attack Count: {0}\r\n", AttackCount);
            sb.AppendFormat("Buff Count: {0}\r\n", BuffCount);
            sb.AppendFormat("Morph: {0}\r\n", Morph);
            sb.AppendFormat("Breath Status: {0}\r\n", BreathState.ToString());
            sb.AppendFormat("Animation: {0}\r\n", CharacterAnimation);

            return(sb.ToString());
        }
コード例 #9
0
 public void SetState(BreathState state)
 {
     breathState = state;
 }
コード例 #10
0
 public void onBreathStateChange(BreathState state)
 {
     textBreathState.text = "BreathState: " + state.ToString();
 }
コード例 #11
0
 /// <summary>
 /// Updates the breath breathState based off sample window calculation.
 /// </summary>
 private void UpdateBreath()
 {
     // don't compare apps first reading
     if(previousReading != 0.0f)
     {
         // passes sensitivity threshold
         if(Mathf.Abs(previousReading - currentReading) > Sensitivity())
         {
             if(breathState == BreathState.In && (lengthT / 2) > breathStateChangeBuf)
             {
                 if(currentReading < previousReading)
                 {
                     breathState = BreathState.Out;
                     exhaled = true;
                 }
             }
             else if(breathState == BreathState.Out && lengthT > breathStateChangeBuf)
             {
                 if(currentReading > previousReading)
                     breathState = BreathState.In;
             }
         }
     }
 }
コード例 #12
0
 public void OnBreathStateChange(BreathState state)
 {
     breathState = state;
 }
コード例 #13
0
 private void SetState(BreathState state)
 {
     _state = state;
     OnStateChanged.InvokeSafe(_state);
 }
コード例 #14
0
 public void Update(GameTime gameTime, DeviceState state, DeviceState prevState)
 {
     //Breath management
     if (_breathState != BreathState.ForceRecovery && Options.Config.Bindings[GameAction.HoldBreath].IsControlDown(state))
     {
         if (_breathTimer.getDuration() == 0 || Options.Config.Bindings[GameAction.HoldBreath].IsControlPressed(state, prevState)) //First time
         {
             Resources.breath.Play(Options.Config.SoundVolume, 0f, 0f);
             _breathTimer.addMilliseconds(500);
             _heartbeat.Play();
         }
         if (!_breathTimer.isActive())
         {
             _breathTimer.Start();
         }
         if (_breathTimer.getDirection() != TimerDirection.Forward)
         {
             _breathTimer.Reverse();
         }
         _breathState = BreathState.Holding;
         GameMain.hud.crosshair.setSway(false);
     }
     else
     {
         if (_breathState != BreathState.ForceRecovery)
         {
             if (_breathTimer.getDirection() != TimerDirection.Backward)
             {
                 _breathTimer.Reverse();
             }
             _breathState = BreathState.Breathing;
             GameMain.hud.crosshair.setSway(true);
         }
         _heartbeat.Stop();
     }
     _breathTimer.Update(gameTime);
     //Weapon management
     if (Options.Config.Bindings[GameAction.Fire].IsControlPressed(state, prevState))
     {
         fire();
     }
     if (Options.Config.Bindings[GameAction.Reload].IsControlPressed(state, prevState))
     {
         _weapon.reload();
     }
     _weapon.Update(gameTime);
     if (contracts.Count > 0)
     {
         for (int i = contracts.Count - 1; i >= 0; i--)
         {
             if (contracts[i].inactive)
             {
                 contracts.RemoveAt(i);                                                                                //Clear obsolete contracts
             }
         }
     }
     if (_health <= 0)
     {
         _heartbeat.Stop(); //Clean heartbeat state
         GameMain.GameOver();
     }
     //Bomb Management
     foreach (var bomb in GameMain.bombs)
     {
         if (GameMain.hud.crosshair.checkCollision(bomb.getRectangle()))
         {
             if (Options.Config.Bindings[GameAction.Defuse].IsControlPressed(state, prevState))
             {
                 bomb.Defuse();                                                                      //User started defusing
             }
             else if (!Options.Config.Bindings[GameAction.Defuse].IsControlDown(state))
             {
                 bomb.Rearm();                                                              //Not holding, rearm
             }
             //Fall here if holding, nothing happens, let the timer go out
         }
         else
         {
             bomb.Rearm(); //None, rearm
         }
     }
     //HUD
     GameMain.hud.updateHealth(_healthMax, _health);
     GameMain.hud.updateKevlar(_kevlarMax, _kevlar);
     GameMain.hud.updateBreath(_breathTimer.getDuration());
     GameMain.hud.updateScoreMultiplier(_scoreMultiplier);
     GameMain.hud.updateScore(_stats.score);
     GameMain.hud.updateMagazine(_weapon.getMagazine());
     GameMain.hud.updateReload(_weapon);
 }