private void OnBonusPicked(BonusSettings bonusItem)
    {
        _heards += bonusItem.AdditionHearts;
        GameManager.Instance.AddScore(bonusItem.ExtraScores * _scoreMulty);

        if (bonusItem.IsInsensitive)
        {
            _isInsensitive = true;
        }
        else if (!bonusItem.IsInsensitive && bonusItem.OldIsInsensitive)
        {
            _isInsensitive = false;
        }

        _scoreMulty = bonusItem.Type == BonusSettings.SettingsType.ForceDefault
                        ? (int)bonusItem.ScoreMultyplayer
                        : (int)Mathf.Max(1f, _scoreMulty * bonusItem.ScoreMultyplayer);

        var newSpeed = bonusItem.Type == BonusSettings.SettingsType.ForceDefault ? bonusItem.SpeedRatio : _speedRatio * bonusItem.SpeedRatio;

        if (Math.Abs(newSpeed - _speedRatio) > Time.deltaTime)
        {
            _speedRatio = newSpeed;
        }
    }
Beispiel #2
0
    public static BonusSettings ForceDefault()
    {
        var res = new BonusSettings();

        res.SetDefault();
        res.Type = SettingsType.ForceDefault;
        return(res);
    }
Beispiel #3
0
    private static IEnumerator PickBonusCoroutine(BonusSettings bonusItem)
    {
        yield return(bonusItem);

        yield return(new WaitForSeconds(bonusItem.ActiveTime));

        yield return(bonusItem.Revert());
    }
Beispiel #4
0
    private void OnBonusPicked(BonusSettings bonusItem)
    {
        if (bonusItem != null)
        {
            if (bonusItem.Type == BonusSettings.SettingsType.Normal)
            {
                if (bonusItem.IsSuperBadItem)
                {
                    _unknownItemView.SetActive(true);
                }
                if (bonusItem.SpeedRatio > 1)
                {
                    _speedUpPlayerView.SetActive(true);
                }
                if (bonusItem.AdditionHearts > 0)
                {
                    _extraHeartsView.SetActive(true);
                }
                if (bonusItem.BombsKind == BombItemKind.NoBombs)
                {
                    _noBombsItemView.SetActive(true);
                }
                if (bonusItem.ExtraScores > 0)
                {
                    _extraPointsView.SetActive(true);
                }
                if (bonusItem.ScoreMultyplayer > 1)
                {
                    _pointsMultyView.SetActive(true);
                }
            }
            if (bonusItem.IsInsensitive)
            {
                _isInsensitive = true;
            }
            else if (!bonusItem.IsInsensitive && bonusItem.OldIsInsensitive)
            {
                _isInsensitive = false;
            }
            _intensiveItemView.SetActive(_isInsensitive);

            bool newEnemiesGenerate = false;
            if (bonusItem.BombsKind != _bombKind)
            {
                _bombKind          = bonusItem.BombsKind;
                newEnemiesGenerate = true;
            }
            if (newEnemiesGenerate || bonusItem.Type == BonusSettings.SettingsType.ForceDefault)
            {
                if (_enemiesDispose != null)
                {
                    _enemiesDispose.Dispose();
                }
                _enemiesDispose = GenerateItems();
            }
        }
    }
Beispiel #5
0
    public BonusSettings Revert()
    {
        var res = new BonusSettings();

        res.OldIsInsensitive  = _isInsensitive;
        res._scoreMultyplayer = 1f / _scoreMultyplayer;
        res._speedRatio       = 1f / _speedRatio;
        res.Type = SettingsType.Reverted;
        return(res);
    }
        public BonusSettingsDto Update([FromBody] BonusSettingsDto bonus)
        {
            BonusSettings model = Map(bonus);

            _context.BonusSettings.Update(model);
            _context.SaveChanges();
            var dto = Map(model);

            dto.Project = bonus.Project;
            return(dto);
        }
 private BonusSettingsDto Map(BonusSettings model)
 {
     return(new BonusSettingsDto()
     {
         Id = model.Id,
         Project = model.Project?.Name,
         ProjectId = model.ProjectId,
         BonusPercent = model.BonusPercent,
         DeltaPercent = model.DeltaPercent,
         Coef = model.Coef,
     });
 }
Beispiel #8
0
    public void GameOver()
    {
        if (_score > HighScore)
        {
            HighScore = _score;
            SaveData(_score);
            IsNewHighScore = true;
        }
        _BonusPicked.OnNext(BonusSettings.ForceDefault());
        _state = GameState.End;
//		if (_timerDisposable != null)
//			_timerDisposable.Dispose();
    }
        public BonusSettingsDto Delete(long id)
        {
            BonusSettings deleted = _context.BonusSettings.FirstOrDefault(x => x.Id == id);

            if (deleted == null)
            {
                return(null);
            }

            _context.BonusSettings.Remove(deleted);
            _context.SaveChanges();
            return(Map(deleted));
        }
        private BonusSettings Map(BonusSettingsDto dto)
        {
            BonusSettings bonus = _context.BonusSettings.FirstOrDefault(x => x.Id == dto.Id);

            if (bonus == null)
            {
                bonus = new BonusSettings();
            }

            bonus.BonusPercent = dto.BonusPercent;
            bonus.Coef         = dto.Coef;
            bonus.DeltaPercent = dto.DeltaPercent;
            bonus.ProjectId    = dto.ProjectId;

            return(bonus);
        }
Beispiel #11
0
    public IEnumerator SpawnBonus(List <BonusSettings> bonuses, List <Transform> points, float spawnTime)
    {
        while (true)
        {
            yield return(new WaitForSeconds(spawnTime));

            Transform spawnPoint = GetRandomPoint(points);

            int           id    = GetRandomId(bonuses);
            BonusSettings bonus = bonuses[id];

            GameObject obj = Instantiate(bonus.Prefab, spawnPoint.position, spawnPoint.rotation);
            Bonus      b   = obj.AddComponent <Bonus>();
            b.SetActionOnDestroy(bonus.BonusAction);
        }
    }
Beispiel #12
0
    public static void BonusSettings(ref BonusSettings bonus, bool showExp)
    {
        EditorGUILayout.BeginHorizontal();
        // status value bonuses
        EditorGUILayout.BeginVertical();
        GUILayout.Label("Status value bonuses", EditorStyles.boldLabel);
        for(int i=0; i<bonus.statusBonus.Length; i++)
        {
            if(DataHolder.StatusValue(i).IsConsumable() ||
                (!showExp && DataHolder.StatusValue(i).IsExperience()))
            {
                bonus.statusBonus[i] = 0;
            }
            else
            {
                bonus.statusBonus[i] = EditorGUILayout.IntField(DataHolder.StatusValues().GetName(i),
                        bonus.statusBonus[i], GUILayout.Width(mWidth));
            }
        }
        EditorGUILayout.EndVertical();

        // chance bonuses
        EditorGUILayout.BeginVertical();
        GUILayout.Label("Chance bonuses", EditorStyles.boldLabel);
        bonus.hitBonus = EditorGUILayout.FloatField("Hit bonus", bonus.hitBonus, GUILayout.Width(mWidth));
        bonus.counterBonus = EditorGUILayout.FloatField("Counter bonus", bonus.counterBonus, GUILayout.Width(mWidth));
        bonus.criticalBonus = EditorGUILayout.FloatField("Critical bonus", bonus.criticalBonus, GUILayout.Width(mWidth));
        bonus.blockBonus = EditorGUILayout.FloatField("Block bonus", bonus.blockBonus, GUILayout.Width(mWidth));
        bonus.escapeBonus = EditorGUILayout.FloatField("Escape bonus", bonus.escapeBonus, GUILayout.Width(mWidth));
        bonus.speedBonus = EditorGUILayout.FloatField("Speed bonus", bonus.speedBonus, GUILayout.Width(mWidth));
        bonus.itemStealBonus = EditorGUILayout.FloatField("Item steal bonus", bonus.itemStealBonus, GUILayout.Width(mWidth));
        bonus.moneyStealBonus = EditorGUILayout.FloatField("Money steal bonus", bonus.moneyStealBonus, GUILayout.Width(mWidth));
        EditorGUILayout.EndVertical();

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Separator();

        if(GUILayout.Button("Add difficulty bonuses", GUILayout.Width(mWidth)))
        {
            bonus.AddDifficultyBonus();
        }

        for(int i=0; i<bonus.difficultyBonus.Length; i++)
        {
            GUILayout.BeginVertical("box");
            if(GUILayout.Button("Remove", GUILayout.Width(mWidth*0.5f)))
            {
                bonus.RemoveDifficultyBonus(i);
                break;
            }
            EditorHelper.DifficultyBonusSettings(ref bonus.difficultyBonus[i], showExp);
            EditorGUILayout.Separator();
            EditorGUILayout.EndVertical();
        }
    }
Beispiel #13
0
 public BonusSettings GetSettings()
 {
     return(_settings ??
            (_settings = new BonusSettings(_activeTime, _isInsensitive, _bombsKind, _additionHearts, _scoreMultyplayer, _speedRatio, _extraScores, _isSuperBadItem)));
 }
Beispiel #14
0
 public void PickBonus(BonusSettings bonusItem)
 {
     Observable.FromCoroutineValue <BonusSettings>(() => PickBonusCoroutine(bonusItem), false).Subscribe(item => _BonusPicked.OnNext(item)).AddTo(_disposables);
 }