Пример #1
0
        public void FillBonuses()
        {
            Random random = new Random();

            while (Bonuses.Count < CntBonuses)
            {
                Point position = new Point(random.Next(0, Width), random.Next(0, Height));

                if (IsFreePosition(position, false))
                {
                    double chance = random.NextDouble();

                    if (chance < 0.05)
                    {
                        Bonuses.Add(new GameFieldObject.Bonus.SuperBonus(position));
                    }
                    else if (chance < 0.25)
                    {
                        Bonuses.Add(new GameFieldObject.Bonus.BonusLife(position));
                    }
                    else
                    {
                        Bonuses.Add(new GameFieldObject.Bonus.BonusPoints(position));
                    }
                }
            }
        }
Пример #2
0
    private void Interact(Vector2 lineOrigin, Vector2 chargePos)
    {
        Interactives.Clear();
        Bonuses.Clear();

        var interactableDetect = Utils.LineCastAll(lineOrigin, chargePos, includeTriggers: true);
        var interactives       = interactableDetect.Where(i => i.transform.CompareTag("Interactive")).ToArray();

        foreach (var interactive in interactives)
        {
            if (interactive.transform.TryGetComponent(out IActivable activable))
            {
                Interactives.Add(activable);
            }
        }

        var bonuses = interactableDetect.Where(b => b.transform.CompareTag("Bonus")).ToArray();

        foreach (var item in bonuses)
        {
            if (item.transform.TryGetComponent(out Bonus bonus))
            {
                Bonuses.Add(bonus);
            }
        }
    }
 private void RecalculateBonuses()
 {
     Bonuses.Clear();
     foreach (var inventoryItem in Slots.Values)
     {
         inventoryItem?.Bonuses.ForEach(b => Bonuses.Add(b));
     }
 }
Пример #4
0
        /// <summary>
        /// <see cref="IGameFieldView.AddBonus(Bonus, Vector2)"/>
        /// </summary>
        public IBonusView AddBonus(Bonus bonusInfo, Vector2 position)
        {
            var bonusView = Instantiate(_bonusPrefab, position, new Quaternion(), this.transform);

            bonusView.BonusParametrs = bonusInfo;
            Bonuses.Add(bonusView);
            return(bonusView);
        }
Пример #5
0
 private void GenerateBonus()
 {
     if (Helpers.RandInt(1, Env.BONUS_CHANCE) == 1 && Bonuses.Count < Env.BONUSES_MAX_COUNT)
     {
         var pos   = Bonus.GenerateCoordinates(Players, GetBusyPoints());
         var bonus = availableBonuses.RandArrayItem().Invoke(pos);
         Bonuses.Add(bonus);
     }
 }
Пример #6
0
        public ItemSet(JObject rawData)
        {
            SetID = int.Parse(rawData["id"].ToString());
            Name  = rawData["name"].ToString();

            foreach (JObject BonusObject in rawData["setBonuses"])
            {
                Bonuses.Add(new SetBonus(BonusObject));
            }

            Items = new List <int>();

            foreach (int ItemInt in rawData["items"])
            {
                Items.Add(ItemInt);
            }
        }
Пример #7
0
 private void Initialize(int[,] matrix)
 {
     Barriers             = new List <Barrier>();
     DammageableBarriers  = new List <DammageableBarrier>();
     EnemySpawns          = new List <EnemySpawn>();
     Configuration.Width  = matrix.GetLength(1);
     Configuration.Height = matrix.GetLength(0);
     for (int i = 0; i < Configuration.Height; i++)
     {
         for (int j = 0; j < Configuration.Width; j++)
         {
             var item = DefineItem(matrix[i, j], i, j);
             if (item.Type == ItemType.Wall)
             {
                 Barriers.Add((Barrier)item);
             }
             else if (item.Type == ItemType.DammageableWall)
             {
                 DammageableBarriers.Add((DammageableBarrier)item);
             }
             else if (item.Type == ItemType.EnemySpawn)
             {
                 EnemySpawns.Add((EnemySpawn)item);
             }
             else if (item.Type == ItemType.Enemy)
             {
                 Enemies.Add((Enemy)item);
             }
             else if (item.Type == ItemType.Bonus)
             {
                 Bonuses.Add((Bonus)item);
             }
             else if (item.Type == ItemType.Empty)
             {
                 Empties.Add((Empty)item);
             }
             else if (item.Type == ItemType.Water)
             {
                 Waters.Add((Water)item);
             }
         }
     }
     GenerateEnemies();
     GenerateBonuses();
 }
Пример #8
0
 private void GenerateBonuses()
 {
     if (Bonuses != null)
     {
         var bonuses = Configuration.Apples - Bonuses.Count;
         while (bonuses > 0)
         {
             var x           = random.Next(1, Configuration.Width);
             var y           = random.Next(1, Configuration.Height);
             var checkedCell = CheckCell(ItemType.Bonus, Point.FromRelative(x, y));
             if (checkedCell)
             {
                 var item = new Bonus(x, y);
                 Bonuses.Add(item);
                 bonuses--;
             }
         }
     }
 }
Пример #9
0
 public static void AddBonus(Bonus B)
 {
     Bonuses.Add(B.Id, B);
     Client.OnBonusAdd(B);
 }
 /// <summary>
 /// Add a bonus to the list
 /// </summary>
 /// <param name="b"></param>
 public void AddBonus(Bonus b)
 {
     Bonuses.Add(b);
 }
Пример #11
0
 public void AddBonus(decimal amount)
 {
     Bonuses.Add(new Bonus(this, DateTime.Now, amount));
 }
Пример #12
0
 public void Buff(int value)
 {
     Bonuses.Add(value);
     UIEventHandler.StatsChanged();
 }
Пример #13
0
        public virtual void AddField(TextSpan field)
        {
            if (Condition.TryParse(field, out var condition))
            {
                Conditions.Add(condition);
                return;
            }

            var(k, v) = field.SplitTuple(':');

            switch (k.Value)
            {
            case "PROHIBITSPELL":
                ProhibitedSpells.Add(ProhibitedSpell.Parse(v));
                return;

            case "BONUS":
                Bonuses.Add(Bonus.Parse(v));
                return;

            case "DEFINE":
            {
                var parts = v.Split('|').ToArray();
                if (parts.Length != 2)
                {
                    throw new ParseFailedException(field, "Unable to parse variable definition.");
                }

                Definitions.Add(new VariableDefinition(parts[0].Value, Helpers.ParseInt(parts[1])));
                return;
            }

            case "ABILITY":
                Abilities.Add(AbilityReference.Parse(v));
                return;

            case "DOMAIN":
                Domains.Add(DomainReference.Parse(v));
                return;

            case "CSKILL":
                ClassSkills.AddRange(v.Value.Split('|'));
                return;

            case "SOURCEPAGE":
                SourcePage = v.Value;
                return;

            case "SPELLLEVEL":
                SpellLists.AddRange(SpellList.Parse(v));
                return;

            case "WEAPONBONUS":
                WeaponBonusProficiencySelections.Add(v.Value.Split('|').ToList());
                return;

            case "KIT":
                // we are ignoring this one
                return;

            case "ADD":
            {
                var(type, parameter) = v.SplitTuple('|');
                switch (type.Value)
                {
                case "SPELLCASTER":
                    AddedSpellCasterLevels.Add(AddedSpellCasterLevel.Parse(parameter));
                    return;
                }
                break;
            }
            }

            throw new ParseFailedException(field, $"Unknown field '{field.Value}'");
        }
Пример #14
0
        /// <summary>
        /// Сгенерировать бонусы внутри разрушаемых стен
        /// </summary>
        /// <param name="bonuses_count">Количество бонусов (будет умножено в 4 раза)</param>
        private void GenerateBonuses(int bonuses_count)
        {
            List <Cell> cells_dest = new List <Cell>();

            for (int i = 0; i < W / 2; i++)
            {
                for (int j = 0; j < H / 2; j++)
                {
                    if (Cells[i, j].Type == CellType.Destructible)
                    {
                        cells_dest.Add(Cells[i, j]);
                    }
                }
            }

            bonuses_count = bonuses_count % cells_dest.Count;

            List <int> cells_dest_indexes = new List <int>();

            for (int i = 0; i < cells_dest.Count; i++)
            {
                cells_dest_indexes.Add(i);
            }

            for (int i = 0; i < bonuses_count; i++)
            {
                int rpoint = cells_dest_indexes[rn.Next(0, cells_dest_indexes.Count)];
                cells_dest_indexes.Remove(rpoint);

                int   rtype = rn.Next(0, 2);
                Bonus tbonus;
                if (rtype % 2 == 0)
                {
                    tbonus      = new Bonus();
                    tbonus.X    = cells_dest[rpoint].X;
                    tbonus.Y    = cells_dest[rpoint].Y;
                    tbonus.Type = BonusType.Ammunition;
                    Bonuses.Add(tbonus);

                    tbonus      = new Bonus();
                    tbonus.X    = W - cells_dest[rpoint].X - 1;
                    tbonus.Y    = cells_dest[rpoint].Y;
                    tbonus.Type = BonusType.Ammunition;
                    Bonuses.Add(tbonus);

                    tbonus      = new Bonus();
                    tbonus.X    = cells_dest[rpoint].X;
                    tbonus.Y    = H - cells_dest[rpoint].Y - 1;
                    tbonus.Type = BonusType.Ammunition;
                    Bonuses.Add(tbonus);

                    tbonus      = new Bonus();
                    tbonus.X    = W - cells_dest[rpoint].X - 1;
                    tbonus.Y    = H - cells_dest[rpoint].Y - 1;
                    tbonus.Type = BonusType.Ammunition;
                    Bonuses.Add(tbonus);
                }
                else
                {
                    tbonus      = new Bonus();
                    tbonus.X    = cells_dest[rpoint].X;
                    tbonus.Y    = cells_dest[rpoint].Y;
                    tbonus.Type = BonusType.Radius;
                    Bonuses.Add(tbonus);

                    tbonus      = new Bonus();
                    tbonus.X    = W - cells_dest[rpoint].X - 1;
                    tbonus.Y    = cells_dest[rpoint].Y;
                    tbonus.Type = BonusType.Radius;
                    Bonuses.Add(tbonus);

                    tbonus      = new Bonus();
                    tbonus.X    = cells_dest[rpoint].X;
                    tbonus.Y    = H - cells_dest[rpoint].Y - 1;
                    tbonus.Type = BonusType.Radius;
                    Bonuses.Add(tbonus);

                    tbonus   = new Bonus();
                    tbonus.X = W - cells_dest[rpoint].X - 1;
                    tbonus.Y = H - cells_dest[rpoint].Y - 1;
                    Bonuses.Add(tbonus);
                }
            }
        }