public static void TurnProductToPlayerFlagship(GameEntity company, GameContext Q, NicheType nicheType, GameEntity parentCompany)
        {
            company.isFlagship = true;
            AttachToPlayer(company);
            company.AddChannelExploration(new Dictionary <int, int>(), new List <int>(), 1);

            // give bad positioning initially
            var infos = Marketing.GetAudienceInfos();

            Marketing.AddClients(company, -50);

            var positionings      = Markets.GetNichePositionings(nicheType, Q);
            var positioningWorths = positionings.OrderBy(Markets.GetPositioningValue);

            // TODO POSITIONING
            var rand           = Random.Range(0, 2);
            var newPositioning = rand < 1 ? 0 : 3; //  positioningWorths.ToArray()[rand].ID;

            // 0 - teens, 3 - old people

            Marketing.ChangePositioning(company, Q, newPositioning);

            Marketing.AddClients(company, 50);

            // give good salary to CEO, so he will not leave company
            var CEO        = Humans.Get(Q, GetCEOId(company));
            var GroupCeoID = GetCEOId(parentCompany);

            CEO.AddPseudoHuman(GroupCeoID);

            // var salary = Teams.GetSalaryPerRating(CEO);
            // Teams.SetJobOffer(CEO, company, new JobOffer(salary), 0, Q);
        }
Example #2
0
        public static void TryToSpawnCompany(GameEntity niche, GameContext gameContext, MarketState phase, bool inPlayerSphereOfInfluence)
        {
            var segments = GetNichePositionings(niche.niche.NicheType, gameContext);

            var  productsOnMarket = Markets.GetProductsOnMarket(niche, gameContext);
            bool willMakeSameProductWithPlayerFlagship = false;

            GameEntity playerFlagship = null;

            if (inPlayerSphereOfInfluence)
            {
                playerFlagship = Companies.GetPlayerFlagship(gameContext);

                if (niche.niche.NicheType == playerFlagship.product.Niche)
                {
                    willMakeSameProductWithPlayerFlagship = true;
                }
            }

            float intensity = 1f / (1 + segments.Count);

            if (inPlayerSphereOfInfluence)
            {
                intensity = 1f;
            }

            foreach (var s in segments)
            {
                var productsCount = productsOnMarket.Count(p => p.productPositioning.Positioning == s.ID);

                bool willCompeteDirectly = false;

                // increase chances if player has companeis in that segment
                if (inPlayerSphereOfInfluence)
                {
                    if (willMakeSameProductWithPlayerFlagship && Companies.IsDirectCompetitor(playerFlagship, niche, s.ID))
                    {
                        willCompeteDirectly = true;
                    }
                }

                var spawnChance = 0f;


                if (productsCount == 0)
                {
                    spawnChance = 20;
                }
                else if (productsCount == 1)
                {
                    spawnChance = 10;
                }
                else if (productsCount == 2)
                {
                    spawnChance = 5;
                }
                else
                {
                    spawnChance = 1;
                }

                if (willCompeteDirectly)
                {
                    spawnChance *= 10;
                }

                spawnChance *= intensity;

                // take into account competition strength too
                // Noone wants to make a browser, cause Google exists already

                if (Random.Range(0f, 100f) < spawnChance)
                {
                    var leaderFunds = Random.Range(50_000, 300_000);

                    var product = SpawnCompany(niche, gameContext, leaderFunds);
                    Marketing.ChangePositioning(product, gameContext, s.ID, true);

                    // NotificationUtils.SendNewCompetitorPopup(gameContext, niche, product);
                }
            }
        }