Beispiel #1
0
    void Update()
    {
        if (currentState == GiftState.IDLE && !rigidBody.IsSleeping())
        {
            ForceSleep();
        }

        if (currentState == GiftState.COLLISIONING && !Input.GetMouseButton(0) && rigidBody.IsSleeping())
        {
            if (canSleep)
            {
                currentState = GiftState.SLEEPING;
            }
        }
    }
Beispiel #2
0
    public void Initialize(SpriteAtlas spriteAtlas, bool canSleep = true)
    {
        this.canSleep = canSleep;
        currentState  = GiftState.IDLE;

        var defaultEyeSprite     = spriteAtlas.GetSprite(EyeSpriteType[0]);
        var defaultMouthSprite   = spriteAtlas.GetSprite(MouthSpriteType[0]);
        var randomBodySpriteName = BodySpriteType[Random.Range(0, BodySpriteType.Length - 1)];

        Body.sprite     = spriteAtlas.GetSprite(randomBodySpriteName);
        Ribbon.sprite   = spriteAtlas.GetSprite(GetCorrespondingRibbon(randomBodySpriteName));
        LeftEye.sprite  = defaultEyeSprite;
        RightEye.sprite = defaultEyeSprite;
        Mouth.sprite    = defaultMouthSprite;

        var randomScale = Random.Range(Config.MIN_GIFT_SCALE_SIZE, Config.MAX_GIFT_SCALE_SIZE);

        transform.localScale *= randomScale;

        rigidBody.mass *= randomScale;
    }
Beispiel #3
0
 public void Select()
 {
     currentState = GiftState.SELECTED;
 }
Beispiel #4
0
 public void OnCollisionEnter2D(Collision2D collision)
 {
     currentState = GiftState.COLLISIONING;
 }