示例#1
0
        public override void PerformSetup(Context context, IState previousState)
        {
            base.PerformSetup(context, previousState);

            _partyDataWrapper = context.Get <PartyDataWrapper>();

            EnemyDefinitionsById = CombatSettings.Enemies.ToDictionary(
                x => x.Id,
                x => HackUtil.GetDefinition <EnemyDefinition>(x.Class.Id));

            PlayerController = new PlayerCharacterController(_partyDataWrapper);
            PlayerController.CombatCompleteSignal.Listen(OnCombatComplete);
            PlayerController.GameStateUpdatedSignal.Listen(OnGameStateUpdated);
            PlayerController.ActiveCharacterChanged += OnActiveCharacterChanged;

            List <IParty> partiesInCombat = new List <IParty>(2);

            partiesInCombat.Add(new Party(
                                    PlayerController.PartyId,
                                    PlayerController,
                                    _partyDataWrapper.Characters));

            foreach (var partyGroup in CombatSettings.Enemies.GroupBy(x => x.Party))
            {
                partiesInCombat.Add(new Party(
                                        partyGroup.Key,
                                        CombatSettings.AI,
                                        partyGroup.ToArray()));
            }

            _combatManager = new CombatManager(
                partiesInCombat,
                PlayerController.GameStateUpdatedSignal,
                PlayerController.CombatCompleteSignal);
        }
示例#2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddServerSideBlazor();

            services.AddScoped <IContext>(provider => new Context());
            services.AddScoped <IStateMachine>(provider =>
            {
                IContext context           = provider.GetRequiredService <IContext>();
                IStateMachine stateMachine = new StateMachine(context as Context);
                stateMachine.ChangeState <LoginState>();
                context.Set <IStateMachine>(stateMachine);
                return(stateMachine);
            });
            services.AddScoped <FirebaseWrapper>(provider =>
            {
                IContext context = provider.GetRequiredService <IContext>();

                JsonSerializerSettings jsonSettings = new JsonSerializerSettings()
                {
                    TypeNameHandling = TypeNameHandling.Auto,
                    ContractResolver = new NewtonsoftContractResolver(),
                    Converters       = new List <JsonConverter>(HackUtil.GetAllJsonConverters())
                };
                FirebaseWrapper fbWrapper = new FirebaseWrapper(jsonSettings);

                context.Set(jsonSettings);
                context.Set(fbWrapper);
                return(fbWrapper);
            });
            services.AddScoped <DialogService>();
            services.AddScoped <NotificationService>();
            services.AddScoped <TooltipService>();
            services.AddScoped <ContextMenuService>();
        }
示例#3
0
        public override void PerformSetup(Context context, IState previousState)
        {
            base.PerformSetup(context, previousState);

            // Generate Calamity
            EnemyDefinition calamityType = HackUtil.GetRandomCalamityClass();

            _calamity = ClassUtil.CreateCharacter(
                calamityType.Id,
                (uint)Guid.NewGuid().GetHashCode(),
                calamityType.NameGenerator.GetName(),
                calamityType.CharacterClass,
                30u);

            // Generate Potential Party Members
            uint partyId = (uint)NewPartyGuid.GetHashCode();

            for (int i = 0; i < 5; i++)
            {
                uint id = (uint)(i + 1);
                PlayerClassDefinition randomClass = HackUtil.GetRandomPlayerClass();
                string          randomName        = randomClass.NameGenerator.GetName();
                PlayerCharacter playerCharacter   = ClassUtil.CreatePlayerCharacter(id, partyId, randomName, randomClass.PlayerClass);
                _generatedCharacters.Add(playerCharacter);
            }

            // Generate (Unequipped) Starting Equipment
            int weaponCount = RANDOM.Next(3);

            for (int i = 0; i < weaponCount; i++)
            {
                if (HackUtil.GetRandomWeapon() is var newWeapon)
                {
                    _generatedInventory.Add(newWeapon.Item);
                }
            }

            int armorCount = RANDOM.Next(3);

            for (int i = 0; i < armorCount; i++)
            {
                if (HackUtil.GetRandomArmor() is var newArmor)
                {
                    _generatedInventory.Add(newArmor.Item);
                }
            }

            int itemCount = RANDOM.Next(5);

            for (int i = 0; i < itemCount; i++)
            {
                if (HackUtil.GetRandomItem() is var newItem)
                {
                    _generatedInventory.Add(newItem.Item);
                }
            }
        }
示例#4
0
        public TownData()
        {
            HasInn  = RANDOM.NextDouble() < 0.75f;
            InnCost = (uint)(50 + RANDOM.Next(50));

            HasDojo  = RANDOM.NextDouble() < 0.2f;
            DojoCost = (uint)(150 + RANDOM.Next(150));

            HasItemShop  = RANDOM.NextDouble() < 0.75f;
            ItemShopCost = (float)(0.8f + RANDOM.NextDouble() * 0.4f);
            if (HasItemShop)
            {
                int itemShopInventoryCount = 5 + RANDOM.Next(10);
                List <ItemDefinition> itemShopInventory = new List <ItemDefinition>(itemShopInventoryCount);
                for (int i = 0; i < itemShopInventoryCount; i++)
                {
                    itemShopInventory.Add(HackUtil.GetRandomItem());
                }
                ItemShopInventory = itemShopInventory;
            }

            HasWeaponShop  = RANDOM.NextDouble() < 0.5f;
            WeaponShopCost = (float)(0.8f + RANDOM.NextDouble() * 0.4f);
            if (HasWeaponShop)
            {
                int weaponShopInventoryCount = 3 + RANDOM.Next(7);
                List <ItemDefinition> weaponShopInventory = new List <ItemDefinition>(weaponShopInventoryCount);
                for (int i = 0; i < weaponShopInventoryCount; i++)
                {
                    weaponShopInventory.Add(HackUtil.GetRandomWeapon());
                }
                WeaponShopInventory = weaponShopInventory;
            }

            HasArmorShop  = RANDOM.NextDouble() < 0.5f;
            ArmorShopCost = (float)(0.8f + RANDOM.NextDouble() * 0.4f);
            if (HasArmorShop)
            {
                int armorShopInventoryCount = 3 + RANDOM.Next(7);
                List <ItemDefinition> armorShopInventory = new List <ItemDefinition>(armorShopInventoryCount);
                for (int i = 0; i < armorShopInventoryCount; i++)
                {
                    armorShopInventory.Add(HackUtil.GetRandomArmor());
                }
                ArmorShopInventory = armorShopInventory;
            }
        }
示例#5
0
 public static CombatSettings CreateFromDifficulty(CombatDifficulty difficulty, PartyDataWrapper playerParty)
 {
     return(CreateFromEnemyGroup(HackUtil.GetRandomEnemyGroup(), difficulty, playerParty));
 }