示例#1
0
    IEnumerator MoveObject(int Num, CoolDown Object)
    {
        while (StillHoldOn)
        {
            yield return(new WaitForFixedUpdate());

            MovableObject.transform.position = Input.mousePosition;
        }

        MovableObject.color = whenNotSpawn;

        float   MinDistance = float.MaxValue;
        Vector2 Minvec      = new Vector2();

        foreach (Vector2 vec in SpawnPoints)
        {
            float Distance = Vector2.Distance(Camera.main.ScreenToWorldPoint(MovableObject.transform.position), vec);

            if (Distance < MinDistance)
            {
                Minvec      = vec;
                MinDistance = Distance;
            }
        }
        if (Object.GetCost() <= CoinSystem.Coin)
        {
            CoinSystem.SpawnObject(Object.GetCost());
            StartCoroutine(Object.Cooldown());
            Instantiate(Characters[Num], Minvec, new Quaternion());
        }
    }
        private void HandleShowResult(ShowResult result)
        {
            switch (result)
            {
            case ShowResult.Finished:
                Debug.Log("The ad was successfully shown.");
                //
                // YOUR CODE TO REWARD THE GAMER
                // Give coins etc.
                var bonus = Player.CurrentBonus;
                switch (bonus)
                {
                case Player.AdSelector.Damage:
                    var dmgmodifier = 1.2f;
                    Player.SetModifier(Player.AdSelector.Damage, dmgmodifier, BonusTime);
                    Player.CurrentBonus = Player.AdSelector.Currency;
                    UIManager.CreateNotificications("Congratulations!", "You have gained " + (int)(dmgmodifier * 100 - 100) + "% damage bonus for " + BonusTime / 60 + " minutes!");
                    break;

                case Player.AdSelector.Currency:
                    var curmodifier = 1.5f;
                    Player.SetModifier(Player.AdSelector.Currency, curmodifier, BonusTime);
                    Player.CurrentBonus = Player.AdSelector.Damage;
                    UIManager.CreateNotificications("Congratulations!", "You have gained " + (int)(curmodifier * 100 - 100) + "% income bonus for " + BonusTime / 60 + " minutes!");
                    break;
                }
                Timer.Cooldown(BonusTime, Time.time);                 //burda mı olmalı?
                break;

            case ShowResult.Skipped:
                Debug.Log("The ad was skipped before reaching the end.");
                Timer.Cooldown(WaitTime, Time.time);                 //no cooldown if not finished
                break;

            case ShowResult.Failed:
                Debug.LogError("The ad failed to be shown.");
                Timer.Cooldown(WaitTime, Time.time);                 //no cooldown if not finished
                break;
            }
        }