Пример #1
0
    private void Start()
    {
        scoreManager = GameObject.FindGameObjectWithTag("Score_Manager");

        presentTypeWish = getRandomPresentWish();
        switch (presentTypeWish)
        {
        case Data.presentTypes.RED:
            presentTypeSprite.sprite = presentTypeSprites[0];
            break;

        case Data.presentTypes.GREEN:
            presentTypeSprite.sprite = presentTypeSprites[1];
            break;

        case Data.presentTypes.YELLOW:
            presentTypeSprite.sprite = presentTypeSprites[2];
            break;

        case Data.presentTypes.NAUGHTY:
            presentTypeSprite.sprite = presentTypeSprites[3];
            break;

        default:
            presentTypeSprite.sprite = presentTypeSprites[0];
            break;
        }
    }
Пример #2
0
    public void setPresentType(Data.presentTypes _presentType)
    {
        presentType = _presentType;
        switch (presentType)
        {
        case Data.presentTypes.RED:
            GetComponent <SpriteRenderer>().sprite = presentTypeSprites[0];
            break;

        case Data.presentTypes.GREEN:
            GetComponent <SpriteRenderer>().sprite = presentTypeSprites[1];
            break;

        case Data.presentTypes.YELLOW:
            GetComponent <SpriteRenderer>().sprite = presentTypeSprites[2];
            break;

        case Data.presentTypes.NAUGHTY:
            GetComponent <SpriteRenderer>().sprite = presentTypeSprites[3];
            break;

        default:
            GetComponent <SpriteRenderer>().sprite = presentTypeSprites[0];
            break;
        }
    }
Пример #3
0
    //But there is only a max of one naughty in 4 houses
    Data.presentTypes getRandomPresentWish()
    {
        //Get Random present Type
        Array values = Enum.GetValues(typeof(Data.presentTypes));

        System.Random     random  = new System.Random();
        Data.presentTypes tmpWish = (Data.presentTypes)values.GetValue(random.Next(values.Length));

        if (tmpWish == Data.presentTypes.NAUGHTY && Data.Instance.getLastFourPresents().Contains(Data.presentTypes.NAUGHTY))
        {
            return(getRandomPresentWish());
        }
        else
        {
            Data.Instance.addToLastFourPresents(tmpWish);
            return(tmpWish);
        }
    }
Пример #4
0
    void dropPresent(Data.presentTypes presentType)
    {
        if (!presentOnCooldown)
        {
            //Play Animation
            animator.SetBool("isThrowing", true);
            StartCoroutine("stopThrowAnimation");
            //Instansiate ("Throw") present
            GameObject tmp = Instantiate(present, presentSpawner.position, Quaternion.identity, presentSpawner);
            switch (presentType)
            {
            case Data.presentTypes.RED:
                tmp.SendMessageUpwards("setPresentType", Data.presentTypes.RED);
                break;

            case Data.presentTypes.GREEN:
                tmp.SendMessageUpwards("setPresentType", Data.presentTypes.GREEN);
                break;

            case Data.presentTypes.YELLOW:
                tmp.SendMessageUpwards("setPresentType", Data.presentTypes.YELLOW);
                break;

            //Naughty is useless right now as your not supposed to throw anything but maybe later you could add coal
            case Data.presentTypes.NAUGHTY:
                tmp.SendMessageUpwards("setPresentType", Data.presentTypes.NAUGHTY);
                break;

            default:
                tmp.SendMessageUpwards("setPresentType", Data.presentTypes.RED);
                break;
            }
            //Add a bit of random rotation to each throw
            if (enableDropSpin)
            {
                tmp.GetComponent <Rigidbody2D>().AddTorque(Random.Range(-dropSpinRange, dropSpinRange), ForceMode2D.Impulse);
            }
            //Start cooldown
            presentOnCooldown = true;
        }
    }