Ejemplo n.º 1
0
    private void OnTriggerExit(Collider other)
    {
        int newPoints = 0;

        if (other.name.ToLower().Contains("food"))
        {
            colType = CollisionType.Food;
            GameData.Pickup p = GetMatchingPickup(other.name);
            newPoints = p.WinPoints;
        }
        else if (other.name.ToLower().Contains("drink"))
        {
            colType = CollisionType.Drink;
            GameData.Pickup p = GetMatchingPickup(other.name);
            newPoints = p.WinPoints;
        }
        else if (other.name.ToLower().Contains("dice"))
        {
            colType = CollisionType.Dice;
            GameData.Pickup p = GetMatchingPickup(other.name);
            newPoints = DeterminePointsUsingProbabilities(p);
            data.currTrial.PointsCollected += newPoints;
        }
        else
        {
            colType = CollisionType.None;
        }

        if (data.currTrial.TrackPickups)
        {
            ShowPickupPopup(newPoints);
        }

        Destroy(other.gameObject);
    }
Ejemplo n.º 2
0
    private GameData.Pickup GetMatchingPickup(string pickupName)
    {
        GameData.Pickup p = null;
        foreach (GameData.Pickup pickup in data.currTrial.Pickups)
        {
            if (pickupName.ToLower().Equals(pickup.PickupName.ToLower()))
            {
                p = pickup;
                break;
            }
        }

        return(p);
    }
Ejemplo n.º 3
0
    private int DeterminePointsUsingProbabilities(GameData.Pickup pickup)
    {
        int    points = 0;
        Random rand   = new Random();
        bool   isWin  = rand.NextDouble() < pickup.WinChance;

        if (isWin)
        {
            points = pickup.WinPoints;
        }
        else
        {
            points = pickup.LosePoints;
        }
        return(points);
    }