public void GetReward() { ProgressStates state = GetProgressState(); switch (state) { case ProgressStates.Progressable: if (userProgress < userPrizes.Count) { userProgress++; GiveReward(); } else if (userProgress == userPrizes.Count) { GiveReward(); } break; case ProgressStates.ResetProgress: userProgress = 1; GiveReward(); break; case ProgressStates.NoProgress: break; default: break; } SaveToDB(); }
protected override bool OnLevelChange(int level) { // level goes from 0 to 10000 but the number of colors divides 10000 // so we need to do that hack that maps level 10000 to level 0 int animationLevel = level == _maxLevel ? 0 : level; // state int stateForLevel = (int)(animationLevel / _maxLevePerCircle); System.Array a = Enum.GetValues(typeof(ProgressStates)); _currentState = (ProgressStates)a.GetValue(stateForLevel); // colors ResetColor(_currentState); int levelForCircle = (int)(animationLevel % _maxLevePerCircle); bool halfPassed; if (!_goesBackward) { halfPassed = levelForCircle != (int)(animationLevel % (_maxLevePerCircle / 2)); } else { halfPassed = levelForCircle == (int)(animationLevel % (_maxLevePerCircle / 2)); levelForCircle = (int)(_maxLevePerCircle - levelForCircle); } if (!halfPassed) { _abovePaint.Color = _secondHalfPaint.Color; } else { _abovePaint.Color = _firstHalfPaint.Color; } // invalidate alpha (Paint#setAlpha is a shortcut for setColor(alpha part) // so alpha is affected by setColor()) SetAlpha(_alpha); // axis _axisValue = (int)(_controlPointMinimum + (_controlPointMaximum - _controlPointMinimum) * (levelForCircle / _maxLevePerCircle)); return(true); }
protected override bool OnLevelChange (int level) { // level goes from 0 to 10000 but the number of colors divides 10000 // so we need to do that hack that maps level 10000 to level 0 int animationLevel = level == _maxLevel ? 0 : level; // state int stateForLevel = (int) (animationLevel / _maxLevePerCircle); System.Array a= Enum.GetValues (typeof(ProgressStates)); _currentState =(ProgressStates)a.GetValue(stateForLevel); // colors ResetColor(_currentState); int levelForCircle = (int) (animationLevel % _maxLevePerCircle); bool halfPassed; if (!_goesBackward) { halfPassed = levelForCircle != (int) (animationLevel % (_maxLevePerCircle / 2)); } else { halfPassed = levelForCircle == (int) (animationLevel % (_maxLevePerCircle / 2)); levelForCircle = (int) (_maxLevePerCircle - levelForCircle); } if (!halfPassed) { _abovePaint.Color=_secondHalfPaint.Color; } else { _abovePaint.Color=_firstHalfPaint.Color; } // invalidate alpha (Paint#setAlpha is a shortcut for setColor(alpha part) // so alpha is affected by setColor()) SetAlpha(_alpha); // axis _axisValue = (int) (_controlPointMinimum + (_controlPointMaximum - _controlPointMinimum) * (levelForCircle / _maxLevePerCircle)); return true; }
private void ResetColor(ProgressStates currentState) { switch (currentState) { case ProgressStates.FOLDING_DOWN: _firstColor = _color1; _secondColor = _color2; _firstHalfPaint.Color = Color.ParseColor("#0099CC"); _secondHalfPaint.Color = Color.ParseColor("#C93437"); _goesBackward = false; break; case ProgressStates.FOLDING_LEFT: _firstColor = _color1; _secondColor = _color3; _firstHalfPaint.Color = Color.ParseColor("#0099CC"); _secondHalfPaint.Color = Color.ParseColor("#F7D23E"); _goesBackward = true; break; case ProgressStates.FOLDING_UP: _firstColor = _color3; _secondColor = _color4; _firstHalfPaint.Color = Color.ParseColor("#F7D23E"); _secondHalfPaint.Color = Color.ParseColor("#34A350"); _goesBackward = true; break; case ProgressStates.FOLDING_RIGHT: _firstColor = _color2; _secondColor = _color4; _firstHalfPaint.Color = Color.ParseColor("#C93437"); _secondHalfPaint.Color = Color.ParseColor("#34A350"); _goesBackward = false; break; } }
private void ResetColor(ProgressStates currentState) { switch (currentState){ case ProgressStates.FOLDING_DOWN: _firstColor = _color1; _secondColor = _color2; _firstHalfPaint.Color = Color.ParseColor ("#0099CC"); _secondHalfPaint.Color=Color.ParseColor ("#C93437"); _goesBackward=false; break; case ProgressStates.FOLDING_LEFT: _firstColor= _color1; _secondColor=_color3; _firstHalfPaint.Color=Color.ParseColor ("#0099CC"); _secondHalfPaint.Color=Color.ParseColor("#F7D23E"); _goesBackward=true; break; case ProgressStates.FOLDING_UP: _firstColor= _color3; _secondColor=_color4; _firstHalfPaint.Color=Color.ParseColor("#F7D23E"); _secondHalfPaint.Color=Color.ParseColor("#34A350"); _goesBackward=true; break; case ProgressStates.FOLDING_RIGHT: _firstColor=_color2; _secondColor=_color4; _firstHalfPaint.Color=Color.ParseColor ("#C93437"); _secondHalfPaint.Color=Color.ParseColor("#34A350"); _goesBackward=false; break; } }