Ejemplo n.º 1
0
        /// <summary>
        /// Deposit the amount to the account
        /// </summary>
        /// <param name="amount">Amount to deposit</param>
        /// <exception cref="MethodAccessException">Account was closed</exception>
        /// <exception cref="ArgumentOutOfRangeException">Amount is negative number</exception>
        public void Deposit(decimal amount)
        {
            if (IsClosed)
            {
                throw new MethodAccessException(AccountClosedEx);
            }

            if (amount < 0)
            {
                throw new ArgumentOutOfRangeException(NegativeAmountEx);
            }

            lock (locker)
            {
                if (!IsClosed)
                {
                    Amount += amount;
                    Bonus.AddBonus();
                }
                else
                {
                    throw new MethodAccessException(AccountClosedEx);
                }
            }
        }
Ejemplo n.º 2
0
    IEnumerator _Hit(CellHitInfo info)
    {
        yield return(new WaitForSeconds(0.05f));

        ChangeMaterial();
        GotHit(info);

        if (info.fatal)
        {
            if (finalBigCell && PongPadBuilder.instance.IsFinalLevel)
            {
                const int STEPS = 24;
                Vector3   point = Vector3.Lerp(info.hit_point, transform.position, 0.5f);
                for (int i = 0; i < STEPS; i++)
                {
                    Vector3 normal = Quaternion.Euler(0, 360 * i / (float)STEPS, 0) * Vector3.forward;
                    EmitHitPS(point, normal, Color.white, velocity_mul: 1.7f);
                }
            }

            Destroy((GameObject)gameObject);
            if (bonus)
            {
                Bonus.AddBonus(transform.position);
            }

            float cell_fraction = GetCellFraction();
            int   points1       = Mathf.RoundToInt(points * cell_fraction);
            Points.AddPoints(transform.position, MyMaterial.color, points1, pointsSize);
            PongPadBuilder.instance.KilledOneCell(cell_fraction);
        }
    }
Ejemplo n.º 3
0
        public static Bonus <float> GetTeamCostForParentTeam(TeamInfo team, GameEntity company, GameContext gameContext, bool fullDescription = false)
        {
            var gain = GetLeaderGain(team, company, gameContext);

            // always positive
            var cost = GetDirectManagementCostOfTeam(team, company, gameContext);

            var directCost = cost.Sum();

            // always positive or 0
            var dependantTeams    = GetDependantTeams(team, company);
            var dependantTeamCost = Math.Abs(dependantTeams.Sum(s => GetTeamCostForParentTeam(s, company, gameContext).Sum()));

            var totalCost = directCost + dependantTeamCost;

            var bonus = new Bonus <float>("Team Cost");

            if (team.isCoreTeam)
            {
                bonus.AddBonus(cost);

                /*bonus.Append("CEO", gain);
                 * bonus.Append($"Direct cost of Core team", -directCost);*/

                ApplyDependantTeamsBonus(bonus, team, company, gameContext);

                return(bonus);
            }


            if (gain > totalCost)
            {
                // team is managed well and can be managed indirectly
                // except it is a core team (or independent team?)

                bonus.Append($"Management of {team.Name}", -GetIndirectManagementCostOfTeam(team, company));

                return(bonus);
            }


            // team managed badly and will cause additional troubles in parent team
            var indirectCost = GetIndirectManagementCostOfTeam(team, company);

            if (fullDescription)
            {
                bonus
                .Append("Manager", gain)
                .Append("Team self cost", -directCost)
                .Append("Indirect cost", -indirectCost);

                ApplyDependantTeamsBonus(bonus, team, company, gameContext);

                return(bonus);
            }

            return(bonus.Append($"Management cost", gain - totalCost - indirectCost));
        }
Ejemplo n.º 4
0
        public static Bonus <float> GetManagerPointChange(GameEntity company, GameContext gameContext)
        {
            var teams = company.team.Teams;

            var bonus = new Bonus <float>("Point gain");

            bool teamsOnly = teams.Count > 3;

            foreach (var team in teams.Where(t => t.isIndependentTeam))
            {
                var b = GetTeamCostForParentTeam(team, company, gameContext, false);

                if (teamsOnly)
                {
                    bonus.Append(team.Name, b.Sum());
                }
                else
                {
                    bonus.AddBonus(b);
                }
            }

            return(bonus);
        }