Exemple #1
0
    void RenderProposalStatus(bool willAcceptOffer, long progress, AcquisitionConditions SellerOffer)
    {
        var cost = Economy.CostOf(SelectedCompany, Q);

        Response.text = $"Cash: {Format.Money(SellerOffer.Price)} (Real valuation = {Format.Money(cost)})";

        var o = AcquisitionOffer;

        if (o.Turn == AcquisitionTurn.Seller)
        {
            // ProposalStatus
            Response.text += "\nThey will respond in a month or so";

            //if (!ScheduleUtils.IsTimerRunning(Q))
            //    ProposalStatus.text += Visuals.Negative("Unpause") + " to get their response";
        }
        //else
        //{
        //    //var status = $"{progress}% of owners want to accept your offer";
        //    //var textDescription = willAcceptOffer ? Visuals.Positive("They will accept offer!") : Visuals.Negative("They will not accept offer!");

        //    //ProposalStatus.text = status; // + "\n" + textDescription;
        //}

        ProgressText.text  = progress + "%";
        ProgressText.color = Visuals.GetColorPositiveOrNegative(willAcceptOffer);
    }
Exemple #2
0
    AcquisitionConditions GetNewBuyerOffer(GameEntity offer, GameEntity target, int shareholderId, long maxOfferedPrice)
    {
        var cost = Economy.CostOf(target, gameContext);

        var modifier = Companies.GetRandomAcquisitionPriceModifier(target.company.Id, shareholderId);
        var maxPrice = (long)(cost * modifier); // the max amount, that we want to pay theoretically

        var newPrice = (long)(maxOfferedPrice * Random.Range(1.05f, 5f));

        if (newPrice > maxPrice)
        {
            newPrice = maxPrice;
        }

        var investor = Investments.GetInvestor(gameContext, shareholderId);
        var balance  = investor.companyResource.Resources.money;

        if (newPrice > balance)
        {
            newPrice = balance;
        }

        return(new AcquisitionConditions
        {
            ByCash = newPrice,
            Price = newPrice,
            ByShares = offer.acquisitionOffer.BuyerOffer.ByShares,
            KeepLeaderAsCEO = offer.acquisitionOffer.BuyerOffer.KeepLeaderAsCEO,
        });
    }
Exemple #3
0
    public override void ViewRender()
    {
        base.ViewRender();

        var offers = Companies.GetAcquisitionOffersToCompany(Q, SelectedCompany)
                     .Select(o => $"{Companies.GetName(Q, o.acquisitionOffer.CompanyId)}: {Format.Money(o.acquisitionOffer.BuyerOffer)}")
                     .ToList();

        var acquisitionOffer = AcquisitionOffer;

        if (acquisitionOffer != null)
        {
            var  conditions = acquisitionOffer.BuyerOffer;
            var  seller     = acquisitionOffer.SellerOffer;
            long price      = conditions.Price;

            var cost = Economy.CostOf(SelectedCompany, Q);


            var sellerPrice = $"They want {Format.Money(seller.Price)} (Real valuation = {Format.Money(cost)})";

            offers.Add(sellerPrice);
        }

        SetItems(offers);
    }
Exemple #4
0
    void Render()
    {
        var c     = Companies.Get(Q, companyId);
        var buyer = Companies.GetInvestorById(Q, buyerId);

        Name.text             = c.company.Name;
        CompanyLink.CompanyId = companyId;
        BuyerLink.CompanyId   = buyer.company.Id;

        Buyer.text = Companies.GetInvestorName(buyer);

        var hasControl = Companies.GetControlInCompany(MyCompany, buyer, Q) > 0;

        Buyer.color = Visuals.GetColorFromString(hasControl ? Colors.COLOR_CONTROL : Colors.COLOR_CONTROL_NO);

        var rating = c.hasProduct ? Markets.GetMarketRating(Q, c.product.Niche): 0;

        NicheStage.SetStars(rating);

        StageHint.SetHint(c.hasProduct ? Markets.GetMarketState(Q, c.product.Niche).ToString() : "");

        Valuation.text = Format.Money(Economy.CostOf(c, Q));

        var offer = Companies.GetAcquisitionOffer(Q, c, buyer);

        //Offer.text = Format.Money(offer.acquisitionOffer.Offer);

        AcceptOffer.SetData(companyId, buyerId);
        RejectOffer.SetData(companyId, buyerId);
    }
Exemple #5
0
 void RenderValuation()
 {
     if (IsInvestmentRoundActive)
     {
         //Valuation.text = "$" + Format.Minify(proposal.Investment.Valuation);
         Valuation.text = Format.Money(Economy.CostOf(MyCompany, Q), true);
     }
 }
Exemple #6
0
    public override void SetItem <T>(Transform t, T entity)
    {
        var company = entity as GameEntity;

        var cost = Economy.CostOf(company, Q);

        t.GetComponent <MockText>().SetEntity($"{company.company.Name} ({Format.Money(cost)})");
    }
Exemple #7
0
    public void Render()
    {
        var groups = Companies.GetGroupCompanies(Q)
                     .OrderByDescending(g => Economy.CostOf(g, Q))
                     .ToArray();

        SetItems(groups);
    }
Exemple #8
0
    public override void ViewRender()
    {
        base.ViewRender();

        var companies = Companies.GetDaughters(SelectedCompany, Q)
                        .OrderByDescending(c => Economy.CostOf(c, Q));

        SetItems(companies);
    }
Exemple #9
0
    public override void ViewRender()
    {
        base.ViewRender();

        var c = SelectedCompany;

        CompanyCost.text = RenderCosts(Economy.CostOf(c, Q));

        RenderBaseCosts(c);
    }
Exemple #10
0
    public override void ViewRender()
    {
        base.ViewRender();

        if (!HasCompany)
        {
            return;
        }

        var name = SelectedCompany.company.Name;

        Title.text = $"Integrate \"{name}\" to our corporation";

        bool willAcceptOffer = false; // Companies.IsCompanyWillAcceptCorporationOffer(Q, SelectedCompany, MyCompany.shareholder.Id);

        var progress = Companies.GetCorporationOfferProgress(Q, SelectedCompany, MyCompany.shareholder.Id);

        Progress.text = Visuals.Colorize(progress + "%", willAcceptOffer);


        // TODO DIVIDE BY ZERO
        var ourCost = Economy.CostOf(MyCompany, Q);

        if (ourCost == 0)
        {
            ourCost = 1;
        }
        var targetCost = Economy.CostOf(SelectedCompany, Q);

        var sizeComparison = targetCost * 100 / ourCost;

        var futureShares = targetCost * 100 / (targetCost + ourCost);

        OurValuation.text    = Format.Money(ourCost);
        TargetValuation.text = $"{Format.Money(targetCost)} ({sizeComparison}% compared to us)";

        bool willStayIndependent = KeepAsIndependent.isOn;

        var isTargetTooBig    = targetCost * 100 > ourCost * 15;
        var tooSmallToAcquire = isTargetTooBig ? Visuals.Negative("This company costs more than 15% of our corporation, so they won't join us.") : "";

        OfferNote.text = $"{tooSmallToAcquire}\n\nCompany {name} will be <b>Fully</b> integrated to our company.\n\n" +
                         $"Their shareholders will own {futureShares} % of our corporation";
        //if (willStayIndependent)
        //{
        //}
        //else
        //{
        //    OfferNote.text = $"Company {name} will be <b>Partially</b> integrated to our company." +
        //        $"\n\nThey will be able to leave whenever they want." +
        //        $"\nTheir shareholders won't receive our shares." +
        //        $"\n\nOur company will get +1 Brand power for all products in Communications industry." +
        //        $"\n\n{name} will get ";
        //}
    }
 private void SaveGroupCompanyMetrics(GameEntity e, int date)
 {
     CompanyStatisticsUtils.AddMetrics(gameContext, e, new MetricsInfo
     {
         AudienceSize = 0,
         Date         = date,
         Income       = Economy.GetIncome(gameContext, e),
         Profit       = Economy.GetProfit(gameContext, e),
         Valuation    = Economy.CostOf(e, gameContext)
     });
 }
Exemple #12
0
    public override void ViewRender()
    {
        base.ViewRender();

        var daughters = Companies.GetDaughters(MyCompany, Q)
                        //.OrderBy(d => CompanyStatisticsUtils.GetIncomeGrowthAbsolute(d, 12))
                        .OrderByDescending(d => Economy.CostOf(d, Q))
                        .ToArray();

        SetItems(daughters);
    }
        public static long GetNewSharesSize(GameContext gameContext, GameEntity company, long offer)
        {
            // calculating new shares size
            long cost = Economy.CostOf(company, gameContext);

            var allShares = (long)GetTotalShares(company);

            long shares = allShares * offer / cost;

            return(shares);
        }
Exemple #14
0
    void RenderOffer()
    {
        long Cost = Economy.CostOf(MyCompany, Q);

        long offer           = proposal.Investment.Offer;
        var  portion         = proposal.Investment.Portion;
        long futureShareSize = offer * 100 / (offer + Cost);

        Offer.text   = $"{Format.Money(offer, true)} for {futureShareSize}% of our company";
        Portion.text = $"{Format.Money(portion, true)} / week (during {proposal.Investment.RemainingPeriods} weeks)";
    }
Exemple #15
0
 void SaveProductCompanyMetrics(GameEntity e, int date)
 {
     CompanyStatisticsUtils.AddMetrics(gameContext, e, new MetricsInfo
     {
         Date         = date,
         AudienceSize = Marketing.GetUsers(e),
         Income       = Economy.GetIncome(gameContext, e),
         Profit       = Economy.GetProfit(gameContext, e),
         Valuation    = Economy.CostOf(e, gameContext)
     });
 }
Exemple #16
0
    void RenderNewCorporationRequirements(PopupMessageCorporationRequirements popup)
    {
        var company = Companies.Get(Q, popup.companyId);
        var cost    = Economy.CostOf(company, Q);
        var goal    = C.CORPORATION_REQUIREMENTS_COMPANY_COST;

        RenderUniversalPopup(
            "You cannot create a corporation :(",
            $"Your company costs {Format.Money(cost)}, but needs to cost at least {Format.Money(goal)} to become a corporation",
            typeof(ClosePopupCancel)
            );
    }
    List <ReportData> GetGroupList()
    {
        var groups = Companies.GetGroupCompanies(gameContext)
                     .OrderByDescending(g => Economy.CostOf(g, gameContext))
                     .ToArray();

        var List = groups.Select(g => new ReportData {
            Cost = Economy.CostOf(g, gameContext), ShareholderId = g.shareholder.Id
        }).ToList();

        return(WrapIndices(List));
    }
    List <ReportData> GetProductList()
    {
        var products = Companies.GetProductCompanies(gameContext)
                       .OrderByDescending(p => Economy.CostOf(p, gameContext));


        var List = products.Select(p => new ReportData {
            Cost = Economy.CostOf(p, gameContext), ShareholderId = p.company.Id
        }).ToList();

        return(WrapIndices(List));
    }
Exemple #19
0
    public override void SetItem <T>(Transform t, T entity)
    {
        // previous prefab: StrategicPartnershipView

        var company   = entity as GameEntity;
        var companyId = company.company.Id;

        //t.GetComponent<LinkToProjectView>().CompanyId = companyId;
        //t.GetComponent<RenderPartnerName>().SetCompanyId(companyId);

        t.gameObject.AddComponent <Button>();
        t.gameObject.AddComponent <LinkToProjectView>().CompanyId = companyId;

        string text = company.company.Name;

        if (Companies.IsDirectlyRelatedToPlayer(Q, company))
        {
            text = Visuals.Colorize(text, Colors.COLOR_GOLD);
        }

        var sameMarkets = new List <NicheType>();

        var m1 = SelectedCompany.companyFocus.Niches;
        var m2 = company.companyFocus.Niches;

        foreach (var m in m1)
        {
            if (m2.Contains(m))
            {
                sameMarkets.Add(m);
            }
        }

        if (company.hasProduct)
        {
            var innovativeness = Products.GetInnovationChance(company, Q);

            var level = Products.GetProductLevel(company);

            text += $" ({level}LVL)\n(Innovativeness: {innovativeness}%)";
        }
        else
        {
            var cost = Economy.CostOf(company, Q);

            text += $" (Cost: {Format.Money(cost)})";
            text += "\nCommon markets: " + String.Join(", ", sameMarkets.Select(Enums.GetFormattedNicheName));
        }



        t.gameObject.GetComponent <MockText>().SetEntity(text);
    }
Exemple #20
0
    public override void ViewRender()
    {
        base.ViewRender();

        var industry = MyCompany.companyFocus.Industries[0];

        // get independent companies, that are interested in this industry
        var companies = Companies.GetNonFundCompaniesInterestedInIndustry(Q, industry)
                        .OrderByDescending(c => Economy.CostOf(c, Q));

        SetItems(companies);
    }
Exemple #21
0
    public override void ViewRender()
    {
        base.ViewRender();

        var industry = MyCompany.companyFocus.Industries[0];

        // get all independent nonfund companies
        var companies = Companies.GetIndependentCompanies(Q)
                        .Where(Companies.IsNotFinancialStructure)
                        .OrderByDescending(c => Economy.CostOf(c, Q));

        SetItems(companies);
    }
    GameEntity[] GetCompetingCompanies()
    {
        var niches = MyCompany.companyFocus.Niches;

        return(Markets.GetNonFinancialCompaniesWithSameInterests(Q, MyCompany)
               .OrderByDescending(c => Economy.CostOf(c, Q))
               .ToArray());

        ////niches.Select()
        //return CompanyUtils.GetAIManagingCompanies(GameContext)
        //    .OrderByDescending(c => CompanyEconomyUtils.GetCompanyCost(GameContext, c))
        //    .ToArray();
    }
Exemple #23
0
    void SendAcquisitionOffer(GameEntity buyer, GameEntity target, GameContext gameContext)
    {
        var cost = Economy.CostOf(target, gameContext) * Random.Range(1, 10) / 2;

        if (!Companies.IsEnoughResources(buyer, cost))
        {
            return;
        }

        Debug.Log("AI.SendAcquisitionOffer: " + buyer.company.Name + " wants " + target.company.Name);

        Companies.SendAcquisitionOffer(gameContext, target, buyer, cost);
    }
Exemple #24
0
    long GetNewPrice(GameEntity target, int shareholderId, AcquisitionConditions BuyerOffer)
    {
        var cost = Economy.CostOf(target, gameContext);

        var Kmin    = Companies.GetRandomAcquisitionPriceModifier(target.company.Id, shareholderId);
        var Kbuyer  = BuyerOffer.Price * 1f / cost;
        var Kseller = 2 * Kmin - Kbuyer;

        var KsellerRandomised = Kseller * Random.Range(0.85f, 1.15f);

        var newPrice = (double)Mathf.Max(KsellerRandomised, Kmin, Kbuyer) * cost;

        return((long)newPrice);
    }
Exemple #25
0
        public static bool IsShareholderWillAcceptCorporationOffer(GameEntity company, int shareholderId, GameContext gameContext)
        {
            // costs
            var targetCost = Economy.CostOf(company, gameContext);

            var corporation     = Investments.GetCompanyByInvestorId(gameContext, shareholderId);
            var corporationCost = Economy.CostOf(corporation, gameContext);

            // desire to sell
            var baseDesireToSellCompany = GetBaseDesireToSellShares(gameContext, company.company.Id, shareholderId);
            var wantsToSellShares       = true || baseDesireToSellCompany == 1;

            var isSmallComparedToCorporation = targetCost * 100 < 15 * corporationCost;

            return(wantsToSellShares && isSmallComparedToCorporation);
        }
Exemple #26
0
    public override void Execute()
    {
        var cost = Economy.CostOf(MyCompany, Q);
        var goal = C.CORPORATION_REQUIREMENTS_COMPANY_COST;

        if (cost < goal)
        {
            NotificationUtils.AddPopup(Q, new PopupMessageCorporationRequirements(MyCompany.company.Id));
        }
        else
        {
            Companies.PromoteToCorporation(MyCompany, Q);

            Navigate(ScreenMode.CorporationScreen);
        }
    }
Exemple #27
0
    public override void ViewRender()
    {
        base.ViewRender();

        var independentCompanies = Companies.GetIndependentCompanies(Q)
                                   .Where(Companies.IsNotFinancialStructure)
                                   .OrderByDescending(c => Economy.CostOf(c, Q))
                                   .ToArray();

        var companies = new List <GameEntity>();

        for (var i = 0; i < 10 && i < independentCompanies.Count(); i++)
        {
            companies.Add(independentCompanies[i]);
        }

        SetItems(companies);
    }
Exemple #28
0
    public override void ViewRender()
    {
        base.ViewRender();


        // TODO also check if products are in same industry
        var dominantIndustry            = MyCompany.companyFocus.Industries[0];
        var dominantIndustryCompetitors = Companies.GetNonFundCompaniesInterestedInIndustry(Q, dominantIndustry)
                                          .OrderByDescending(c => Economy.CostOf(c, Q));

        bool isDomineeringOnMarket = dominantIndustryCompetitors.First().company.Id == MyCompany.company.Id;

        IndustrialScreen.SetActive(!isDomineeringOnMarket);

        // check company goal here
        // top1 screen or mission screen

        TOP1Screen.SetActive(isDomineeringOnMarket);
    }
Exemple #29
0
    void RenderCashOffer(AcquisitionConditions BuyerOffer, AcquisitionTurn turn)
    {
        var  cost  = Economy.CostOf(SelectedCompany, Q);
        long price = BuyerOffer.Price;

        string overpriceText = "";

        if (price > cost)
        {
            var overprice = Mathf.Ceil(price * 10 / cost);
            overpriceText = $"  ({(overprice / 10)}x)";
        }

        Offer.text          = Format.Money(price) + overpriceText;
        CashOfferInput.text = price.ToString();


        Draw(CashOfferInput, turn == AcquisitionTurn.Buyer);
        Draw(CashOfferContainer, turn == AcquisitionTurn.Buyer);
    }
Exemple #30
0
    public void Render()
    {
        if (entity == null)
        {
            return;
        }

        SetProductCompanyTableView();

        CompanyName.text = entity.company.Name;

        SetPanelColor();

        Cost.text = Format.Money(Economy.CostOf(entity, Q), true);


        RenderValuationGrowth();

        GetComponent <LinkToProjectView>().CompanyId = entity.company.Id;
    }