Пример #1
0
        public void GenerarNPC(string planta, int x, int y)
        {
            INPC npc;

            switch (planta.ToUpper())
            {
            case "S":
            case "SUNFLOWER":
                npc = Factoria.CreateNPC("Girasol", turno, x, y, _soles);
                if (npc != null)
                {
                    Tablero.Add(npc);


                    _soles -= npc.Coste;
                }
                break;

            case "P":
            case "PEASHOOTER":
                npc = Factoria.CreateNPC("Planta", turno, x, y, _soles);
                if (npc != null)
                {
                    Tablero.Add(npc);
                    _soles -= npc.Coste;
                }

                break;

            default:
                Random rand = new Random(Guid.NewGuid().GetHashCode());

                var porcentaje = rand.Next(1, 100);
                if (porcentaje <= _refresco * 100)
                {
                    npc = Factoria.CreateNPC("Zombie", turno, x, y, _soles);
                    Tablero.Add(npc);
                }
                break;
            }
        }