Esempio n. 1
0
 public bool IsAnimationPlayng(SpriteAnimations anim)
 {
     if (CurrentAnimation == null && anim == SpriteAnimations.NONE)
     {
         return(true);
     }
     return(CurrentAnimation == Animations.GetAnimation(anim));
 }
Esempio n. 2
0
    private void OnEnable()
    {
        _target    = target as SpriteAnimations;
        _scrollPos = Vector2.zero;

        _previewOptions[0] = GUILayout.Width(64);
        _previewOptions[1] = GUILayout.Height(64);
    }
Esempio n. 3
0
        public void LoadContent()
        {
            // Load animated textures.
            SpriteTextures.Add(Level.Content.Load <Texture2D>("Sprites/Player/player"));
            Animation anim = new Animation();

            anim.LoadAnimation("Idle", 0, new List <int>
            {
                0,
                11,
                0,
                12
            }, 7, true);
            SpriteAnimations.Add("Idle", anim);
            anim = new Animation();
            anim.LoadAnimation("Walking", 0, new List <int>
            {
                0,
                1,
                2,
                3,
                4,
                5,
                6
            }, 7, true);
            SpriteAnimations.Add("Walking", anim);
            anim = new Animation();
            anim.LoadAnimation("Jump", 0, new List <int>
            {
                7,
                8,
                9,
                10,
                9,
                8,
                7
            }, 20, false);
            anim.AnimationCallBack(JumpAnimEnd);
            SpriteAnimations.Add("Jump", anim);
            // Calculate bounds within texture size.
            // subtract 4 from width and height to remove a 2px buffer
            // around the player.
            int width  = FrameWidth - 4;
            int left   = (FrameWidth - width) / 2;
            int height = FrameHeight - 4;
            int top    = FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);
            anim        = new Animation();
            anim.LoadAnimation("Dead", 0, new List <int>
            {
                13,
                14,
                15
            }, 6, false);
            anim.AnimationCallBack(DeadAnimEnd);
            SpriteAnimations.Add("Dead", anim);
        }
Esempio n. 4
0
        // Use this for initialization
        void Start()
        {
            spriteAnimations = GetComponent <SpriteAnimations>();
            spriteAnimations.Run();

            animator = GetComponent <Animator>();

            coroutine = Run();
            StartCoroutine(coroutine);
        }
Esempio n. 5
0
    public Texture2D GetImage()
    {
        SpriteAnimation ani = SpriteAnimations.Get(name + pose);

        if (ani != null)
        {
            return(ani.GetImage());
        }
        if (table.ContainsKey(pose))
        {
            return(table[pose]);
        }
        return(null);
    }
Esempio n. 6
0
        public void LoadContent(string _enemy)
        {
            string enemyString = string.Empty;

            switch (_enemy)
            {
            case "e":
                enemyString = "Sprites/Enemies/muffinman";
                break;

            default:
                enemyString = "Sprites/Enemies/muffinman";
                break;
            }
            // Load animated textures.
            Texture2D tex = Level.Content.Load <Texture2D>(enemyString);

            if (!SpriteTextures.Contains(tex))
            {
                SpriteTextures.Add(tex);
            }
            Animation anim = new Animation();

            anim.LoadAnimation("Walk", 0, new List <int>
            {
                0,
                1
            }, 4, true);
            SpriteAnimations.Add("Walk", anim);
            anim = new Animation();
            anim.LoadAnimation("Dead", 0, new List <int>
            {
                2,
                3,
                4,
                5
            }, 36, false);
            anim.AnimationCallBack(DeadAnimEnd);
            SpriteAnimations.Add("Dead", anim);
            // Calculate bounds within texture size.
            // subtract 10 from width and height to remove a 5px buffer
            // around the enemy.
            int width  = FrameWidth - 10;
            int left   = (FrameWidth - width) / 2;
            int height = FrameHeight - 10;
            int top    = FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);
            SpriteAnimations[currentAnim].ResetPlay();
        }
Esempio n. 7
0
        public void LoadContent(string _collectable)
        {
            string sheetString = string.Empty;

            switch (_collectable)
            {
            case "s":
                sheetString = "Sprites/Collectables/scribbles";
                colorOffset = Color.Black;
                break;

            case "S":
                sheetString = "Sprites/Collectables/scribbles";
                colorOffset = Color.Gold;
                break;

            default:
                sheetString = "Sprites/Collectables/scribbles";
                colorOffset = Color.White;
                break;
            }
            // Load animated textures.
            Texture2D tex = Level.Content.Load <Texture2D>(sheetString);

            if (!SpriteTextures.Contains(tex))
            {
                SpriteTextures.Add(tex);
            }
            Animation anim = new Animation();

            anim.LoadAnimation("Idle", 0, new List <int>
            {
                0,
                1,
                2,
                3
            }, 16, true);
            SpriteAnimations.Add("Idle", anim);
            // Calculate bounds within texture size.
            // subtract 4 from height to remove a 2px buffer
            // around the collectable.
            int width  = FrameWidth;
            int left   = (FrameWidth - width) / 2;
            int height = FrameHeight - 4;
            int top    = FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);
            SpriteAnimations[currentAnim].ResetPlay();
        }
Esempio n. 8
0
        public void LoadContent(string _collectable)
        {
            string sheetString = string.Empty;

            switch (_collectable)
            {
            case "s":
                sheetString   = "Sprites//Collectable/scribbles";
                colorOffset   = Color.Black;
                pointsAwarded = 500;
                break;

            case "S":
                sheetString   = "Sprites/Collectable/scribbles";
                colorOffset   = Color.Gold;
                pointsAwarded = 1000;
                break;

            default:
                sheetString = "Sprites/Collectable/scribbles";
                colorOffset = Color.White;
                break;
            }

            Texture2D tex = Level.Content.Load <Texture2D>(sheetString);

            if (!SpriteTextures.Contains(tex))
            {
                SpriteTextures.Add(tex);
            }

            Animation anim = new Animation();

            anim.LoadAnimation("Idle", 0, new List <int> {
                0, 1, 2, 3
            }, 16, true);
            SpriteAnimations.Add("Idle", anim);

            int width  = FrameWidth;
            int left   = (FrameWidth - width) / 2;
            int height = FrameHeight - 4;
            int top    = FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);

            SpriteAnimations[currentAnim].ResetPlay();
        }
Esempio n. 9
0
        private void LoadAnimations()
        {
            Animation anim = new Animation();

            anim.LoadAnimation("Idle", new List <int> {
                0, 0, 6, 6, 7, 7, 7, 8, 8, 8
            }, 3, true);
            SpriteAnimations.Add("Idle", anim);

            anim = new Animation();
            anim.LoadAnimation("Walking", new List <int> {
                9, 12, 9, 10
            }, 5, true);
            SpriteAnimations.Add("Walking", anim);

            anim = new Animation();
            anim.LoadAnimation("Jump", new List <int> {
                2
            }, 1, true);
            SpriteAnimations.Add("Jump", anim);

            anim = new Animation();
            anim.LoadAnimation("Land", new List <int> {
                2, 3, 3, 3, 3
            }, 10, false);
            anim.AnimationCallBack(() =>
            {
                currentAnim = "Idle";
                SpriteAnimations[currentAnim].ResetPlay();
            });
            SpriteAnimations.Add("Land", anim);

            anim = new Animation();
            anim.LoadAnimation("Dead", new List <int> {
                0, 4, 4, 5, 5, 5, 5, 5, 16, 16, 16
            }, 3, false);
            anim.AnimationCallBack(() => DeadAnimationEnded = true);
            SpriteAnimations.Add("Dead", anim);

            int width  = FrameWidth - 48;
            int left   = (FrameWidth - width) / 2;
            int height = FrameHeight - 23;
            int top    = FrameHeight - height - 10;

            localBounds = new Rectangle(left, top, width, height);
            SpriteAnimations[currentAnim].ResetPlay();
        }
Esempio n. 10
0
        public void SetAnimation(SpriteAnimations animation, float animationTimeInMS = -1)
        {
            if (animation == SpriteAnimations.NONE)
            {
                if (CurrentAnimation != null)
                {
                    CurrentAnimation.Reset();
                }

                CurrentAnimation = null;
                return;
            }

            var animationToSet = Animations.GetAnimation(animation);

            if (animationToSet != CurrentAnimation)
            {
                // if my animation had callbacks i will still wanna run them
                if (CurrentAnimation?.Callbacks.Count > 0)
                {
                    foreach (var animCallback in CurrentAnimation.Callbacks)
                    {
                        var framesUntilCallback = animCallback.PlayOnFrame - CurrentAnimation.CurrentFrame;
                        animCallback.PlayOnFrame = framesUntilCallback;
                        PendingCallbacks.Add(animCallback);
                    }
                }

                CurrentAnimation?.Reset();
                CurrentAnimation = animationToSet;
                CurrentAnimation.Reset();
                if (animationTimeInMS > 0)
                {
                    //  CurrentAnimation.AnimationTimeInSeconds = animationTimeInMS / 1000;
                }

                if (animation == SpriteAnimations.DEAD)
                {
                    CurrentAnimation.Loop(Direction);
                }
            }
        }
Esempio n. 11
0
    void OnGUI()
    {
        if (ani == null || ani.name == "")
        {
            ani = SpriteAnimations.Get(skin);
            if (ani == null)
            {
                return;
            }
        }

        GUI.depth = depth;
        Rect brush = area;

        if (lockWidthToHeight)
        {
            brush = area.MiddleCenter(area.height / area.width, 1);
        }

        GUI.DrawTexture(brush, ani.GetImageNormalized(val));
    }
Esempio n. 12
0
        public void LoadContent()
        {
            // Load animated textures.
            SpriteTextures.Add(Level.Content.Load <Texture2D>("Sprites/Player/player"));
            Animation anim = new Animation();

            anim.LoadAnimation("Idle", 0, new List <int> {
                0, 11, 0, 12
            }, 7, true);
            SpriteAnimations.Add("Idle", anim);

            anim = new Animation();
            anim.LoadAnimation("Walking", 0, new List <int> {
                9, 12, 9, 10
            }, 7, true);
            SpriteAnimations.Add("Walking", anim);

            anim = new Animation();
            anim.LoadAnimation("Jump", 0, new List <int> {
                7, 8, 9, 10, 9, 8, 7
            }, 20, false);
            anim.AnimationCallBack(JumpAnimEnd);
            SpriteAnimations.Add("Jump", anim);

            anim = new Animation();
            anim.LoadAnimation("Dead", 0, new List <int> {
                13, 14, 15
            }, 6, false);
            anim.AnimationCallBack(DeadAnimEnd);
            SpriteAnimations.Add("Dead", anim);

            int width  = FrameWidth - 4;
            int left   = (FrameWidth - width) / 2;
            int height = FrameHeight - 4;
            int top    = FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);
        }
Esempio n. 13
0
 public AnimationBase GetAnimation(SpriteAnimations animation)
 {
     return(Animations[animation]);
 }
Esempio n. 14
0
 void Start()
 {
     ani = SpriteAnimations.Get(skin);
 }