Ejemplo n.º 1
0
        public void Add(string animationKey, AnimationDNABlock animation)
        {
            var cacheKey = animationKey.Split('_').FirstOrDefault();
            var cache    = _cacheLookup.SafeGet(cacheKey);

            cache[animationKey] = animation;
        }
Ejemplo n.º 2
0
        public void Add(string animationKey, AnimationDNABlock animation)
        {
            string cacheKey = animationKey.Split('_')[0];
            Dictionary <string, AnimationDNABlock> cache = _cacheLookup[cacheKey];

            cache[animationKey] = animation;
        }
        void RenderAnimationFrame(string animationKey, int currentFrameIndex)
        {
            AnimationDNABlock animationDNABlock = _animationDNA.DNABlocks[animationKey];
            SpriteRenderer    renderer          = _spriteRenderers[animationKey];

            if (animationDNABlock.Enabled)
            {
                renderer.sprite           = animationDNABlock.SpriteList[currentFrameIndex];
                renderer.sortingOrder     = animationDNABlock.SortingOrder;
                renderer.sortingLayerName = "Units";

                // Don't color clear objects
                if (animationDNABlock.SpriteColor != Color.clear)
                {
                    renderer.material.SetColor("_Color", animationDNABlock.SpriteColor);
                }
            }
            else
            {
                renderer.sprite = null;
            }
        }
        public void UpdateDNAForAction(CharacterDNA characterDNA, AnimationDNA animationDNA, BaseAction actionAnimation, string newDirection)
        {
            /*
             *  Uses the characterDNA to fetch the proper animations and update the animationDNA.
             */
            foreach (string blockType in DNABlockType.GetTypeList())
            {
                CharacterDNABlock characterDNABlock = characterDNA.DNABlocks[blockType];

                if (characterDNABlock.Enabled)
                {
                    animationDNA.DNABlocks[blockType] = getAnimation(characterDNABlock.ModelKey, actionAnimation, newDirection);
                    AnimationDNABlock animationDNABlock = animationDNA.DNABlocks[blockType];
                    animationDNABlock.UpdateSpriteColor(characterDNABlock.ItemColor);
                    animationDNABlock.Enabled = true;
                }
                else
                {
                    // Disable the animation slot if the character slot isnt enabled
                    animationDNA.DNABlocks[blockType].Enabled = false;
                }
                characterDNABlock.IsDirty = false;
            }
        }