Exemplo n.º 1
0
    private BalancerEvent GetBalancerEvent(string id)
    {
        for (int i = 0; i < balancer_events.Count; i++)
        {
            BalancerEvent balancer_event = balancer_events[i];

            if (balancer_event.id == id)
            {
                return(balancer_event);
            }
        }

        throw new System.Exception("No balancer event found by this id: " + id);
    }
Exemplo n.º 2
0
    // With rewarded ads, opportunity should be realized (this method should be called) when the ad is proposed. With interstitials - when it is shown.
    // Developer needs to call the event that this method is called upon, when it is appropriate
    public void CallBalancerEvent(string event_id)
    {
        // Get Stuff about the event
        BalancerEvent balancer_event = GetBalancerEvent(event_id);

        // Get the placement group that will be affected by this event
        PlacementGroup affected_placement_group = GetPlacementGroupById(balancer_event.placement_group_id);

        // Change by delta
        affected_placement_group.balance.v += balancer_event.delta;

        if (affected_placement_group.balance.v < affected_placement_group.balance_min)
        {
            affected_placement_group.balance.v = affected_placement_group.balance_min;
        }
        if (affected_placement_group.balance.v > affected_placement_group.balance_max)
        {
            affected_placement_group.balance.v = affected_placement_group.balance_max;
        }

        // Debug.Log("Event. id: " + event_id + " group: " + affected_placement_group.id + " bal: " + affected_placement_group.balance.v);
    }