Beispiel #1
0
        public override void Press(int cell, Character ch)
        {
            base.Press(cell, ch);

            if (ch != Dungeon.Hero || _enteredArena || !RoomExit.Inside(cell))
            {
                return;
            }

            _enteredArena = true;

            int pos;

            do
            {
                pos = RoomExit.Random();
            }while (pos == cell || Actor.FindChar(pos) != null);

            var boss = Bestiary.Mob(Dungeon.Depth);

            boss.State = boss.HUNTING;
            boss.pos   = pos;
            GameScene.Add(boss);
            boss.Notice();

            MobPress(boss);

            Set(_arenaDoor, Terrain.LOCKED_DOOR);
            GameScene.UpdateMap(_arenaDoor);
            Dungeon.Observe();
        }
Beispiel #2
0
        public override void Press(int cell, Character hero)
        {
            base.Press(cell, hero);

            if (enteredArena || !OutsideEntraceRoom(cell) || hero != Dungeon.Hero)
            {
                return;
            }

            enteredArena = true;

            var boss = Bestiary.Mob(Dungeon.Depth);

            boss.State = boss.HUNTING;
            do
            {
                boss.pos = pdsharp.utils.Random.Int(Length);
            }while (!passable[boss.pos] || !OutsideEntraceRoom(boss.pos) || Dungeon.Visible[boss.pos]);

            GameScene.Add(boss);

            Set(arenaDoor, Terrain.LOCKED_DOOR);
            GameScene.UpdateMap(arenaDoor);
            Dungeon.Observe();
        }
Beispiel #3
0
    // Start is called before the first frame update
    void Start()
    {
        Bestiary entry1 = new Bestiary("Clara", 60, 15);
        Bestiary entry2 = new Bestiary("April", 80, 12);
        Bestiary entry3 = new Bestiary("Laura", 100, 10);

        // Add variables to dictionary
        bestiary.Add(1, entry1);
        bestiary.Add(2, entry2);
        bestiary.Add(3, entry3);

        // Access the dictionary
        Bestiary currentBoss = bestiary[1];

        print(currentBoss.name + " - " + (currentBoss.health + currentBoss.attack));

        Bestiary temp = null;

        // Try accessing the value in a dictionary
        if (bestiary.TryGetValue(4, out temp))
        {
            // If successful
            print(temp);
        }
        else
        {
            // Failure
            print("Dictionary entry not found.");
        }
    }
Beispiel #4
0
        public override void Press(int cell, Character hero)
        {
            base.Press(cell, hero);

            if (enteredArena || !outsideEntraceRoom(cell) || hero != Dungeon.Hero)
            {
                return;
            }

            enteredArena = true;

            var boss = Bestiary.Mob(Dungeon.Depth);

            boss.State = boss.HUNTING;
            do
            {
                boss.pos = Random.Int(Length);
            }while (!passable[boss.pos] || !outsideEntraceRoom(boss.pos) || Dungeon.Visible[boss.pos]);

            GameScene.Add(boss);

            Set(arenaDoor, Terrain.WALL);
            GameScene.UpdateMap(arenaDoor);
            Dungeon.Observe();

            CellEmitter.Get(arenaDoor).Start(Speck.Factory(Speck.ROCK), 0.07f, 10);
            Camera.Main.Shake(3, 0.7f);
            Sample.Instance.Play(Assets.SND_ROCKS);
        }
Beispiel #5
0
        protected internal override void CreateMobs()
        {
            var mob = Bestiary.Mob(Dungeon.Depth);

            mob.pos = RoomExit.Random();
            mobs.Add(mob);
        }
        private void BtnAddNew_Click(object sender, RoutedEventArgs e)
        {
            ActiveBestiary       = new Bestiary();
            ActiveBestiaryDetail = new BestiaryDetail();

            LoadActiveBestiary();
        }
Beispiel #7
0
        private static readonly Mob Dummy; // = new Mob();

        // 0x770088
        public static void Trigger(int pos, Character c)
        {
            if (Dungeon.BossLevel())
            {
                return;
            }

            if (c != null)
            {
                Actor.OccupyCell(c);
            }

            var nMobs = 1;

            if (Random.Int(2) == 0)
            {
                nMobs++;
                if (Random.Int(2) == 0)
                {
                    nMobs++;
                }
            }

            // It's complicated here, because these traps can be activated in chain
            var candidates = new List <int>();

            foreach (var neighbour in Level.NEIGHBOURS8)
            {
                var p = pos + neighbour;
                if (Actor.FindChar(p) == null && (Level.passable[p] || Level.avoid[p]))
                {
                    candidates.Add(p);
                }
            }

            var respawnPoints = new List <int>();

            while (nMobs > 0 && candidates.Count > 0)
            {
                var index = Random.Index(candidates);

                Dummy.pos = candidates[index];
                Actor.OccupyCell(Dummy);

                var cand = candidates[index];
                candidates.RemoveAt(index);
                respawnPoints.Add(cand);

                nMobs--;
            }

            foreach (var point in respawnPoints)
            {
                var mob = Bestiary.Mob(Dungeon.Depth);
                mob.State = mob.WANDERING;
                GameScene.Add(mob, Delay);
                WandOfBlink.Appear(mob, point);
            }
        }
Beispiel #8
0
 /* Create monsters' files */
 public static void Monsters()
 {
     Bestiary.Make("Giant Bee", 1, 3, 0, 0, 0, false);
     Bestiary.Make("Abomination", 2, 3, 4, 1, 0, false);
     Bestiary.Make("Rattling Sniffer", 1, 1, 3, 1, 1, true);
     Bestiary.Make("Gryph Bee", 2, 2, 2, 3, 0, false);
     Bestiary.Make("Atrocious Vulture", 1, 2, 1, 0, 0, false);
     Bestiary.Make("Giant Eagle", 3, 3, 3, 3, 0, false);
     Bestiary.Make("Amoeba", 4, 1, 6, 1, 0, false);
     Bestiary.Make("Ankheg", 2, 1, 2, 2, 3, true);
     Bestiary.Make("Apparition", 3, 2, 2, 1, 0, false);
     Bestiary.Make("Giant Spider", 1, 3, 1, 0, 1, true);
     Bestiary.Make("Walking Bush", 4, 1, 2, 2, 0, false);
     Bestiary.Make("Archon", 0, 3, 1, 0, 5, true);
     Bestiary.Make("Banshee", 3, 4, 3, 4, 4, true);
     Bestiary.Make("Basilisk", 0, 3, 2, 1, 1, true);
     Bestiary.Make("Beholder", 3, 3, 5, 5, 6, true);
     Bestiary.Make("Voracious Beetle", 4, 1, 18, 2, 0, false);
     Bestiary.Make("Witch", 3, 0, 3, 3, 0, false);
     Bestiary.Make("War Horse", 2, 1, 2, 1, 0, false);
     Bestiary.Make("Infernal Hound", 2, 2, 2, 2, 4, true);
     Bestiary.Make("Centaur", 4, 3, 3, 1, 1, false);
     Bestiary.Make("Giant Centipede", 3, 3, 2, 1, 0, false);
     Bestiary.Make("Jelly Cube", 1, 0, 5, 0, 0, false);
     Bestiary.Make("Dark Dragon", 4, 4, 4, 5, 9, true);
     Bestiary.Make("Earth Elemental", 1, 4, 3, 1, 1, true);
     Bestiary.Make("Smasher", 3, 2, 3, 3, 0, false);
     Bestiary.Make("Skeleton", 1, 0, 0, 2, 0, false);
     Bestiary.Make("Ent", 7, 3, 12, 5, 0, false);
     Bestiary.Make("Giant Scorpion", 2, 2, 3, 2, 0, false);
     Bestiary.Make("Ghost", 1, 1, 2, 2, 4, true);
     Bestiary.Make("Phoenix", 5, 6, 7, 6, 8, true);
     Bestiary.Make("Wisp", 0, 4, 0, 0, 0, false);
     Bestiary.Make("Giant Grasshopper", 1, 3, 2, 1, 1, false);
     Bestiary.Make("Gargoyle", 3, 5, 4, 4, 0, false);
     Bestiary.Make("Cyclope", 20, 4, 9, 7, 18, false);
     Bestiary.Make("Goblin Soldier", 0, 1, 1, 0, 1, true);
     Bestiary.Make("Carnivorous Grass", 0, 1, 0, 0, 0, false);
     Bestiary.Make("Lion", 3, 3, 2, 0, 0, false);
     Bestiary.Make("Tiger", 2, 3, 2, 0, 0, false);
     Bestiary.Make("Gryph", 2, 7, 3, 1, 0, false);
     Bestiary.Make("Harpy", 2, 5, 3, 1, 3, true);
     Bestiary.Make("Hydra", 4, 3, 10, 4, 10, true);
     Bestiary.Make("Kobold Guard", 0, 1, 0, 1, 0, false);
     Bestiary.Make("Kraken", 7, 5, 10, 6, 0, false);
     Bestiary.Make("Lich", 3, 5, 5, 6, 5, true);
     Bestiary.Make("Wolf", 1, 2, 1, 0, 0, false);
     Bestiary.Make("Medusa", 1, 2, 3, 0, 6, false);
     Bestiary.Make("Mummy", 4, 1, 3, 4, 0, false);
     Bestiary.Make("Slark", 0, 0, 0, 0, 0, false);
     Bestiary.Make("Tarrasque", 8, 5, 8, 10, 0, false);
     Bestiary.Make("Badger", 2, 1, 2, 1, 0, false);
     Bestiary.Make("Tentacute", 0, 0, 0, 0, 0, true);
     Bestiary.Make("White Bear", 3, 2, 3, 1, 0, false);
     Bestiary.Make("Wyvern", 5, 5, 4, 4, 3, false);
     Bestiary.Make("Cave Worm", 10, 1, 30, 4, 0, false);
     Bestiary.Make("Carrion Worm", 1, 2, 2, 2, 0, false);
 }
        private void LbxBestiary_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (LbxBestiary.SelectedItem != null)
            {
                ActiveBestiary       = DBClient.GetBestiary((int)LbxBestiary.SelectedValue);
                ActiveBestiaryDetail = DBClient.GetBestiaryDetail((int)LbxBestiary.SelectedValue);

                LoadActiveBestiary();
            }
        }
Beispiel #10
0
 private void TurnOptionsOff()
 {
     ToggleButtons(false);
     Exit.SetActive(false);
     Definitions.SetActive(false);
     Bestiary.SetActive(false);
     Player.SetActive(false);
     Squadron.SetActive(false);
     Abilities.SetActive(false);
     TitleHelper.SetActive(false);
 }
Beispiel #11
0
        private RunescapeAPI(RunescapeWebClient Client)
        {
            Client.BaseAddress = new Uri($@"http://services.runescape.com/");

            Client.DefaultRequestHeaders.Accept.Clear();
            Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            GrandExchange = new GrandExchange(Client);
            Bestiary      = new Bestiary(Client);
            Hiscores      = new Hiscores(Client);
        }
        public async Task <ActionResult> NewBeast(BeastModel model)
        {
            List <BeastTypeDO> beastType =
                await BeastTypeDO.GetBeastTypeAsync();

            // hardcoded - povoluje přidat bestie pouze mimo města
            List <LocationsDO> locations =
                await LocationsDO.GetLocationsAsync(0);

            ViewBag.beastType = beastType
                                .Select(x => new SelectListItem()
            {
                Text  = x.Name,
                Value = x.Idbeasttype.ToString()
            })
                                .ToList();

            ViewBag.Location = locations
                               .Select(x => new SelectListItem()
            {
                Text  = x.Name,
                Value = x.LocationID.ToString()
            })
                               .ToList();

            if (ModelState.IsValid)
            {
                if (model.BeastName != null && model.BeastBio != null)
                {
                    using (fantasyDbEntities context = new fantasyDbEntities())
                    {
                        // Vytvoření nové bestie a načtení hodnot zvolených uživatelem
                        Bestiary beast = new Bestiary();
                        beast.name        = model.BeastName;
                        beast.bio         = model.BeastBio;
                        beast.hp          = model.BeastHp;
                        beast.attack      = model.BeastAttack;
                        beast.defense     = model.BeastDefense;
                        beast.locationid  = model.BeastLocation;
                        beast.beasttypeid = model.BeastTypeID;
                        // Přidání řádku tabulky a uložení změn
                        context.Bestiary.Add(beast);
                        context.SaveChanges();
                    }
                }
            }

            return(RedirectToAction("Bestiary"));
        }
Beispiel #13
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bestiary = await _context.Bestiary
                       .Include(b => b.BestiaryType).SingleOrDefaultAsync(m => m.BestiaryId == id);

            if (Bestiary == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Beispiel #14
0
        public RandomEncounterResult GenerateRandomEncounters(RandomEncounterRequest request)
        {
            var context       = PFDAL.GetContext();
            var encounterList = new List <RandomEncounterItem>();
            var groupMon      = new List <Bestiary>();
            var validSpawns   = from s in context.MonsterSpawn
                                join b in context.Bestiary on s.BestiaryId equals b.BestiaryId
                                where (s.ContinentId == request.ContinentId || request.ContinentId <= 0) &&
                                (s.SeasonId == request.SeasonId || request.SeasonId <= 0) &&
                                (s.TimeId == request.TimeId || request.TimeId <= 0) &&
                                b.CharacterFlag == request.Npc
                                select b;

            foreach (var cr in request.Crs)
            {
                Bestiary mon = new Bestiary();
                if (request.Group && (groupMon.Select(x => x.Cr).Contains(cr)))
                {
                    mon = groupMon.First(x => x.Cr == cr);
                }
                else
                {
                    var monList = validSpawns.Where(x => x.Cr == cr || cr == (int)CRSpecial.ALL).ToList();
                    if (monList.Count > 0)
                    {
                        mon = monList.ElementAt(random.Next(monList.Count));
                    }
                }

                if (mon != null)
                {
                    groupMon.Add(mon);
                    encounterList.Add(new RandomEncounterItem()
                    {
                        BestiaryId = mon.BestiaryId, Cr = mon.Cr, Name = mon.Name
                    });
                }
            }

            return(new RandomEncounterResult()
            {
                EncounterItems = encounterList,
                Message = $"Generated {encounterList.Count} items",
                Success = encounterList.Any()
            });
        }
Beispiel #15
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bestiary = await _context.Bestiary
                       .Include(b => b.BestiaryType).SingleOrDefaultAsync(m => m.BestiaryId == id);

            if (Bestiary == null)
            {
                return(NotFound());
            }
            ViewData["Type"] = new SelectList(_context.BestiaryType, "BestiaryTypeId", "Name");
            return(Page());
        }
        public ActionResult EditBeast(BeastModel model, int id)
        {
            ModelState.Clear();

            if (ModelState.IsValid)
            {
                try
                {
                    using (fantasyDbEntities context = new fantasyDbEntities())
                    {
                        Bestiary beast = new Bestiary();
                        beast             = context.Bestiary.Find(id);
                        beast.idbeast     = id;
                        beast.beasttypeid = model.BeastTypeID;

                        // kontrola stringových hodnot - nezměněné hodnoty jsou NULL
                        if (model.BeastName != null)
                        {
                            beast.name = model.BeastName;
                        }
                        if (model.BeastBio != null)
                        {
                            beast.bio = model.BeastBio;
                        }
                        try
                        {
                            context.Entry(beast).State = EntityState.Modified;
                            context.SaveChanges();
                        }
                        catch (DbUpdateConcurrencyException ex)
                        {
                            var error = ex.ToString();
                            return(View());
                        }
                    }

                    return(RedirectToAction("Bestiary"));
                }
                catch (Exception exception)
                {
                    var error = exception.ToString();
                    return(View());
                }
            }
            return(View());
        }
Beispiel #17
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bestiary = await _context.Bestiary.FindAsync(id);

            if (Bestiary != null)
            {
                _context.Bestiary.Remove(Bestiary);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
    void spawnMonster(char type)
    {
        GameObject toSpawn = Bestiary.GetMonster(type);

        if (toSpawn != null)
        {
            monsterCountOverall++;
            Vector3    spawnPosition = transform.position;
            Quaternion spawnRotation = Quaternion.Euler(new Vector3(0, 90, 0));
            GameObject go            = Instantiate(toSpawn, spawnPosition, spawnRotation);
            go.GetComponent <MonsterBehaviour>().SetSpawner(this);
        }
        else
        {
            return;
        }
    }
Beispiel #19
0
	// Use this for initialization
	void Start () {
		instance = this;
		for (int i = 0; i <= 100; i++) {
			baddies [i] = new List<string> ();
		}

		DirectoryInfo dir = new DirectoryInfo("Assets/Resources/Baddies");
		FileInfo[] info = dir.GetFiles("*.prefab");
		foreach (FileInfo f in info) 
		{ 
			string baddieName = f.Name.Replace(".prefab", "");
			GameObject baddieObject = Instantiate(Resources.Load ("Baddies/" + baddieName), Vector3.zero, Quaternion.identity) as GameObject;
			Baddie baddie = baddieObject.GetComponent<Baddie> ();
			int level = baddie.Level ();
			baddies [level].Add (baddieName);
			Destroy (baddieObject);
		}
	}
Beispiel #20
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            if (ActiveBestiary.BestiaryId == 0)
            {
                ActiveBestiary = DBClient.CreateBestiary(ActiveBestiary);
            }
            else
            {
                DBClient.UpdateBestiary(ActiveBestiary);
            }

            ActiveBestiaryDetail.BestiaryId = ActiveBestiary.BestiaryId;
            DBClient.UpdateBestiaryDetail(ActiveBestiaryDetail);

            BestiaryId = ActiveBestiary.BestiaryId;
            BestiaryList.Clear();
            BestiaryList.AddRange(DBClient.GetList("Bestiary"));
        }
Beispiel #21
0
 public CombatGridItem(Bestiary b)
 {
     BestiaryId = b.BestiaryId;
     Init       = rand.Next(1, 21) + b.Init;
     Name       = b.Name;
     PC         = false;
     HP         = b.Hp;
     MaxHP      = b.Hp;
     AC         = b.Ac;
     ACTouch    = b.Actouch;
     ACFlat     = b.Acflat;
     CMB        = b.Cmb;
     CMD        = b.Cmd;
     Fort       = b.Fortitude;
     Ref        = b.Reflex;
     Will       = b.Will;
     Subd       = 0;
     Note       = string.Empty;
 }
Beispiel #22
0
        protected internal override void CreateMobs()
        {
#if DEBUG
            return;
#endif

            var nMobs = NMobs();
            for (var i = 0; i < nMobs; i++)
            {
                var mob = Bestiary.Mob(Dungeon.Depth);

                do
                {
                    mob.pos = RandomRespawnCell();
                }while (mob.pos == -1);

                mobs.Add(mob);
                Actor.OccupyCell(mob);
            }
        }
Beispiel #23
0
        protected override bool Act()
        {
            if (_level.mobs.Count < _level.NMobs())
            {
                var mob = Bestiary.Mutable(Dungeon.Depth);
                mob.State = mob.WANDERING;
                mob.pos   = _level.RandomRespawnCell();
                if (Dungeon.Hero.IsAlive && mob.pos != -1)
                {
                    GameScene.Add(mob);
                    if (Statistics.AmuletObtained)
                    {
                        mob.Beckon(Dungeon.Hero.pos);
                    }
                }
            }

            Spend(Dungeon.NightMode || Statistics.AmuletObtained ? Level.TimeToRespawn / 2 : Level.TimeToRespawn);

            return(true);
        }
Beispiel #24
0
    public void Town()
    {
        string Input;

        Console.Clear();
        while (true)
        {
            Console.WriteLine("Where do you want to go now?");
            Console.WriteLine("1. Battle");
            Console.WriteLine("2. Shop");
            Console.WriteLine("3. Manage Inventory");
            Console.WriteLine("4. Rest");
            Console.WriteLine("5. Save Game");
            Console.WriteLine("6. Exit Game");

            Input = Console.ReadLine();
            Input = this.ParseTownCommand(Input);

            if (Input.Equals("battle"))
            {
                Console.Clear();
                List <string> Monsters = Initializer.InitMonsters();
                while (true)
                {
                    this.ShowMonsters(Monsters);

                    string Ans = Console.ReadLine();
                    Ans = Ans.ToLower();
                    int  Index   = new int();
                    int  Value   = -1;
                    bool Numeric = false;

                    if (Ans.Equals("1") || Ans.Equals("random"))
                    {
                        int              d      = Dice.Roll(Monsters.Count) - 1;
                        string[]         tokens = Monsters[d].Split(' ');
                        string           file   = String.Join("", tokens);
                        Enemy            E      = Bestiary.Load(file);
                        BattleController BC     = new BattleController(this.DM.Hero, E);
                        BC.Battle();
                        Console.Clear();
                        break;
                    }
                    else if (Ans.Equals(""))
                    {
                        break;
                    }
                    else
                    {
                        try {
                            Value   = Int32.Parse(Ans);
                            Numeric = true;
                        }
                        catch (SystemException) {
                            Console.Clear();
                            Console.WriteLine("Invalid monster\n");
                            Numeric = false;
                        }
                    }

                    if (Numeric)
                    {
                        if (Value >= 2 && Value <= Monsters.Count + 1)
                        {
                            Index = Value - 2;
                        }
                        else
                        {
                            Index = Monsters.BinarySearch(Ans);
                        }
                    }
                    else
                    {
                        Index = Monsters.BinarySearch(Ans);
                    }

                    if (Index < 0)
                    {
                        Console.Clear();
                        Console.WriteLine("Invalid monster\n");
                    }
                    else
                    {
                        string[]         tokens = Monsters[Index].Split(' ');
                        string           file   = String.Join("", tokens);
                        Enemy            E      = Bestiary.Load(file);
                        BattleController BC     = new BattleController(this.DM.Hero, E);
                        BC.Battle();
                        Console.Clear();
                        break;
                    }
                }
            }
            else if (Input.Equals("shop"))
            {
                string Market;

                Console.Clear();
                while (true)
                {
                    Console.WriteLine("Which shop do you want to visit?");
                    Console.WriteLine("1. Gold Shop");
                    Console.WriteLine("2. Experience Shop");
                    Console.WriteLine("3. Return");

                    Market = Console.ReadLine();
                    Market = this.ParseShop(Market);

                    if (Market.Equals("gold"))
                    {
                        Market MK = new Market(this.DM.Hero);
                        MK.Shop();
                        Console.Clear();
                    }
                    else if (Market.Equals("exp"))
                    {
                        ExpMarket EM = new ExpMarket(this.DM.Hero);
                        EM.Shop();
                        Console.Clear();
                    }
                    else if (Market.Equals("return"))
                    {
                        Console.Clear();
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Invalid shop\n");
                    }
                }
            }
            else if (Input.Equals("manage inventory"))
            {
                InventoryController.Manage(this.DM.Hero);
            }
            else if (Input.Equals("rest"))
            {
                this.DM.Hero.Rest();
                Console.Clear();
                Console.WriteLine("You are fully replenished\n");
            }
            else if (Input.Equals("save game"))
            {
                Console.Clear();
                if (this.SM.SaveGame(this.DM.Hero, this.SM.CurrentSlot))
                {
                    Console.WriteLine("Game saved!\n");
                }
                else
                {
                    Console.WriteLine("Error! Could not save game\n");
                }
            }
            else if (Input.Equals("exit"))
            {
                Console.Clear();
                return;
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Invalid command\n");
            }
        }
    }
Beispiel #25
0
        // Menu 6
        private static void UpdateNPC()
        {
            int i       = 0;
            var npcList = PFDAL.GetContext(false).Npc;

            foreach (var z in npcList)
            {
                try
                {
                    var context = PFDAL.GetContext(false);
                    var npc     = context.Npc.First(x => x.Npcid == z.Npcid);
                    var b       = new Bestiary();
                    context.Bestiary.Attach(b);

                    // AbilityScores - split
                    // Str 12, Dex 14, Con 13, Int 9, Wis 10, Cha 9
                    // Handle creatures with no Con, Int, etc like undead or plants
                    foreach (var item in npc.AbilityScores.Split(','))
                    {
                        var stat = item.Trim();
                        if (stat.StartsWith("Str", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (int.TryParse(Regex.Match(stat, "[0-9]+").ToString(), out int val))
                            {
                                b.Str = val;
                            }
                        }
                        else if (stat.StartsWith("Dex", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (int.TryParse(Regex.Match(stat, "[0-9]+").ToString(), out int val))
                            {
                                b.Dex = val;
                            }
                        }
                        else if (stat.StartsWith("Con", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (int.TryParse(Regex.Match(stat, "[0-9]+").ToString(), out int val))
                            {
                                b.Con = val;
                            }
                        }
                        else if (stat.StartsWith("Int", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (int.TryParse(Regex.Match(stat, "[0-9]+").ToString(), out int val))
                            {
                                b.Int = val;
                            }
                        }
                        else if (stat.StartsWith("Wis", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (int.TryParse(Regex.Match(stat, "[0-9]+").ToString(), out int val))
                            {
                                b.Wis = val;
                            }
                        }
                        else if (stat.StartsWith("Cha", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (int.TryParse(Regex.Match(stat, "[0-9]+").ToString(), out int val))
                            {
                                b.Cha = val;
                            }
                        }
                    }

                    npc.AbilityScores = null;

                    // AC - split, make sure AC is an int
                    // 17, touch 17, flat-footed 12
                    foreach (Match item in Regex.Matches(npc.Ac, REGEX_SPLIT))
                    {
                        var ac = item.Groups[1].Value;
                        if (ac.StartsWith("touch"))
                        {
                            if (int.TryParse(Regex.Match(ac, "[0-9]+").ToString(), out int val))
                            {
                                b.Actouch = val;
                            }
                        }
                        else if (ac.StartsWith("flat"))
                        {
                            if (int.TryParse(Regex.Match(ac, "[0-9]+").ToString(), out int val))
                            {
                                b.Acflat = val;
                            }
                        }
                        else
                        {
                            if (int.TryParse(Regex.Match(ac, "[0-9]+").ToString(), out int val))
                            {
                                b.Ac = val;
                            }
                        }
                    }

                    // HD - remove parenthesis, make sure it's in AdB+C format
                    b.Hd = npc.Hd.Replace("(", "").Replace(")", "");
                    if (!b.Hd.Contains("d"))
                    {
                        b.Hd = "1d" + b.Hd;
                    }
                    if (!b.Hd.Contains("+") && !b.Hd.Contains("-"))
                    {
                        b.Hd = b.Hd + "+0";
                    }

                    b.BaseAtk = npc.BaseAtk ?? 0;

                    b.CharacterFlag = true;

                    b.Cmb = npc.Cmb ?? b.BaseAtk + GetAbilityMod(b.Str);

                    b.Cmd = npc.Cmd ?? 10 + b.BaseAtk + GetAbilityMod(b.Str) + GetAbilityMod(b.Dex);

                    b.CompanionFlag = npc.CompanionFlag ?? false;

                    if (npc.Cr.HasValue)
                    {
                        b.Cr = npc.Cr.Value;
                    }
                    else
                    {
                        int cr = -10;
                        int.TryParse(Regex.Match(npc.Hd, "[0-9]+").ToString(), out cr);
                        b.Cr = cr;
                    }

                    b.DontUseRacialHd = false;

                    b.Fortitude = npc.Fort ?? GetAbilityMod(b.Con);

                    b.Hp = npc.Hp ?? 0;

                    b.Init = npc.Init ?? GetAbilityMod(b.Dex);

                    b.IsTemplate = npc.IsTemplate ?? false;

                    b.Mr = npc.Mr ?? 0;

                    b.Mt = npc.Mt ?? 0;

                    b.Reflex = npc.Ref ?? GetAbilityMod(b.Dex);

                    int.TryParse(npc.Sr, out int sr);
                    b.Sr = sr;

                    b.UniqueMonster = npc.UniqueMonster ?? false;

                    b.Will = npc.Will ?? GetAbilityMod(b.Wis);

                    b.Xp = npc.Xp ?? 0;

                    context.SaveChanges(); // Make sure we have a BestiaryId for our new NPC

                    // Spawn
                    context.MonsterSpawn.Add(new MonsterSpawn()
                    {
                        BestiaryId = b.BestiaryId
                    });

                    // Feat
                    // Improved Initiative, Iron Will, Lightning Reflexes, Skill Focus (Perception)
                    if (!string.IsNullOrWhiteSpace(b.Feats))
                    {
                        foreach (Match m in Regex.Matches(b.Feats, REGEX_SPLIT))
                        {
                            string feat  = m.Groups[1].Value;
                            string notes = null;
                            if (feat.Contains("("))
                            {
                                notes = feat.Split('(')[1].TrimEnd(')');
                                feat  = feat.Split('(')[0].Trim();
                            }
                            if (feat.EndsWith('B'))
                            {
                                feat = feat.Substring(0, feat.Length - 1);
                            }
                            var f = new BestiaryFeat
                            {
                                BestiaryId = b.BestiaryId,
                                FeatId     = context.Feat.FirstOrDefault(x => feat.Equals(x.Name, StringComparison.InvariantCultureIgnoreCase))?.FeatId ?? 0,
                                Notes      = notes
                            };

                            context.BestiaryFeat.Add(f);
                        }
                    }

                    // Skill
                    if (!string.IsNullOrWhiteSpace(b.Skills))
                    {
                        foreach (Match m in Regex.Matches(b.Skills, REGEX_SPLIT))
                        {
                            string skill = m.Groups[1].Value;
                            string notes = null;
                            int    bonus = 0;

                            if (skill.Contains("("))
                            {
                                var idxA = skill.IndexOf('(') + 1;
                                var idxB = skill.LastIndexOf(')');
                                notes = skill.Substring(idxA, idxB - idxA);
                                var newName = skill.Substring(0, --idxA) + skill.Substring(++idxB, skill.Length - idxB); // -- and ++ to make sure parentheses are dropped
                                skill = newName.Trim();
                            }

                            if (skill.Contains("+"))
                            {
                                var skillsplit = skill.Split('+');
                                bonus = Convert.ToInt32(Regex.Match(skillsplit[1], "[0-9]+").Value);

                                skill = skill.Split('+')[0].Trim();
                            }
                            else if (skill.Contains("-"))
                            {
                                var skillsplit = skill.Split('-');
                                bonus = Convert.ToInt32(Regex.Match(skillsplit[1], "[0-9]+").Value) * -1;
                                skill = skillsplit[0].Trim();
                            }

                            if (!context.Skill.Select(x => x.Name.ToLower()).Contains(skill.ToLower()))
                            {
                                context.Skill.Add(new Skill()
                                {
                                    Name        = skill,
                                    Description = "UPDATE ME",
                                    TrainedOnly = false
                                });
                                context.SaveChanges();
                            }

                            var s = new BestiarySkill
                            {
                                BestiaryId = b.BestiaryId,
                                SkillId    = context.Skill.FirstOrDefault(x => skill.Equals(x.Name, StringComparison.InvariantCultureIgnoreCase))?.SkillId ?? 0,
                                Notes      = notes
                            };

                            context.BestiarySkill.Add(s);
                            context.SaveChanges();
                        }
                    }

                    context.SaveChanges();

                    if (i++ >= 5)
                    {
                        i = 0;
                        Console.WriteLine("Finished NPCID " + npc.Npcid.ToString());
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"[{z.Npcid}] - {ex.Message}");
                    if (ex.InnerException != null)
                    {
                        Console.WriteLine("InnerException: " + ex.InnerException.Message);
                    }
                }
            }
        }
Beispiel #26
0
 void Start()
 {
     bestiaryScript = this.GetComponent <Bestiary> ();
 }
    // Use this for initialization
    public void Start()
    {
        //These kind of have to be deserialized in this order to make any sense.
        this.powerBook = PowerBook.Deserialize(this.PowerBookXML.text);
        this.bestiary = Bestiary.Deserialize(this.BestiaryXML.text, this.powerBook);
        this.scenario = Scenario.Deserialize(this.ScenarioXML.text, this.bestiary);

        #region Temp Bestiary...
        //Bestiary bst = new Bestiary();
        //bst.Creatures.Add(new Creature("Player Character Alpha"));
        //bst.Creatures.Add(new Creature("Player Character Bravo"));

        //string[] p1 = new string[] { "Acid Arrow", "Tectonic Shift" };
        //string[] p2 = new string[] { "Flame Burst", "Force Orb" };
        //bst.Creatures[0].AtWillPowerNames = new List<string>(p1);
        //bst.Creatures[1].AtWillPowerNames = new List<string>(p2);

        //bst.Creatures.Add(new Creature("Monster Yankee"));
        //bst.Creatures.Add(new Creature("Monster Zulu"));

        //string[] m = new string[] { "Strike" };
        //bst.Creatures[2].AtWillPowerNames = new List<string>(m);
        //bst.Creatures[3].AtWillPowerNames = new List<string>(m);

        //string bXML = bst.Serialize();
        //StreamWriter writer = new StreamWriter("ThisIsWhereOutputGoes.txt");
        //writer.Write("Nothing to see here.");
        //writer.Close();
        #endregion

        #region Temp Scenario...
        //Scenario scen = new Scenario();

        //Battle a = new Battle();
        //a.FriendlyNames.Add("Player Character Alpha");
        //a.FriendlyNames.Add("Player Character Bravo");
        //a.HostileNames.Add("Monster Zulu");

        //Battle b = new Battle();
        //b.FriendlyNames.Add("Player Character Alpha");
        //b.HostileNames.Add("Monster Yankee");
        //b.HostileNames.Add("Monster Zulu");

        //scen.Battles.Add(a);
        //scen.Battles.Add(b);

        //string sXML = scen.Serialize();
        //StreamWriter writer = new StreamWriter("Assets/Data/scenario.xml");
        //writer.Write(sXML);
        //writer.Close();
        #endregion

        //Make sure there's at least one battle, creature, and power.
        if (this.scenario.Battles.Count == 0 || this.bestiary.Prototypes.Count == 0 || this.powerBook.Powers.Count == 0) {
            Debug.LogError("Data files do not contain sufficient information to play a scenario.");
            Application.Quit();
        }

        this.battleReports = new List<BattleReport>();
        this.surveyReports = new List<SurveyReport>();
    }
Beispiel #28
0
        public virtual bool Attack(Character enemy)
        {
            var visibleFight = Dungeon.Visible[pos] || Dungeon.Visible[enemy.pos];

            if (Hit(this, enemy, false))
            {
                if (visibleFight)
                {
                    GLog.Information(TxtHit, Name, enemy.Name);
                }

                // FIXME
                var dr = this is Hero && ((Hero)this).RangedWeapon != null && ((Hero)this).subClass == HeroSubClass.SNIPER ? 0 : Random.IntRange(0, enemy.Dr());

                var dmg             = DamageRoll();
                var effectiveDamage = Math.Max(dmg - dr, 0);

                effectiveDamage = AttackProc(enemy, effectiveDamage);
                effectiveDamage = enemy.DefenseProc(this, effectiveDamage);
                enemy.Damage(effectiveDamage, this);

                if (visibleFight)
                {
                    Sample.Instance.Play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f));
                }

                if (enemy == Dungeon.Hero)
                {
                    Dungeon.Hero.Interrupt();
                }

                enemy.Sprite.BloodBurstA(Sprite.Center(), effectiveDamage);
                enemy.Sprite.Flash();

                if (!enemy.IsAlive && visibleFight)
                {
                    if (enemy == Dungeon.Hero)
                    {
                        if (Dungeon.Hero.KillerGlyph != null)
                        {
                            Dungeon.Fail(Utils.Format(ResultDescriptions.GLYPH, Dungeon.Hero.KillerGlyph.Name(), Dungeon.Depth));
                            GLog.Negative(TxtKill, Dungeon.Hero.KillerGlyph.Name());
                        }
                        else
                        {
                            if (Bestiary.IsUnique(this))
                            {
                                Dungeon.Fail(Utils.Format(ResultDescriptions.BOSS, Name, Dungeon.Depth));
                            }
                            else
                            {
                                Dungeon.Fail(Utils.Format(ResultDescriptions.MOB, Utils.Indefinite(Name), Dungeon.Depth));
                            }

                            GLog.Negative(TxtKill, Name);
                        }
                    }
                    else
                    {
                        GLog.Information(TxtDefeat, Name, enemy.Name);
                    }
                }

                return(true);
            }

            if (!visibleFight)
            {
                return(false);
            }

            var defense = enemy.DefenseVerb();

            enemy.Sprite.ShowStatus(CharSprite.Neutral, defense);
            if (this == Dungeon.Hero)
            {
                GLog.Information(TxtYouMissed, enemy.Name, defense);
            }
            else
            {
                GLog.Information(TxtSmbMissed, enemy.Name, defense, Name);
            }

            Sample.Instance.Play(Assets.SND_MISS);

            return(false);
        }