public static void UpdateDNAForAction(CharacterDNA characterDNA, AnimationDNA animationDNA, BaseAction actionAnimation, string newDirection) { foreach (var blockType in DNABlockType.TypeList) { CharacterDNABlock characterDnaBlock = characterDNA.DNABlocks[blockType]; if (characterDnaBlock.Enabled) { animationDNA.DNABlocks[blockType] = GetAnimation(characterDnaBlock.ModelKey, actionAnimation, newDirection); AnimationDNABlock animationDnaBlock = animationDNA.DNABlocks[blockType]; if (animationDnaBlock == null) { Debug.Log($"Block not found: {blockType}"); continue; } 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; } }
public void Add(string animationKey, AnimationDNABlock animationDnaBlock) { string cacheKey = animationKey.Split('_').FirstOrDefault(); var cache = _cacheLookup.SafeGet(cacheKey); cache[animationKey] = animationDnaBlock; }
void RenderAnimationFrame(string animationKey, int currentFrameIndex) { AnimationDNABlock animationDnaBlock = _animationDNA.DNABlocks[animationKey]; SpriteRenderer rendererCurrent = _spriteRenderers[animationKey]; if (animationDnaBlock?.Enabled == true) { // set sprite renderer info rendererCurrent.sprite = animationDnaBlock.SpriteList[currentFrameIndex]; rendererCurrent.sortingOrder = animationDnaBlock.SortingOrder; rendererCurrent.sortingLayerName = "Units"; // Don't color clear objects if (animationDnaBlock.SpriteColor != Color.clear) { rendererCurrent.material.SetColor("_Color", animationDnaBlock.SpriteColor); } } else { rendererCurrent.sprite = null; } }