Exemplo n.º 1
0
        protected virtual void SetDatas()
        {
            playerViewController = this;

            this.buildingContent = new BuildingContent(signalBus, monoBehaviour, cloud, ref uiData);
            uiData.buildingInfo.SetActive(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fills the database with default data.
        /// </summary>
        /// <param name="context">The dbcontext to use.</param>
        /// <returns>The task representing the operation.</returns>
        public static async Task FillWithDefaultAsync(this UnderSeaDatabaseContext context)
        {
            // Effects, Buildings, researches
            // áramlásirányító
            var popIn = new Effect {
                Name = KnownValues.PopulationIncrease, Value = 50
            };
            var cp = new Effect {
                Name = KnownValues.CoralProductionIncrease, Value = 200
            };
            var currentController = new BuildingType {
                CostPearl = 1000, CostCoral = 0, BuildTime = 5, MaxCount = -1
            };

            // zátonyvár
            var bsIn = new Effect {
                Name = KnownValues.BarrackSpaceIncrease, Value = 200
            };
            var reefCastle = new BuildingType {
                CostPearl = 1000, CostCoral = 0, BuildTime = 5, MaxCount = -1
            };

            // Iszaptraktor
            var harvMod1 = new Effect {
                Name = KnownValues.HarvestModifier, Value = 0.1
            };
            var mudT = new ResearchType {
                CostPearl = 1000, CostCoral = 0, ResearchTime = 15, MaxCompletedAmount = 1
            };

            // Iszapkombájn
            var harvMod2 = new Effect {
                Name = KnownValues.HarvestModifier, Value = 0.15
            };
            var mudC = new ResearchType {
                CostPearl = 1000, CostCoral = 0, ResearchTime = 15, MaxCompletedAmount = 1
            };

            // korallfal
            var defMod1 = new Effect {
                Name = KnownValues.UnitDefenseModifier, Value = 0.2
            };
            var wall = new ResearchType {
                CostPearl = 1000, CostCoral = 0, ResearchTime = 15, MaxCompletedAmount = 1
            };

            // Szonárágyú
            var attMod1 = new Effect {
                Name = KnownValues.UnitAttackModifier, Value = 0.2
            };
            var canon = new ResearchType {
                CostPearl = 1000, CostCoral = 0, ResearchTime = 15, MaxCompletedAmount = 1
            };

            // Harcművészet
            var combModA = new Effect {
                Name = KnownValues.UnitAttackModifier, Value = 0.1
            };
            var combModD = new Effect {
                Name = KnownValues.UnitDefenseModifier, Value = 0.1
            };
            var martialArts = new ResearchType {
                CostPearl = 1000, CostCoral = 0, ResearchTime = 15, MaxCompletedAmount = 1
            };

            // Alchemy
            var taxMod1 = new Effect {
                Name = KnownValues.TaxationModifier, Value = 0.3
            };
            var alchemy = new ResearchType {
                CostPearl = 1000, CostCoral = 0, ResearchTime = 15, MaxCompletedAmount = 1
            };


            // Add effects, buildings, researches
            context.Effects.AddRange(popIn, cp, bsIn, harvMod1, harvMod2,
                                     defMod1, attMod1, combModA, combModD, taxMod1);
            context.BuildingTypes.AddRange(currentController, reefCastle);
            context.ResearchTypes.AddRange(mudT, mudC, wall, canon, martialArts, alchemy);
            await context.SaveChangesAsync();


            // Add effects to buildings and researches
            context.BuildingEffects.AddRange(
                new BuildingEffect {
                Building = currentController, Effect = popIn
            },
                new BuildingEffect {
                Building = currentController, Effect = cp
            },
                new BuildingEffect {
                Building = reefCastle, Effect = bsIn
            });

            context.ResearchEffects.AddRange(
                new ResearchEffect {
                Research = mudT, Effect = harvMod1
            },
                new ResearchEffect {
                Research = mudC, Effect = harvMod2
            },
                new ResearchEffect {
                Research = wall, Effect = defMod1
            },
                new ResearchEffect {
                Research = canon, Effect = attMod1
            },
                new ResearchEffect {
                Research = martialArts, Effect = combModA
            },
                new ResearchEffect {
                Research = martialArts, Effect = combModD
            },
                new ResearchEffect {
                Research = alchemy, Effect = taxMod1
            });
            await context.SaveChangesAsync();


            // Add units
            // rohamfóka
            var seal = new UnitType
            {
                AttackPower = 6, DefensePower = 2, CostPearl = 50, CostCoral = 0, MaintenancePearl = 1, MaintenanceCoral = 1
            };
            // csatacsikó
            var pony = new UnitType
            {
                AttackPower = 2, DefensePower = 6, CostPearl = 50, CostCoral = 0, MaintenancePearl = 1, MaintenanceCoral = 1
            };
            // lézercápa
            var lazor = new UnitType
            {
                AttackPower = 5, DefensePower = 5, CostPearl = 100, CostCoral = 0, MaintenancePearl = 3, MaintenanceCoral = 2
            };
            // hadvezér
            var leader = new LeaderType
            {
                AttackPower = 0, DefensePower = 0, CostPearl = 400, CostCoral = 0, MaintenancePearl = 4, MaintenanceCoral = 2
            };

            context.UnitTypes.AddRange(seal, pony, lazor, leader);
            await context.SaveChangesAsync();


            // Add events
            var plague        = new RandomEvent();
            var removeCurrent = new Effect
            {
                TargetId = currentController.Id, Name = KnownValues.AddBuildingEffect, Value = -1
            };

            var fire         = new RandomEvent();
            var removeCastle = new Effect
            {
                TargetId = reefCastle.Id, Name = KnownValues.AddBuildingEffect, Value = -1
            };

            var mine     = new RandomEvent();
            var addPearl = new Effect
            {
                Value = 1000, Name = KnownValues.PearlProductionIncrease
            };

            var goodHarvest = new RandomEvent();
            var extraCoral  = new Effect
            {
                Name = KnownValues.BuildingProductionIncrease, Value = 50
            };

            var badHarvest = new RandomEvent();
            var lessCoral  = new Effect
            {
                Name = KnownValues.BuildingProductionIncrease, Value = -50
            };

            var contentPopulation = new RandomEvent();
            var addCurrent        = new Effect
            {
                Name = KnownValues.AddBuildingEffect, TargetId = currentController.Id, Value = 1
            };
            var discontentPopulation = new RandomEvent();

            var contentSoldiers = new RandomEvent();
            var addAttack       = new Effect
            {
                Name = KnownValues.IncreaseUnitAttack, Value = 1
            };

            var discontentSoldiers = new RandomEvent();
            var removeAttack       = new Effect
            {
                Name = KnownValues.IncreaseUnitAttack, Value = -1
            };

            await context.SaveChangesAsync();

            // Add event effects
            context.EventEffects.AddRange(
                new EventEffect {
                Effect = removeCurrent, Event = plague
            },
                new EventEffect {
                Effect = removeCastle, Event = fire
            },
                new EventEffect {
                Effect = addPearl, Event = mine
            },
                new EventEffect {
                Effect = extraCoral, Event = goodHarvest
            },
                new EventEffect {
                Effect = lessCoral, Event = badHarvest
            },
                new EventEffect {
                Effect = addCurrent, Event = contentPopulation
            },
                new EventEffect {
                Effect = removeCurrent, Event = discontentPopulation
            },
                new EventEffect {
                Effect = addAttack, Event = contentSoldiers
            },
                new EventEffect {
                Effect = removeAttack, Event = discontentSoldiers
            }
                );
            await context.SaveChangesAsync();


            // Add contents
            var currentCont = new BuildingContent
            {
                Parent       = currentController,
                Name         = "Áramlásirányító",
                Description  = "+50 lakos, 200 korall / kör",
                ImageUrl     = "images/static/buildings/aramlasiranyito-lg.png",
                IconImageUrl = "images/static/buildings/aramlasiranyito-icon.png"
            };

            var reefCastCont = new BuildingContent
            {
                Parent       = reefCastle,
                Name         = "Zátonyvár",
                Description  = "+200 szállás",
                ImageUrl     = "images/static/buildings/zatonyvar-lg.png",
                IconImageUrl = "images/static/buildings/zatonyvar-icon.png"
            };

            context.BuildingContents.AddRange(currentCont, reefCastCont);

            var sealCont = new UnitContent
            {
                Parent       = seal,
                Name         = "Rohamfóka",
                Description  = "Jól támad de rosszul véd",
                ImageUrl     = "images/static/units/rohamfoka.svg",
                IconImageUrl = "images/static/units/rohamfoka.svg"
            };
            var ponyCont = new UnitContent
            {
                Parent       = pony,
                Name         = "Csatacsikó",
                Description  = "Jól véd de rosszul támad",
                ImageUrl     = "images/static/units/csatacsiko.svg",
                IconImageUrl = "images/static/units/csatacsiko.svg"
            };
            var lazorCont = new UnitContent
            {
                Parent       = lazor,
                Name         = "Lézercápa",
                Description  = "lazers man",
                ImageUrl     = "images/static/units/lezercapa.svg",
                IconImageUrl = "images/static/units/lezercapa.svg"
            };
            var leaderCont = new UnitContent
            {
                Parent      = leader,
                Name        = "Parancsnok",
                Description = "Támadást csak parancsnok tud vezetni",
            };

            context.UnitContents.AddRange(sealCont, ponyCont, lazorCont, leaderCont);

            var mudTCont = new ResearchContent
            {
                Parent       = mudT,
                Name         = "Iszap traktor",
                Description  = "Iszapozza a korallt (amitől amúgy IRL meghalna, korall nem növény nem kell neki föld), +10% korall termelés",
                ImageUrl     = "images/static/researches/iszaptraktor-lg.png",
                IconImageUrl = "images/static/researches/iszaptraktor-sm.png"
            };
            var mudCCont = new ResearchContent
            {
                Parent       = mudC,
                Name         = "Iszap kombájn",
                Description  = "Nagyon iszapozza a korallt, +15% korall termelés",
                ImageUrl     = "images/static/researches/iszapkombajn-lg.png",
                IconImageUrl = "images/static/researches/iszapkombajn-sm.png"
            };
            var defCont = new ResearchContent
            {
                Parent       = wall,
                Name         = "Korallfal",
                Description  = "Fal, korallból. +20% védekezés",
                ImageUrl     = "images/static/buildings/korallfal.svg",
                IconImageUrl = "images/static/buildings/korallfal.svg"
            };
            var attCont = new ResearchContent
            {
                Parent       = canon,
                Name         = "Szonárágyú",
                Description  = "Mint a denevér, echo-lokáció. +20% támadás",
                ImageUrl     = "images/static/researches/szonaragyu-lg.png",
                IconImageUrl = "images/static/researches/szonaragyu-sm.png"
            };
            var cCont = new ResearchContent
            {
                Parent       = martialArts,
                Name         = "Vízalatti harcművészetek",
                Description  = "\"A különbség a lehetetlen és a lehetséges között az egyén akarata.\", +10% védekezés és támadás",
                ImageUrl     = "images/static/buildings/vizalatti-harcmuveszetek.svg",
                IconImageUrl = "images/static/buildings/vizalatti-harcmuveszetek.svg"
            };
            var taxCont = new ResearchContent
            {
                Parent       = alchemy,
                Name         = "Alkímia",
                Description  = "A népesség pénzt csinál, +30% adó bevétel",
                ImageUrl     = "images/static/buildings/alkimia.svg",
                IconImageUrl = "images/static/buildings/alkimia.svg"
            };

            context.ResearchContents.AddRange(mudTCont, mudCCont, defCont, attCont, cCont, taxCont);

            var plagueCont = new EventContent
            {
                Parent      = plague,
                Name        = "Pestis",
                Description = "Az országodban kitört a pestis, elveszítesz 50 embert és egy áramlásirányítót.",
                FlavourText = "Hozzátok a halottakat!"
            };
            var fireCont = new EventContent
            {
                Parent      = fire,
                Name        = "Víz alatti tűz",
                Description = "Az országodban tűz ütött ki és leégett egy zátonyvár.",
                FlavourText = "Tűz víz alatt? Micsoda?!"
            };
            var mineCont = new EventContent
            {
                Parent      = mine,
                Name        = "Aranybánya",
                Description = "Az embereid felfedeztek egy új aranybányát, kapsz 1000 bónusz aranyat.",
                FlavourText = "Nagyon fényes"
            };
            var goodhvCont = new EventContent
            {
                Parent      = goodHarvest,
                Name        = "Jó termés",
                Description = "Minden áramlásirányító +50 korallt ad ebben a körben.",
                FlavourText = "A termés egy stabil ország alapja"
            };
            var badhvCont = new EventContent
            {
                Parent      = badHarvest,
                Name        = "Rossz termés",
                Description = "Minden áramlásirányító -50 korallt ad ebben a körben.",
                FlavourText = "A király lakomázik, a paraszt éhezik"
            };
            var contPopCont = new EventContent
            {
                Parent      = contentPopulation,
                Name        = "Elégedett emberek",
                Description = "Az országodban elégedettek az emberek, ezért extra 50 ember költözött be és építettek maguknak egy áramlásirányítót.",
                FlavourText = "Nő a nép, nő a felelősség"
            };
            var discontPopCont = new EventContent
            {
                Parent      = discontentPopulation,
                Name        = "Elégedetlen emberek",
                Description = "Az országodban elégedetlenek az emberek, ezért 50 ember elköltözött és az áramlásirányítójukat lerombolták.",
                FlavourText = "A paraszt elmegy, pusztítást hagy maga után"
            };
            var contSolCont = new EventContent
            {
                Parent      = contentSoldiers,
                Name        = "Elégedett katonák",
                Description = "Katonáid elégedettek ebben a körben, minden katona támadása nő eggyel.",
                FlavourText = "Elégedett katona motivált katona"
            };
            var disconSolCont = new EventContent
            {
                Parent      = discontentSoldiers,
                Name        = "Elégedetlen katonák",
                Description = "Katonáid elégedetlenek ebben a körben, minden katona támadása csökken eggyel.",
                FlavourText = "Elsőnek a morál, utána a hűség"
            };

            context.EventContents.AddRange(plagueCont, mineCont, fireCont, goodhvCont, badhvCont,
                                           contPopCont, contSolCont, disconSolCont, discontPopCont);
            await context.SaveChangesAsync();


            // globals
            context.GlobalValues.Add(new GlobalValue
            {
                BaseTaxation              = 25,
                Round                     = 1,
                StartingBarrackSpace      = 0,
                StartingCorals            = 2000,
                StartingPearls            = 2000,
                StartingPopulation        = 0,
                LootPercentage            = 0.5,
                UnitLossOnLostBatle       = 0.1,
                RandomEventChance         = 0.1,
                RandomEventGraceTimer     = 10,
                ScoreBuildingMultiplier   = 50,
                ScoreResearchMultiplier   = 100,
                ScorePopulationMultiplier = 1,
                ScoreUnitMultiplier       = 5,
                FirstStartingBuilding     = reefCastle,
                SecondStartingBuilding    = currentController,
                RandomAttackModifier      = 0.1
            });
            await context.SaveChangesAsync();
        }