Example #1
0
    public void ChangeMotion(MotionRequest motion, MotionRequest?nextMotion = null)
    {
        State = SpriteState.Alive;

        int newAction;

        if (motion.Motion == SpriteMotion.Attack)
        {
            var attackActions = new SpriteMotion[] { SpriteMotion.Attack1, SpriteMotion.Attack2, SpriteMotion.Attack3 };
            var action        = DBManager.GetWeaponAction((Job)Entity.Status.jobId, Entity.Status.sex, Entity.EquipInfo.Weapon);
            newAction = AnimationHelper.GetMotionIdForSprite(Entity.Type, attackActions[action]);
        }
        else
        {
            newAction = AnimationHelper.GetMotionIdForSprite(Entity.Type, motion.Motion);
        }

        CurrentMotion  = motion;
        NextMotion     = nextMotion;
        Entity.Action  = newAction;
        ActionId       = newAction;
        AnimationStart = Core.Tick;
        previousFrame  = 0;

        foreach (var child in Children)
        {
            child.ChangeMotion(motion, nextMotion);
        }
    }
Example #2
0
        public static bool IsLoopingMotion(SpriteMotion motion)
        {
            switch (motion)
            {
            case SpriteMotion.Idle:
            case SpriteMotion.Sit:
            case SpriteMotion.Walk:
            case SpriteMotion.Casting:
            case SpriteMotion.Freeze1:
            case SpriteMotion.Freeze2:
            case SpriteMotion.Dead:
                return(true);

            case SpriteMotion.Attack1:
            case SpriteMotion.Attack2:
            case SpriteMotion.Attack3:
            case SpriteMotion.Hit:
            case SpriteMotion.PickUp:
            case SpriteMotion.Special:
            case SpriteMotion.Performance1:
            case SpriteMotion.Performance2:
            case SpriteMotion.Performance3:
                return(false);
            }

            return(false);
        }
Example #3
0
        public void ChangeMotion(SpriteMotion nextMotion, bool forceUpdate = false)
        {
            //Debug.Log($"{name} state {State} change motion from {CurrentMotion} to {nextMotion}");

            if (CurrentMotion == nextMotion && !forceUpdate)
            {
                return;
            }

            CurrentMotion = nextMotion;
            currentFrame  = 0;

            if (!isInitialized)
            {
                return;
            }

            var action = RoAnimationHelper.GetMotionIdForSprite(Type, nextMotion);

            if (action < 0 || action > SpriteData.Actions.Length)
            {
                action = 0;
            }
            ChangeAction(action);
            isPaused = false;
            isDirty  = true;

            if (Type == SpriteType.Player)
            {
                if (CurrentMotion == SpriteMotion.Idle || CurrentMotion == SpriteMotion.Sit)
                {
                    currentFrame = (int)HeadFacing;
                    UpdateSpriteFrame();
                    isPaused = true;
                }
                else
                {
                    HeadFacing = HeadFacing.Center;
                }
            }

            if (Shadow != null)
            {
                if (CurrentMotion == SpriteMotion.Sit || CurrentMotion == SpriteMotion.Dead)
                {
                    Shadow.SetActive(false);
                }
                else
                {
                    Shadow.SetActive(true);
                }
            }
        }
Example #4
0
    public void ChangeMotion(SpriteMotion motion, SpriteMotion?nextMotion = null, bool forceUpdate = false)
    {
        if (CurrentMotion == motion && !forceUpdate)
        {
            return;
        }

        CurrentMotion = motion;
        NextMotion    = nextMotion;
        State         = AnimationHelper.GetStateForMotion(CurrentMotion);
        currentFrame  = 0;

        if (!Entity.IsReady)
        {
            return;
        }

        foreach (var child in Children)
        {
            child.ChangeMotion(motion, nextMotion);
        }


        var action = AnimationHelper.GetMotionIdForSprite(Type, motion);

        if (motion == SpriteMotion.Attack)
        {
            var attackAction = DBManager.GetWeaponAction((Job)Entity.Job, Entity.Sex, Entity.Weapon);
        }
        if (action < 0 || action > currentACT.actions.Length)
        {
            action = 0;
        }

        ChangeAction(action);
        isPaused = false;
        isDirty  = true;

        if (Type == EntityType.PC)
        {
            if (CurrentMotion == SpriteMotion.Idle || CurrentMotion == SpriteMotion.Sit)
            {
                //currentFrame = (int) HeadF
                UpdateSpriteFrame();
                isPaused = true;
            }
            else
            {
                //HeadFacing
            }
        }
    }
Example #5
0
        public static bool IsFourDirectionAnimation(SpriteType type, SpriteMotion motion)
        {
            if (type != SpriteType.Player)
            {
                return(true);
            }

            switch (motion)
            {
            case SpriteMotion.Idle:
            case SpriteMotion.Sit:
            case SpriteMotion.Walk:
                return(false);
            }

            return(true);
        }
Example #6
0
    public static bool IsFourDirectionAnimation(EntityType type, SpriteMotion motion)
    {
        if (type != EntityType.PC)
        {
            return(false);
        }

        switch (motion)
        {
        case SpriteMotion.Idle:
        case SpriteMotion.Sit:
        case SpriteMotion.Walk:
            return(false);

        default:
            return(true);
        }
    }
Example #7
0
    public static SpriteState GetStateForMotion(SpriteMotion motion)
    {
        switch (motion)
        {
        case SpriteMotion.Idle:
            return(SpriteState.Idle);

        case SpriteMotion.Standby:
            return(SpriteState.Standby);

        case SpriteMotion.Walk:
            return(SpriteState.Walking);

        case SpriteMotion.Dead:
            return(SpriteState.Dead);

        default:
            return(SpriteState.Idle);
        }
    }
Example #8
0
        public static int GetMotionIdForSprite(SpriteType type, SpriteMotion motion)
        {
            if (motion == SpriteMotion.Idle)
            {
                return(0);
            }

            if (type == SpriteType.ActionNpc)
            {
                switch (motion)
                {
                case SpriteMotion.Walk: return(1 * 8);

                case SpriteMotion.Hit: return(2 * 8);

                case SpriteMotion.Attack1: return(3 * 8);
                }
            }

            if (type == SpriteType.Monster2)
            {
                if (motion == SpriteMotion.Attack2)
                {
                    return(5 * 8);
                }
            }

            if (type == SpriteType.Monster || type == SpriteType.Monster2 || type == SpriteType.Pet)
            {
                switch (motion)
                {
                case SpriteMotion.Walk: return(1 * 8);

                case SpriteMotion.Attack1: return(2 * 8);

                case SpriteMotion.Attack2: return(2 * 8);

                case SpriteMotion.Attack3: return(2 * 8);

                case SpriteMotion.Hit: return(3 * 8);

                case SpriteMotion.Dead: return(4 * 8);
                }
            }

            if (type == SpriteType.Pet)
            {
                switch (motion)
                {
                case SpriteMotion.Special: return(5 * 8);

                case SpriteMotion.Performance1: return(6 * 8);

                case SpriteMotion.Performance2: return(7 * 8);

                case SpriteMotion.Performance3: return(8 * 8);
                }
            }

            if (type == SpriteType.Player)
            {
                switch (motion)
                {
                case SpriteMotion.Walk: return(1 * 8);

                case SpriteMotion.Sit: return(2 * 8);

                case SpriteMotion.PickUp: return(3 * 8);

                case SpriteMotion.Standby: return(4 * 8);

                case SpriteMotion.Attack1: return(11 * 8);

                case SpriteMotion.Hit: return(6 * 8);

                case SpriteMotion.Freeze1: return(7 * 8);

                case SpriteMotion.Dead: return(8 * 8);

                case SpriteMotion.Freeze2: return(9 * 8);

                case SpriteMotion.Attack2: return(10 * 8);

                case SpriteMotion.Attack3: return(11 * 8);

                case SpriteMotion.Casting: return(12 * 8);
                }
            }

            return(-1);
        }
Example #9
0
    public static int GetMotionIdForSprite(EntityType type, SpriteMotion motion)
    {
        if (motion == SpriteMotion.Idle)
        {
            return(0);
        }

        if (type == EntityType.NPC)
        {
            switch (motion)
            {
            case SpriteMotion.Walk: return(1 * 8);

            case SpriteMotion.Hit: return(2 * 8);

            case SpriteMotion.Attack1: return(3 * 8);
            }
        }

        //if(type == EntityType.Monster2) {
        //    if(motion == SpriteMotion.Attack2)
        //        return 5 * 8;
        //}

        if (type == EntityType.MOB || type == EntityType.PET)
        {
            switch (motion)
            {
            case SpriteMotion.Walk: return(1 * 8);

            case SpriteMotion.Attack1: return(2 * 8);

            case SpriteMotion.Attack2: return(2 * 8);

            case SpriteMotion.Attack3: return(2 * 8);

            case SpriteMotion.Hit: return(3 * 8);

            case SpriteMotion.Dead: return(4 * 8);
            }
        }

        if (type == EntityType.PET)
        {
            switch (motion)
            {
            case SpriteMotion.Special: return(5 * 8);

            case SpriteMotion.Performance1: return(6 * 8);

            case SpriteMotion.Performance2: return(7 * 8);

            case SpriteMotion.Performance3: return(8 * 8);
            }
        }

        if (type == EntityType.PC)
        {
            switch (motion)
            {
            case SpriteMotion.Walk: return(1 * 8);

            case SpriteMotion.Sit: return(2 * 8);

            case SpriteMotion.PickUp: return(3 * 8);

            case SpriteMotion.Standby: return(4 * 8);

            case SpriteMotion.Attack1: return(5 * 8);

            case SpriteMotion.Hit: return(6 * 8);

            case SpriteMotion.Freeze1: return(7 * 8);

            case SpriteMotion.Dead: return(8 * 8);

            case SpriteMotion.Freeze2: return(9 * 8);

            case SpriteMotion.Attack2: return(10 * 8);

            case SpriteMotion.Attack3: return(11 * 8);

            case SpriteMotion.Casting: return(12 * 8);
            }
        }


        return(0);
    }
Example #10
0
 public void ChangeMotion(SpriteMotion motion, SpriteMotion?nextMotion = null)
 {
     EntityViewer.ChangeMotion(motion, nextMotion);
     //EntityViewer.State = AnimationHelper.GetStateForMotion(motion);
 }