Beispiel #1
0
        public void PlayRunAnimation(UnitAnimatorType type)
        {
            act = (int)type;
            var dataUnit = GetComponent <UnitInfo>().dataUnit;

            anList = new [] { dataUnit.Sprite(act - 1), dataUnit.Sprite(act), dataUnit.Sprite(act - 1), dataUnit.Sprite(act + 1) };
            act    = 0;
            ShowRen();
            running = true;
        }
Beispiel #2
0
        public void PlayIdleAnimation(UnitAnimatorType type, int repeat = 3)
        {
            var dataUnit = GetComponent <UnitInfo>().dataUnit;

            //has animation?
            if (!dataUnit.ExistAnimationSprite(type))
            {
                return;
            }

            //build it
            anList    = new [] { dataUnit.AnimationSprite(type), dataUnit.AnimationSprite(type, -1), dataUnit.AnimationSprite(type), dataUnit.AnimationSprite(type, 1) };
            act       = 0;
            maxRepeat = 4 * repeat;
            ShowRen();
            running = true;
        }
Beispiel #3
0
        public bool ExistAnimationSprite(UnitAnimatorType typ)
        {
            if (typ == UnitAnimatorType.Face)
            {
                return(SpriteHelper.Exist(folder + "face"));
            }

            if (typ.ToString().StartsWith("Attack") || typ.ToString().StartsWith("Defend"))
            {
                return(SpriteHelper.Exist(folder + "fight"));
            }

            if (typ == UnitAnimatorType.Yes || typ == UnitAnimatorType.No || typ == UnitAnimatorType.Laugh ||
                typ == UnitAnimatorType.Cast)
            {
                return(SpriteHelper.Exist(folder + "emo"));
            }

            return(false);
        }
Beispiel #4
0
        public void MoveAnimationCalc(int x, int y)
        {
            var dataUnit          = GetComponent <UnitInfo>().dataUnit;
            UnitAnimatorType type = UnitAnimatorType.MoveSouth;

            //rotate
            if (x > 0)
            {
                type = UnitAnimatorType.MoveEast;
            }
            else if (x < 0)
            {
                type = UnitAnimatorType.MoveWest;
            }
            else if (y < 0)
            {
                type = UnitAnimatorType.MoveNorth;
            }

            PlayRunAnimation(type);
        }
Beispiel #5
0
        public Sprite AnimationSprite(UnitAnimatorType typ, int offset = 0)
        {
            //has a face?
            if (typ == UnitAnimatorType.Face)
            {
                return(ExistAnimationSprite(typ) ? SpriteHelper.Load(folder + "face:face") : Sprite());
            }

            //show attack
            if (typ.ToString().StartsWith("Attack") || typ.ToString().StartsWith("Defend"))
            {
                return(SpriteHelper.Load(folder + "fight:fight_" + ((int)typ + offset)));
            }

            //has default animations?
            if (typ == UnitAnimatorType.Yes || typ == UnitAnimatorType.No || typ == UnitAnimatorType.Laugh ||
                typ == UnitAnimatorType.Cast)
            {
                return(SpriteHelper.Load(folder + "emo:emo_" + ((int)typ + offset)));
            }

            return(null);
        }
Beispiel #6
0
        public void PlayFightAnimation(UnitAnimatorType type)
        {
            var dataUnit = GetComponent <UnitInfo>().dataUnit;

            //has animation?
            if (!dataUnit.ExistAnimationSprite(type))
            {
                if (type == UnitAnimatorType.AttackEast || type == UnitAnimatorType.DefendEast)
                {
                    type = UnitAnimatorType.MoveEast;
                }
                else if (type == UnitAnimatorType.AttackWest || type == UnitAnimatorType.DefendWest)
                {
                    type = UnitAnimatorType.MoveWest;
                }
                else if (type == UnitAnimatorType.AttackSouth || type == UnitAnimatorType.DefendSouth)
                {
                    type = UnitAnimatorType.MoveSouth;
                }
                else
                {
                    type = UnitAnimatorType.MoveNorth;
                }
                PlayRunAnimation(type);
                maxRepeat = 4;
                return;
            }

            //build it
            anList    = new [] { dataUnit.AnimationSprite(type), dataUnit.AnimationSprite(type, -1), dataUnit.AnimationSprite(type), dataUnit.AnimationSprite(type, 1) };
            act       = 0;
            maxRepeat = 4;
            ShowRen();
            running = true;

            GetComponent <SpriteRenderer>().flipX = type == UnitAnimatorType.DefendEast || type == UnitAnimatorType.AttackWest;
        }