Пример #1
0
        private static tk2dSpriteDefinition ConstructDefinition(YAML.Clip clip, YAML.Frame frame, Texture2D texture, Material material)
        {
            var width  = frame.W ?? clip.FrameSize.Width;
            var height = frame.H ?? clip.FrameSize.Height;

            var spritedef = new tk2dSpriteDefinition {
                normals = new Vector3[] {
                    new Vector3(0.0f, 0.0f, -1.0f),
                    new Vector3(0.0f, 0.0f, -1.0f),
                    new Vector3(0.0f, 0.0f, -1.0f),
                    new Vector3(0.0f, 0.0f, -1.0f),
                },
                tangents = new Vector4[] {
                    new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                    new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                    new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                    new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                },
                texelSize       = new Vector2(0.1f, 0.1f),
                extractRegion   = false,
                regionX         = 0,
                regionY         = 0,
                regionW         = 0,
                regionH         = 0,
                flipped         = tk2dSpriteDefinition.FlipMode.None,
                complexGeometry = false,
                physicsEngine   = tk2dSpriteDefinition.PhysicsEngine.Physics3D,
                colliderType    = tk2dSpriteDefinition.ColliderType.Box,
                collisionLayer  = CollisionLayer.PlayerHitBox,
                position0       = new Vector3(16 / frame.Position.X, 16 / frame.Position.Y),
                position1       = new Vector3(16 / frame.Position.X + width, 16 / frame.Position.Y),
                position2       = new Vector3(16 / frame.Position.X, 16 / frame.Position.Y + height),
                position3       = new Vector3(16 / frame.Position.X + width, 16 / frame.Position.Y + height),
                material        = material,
                materialInst    = material,
                materialId      = 0,
            };

            spritedef.uvs = ETGMod.Assets.GenerateUVs(texture, frame.X, frame.Y, width, height);

            return(spritedef);
        }
Пример #2
0
            internal tk2dSpriteAnimationFrame[] ConstructFrames(YAML.Clip clip, tk2dSpriteCollectionData collection)
            {
                var frames = new List <tk2dSpriteAnimationFrame>();

                for (int i = 0; i < clip.Frames.Count; i++)
                {
                    var mframe = clip.Frames[i];

                    var sprite_id = Collection.GetSpriteDefinitionIndex(mframe.Definition);
                    if (sprite_id == null)
                    {
                        Logger.Error($"Definition '{mframe.Definition}' doesn't exist!");
                        continue;
                    }

                    var frame = new tk2dSpriteAnimationFrame {
                        spriteCollection  = collection,
                        spriteId          = Collection.GetSpriteDefinitionIndex(mframe.Definition).Value,
                        groundedFrame     = true,
                        invulnerableFrame = false
                    };

                    if (clip.AllInvulnerable)
                    {
                        frame.invulnerableFrame = true;
                    }
                    if (clip.AllOffGround)
                    {
                        frame.groundedFrame = false;
                    }

                    var @event = YAML.Frame.DEFAULT_EVENT;
                    if (mframe.Event != null)
                    {
                        frame.triggerEvent = true;
                        @event             = mframe.Event;
                    }
                    frame.eventInfo    = @event.Name;
                    frame.eventVfx     = @event.PlayVFX;
                    frame.eventStopVfx = @event.StopVFX;
                    frame.eventInt     = @event.Int;
                    frame.eventFloat   = @event.Float;
                    frame.eventAudio   = @event.Audio;

                    var outline = tk2dSpriteAnimationFrame.OutlineModifier.Unspecified;

                    if (@event.Outline != null)
                    {
                        outline = (tk2dSpriteAnimationFrame.OutlineModifier)Enum.Parse(typeof(tk2dSpriteAnimationFrame.OutlineModifier), @event.Outline.Replace('_', ' ').ToTitleCaseInvariant().Replace(" ", ""));
                    }

                    frame.eventOutline = outline;

                    var lerp_emissive = YAML.Event.DEFAULT_LERP_EMISSIVE;
                    if (@event.LerpEmissive != null)
                    {
                        lerp_emissive           = @event.LerpEmissive;
                        frame.eventLerpEmissive = true;
                    }


                    frame.eventLerpEmissiveTime  = lerp_emissive.Time;
                    frame.eventLerpEmissivePower = lerp_emissive.Power;

                    // TODO reverse order, or not reverse order?
                    frames.Add(frame);
                }

                return(frames.ToArray());
            }
Пример #3
0
        private static tk2dSpriteAnimationFrame[] ConstructFrames(YAML.Animation mapping, GameObject go, YAML.Clip clip)
        {
            var frames = new List <tk2dSpriteAnimationFrame>();

            var collection = ConstructCollection(mapping, go, Resources.Load <Texture2D>(mapping.Spritesheet));

            for (int i = 0; i < clip.Frames.Count; i++)
            {
                var mframe = clip.Frames[i];

                var frame = new tk2dSpriteAnimationFrame {
                    spriteCollection = collection,
                    spriteId         = mframe.SpriteDefinitionId,
                };
            }

            return(frames.ToArray());
        }