Esempio n. 1
0
 public void AddBonus(Bonus.Type bonus)
 {
     if (EnergyPoints >= Bonus.Price(bonus))
     {
         AudioSystem.AudioController.PlaySound("POWER");
         ActiveBonuses.Add(bonus);
         EnergyPoints -= Bonus.Price(bonus);
     }
 }
Esempio n. 2
0
        public Entity CreateBonus(Position p, Bonus.Type type)
        {
            Entity entity = new Entity();

            entity.AddComponent(new Bonus(type))
            .AddComponent(new Position(p))
            .AddComponent(new Velocity(0, 300, 0))
            .AddComponent(new Display(Properties.Resources.bonus));
            e.AddEntity(entity);
            return(entity);
        }
Esempio n. 3
0
        public Board()
        {
            IEnumerable <string> lines = File.ReadLines(@"..\..\Resources\board15.txt");

            int row    = 0;
            int column = 0;

            foreach (string line in lines)
            {
                string[] tokens = line.Split(null);

                if (column == 0)
                {
                    column = tokens.Length;
                }

                else if (column != tokens.Length)
                {
                    throw new Exception("Invalid input string");
                }

                row++;
            }

            slots = new Slots(row, column);

            int i = 0;

            foreach (string line in lines)
            {
                string[] tokens = line.Split(null);
                for (int j = 0; j < tokens.Length; j++)
                {
                    Bonus.Type type       = tokens[j].Length == 2 && tokens[j][1] == 'W' ? Bonus.Type.Word : Bonus.Type.Letter;
                    int        multiplier = tokens[j].Length == 2 ? int.Parse(tokens[j][0].ToString()) : 1;

                    Bonus bonus = new Bonus(type, multiplier);

                    slots[i, j] = new Slot(i, j, bonus);
                }

                i++;
            }

            for (i = 0; i < row; i++)
            {
                for (int j = 0; j < column; j++)
                {
                    if (i > 0)
                    {
                        slots[i, j].top = slots[i - 1, j];
                    }
                    if (j > 0)
                    {
                        slots[i, j].left = slots[i, j - 1];
                    }
                    if (i < row - 1)
                    {
                        slots[i, j].bottom = slots[i + 1, j];
                    }
                    if (j < column - 1)
                    {
                        slots[i, j].right = slots[i, j + 1];
                    }
                }
            }

            slotList = new List <Slot>();
        }