Ejemplo n.º 1
0
        public static GameEntity CreateProductAndAttachItToGroup(GameContext gameContext, NicheType nicheType, GameEntity group)
        {
            string name = group.company.Name + " " + Enums.GetFormattedNicheName(nicheType);

            var c = GenerateProductCompany(gameContext, name, nicheType);

            //AttachToGroup(gameContext, group.company.Id, c.company.Id);
            AttachToGroup(gameContext, group, c);

            return(c);
        }
Ejemplo n.º 2
0
        public static GameEntity AutoGenerateProductCompany(NicheType nicheType, GameContext gameContext)
        {
            var playersOnMarket = Markets.GetCompetitorsAmount(nicheType, gameContext);

            var c = GenerateProductCompany(gameContext, Enums.GetFormattedNicheName(nicheType) + " " + playersOnMarket, nicheType);

            AutoFillShareholders(gameContext, c, true);
            //SetFounderAmbitionDueToMarketSize(c, gameContext);

            return(c);
        }
Ejemplo n.º 3
0
        internal static long GetProductCompanyIncome(GameEntity e, GameContext context)
        {
            var   segmentId = e.productPositioning.Positioning;
            float income    = GetIncomeBySegment(context, e, segmentId);

            long result = 0;

            try
            {
                result = Convert.ToInt64(income);
            }
            catch
            {
                Debug.LogWarning("GetProductCompanyIncome " + Enums.GetFormattedNicheName(e.product.Niche) + " error " + e.company.Name);
            }

            return(result * Balance.PERIOD / 30);
        }
Ejemplo n.º 4
0
        public static long GetMarketSize(GameContext gameContext, NicheType nicheType)
        {
            var products = GetProductsOnMarket(gameContext, nicheType);

            try
            {
                return(products
                       .Sum(p => Economy.CostOf(p, gameContext)));
            }
            catch
            {
                Debug.LogWarning("Get market size of " + Enums.GetFormattedNicheName(nicheType));
            }

            return(0);

            //return products.Select(p => CompanyEconomyUtils.GetProductCompanyBaseCost(gameContext, p.company.Id)).Sum();
        }
Ejemplo n.º 5
0
        public static long GetAudienceSize(GameContext gameContext, NicheType nicheType)
        {
            var products = GetProductsOnMarket(gameContext, nicheType);

            try
            {
                var sum = products
                          .Sum(Marketing.GetUsers);

                return(sum);
            }
            catch
            {
                Debug.LogWarning("Get audience size of " + Enums.GetFormattedNicheName(nicheType));
            }

            return(0);
        }
Ejemplo n.º 6
0
        public static int CreateProductAndAttachItToGroup(GameContext gameContext, NicheType nicheType, GameEntity group)
        {
            //var startCapital = NicheUtils.GetStartCapital(nicheType, gameContext) / 2;

            //if (!IsEnoughResources(group, startCapital))
            //    return;

            //SpendResources(group, startCapital);



            string name = group.company.Name + " " + Enums.GetFormattedNicheName(nicheType);

            //if (GetCompanyByName(gameContext, name) != null)
            //    name += " " + Markets.GetCompetitorsAmount(nicheType, gameContext);

            var c = GenerateProductCompany(gameContext, name, nicheType);

            AttachToGroup(gameContext, group.company.Id, c.company.Id);

            return(c.company.Id);
        }
        public static List <ProductPositioning> GetStandardPositionings(NicheType nicheType)
        {
            // Debug.Log("GetStandardPositionings");
            var audiences = Marketing.GetAudienceInfos();

            var nicheName = Enums.GetFormattedNicheName(nicheType);

            var list = new List <ProductPositioning>();

            var adore = 10;
            var hate  = -20;
            var mass  = 3;

            var like = 7;

            int Kids_ID   = 0;
            int Adults_ID = 1;
            int Family_ID = 2;
            int Old_ID    = 3;

            // focus each audience specifically
            foreach (var a in audiences)
            {
                var index = a.ID;

                var loyalties = audiences.Select(a1 => hate).ToList();

                loyalties[index] = adore;

                list.Add(new ProductPositioning
                {
                    ID = list.Count,

                    name          = nicheName + " for " + a.Name,
                    isCompetitive = false,
                    Loyalties     = loyalties,

                    marketShare   = 100,
                    priceModifier = 1f
                });
            }

            AddPositioning(ref list, "Cool " + nicheName, Kids_ID);
            AddPositioning(ref list, "Trendy " + nicheName, Adults_ID, Kids_ID);
            AddPositioning(ref list, "Corporate " + nicheName, Adults_ID, Family_ID);

            // // focus multiple audiences
            // var randomPositionings = Random.Range(6, 10);
            //
            // //var goodness = Random.Range(hate, adore);
            // for (var i = 0; i < randomPositionings; i++)
            // {
            //     int points = audiences.Count * mass;
            //
            //     List<int> loyalties = new List<int> { };
            //
            //     foreach (var s in audiences)
            //     {
            //         var value = Random.Range(-1, like);
            //
            //         var l = Mathf.Clamp(value, hate, Mathf.Min(points, like));
            //
            //         if (l >= 0)
            //             points -= l;
            //         else
            //             l = hate;
            //
            //         loyalties.Add(l);
            //     }
            //
            //     list.Add(new ProductPositioning
            //     {
            //         ID = list.Count,
            //         name = "RANDOM " + nicheName + " " + i,
            //         Loyalties = loyalties.ToList(),
            //         //Loyalties = audiences.Select(a1 => Random.Range(-10, 4)).ToList(),
            //
            //         isCompetitive = false,
            //         marketShare = 100,
            //         priceModifier = 1f,
            //     });
            // }
            //
            // var maxPositioning = list.Count;
            //
            // // remove positionings for noone
            // list.RemoveAll(p => p.Loyalties.All(l => l < 0));
            //
            // // better than global positioning?
            // list.RemoveAll(p => p.Loyalties.All(l => l >= mass));
            //
            // // better than strictly focused positioning
            // list.RemoveAll(p => p.Loyalties.Count(l => l >= adore) >= 2);
            //
            //
            // take ALL
            list.Add(new ProductPositioning
            {
                ID        = list.Count,
                name      = nicheName + " for EVERYONE",
                Loyalties = audiences.Select(a => mass).ToList(),

                isCompetitive = false,
                marketShare   = 100,
                priceModifier = 1f,
            });

            // foreach (ProductPositioning positioning in list)
            // {
            //     Debug.Log($"Added positioning in niche {nicheName}: " + positioning.name + " #" + positioning.ID);
            // }

            // Debug.Log($"Created {list.Count} positionings");

            return(list);
        }