Example #1
0
        public void StartAnimation(animType type)
        {
            animState res;

            res.startframe = animlist[(int)type].first_frame;
            if (type == animType.AllAnimations)
            {
                res.endframe = animlist[(int)type].last_frame - 1;
            }
            else
            {
                res.endframe = animlist[(int)type].last_frame;
            }
            res.curr_frame = animlist[(int)type].first_frame;
            res.next_frame = animlist[(int)type].first_frame + 1;

            res.fps  = animlist[(int)type].fps;
            res.type = type;

            res.curr_time = 0.0f;
            res.old_time  = 0.0f;

            res.interpol   = 0.0f;
            animSt         = res;
            AnimationSpeed = 0.01f;
            Loop           = true;
            currframe      = animSt.curr_frame;
            oldframe       = currframe;
        }
Example #2
0
    protected void PlayAnim(animType animationType, float parameter = 0f)
    {
        if (anim != null)
        {
            switch (animationType)
            {
            case animType.death:
                anim.SetTrigger("death");
                break;

            case animType.shoot:
                //on devra peut-ĂȘtre mettre cette animation dans une interface "IShoot" pour rester cohĂ©rent (car tous les "characters" ne tirent pas)
                //Je l'ai mis ici pour simplifier dans un premier temps : le player en a besoin
                anim.SetTrigger("fire");
                break;

            case animType.walk:
                anim.SetFloat("walkSpeed", parameter);
                break;
            }
        }
    }
Example #3
0
    public void Play(animType anim)
    {
        switch (anim)
        {
        case animType.Hit:
            StartCoroutine(HitRoutine());
            if (blood.activeSelf)
            {
                InstantiatedObjects.Add(Instantiate(blood, blood.transform.position, Quaternion.Euler(new Vector3(0, 0, Random.Range(0, 359))), blood.transform.parent));
            }
            blood.SetActive(true);

            break;

        case animType.Attack:
            StartCoroutine(AttackRoutine());
            break;

        case animType.Death:
            StartCoroutine(DeathRoutine());
            break;

        case animType.Locking:
            DogShadowImage.gameObject.SetActive(true);
            break;

        case animType.Locked:
            BloodAura.gameObject.SetActive(true);
            break;

        case animType.Unlock:
            BloodAura.gameObject.SetActive(false);
            break;

        default:
            break;
        }
    }
Example #4
0
    public void doAnim(animType animType, int x, int y)
    {
        switch (animType)
        {
        case animType.GLOBALDESTROY:
            if (PieceDestroyEffect)
            {
                Instantiate(PieceDestroyEffect, gm.board[x, y].position, Quaternion.identity);
            }
            break;

        case animType.NOMOREMOVES:
            if (noMoreMoves)
            {
                Instantiate(noMoreMoves);
            }
            break;

        case animType.ARROWH:
            if (horizontalAnim != null)
            {
                GameObject a = Instantiate(horizontalAnim, gm.board[x, y].position, Quaternion.identity) as  GameObject;
                Destroy(a, 2f);
            }
            break;

        case animType.ARROWV:
            if (verticalAnim != null)
            {
                GameObject a = Instantiate(verticalAnim, gm.board[x, y].position, Quaternion.identity) as GameObject;
                Destroy(a, 2f);
            }
            break;

        case animType.ARROWVH:
            if (verticalAnim != null && horizontalAnim != null)
            {     // animation effect
                Instantiate(verticalAnim, gm.board[x, y].position, Quaternion.identity);
                Instantiate(horizontalAnim, gm.board[x, y].position, Quaternion.identity);
            }
            break;

        case animType.ARROWTX: // is when match-4 power combine with match-T
            if (verticalAnim != null && horizontalAnim != null)
            {                  // animation effect
                Instantiate(verticalAnim, gm.board[x, y].position, Quaternion.identity);
                Instantiate(horizontalAnim, gm.board[x, y].position, Quaternion.identity);
                if (x + 1 < gm.boardWidth)
                {
                    Instantiate(verticalAnim, gm.board[x + 1, y].position, Quaternion.identity);
                }
                if (x - 1 >= 0)
                {
                    Instantiate(verticalAnim, gm.board[x - 1, y].position, Quaternion.identity);
                }
                if (y + 1 < gm.boardHeight)
                {
                    Instantiate(horizontalAnim, gm.board[x, y + 1].position, Quaternion.identity);
                }
                if (y - 1 >= 0)
                {
                    Instantiate(horizontalAnim, gm.board[x, y - 1].position, Quaternion.identity);
                }
            }
            break;

        case animType.ARROWTLBR: // is when match-4 power TopLeft <> BottomRight
            if (TLBRAnim != null)
            {                    // animation effect
                Instantiate(TLBRAnim, gm.board[x, y].position, Quaternion.identity);
            }
            break;

        case animType.ARROWTRBL: // is when match-4 power TopLeft <> BottomRight
            if (TRBLAnim != null)
            {                    // animation effect
                Instantiate(TRBLAnim, gm.board[x, y].position, Quaternion.identity);
            }
            break;

        case animType.STAR:
            if (starAnim != null)
            {
                Instantiate(starAnim, gm.board[x, y].position, Quaternion.identity);
            }
            break;

        case animType.RAINBOW:
            if (rainbowAnim != null)
            {
                GameObject a = Instantiate(growingEffect, gm.board[x, y].position, Quaternion.identity) as GameObject;
                Destroy(a, 2);
            }
            break;

        case animType.BOMB:
            if (bombAnim != null)
            {
                GameObject a = Instantiate(bombAnim, gm.board[x, y].position, Quaternion.identity) as GameObject;
                Destroy(a, 0.5f);
            }
            break;

        case animType.LOCKHIT:
            if (lockAnim != null)
            {
                Instantiate(lockAnim, new Vector3(gm.board[x, y].position.x, gm.board[x, y].position.y, -10), Quaternion.identity);
            }
            break;

        case animType.ROCKHIT:
            if (rockAnim != null)
            {
                Instantiate(rockAnim, gm.board[x, y].position, Quaternion.identity);
            }
            break;

        case animType.ICEHIT:
            if (iceAnim != null)
            {
                Instantiate(iceAnim, new Vector3(gm.board[x, y].position.x, gm.board[x, y].position.y, -10), Quaternion.identity);
            }
            break;

        case animType.SHADEHIT:
            if (shadedAnim != null)
            {
                Instantiate(shadedAnim, gm.board[x, y].position, Quaternion.identity);
            }
            break;

        case animType.CONVERTSPEC:
            if (convertingAnim != null)
            {
                GameObject a = Instantiate(convertingAnim, new Vector3(gm.board[x, y].position.x, gm.board[x, y].position.y, -5), Quaternion.identity) as GameObject;
                Destroy(a, 2f);
            }
            break;

        case animType.TREASURECOLLECTED:
            if (treasureCollectedAnim != null)
            {
                Instantiate(treasureCollectedAnim, gm.board[x, y].position, Quaternion.identity);
            }
            break;

        case animType.BOMBX3:
            if (bombx3Anim != null)
            {
                GameObject a = Instantiate(bombx3Anim, gm.board[x, y].position, Quaternion.identity) as GameObject;
                Destroy(a, 1f);
            }
            break;
        }
    }
Example #5
0
    /*
     * NOTES :
     *
     * Use "gm.board[x,y].position" to get the origin location of the caller
     * gm.boardWidth / gm.boardHeight    <--- the width and height of the current board
     *
     * ---------------------------
     *
     * IMPORTANT ~!!
     *
     * Pool Manager version of the script has an auto-despawn function
     * located in the "Lifespan.cs" script found in area 51/GUI Related/
     *
     *
     */

    // External scripts will call this function
    // From here, CustomAnimations script will select the appropriate anim to use.

    // OVERLOADED FUNCTION for doAnim
    public void doAnim(animType animType, int[] arrayRef)
    {
        doAnim(animType, arrayRef[0], arrayRef[1]); // call main function
    }
Example #6
0
    IEnumerator IE_AnimOpenDialog(animType _type, float _width, float _height, Dialog _dial)
    {
        Vector2 targetScale = new Vector2(_width * dialogBox_Xscale, _height * dialogBox_Yscale);

        switch (_type)
        {
        case animType.Start:
            scGod.RegTalkingNPC(true, myName, transform);
            BoxSwitchSide(false, 0f, _width, _height);
            scOutline.OpenOutline(_type, _width, _height);
            tr_DialogBox.localScale = targetScale;
            DialogObj.SetActive(true);
            spr_DialogBox.color = boxColor;
            myDialog.color      = Color.white;
            yield return(new WaitForSeconds(0.35f));

            tr_DialogBox.gameObject.SetActive(true);
            break;

        case animType.End:
            scGod.RegTalkingNPC(false, myName, transform);
            scOutline.OpenOutline(_type, _width, _height);
            spr_DialogBox.DOFade(0f, 0.3f);
            myDialog.DOFade(0f, 0.25f);
            yield return(new WaitForSeconds(0.7f));

            tr_DialogBox.gameObject.SetActive(false);
            DialogObj.SetActive(false);
            break;

        case animType.Update:
            scOutline.OpenOutline(_type, _width, _height);
            Sequence seq0 = DOTween.Sequence();
            seq0.Append(tr_DialogBox.DOScale(targetScale, 0.2f)).Join(spr_DialogBox.DOFade(boxColor.a, 0.15f)).Join(myDialog.DOFade(1f, 0.15f));
            BoxSwitchSide(true, 0.2f, _width, _height);
            yield return(seq0.WaitForCompletion());

            break;

        case animType.Jump:
            myDialog.text = _dial.text;
            float scale    = DialogObj.transform.localScale.x * (1.04f + 0.006f * (float)(_dial.size - 20));
            float LerpTime = scale > 1.08f ? 0.08f : 0.06f;
            scOutline.OpenOutline(tr_DialogBox.localScale.x / dialogBox_Xscale, tr_DialogBox.localScale.y / dialogBox_Yscale, _width, _height, LerpTime);
            Vector2 loudScale   = new Vector2(scale, scale);
            Vector2 originScale = DialogObj.transform.localScale;
            float   midX        = tr_DialogBox.localScale.x > targetScale.x ? tr_DialogBox.localScale.x : targetScale.x;
            float   midY        = tr_DialogBox.localScale.y > targetScale.y ? tr_DialogBox.localScale.y : targetScale.y;
            Vector2 midScale    = new Vector2(midX, midY);

            Sequence seq1 = DOTween.Sequence();
            seq1.Append(DialogObj.transform.DOScale(loudScale, LerpTime)).Join(tr_DialogBox.DOScale(midScale, LerpTime))
            .Append(DialogObj.transform.DOScale(originScale, 0.16f)).Join(tr_DialogBox.DOScale(targetScale, 0.16f));
            seq1.Insert(0f, myDialog.DOFade(1f, 0.15f)).Insert(0f, spr_DialogBox.DOFade(boxColor.a, 0.15f));

            if (!isRightBox)
            {
                float midWidth = midX / dialogBox_Xscale;
                seq1.Insert(0, tr_DialogBox.DOLocalMoveX(-midWidth * UI2VectorRate, LerpTime, false))
                .Insert(LerpTime, tr_DialogBox.DOLocalMoveX(-_width * UI2VectorRate, 0.15f, false));
                tr_DialCanvas.localPosition = new Vector2(-_width * UI2VectorRate, 0f);
            }

            yield return(seq1.WaitForCompletion());

            break;

        case animType.Rest:
            scOutline.OpenOutline(_type, _width, _height);
            Sequence seq2 = DOTween.Sequence();
            seq2.Append(tr_DialogBox.DOScale(targetScale, 0.3f)).Join(spr_DialogBox.DOFade(boxColor.a * 0.5f, 0.3f)).Join(myDialog.DOFade(0.5f, 0.3f));
            BoxSwitchSide(true, 0.3f, _width, _height);
            yield return(seq2.WaitForCompletion());

            break;
        }
        yield break;
    }