public static ContourReader NewReader(ContourBlueprint blueprint) { if (blueprint == null || blueprint.material == null) { return(null); } ContourReader newReader = null; if (blueprint.material is ContourFaceMaterial) { newReader = new ContourFaceReader(); } else if (blueprint.material is ContourLineMaterial) { newReader = new ContourLineReader(); } else if (blueprint.material is ContourColliderMaterial) { newReader = new ContourColliderReader(); } else if (blueprint.material is ContourAnimationMaterial) { newReader = new ContourAnimationReader(); } if (newReader == null) { throw new Exception(newReader.ToString() + " creation error. " + blueprint.material.ToString() + " reading not implemented"); } newReader.TryReadBlueprint(blueprint); // Return created reader //newReader.blueprint = blueprint; return(newReader); }
private void FixedUpdate() { if (blueprints != null && animatedPoints != null && animatedContours != null) { float time = Time.fixedTime; // Set every point to its default position foreach (AnimatedPoint apt in animatedPoints) { apt.position = apt.idlePosition; } // Start from here to add each movement int blueprintCount = blueprints.Count; for (int bpi = 0; bpi < blueprintCount; bpi++) { // Play each animation if (readers[bpi] == null || blueprints[bpi] == null) { continue; } ContourShape shape = blueprints[bpi].shape; if (shape == null) { continue; } ContourAnimationReader reader = readers[bpi] as ContourAnimationReader; reader.Animate(time); // Add movement to each concerned point AnimatedContour act = animatedContours[bpi]; act.AddPointOffset(reader.animationPositions); } // Apply movement to each contour foreach (AnimatedContour act in animatedContours) { act.AnimationUpdate(); } } }