Ejemplo n.º 1
0
    void DecreaseCompanyPrice(GameEntity offer, int targetId, int shareholderId)
    {
        var o = offer.acquisitionOffer;


        var cost = Economy.GetCompanyCost(gameContext, targetId);

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

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

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

        var sellerConditions = new AcquisitionConditions
        {
            Price           = (long)newPrice,
            ByCash          = (long)newPrice,
            ByShares        = 0,
            KeepLeaderAsCEO = o.SellerOffer.KeepLeaderAsCEO
        };


        offer.ReplaceAcquisitionOffer(targetId, shareholderId, AcquisitionTurn.Buyer, o.BuyerOffer, sellerConditions);

        var investor = Investments.GetInvestorById(gameContext, shareholderId);

        if (investor.isControlledByPlayer)
        {
            NotificationUtils.AddPopup(gameContext, new PopupMessageAcquisitionOfferResponse(targetId, shareholderId));
        }
    }
Ejemplo n.º 2
0
        internal static void SetCompanyGoal(GameContext gameContext, GameEntity company, InvestorGoal investorGoal)
        {
            long measurableGoal = 5000;

            switch (investorGoal)
            {
            case InvestorGoal.Prototype: measurableGoal = 1; break;

            case InvestorGoal.FirstUsers: measurableGoal = 50; break;

            case InvestorGoal.BecomeMarketFit: measurableGoal = -1; break;

            case InvestorGoal.Release: measurableGoal = 1; break;

            case InvestorGoal.BecomeProfitable: measurableGoal = 0; break;

            case InvestorGoal.IPO: measurableGoal = 1; break;

            case InvestorGoal.GrowCompanyCost:
                measurableGoal = Economy.GetCompanyCost(gameContext, company.company.Id) * (100 + Balance.INVESTMENT_GOAL_GROWTH_REQUIREMENT_COMPANY_COST) / 100;
                break;
            }

            company.ReplaceCompanyGoal(investorGoal, measurableGoal);
        }
Ejemplo n.º 3
0
    AcquisitionConditions GetNewCounterOffer(GameEntity offer, int targetId, int shareholderId, long maxOfferedPrice)
    {
        var cost = Economy.GetCompanyCost(gameContext, targetId);

        var modifier = Companies.GetRandomAcquisitionPriceModifier(targetId, 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.GetInvestorById(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,
        });
    }
Ejemplo n.º 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.GetCompanyCost(Q, companyId));

        var offer = Companies.GetAcquisitionOffer(Q, companyId, buyerId);

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

        AcceptOffer.SetData(companyId, buyerId);
        RejectOffer.SetData(companyId, buyerId);
    }
Ejemplo n.º 5
0
    void RenderShareOfferSlider(AcquisitionConditions conditions, long price)
    {
        var ourCompanyCost = Economy.GetCompanyCost(Q, MyCompany);


        var sharePercent        = conditions.ByShares; // ;
        var maxAllowedShareCost = 25 * ourCompanyCost / 100;

        var shareCost = Mathf.Clamp(sharePercent * price / 100, 0, maxAllowedShareCost);

        sharePercent = (int)(shareCost * 100 / price);



        Slider.minValue = 0;
        Slider.maxValue = 100;


        Slider.maxValue = Mathf.Clamp(maxAllowedShareCost * 100 / price, 0, 100);

        var sharePartOfCompany = shareCost * 100 / ourCompanyCost;

        var cash = price - shareCost;

        SharePercentage.text = $"You will pay {Format.Money(cash)} with cash and give {sharePartOfCompany}% of your company shares (worth ${Format.Money(shareCost)})";
    }
Ejemplo n.º 6
0
 private static GoalRequirements GoalCompanyCost(GameEntity company, GameContext gameContext)
 {
     return(new GoalRequirements
     {
         have = Economy.GetCompanyCost(gameContext, company.company.Id),
         need = company.companyGoal.MeasurableGoal
     });
 }
Ejemplo n.º 7
0
    public void Render()
    {
        var groups = Companies.GetGroupCompanies(Q)
                     .OrderByDescending(g => Economy.GetCompanyCost(Q, g.company.Id))
                     .ToArray();

        SetItems(groups, GrowthFilterQuarterly.Quarterly);
    }
Ejemplo n.º 8
0
    void RenderOffer()
    {
        long Cost = Economy.GetCompanyCost(Q, SelectedCompany.company.Id);

        long offer           = proposal.Offer;
        long futureShareSize = offer * 100 / (offer + Cost);

        Offer.text = $"${Format.Minify(offer)} for {futureShareSize}% of our company";
    }
Ejemplo n.º 9
0
    public override void ViewRender()
    {
        base.ViewRender();

        if (!HasCompany)
        {
            return;
        }

        var name = SelectedCompany.company.Name;

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

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

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

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


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

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

        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 ";
        //}
    }
Ejemplo n.º 10
0
    void RenderNewCorporationRequirements(PopupMessageCorporationRequirements popup)
    {
        var cost = Economy.GetCompanyCost(Q, popup.companyId);
        var goal = Balance.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)
            );
    }
Ejemplo n.º 11
0
    public override void ViewRender()
    {
        base.ViewRender();

        var daughters = Companies.GetDaughterCompanies(Q, MyCompany.company.Id)
                        //.OrderBy(d => CompanyStatisticsUtils.GetIncomeGrowthAbsolute(d, 12))
                        .OrderByDescending(d => Economy.GetCompanyCost(Q, d.company.Id))
                        .ToArray();

        SetItems(daughters);
    }
Ejemplo n.º 12
0
 void SaveProductCompanyMetrics(GameEntity e, int date)
 {
     CompanyStatisticsUtils.AddMetrics(gameContext, e, new MetricsInfo
     {
         Date         = date,
         AudienceSize = Marketing.GetClients(e),
         Income       = Economy.GetCompanyIncome(gameContext, e),
         Profit       = Economy.GetProfit(gameContext, e),
         Valuation    = Economy.GetCompanyCost(gameContext, e)
     });
 }
Ejemplo n.º 13
0
 private void SaveGroupCompanyMetrics(GameEntity e, int date)
 {
     CompanyStatisticsUtils.AddMetrics(gameContext, e, new MetricsInfo
     {
         Date         = date,
         AudienceSize = 0,
         Income       = Economy.GetCompanyIncome(gameContext, e),
         Profit       = Economy.GetProfit(gameContext, e),
         Valuation    = Economy.GetCompanyCost(gameContext, e)
     });
 }
Ejemplo n.º 14
0
    GameEntity[] GetOwnings()
    {
        var arr = Companies.GetDaughterCompanies(Q, ObservableCompany.company.Id)
                  .OrderByDescending(c => Economy.GetCompanyCost(Q, c.company.Id))
                  .ToArray();

        //if (SortingOrder)
        //    Array.Reverse(arr);

        return(arr);
    }
Ejemplo n.º 15
0
    public override void ViewRender()
    {
        base.ViewRender();

        var c         = SelectedCompany;
        var companyId = c.company.Id;

        CompanyCost.text = RenderCosts(Economy.GetCompanyCost(Q, companyId));

        RenderBaseCosts(companyId, c);
    }
Ejemplo n.º 16
0
    GameEntity[] GetCompetingCompanies()
    {
        var niches = MyCompany.companyFocus.Niches;

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

        ////niches.Select()
        //return CompanyUtils.GetAIManagingCompanies(GameContext)
        //    .OrderByDescending(c => CompanyEconomyUtils.GetCompanyCost(GameContext, c))
        //    .ToArray();
    }
    void SendAcquisitionOffer(GameEntity buyer, GameEntity target, GameContext gameContext)
    {
        var cost = Economy.GetCompanyCost(gameContext, target.company.Id) * 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.company.Id, buyer.shareholder.Id, cost);
    }
Ejemplo n.º 18
0
    public override void Execute()
    {
        var cost = Economy.GetCompanyCost(Q, MyCompany);
        var goal = Balance.CORPORATION_REQUIREMENTS_COMPANY_COST;

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

            Navigate(ScreenMode.CorporationScreen);
        }
    }
        public static bool IsShareholderWillAcceptAcquisitionOffer(AcquisitionOfferComponent ackOffer, int shareholderId, GameContext gameContext)
        {
            var cost = Economy.GetCompanyCost(gameContext, ackOffer.CompanyId);

            var company  = Get(gameContext, ackOffer.CompanyId);
            var investor = GetInvestorById(gameContext, shareholderId);

            var  container       = GetInvestorOpinionAboutAcquisitionOffer(ackOffer, investor, company, gameContext);
            bool willAcceptOffer = container.Sum() >= 0; // ackOffer.Offer > cost * modifier;


            bool isBestOffer = true; // when competing with other companies
            var  offers      = GetAcquisitionOffersToCompany(gameContext, ackOffer.CompanyId);

            var baseDesireToSellCompany = GetBaseDesireToSellShares(gameContext, company, shareholderId, investor.shareholder.InvestorType);
            var wantsToSellShares       = true || baseDesireToSellCompany == 1;

            return(wantsToSellShares && willAcceptOffer && isBestOffer);
        }
Ejemplo n.º 20
0
    public void Render()
    {
        if (entity == null)
        {
            return;
        }

        SetProductCompanyTableView();

        CompanyName.text = entity.company.Name;

        SetPanelColor();

        Cost.text = "$" + Format.MinifyToInteger(Economy.GetCompanyCost(Q, entity.company.Id));


        RenderValuationGrowth();

        GetComponent <LinkToProjectView>().CompanyId = entity.company.Id;
    }
Ejemplo n.º 21
0
    List <ReportData> GetGroupList()
    {
        var groups = Companies.GetGroupCompanies(gameContext)
                     .OrderByDescending(g => Economy.GetCompanyCost(gameContext, g.company.Id))
                     .ToArray();

        var List = new List <ReportData>();

        for (var i = 0; i < groups.Length; i++)
        {
            var g = groups[i];

            List.Add(new ReportData
            {
                Cost          = Economy.GetCompanyCost(gameContext, g.company.Id),
                ShareholderId = g.shareholder.Id,
                position      = i
            });
        }

        return(List);
    }
Ejemplo n.º 22
0
    List <ReportData> GetProductList()
    {
        var products = Companies.GetProductCompanies(gameContext)
                       .OrderByDescending(p => Economy.GetCompanyCost(gameContext, p.company.Id))
                       .ToArray();

        var List = new List <ReportData>();

        for (var i = 0; i < products.Length; i++)
        {
            var p  = products[i];
            var id = p.company.Id;

            List.Add(new ReportData
            {
                Cost          = Economy.GetCompanyCost(gameContext, id),
                ShareholderId = id,
                position      = i
            });
        }

        return(List);
    }
Ejemplo n.º 23
0
    void RenderOffer(bool willAcceptOffer)
    {
        var acquisitionOffer = AcquisitionOffer;

        if (acquisitionOffer == null)
        {
            return;
        }

        var  conditions = acquisitionOffer.BuyerOffer;
        var  seller     = acquisitionOffer.SellerOffer;
        long price      = conditions.Price;


        var    cost          = Economy.GetCompanyCost(Q, SelectedCompany.company.Id);
        string overpriceText = "";

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

        Offer.text       = Format.Money(price) + overpriceText;
        SellerPrice.text = Format.Money(seller.Price);



        var showInputField = acquisitionOffer.Turn == AcquisitionTurn.Buyer;

        CashOfferInput.gameObject.SetActive(showInputField);
        CashOfferInput.text = price.ToString();

        SharesOfferInput.text = conditions.ByShares.ToString();

        RenderShareOfferSlider(conditions, price);
    }
Ejemplo n.º 24
0
    public override string RenderValue()
    {
        var cost = Economy.GetCompanyCost(Q, SelectedCompany);

        return($"ECONOMY ({Format.MinifyMoney(cost)})");
    }
Ejemplo n.º 25
0
 public override string RenderValue()
 {
     return(Format.Money(Economy.GetCompanyCost(Q, SelectedCompany.company.Id)));
 }
Ejemplo n.º 26
0
    private void RenderCompanyCost(GameEntity e)
    {
        var cost = Economy.GetCompanyCost(Q, e.company.Id);

        ShareCostLabel.text = Format.Money(cost);
    }
Ejemplo n.º 27
0
 private static bool IsCanTakeIPOGoal(GameEntity company, GameContext gameContext, InvestorGoal nextGoal)
 {
     return(nextGoal == InvestorGoal.GrowCompanyCost && Economy.GetCompanyCost(gameContext, company.company.Id) > Balance.IPO_REQUIREMENTS_COMPANY_COST / 2);
 }
Ejemplo n.º 28
0
    public override string RenderValue()
    {
        var rank = Economy.GetCompanyCost(Q, MyCompany);

        return($"{Format.Money(rank)}");
    }
Ejemplo n.º 29
0
    void RenderCompanyEconomy()
    {
        var cost = Economy.GetCompanyCost(Q, SelectedCompany.company.Id);

        CompanyValuation.text = Format.Money(cost);
    }
Ejemplo n.º 30
0
    public override string RenderValue()
    {
        var cost = Economy.GetCompanyCost(Q, MyCompany);

        return(Visuals.Link($"Head company: {MyCompany.company.Name} ({Format.Money(cost)})"));
    }