Exemple #1
0
    public void PlayAnim(AnimList animName)
    {
        if (animNowSelect == animName)
        {
            return;
        }

        foreach (AnimList item in (AnimList[])Enum.GetValues(typeof(AnimList)))

        {
            anim.SetBool(item.ToString(), item == animName);
        }
        animNowSelect = animName;
    }
Exemple #2
0
    public bool GetAni(string aniName, ref Animation anim)
    {
        AnimList animList;

        if (!AnimMap.TryGetValue(aniName, out animList))
        {
            animList = new AnimList();
            bool ret = Utils.LoadAnim(anipath, ref animList);
            if (!ret)
            {
                return(false);
            }
            AnimMap.Add(aniName, animList);
        }
        foreach (auto var in animList)
        {
            AnimationClip clip     = var.key;
            string        ani_name = var.value;
            anim.AddClip(clip, ani_name)
        }
        return(true);
    }
    private void TriggerAnim(AnimList state)
    {
        switch (state)
        {
        case AnimList.Idle:
            WalkFx.Stop();
            anim.SetBool("Walk", false);
            anim.SetBool("Run", false);
            break;

        case AnimList.Walk:
            WalkFx.Play();
            anim.SetBool("Walk", true);
            break;

        case AnimList.Atk:
            Fx1.PlayOneShot(attack);
            anim.SetTrigger("Attack");
            break;

        case AnimList.LookAround:
            anim.SetTrigger("Look");
            break;

        case AnimList.Angry:
            Fx1.PlayOneShot(angry);
            anim.SetTrigger("Angry");
            break;

        case AnimList.Run:
            anim.SetBool("Run", true);
            break;

        default:
            break;
        }
    }
    public static SpriteAnim SetMageAnim(uint ownerID, AnimList anim)
    {
        SpriteAnim spriteAnim = new SpriteAnim()
        {
            EntityID = ownerID,
            AnimArray = new List<Sprite>(),
            FPS = 10,
            AnimIndex = 0,
            TimeLeft = 0,
            FrameIncrement = 1,
            AnimType = SpriteType.Loop
        };

        switch (anim)
        {
            case AnimList.Left:
            {
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Left2));
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Left1));
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Left2));
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Left3));

                spriteAnim.AnimID = AnimList.Left;
                break;
            }

            case AnimList.Right:
            {
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Right2));
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Right1));
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Right2));
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID, CharPosition.Right3));

                spriteAnim.AnimID = AnimList.Right;
                break;
            }

            case AnimList.Up:
            {
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Up2));
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Up1));
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Up2));
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID, CharPosition.Up3));

                spriteAnim.AnimID = AnimList.Up;
                break;
            }

            case AnimList.Down:
            {
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Down2));
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Down1));
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID,CharPosition.Down2));
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID, CharPosition.Down3));

                spriteAnim.AnimID = AnimList.Down;
                break;
            }
            case AnimList.IdleUp:
            {
                spriteAnim.FrameIncrement = 0;
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID, CharPosition.IdleUp));

                spriteAnim.AnimID = AnimList.IdleUp;
                break;
            }
            case AnimList.IdleDown:
            {
                spriteAnim.FrameIncrement = 0;
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID, CharPosition.IdleDown));

                spriteAnim.AnimID = AnimList.IdleDown;
                break;
            }
            case AnimList.IdleLeft:
            {
                spriteAnim.FrameIncrement = 0;
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID, CharPosition.IdleLeft));

                spriteAnim.AnimID = AnimList.IdleLeft;
                break;
            }
            case AnimList.IdleRight:
            {
                spriteAnim.FrameIncrement = 0;
                spriteAnim.AnimArray.Add(SetMageSprite(ownerID, CharPosition.IdleRight));

                spriteAnim.AnimID = AnimList.IdleRight;
                break;
            }

            default:
            {
                throw new UnityException("PlayerAnimList is null or does not exist");
            }

        }

        return spriteAnim;
    }