Пример #1
0
    MadSprite BuildSlide(MadSprite template, string anchorName, bool left)
    {
        MadAnchor slideAnchor = MadTransform.FindChildWithName <MadAnchor>(transform, anchorName);

        if (slideAnchor != null)
        {
            DestroyImmediate(slideAnchor.gameObject);
        }

        slideAnchor = CreateChild <MadAnchor>(anchorName);
        if (hideManagedObjects)
        {
            slideAnchor.gameObject.hideFlags = HideFlags.HideInHierarchy;
        }

        slideAnchor.position = left ? MadAnchor.Position.Left : MadAnchor.Position.Right;
        slideAnchor.Update(); // explict update call because position has changed

        var offset = MadTransform.CreateChild(slideAnchor.transform, "Offset");

        offset.transform.localPosition =
            new Vector3(left ? template.texture.width / 2 : -template.texture.width / 2, 0, 0);

        var slide = MadTransform.CreateChild <MadSprite>(offset.transform, "slide", template);

        slide.transform.localScale    = Vector3.one;
        slide.transform.localPosition = Vector3.zero;
        slide.guiDepth = 1000;

        return(slide);
    }
Пример #2
0
    protected void OnEnable() {
        sprite = target as MadSprite;

        panel = serializedObject.FindProperty("panel");
        visible = serializedObject.FindProperty("visible");
        pivotPoint = serializedObject.FindProperty("pivotPoint");
        customPivotPoint = serializedObject.FindProperty("customPivotPoint");
        tint = serializedObject.FindProperty("tint");
        inputType = serializedObject.FindProperty("inputType");
        texture = serializedObject.FindProperty("texture");
        textureAtlas = serializedObject.FindProperty("textureAtlas");
        textureAtlasSpriteGUID = serializedObject.FindProperty("textureAtlasSpriteGUID");
        textureOffset = serializedObject.FindProperty("textureOffset");
        textureRepeat = serializedObject.FindProperty("textureRepeat");
        hasPremultipliedAlpha = serializedObject.FindProperty("hasPremultipliedAlpha");
        guiDepth = serializedObject.FindProperty("guiDepth");
        fillType = serializedObject.FindProperty("fillType");
        fillValue = serializedObject.FindProperty("fillValue");
        radialFillOffset = serializedObject.FindProperty("radialFillOffset");
        radialFillLength = serializedObject.FindProperty("radialFillLength");

        hasLiveBounds = serializedObject.FindProperty("hasLiveBounds");
        liveLeft = serializedObject.FindProperty("liveLeft");
        liveBottom = serializedObject.FindProperty("liveBottom");
        liveRight = serializedObject.FindProperty("liveRight");
        liveTop = serializedObject.FindProperty("liveTop");

        gridTexture = Resources.Load("Mad2D/Textures/grid", typeof(Texture2D)) as Texture2D;
        whiteTexture = Resources.Load("Textures/white", typeof(Texture2D)) as Texture2D;

        
    }
Пример #3
0
    bool CanBatch(MadSprite a, MadSprite b)
    {
        var materialA = a.GetMaterial();
        var materialB = b.GetMaterial();

        return(materialA.Equals(materialB));
    }
    protected void OnEnable()
    {
        sprite = target as MadSprite;

        panel                  = serializedObject.FindProperty("panel");
        visible                = serializedObject.FindProperty("visible");
        pivotPoint             = serializedObject.FindProperty("pivotPoint");
        customPivotPoint       = serializedObject.FindProperty("customPivotPoint");
        tint                   = serializedObject.FindProperty("tint");
        inputType              = serializedObject.FindProperty("inputType");
        texture                = serializedObject.FindProperty("texture");
        textureAtlas           = serializedObject.FindProperty("textureAtlas");
        textureAtlasSpriteGUID = serializedObject.FindProperty("textureAtlasSpriteGUID");
        textureOffset          = serializedObject.FindProperty("textureOffset");
        textureRepeat          = serializedObject.FindProperty("textureRepeat");
        hasPremultipliedAlpha  = serializedObject.FindProperty("hasPremultipliedAlpha");
        guiDepth               = serializedObject.FindProperty("guiDepth");
        fillType               = serializedObject.FindProperty("fillType");
        fillValue              = serializedObject.FindProperty("fillValue");
        radialFillOffset       = serializedObject.FindProperty("radialFillOffset");
        radialFillLength       = serializedObject.FindProperty("radialFillLength");

        hasLiveBounds = serializedObject.FindProperty("hasLiveBounds");
        liveLeft      = serializedObject.FindProperty("liveLeft");
        liveBottom    = serializedObject.FindProperty("liveBottom");
        liveRight     = serializedObject.FindProperty("liveRight");
        liveTop       = serializedObject.FindProperty("liveTop");

        gridTexture  = Resources.Load("Mad2D/Textures/grid", typeof(Texture2D)) as Texture2D;
        whiteTexture = Resources.Load("Textures/white", typeof(Texture2D)) as Texture2D;
    }
Пример #5
0
    void BuildSlideIcons()
    {
        if (leftSlideSprite == null || rightSlideSprite == null)
        {
            Debug.LogWarning("Slide prefabs not set yet.");
            return;
        }

        slideLeft  = BuildSlide(leftSlideSprite, "SlideLeftAnchor", true);
        slideRight = BuildSlide(rightSlideSprite, "SlideRightAnchor", false);

        slideLeft.transform.localScale  = new Vector3(leftSlideScale.x, leftSlideScale.y, 1);
        slideRight.transform.localScale = new Vector3(rightSlideScale.x, rightSlideScale.y, 1);

        slideLeft.transform.localPosition  += (Vector3)leftSlideOffset;
        slideRight.transform.localPosition += (Vector3)rightSlideOffset;

        MadSprite.Action goToPrevPage = (sprite) => {
            if (HasPrevPage())
            {
                GoToPrevPage();
            }
        };
        slideLeft.onTap     += goToPrevPage;
        slideLeft.onMouseUp += goToPrevPage;

        MadSprite.Action goToNextPage = (sprite) => {
            if (HasNextPage())
            {
                GoToNextPage();
            }
        };
        slideRight.onTap     += goToNextPage;
        slideRight.onMouseUp += goToNextPage;
    }
Пример #6
0
    private void Invoke(MadSprite sprite) {
        var cam = Camera.main;
        if (cam == null) {
            cam = FindObjectOfType(typeof (Camera)) as Camera;
        }

        AudioSource.PlayClipAtPoint(audioClip, cam.transform.position, volume);
    }
Пример #7
0
    // ===========================================================
    // Methods
    // ===========================================================

    void CreateGrid(MadRootNode root, MadLevelIcon icon, MadSprite slideLeft, MadSprite slideRight) {
        var panel = MadTransform.FindChild<MadPanel>(root.transform);
        var gridLayout = MadLevelGridTool.CreateUnderPanel(panel);

        gridLayout.iconTemplate = icon;
        gridLayout.leftSlideSprite = slideLeft;
        gridLayout.rightSlideSprite = slideRight;
        gridLayout.dirty = true;
    }
Пример #8
0
    static void SlideSetActive(MadSprite icon, bool act)
    {
        bool currentlyActive = MadGameObject.IsActive(icon.gameObject);

        if (currentlyActive != act)
        {
            MadGameObject.SetActive(icon.gameObject, act);
        }
    }
Пример #9
0
    // ===========================================================
    // Methods
    // ===========================================================

    void CreateGrid(MadRootNode root, MadLevelIcon icon, MadSprite slideLeft, MadSprite slideRight)
    {
        var panel      = MadTransform.FindChild <MadPanel>(root.transform);
        var gridLayout = MadLevelGridTool.CreateUnderPanel(panel);

        gridLayout.iconTemplate     = icon;
        gridLayout.leftSlideSprite  = slideLeft;
        gridLayout.rightSlideSprite = slideRight;
        gridLayout.dirty            = true;
    }
Пример #10
0
    private void Invoke(MadSprite sprite)
    {
        var cam = Camera.main;

        if (cam == null)
        {
            cam = FindObjectOfType(typeof(Camera)) as Camera;
        }

        AudioSource.PlayClipAtPoint(audioClip, cam.transform.position, volume);
    }
Пример #11
0
 void Start()
 {
     icon   = MadTransform.FindParent <MadLevelIcon>(transform);
     sprite = GetComponent <MadSprite>();
     if (icon != null)
     {
         AssignTexture();
     }
     else
     {
         Debug.LogError("MadLevelImage may be set only as a MadLevelIcon child");
     }
 }
Пример #12
0
    protected override void Start() {
        sprite = GetComponent<MadSprite>();
        if (sprite == null) {
            Debug.Log("Anim Color component requires MadSprite component!", this);
            return;
        }

        origin = sprite.tint;

        easingFunction = MadiTween.GetEasingFunction(easing);

        base.Start();
    }
Пример #13
0
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================
    
    void Start() {
        sprite = GetComponent<MadSprite>();
        if (sprite != null) {
            sprite.onMouseEnter += (s) => AnimOnMouseEnter();
            sprite.onMouseExit += (s) => AnimOnMouseExit();
            sprite.onTouchEnter += (s) => AnimOnTouchEnter();
            sprite.onTouchExit += (s) => AnimOnTouchExit();
            sprite.onFocus += (s) => PlayOnFocus();
            sprite.onFocusLost += (s) => PlayOnFocusLost();
        } else {
            Debug.LogError("This component must be attached with sprite!", this);
        }
    }
Пример #14
0
    static void SlideSetActive(MadSprite icon, bool act)
    {
        if (!MadGameObject.IsActive(icon.gameObject))
        {
            MadGameObject.SetActive(icon.gameObject, true);
        }

        bool currentlyActive = icon.visible;

        if (currentlyActive != act)
        {
            icon.visible = act;
        }
    }
Пример #15
0
    bool IsDragging(MadSprite sprite)
    {
        var dragHandler = sprite.FindParent <MadDraggable>();

        if (dragHandler != null)
        {
            if (dragHandler.dragging)
            {
                return(true);
            }
        }

        return(false);
    }
Пример #16
0
    void Start() {
        sprite = GetComponent<MadSprite>();
        if (sprite == null) {
            Debug.LogError("Condition needs a MadSprite to be attached to this game object.", this);
            return;
        }

        icon = MadTransform.FindParent<MadLevelIcon>(transform);
        if (icon == null) {
            Debug.LogError("Condition need to be set under MadLevelIcon.", this);
            return;
        }

        Apply();
    }
Пример #17
0
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================

    void Start()
    {
        sprite = GetComponent <MadSprite>();
        if (sprite != null)
        {
            sprite.onMouseEnter += (s) => AnimOnMouseEnter();
            sprite.onMouseExit  += (s) => AnimOnMouseExit();
            sprite.onFocus      += (s) => PlayOnFocus();
            sprite.onFocusLost  += (s) => PlayOnFocusLost();
        }
        else
        {
            Debug.LogError("This component must be attached with sprite!", this);
        }
    }
Пример #18
0
    protected override void Start()
    {
        sprite = GetComponent <MadSprite>();
        if (sprite == null)
        {
            Debug.Log("Anim Color component requires MadSprite component!", this);
            return;
        }

        origin = sprite.tint;

        easingFunction = MadiTween.GetEasingFunction(easing);

        base.Start();
    }
Пример #19
0
    void InitTemplates(MadRootNode root, out MadLevelIcon icon, out MadSprite slideLeftSprite,
                       out MadSprite slideRightSprite)
    {
        var panel     = MadTransform.FindChild <MadPanel>(root.transform);
        var templates = MadTransform.CreateChild(panel.transform, "Templates");

        GameObject iconPrefab       = (GameObject)AssetDatabase.LoadAssetAtPath(IconPrefab, typeof(GameObject));
        GameObject slideLeftPrefab  = (GameObject)AssetDatabase.LoadAssetAtPath(SlideLeftPrefab, typeof(GameObject));
        GameObject slideRightPrefab = (GameObject)AssetDatabase.LoadAssetAtPath(SlideRightPrefab, typeof(GameObject));

        if (MadGameObject.AnyNull(iconPrefab, slideLeftPrefab, slideRightPrefab))
        {
            Debug.LogWarning("I cannot find all needed prefabs to create example templates. Have you moved Mad Level "
                             + "Manager directory to other than default place?");
        }

        if (iconPrefab != null)
        {
            var obj = MadTransform.CreateChild(templates.transform, "icon", iconPrefab);
            icon = obj.GetComponent <MadLevelIcon>();
        }
        else
        {
            icon = null;
        }

        if (slideLeftPrefab != null)
        {
            var slide = MadTransform.CreateChild(templates.transform, "slide left", slideLeftPrefab);
            slideLeftSprite = slide.GetComponent <MadSprite>();
        }
        else
        {
            slideLeftSprite = null;
        }

        if (slideRightPrefab != null)
        {
            var slide = MadTransform.CreateChild(templates.transform, "slide right", slideRightPrefab);
            slideRightSprite = slide.GetComponent <MadSprite>();
        }
        else
        {
            slideRightSprite = null;
        }

        MadGameObject.SetActive(templates, false);
    }
Пример #20
0
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    protected void OnEnable()
    {
        sprite = target as MadSprite;

        visible          = serializedObject.FindProperty("visible");
        pivotPoint       = serializedObject.FindProperty("pivotPoint");
        tint             = serializedObject.FindProperty("tint");
        texture          = serializedObject.FindProperty("texture");
        textureOffset    = serializedObject.FindProperty("textureOffset");
        textureRepeat    = serializedObject.FindProperty("textureRepeat");
        guiDepth         = serializedObject.FindProperty("guiDepth");
        fillType         = serializedObject.FindProperty("fillType");
        fillValue        = serializedObject.FindProperty("fillValue");
        radialFillOffset = serializedObject.FindProperty("radialFillOffset");
        radialFillLength = serializedObject.FindProperty("radialFillLength");
    }
    void Start()
    {
        sprite = GetComponent <MadSprite>();
        if (sprite == null)
        {
            Debug.LogError("Condition needs a MadSprite to be attached to this game object.", this);
            return;
        }

        icon = MadTransform.FindParent <MadLevelIcon>(transform);
        if (icon == null)
        {
            Debug.LogError("Condition need to be set under MadLevelIcon.", this);
            return;
        }

        Apply();
    }
Пример #22
0
    static void SlideSetActive(MadSprite icon, bool act) {
        bool currentlyActive = MadGameObject.IsActive(icon.gameObject);

        if (currentlyActive != act) {
            MadGameObject.SetActive(icon.gameObject, act);
        }
    }
Пример #23
0
    static void SlideSetActive(MadSprite icon, bool act) {
        if (!MadGameObject.IsActive(icon.gameObject)) {
            MadGameObject.SetActive(icon.gameObject, true);
        }

        bool currentlyActive = icon.visible;

        if (currentlyActive != act) {
            icon.visible = act;
        }
    }
Пример #24
0
    private void BuildSlideIcons() {
        if (leftSlideSprite == null || rightSlideSprite == null) {
            return;
        }

        slideLeft = BuildSlide(leftSlideSprite, "SlideLeftAnchor", true);
        slideRight = BuildSlide(rightSlideSprite, "SlideRightAnchor", false);

        slideLeft.transform.localScale = new Vector3(leftSlideScale.x, leftSlideScale.y, 1);
        slideRight.transform.localScale = new Vector3(rightSlideScale.x, rightSlideScale.y, 1);

        slideLeft.transform.localPosition += (Vector3) leftSlideOffset;
        slideRight.transform.localPosition += (Vector3) rightSlideOffset;

        MadSprite.Action goToPrevPage = (sprite) => {
            if (HasPrevPage()) {
                GoToPrevPage();
            }
        };
        slideLeft.onTap += goToPrevPage;
        slideLeft.onMouseUp += goToPrevPage;

        MadSprite.Action goToNextPage = (sprite) => {
            if (HasNextPage()) {
                GoToNextPage();
            }
        };
        slideRight.onTap += goToNextPage;
        slideRight.onMouseUp += goToNextPage;
    }
Пример #25
0
 public void PlayFinishAnimation(MadSprite chosenSprite, bool completed) {
     levelNameText.eventFlags = MadSprite.EventFlags.None;
     argumentsText.eventFlags = MadSprite.EventFlags.None;
     backToMenu.eventFlags = MadSprite.EventFlags.None;
 
     Color transparent = new Color(1, 1, 1, 0);
     Color opaque = new Color(1, 1, 1, 1);
     
     levelNameText.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
     argumentsText.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
     backToMenu.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
     
     if (completed) {
         levelCompletedText.tint = transparent;
         levelCompletedText.visible = true;
         levelCompletedText.AnimColorTo(opaque, 1, MadiTween.EaseType.linear);
     } else {
         levelNotCompletedText.tint = transparent;
         levelNotCompletedText.visible = true;
         levelNotCompletedText.AnimColorTo(opaque, 1, MadiTween.EaseType.linear);
     }
     
     foreach (var sprite in other) {
         var children = MadTransform.FindChildren<MadSprite>(sprite.transform);
         
         sprite.eventFlags = MadSprite.EventFlags.None;
         foreach (var s in children) {
             s.eventFlags = MadSprite.EventFlags.None;
         }
     
         if (sprite != chosenSprite) {
             sprite.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
             
             foreach (var s in children) {
                 s.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
             }
         }
     }
     
     chosenSprite.AnimMoveTo(new Vector3(), 1, MadiTween.EaseType.easeOutSine);
         
     MadiTween.ScaleTo(chosenSprite.gameObject, MadiTween.Hash(
         "scale", new Vector3(7, 7, 7),
         "time", 0.5f,
         "easetype", MadiTween.EaseType.easeInQuint,
         "delay", 1.5f
     ));
     
     MadiTween.ValueTo(chosenSprite.gameObject, MadiTween.Hash(
         "from", chosenSprite.tint,
         "to", transparent,
         "time", 0.5f,
         "onupdate", "OnTintChange",
         "easetype", MadiTween.EaseType.easeInQuint,
         "delay", 1.5f
     ));
         
     foreach (var s in MadTransform.FindChildren<MadSprite>(chosenSprite.transform)) {
         MadiTween.ValueTo(s.gameObject, MadiTween.Hash(
             "from", s.tint,
             "to", transparent,
             "time", 0.5f,
             "onupdate", "OnTintChange",
                 "easetype", MadiTween.EaseType.easeInQuint,
             "delay", 1.5f
         ));
     }
 }
Пример #26
0
 void NullAction(MadSprite s)
 {
 }
Пример #27
0
    void InitTemplates(MadRootNode root, out MadLevelIcon icon, out MadSprite slideLeftSprite,
            out MadSprite slideRightSprite) {
        var panel = MadTransform.FindChild<MadPanel>(root.transform);
        var templates = MadTransform.CreateChild(panel.transform, "Templates");

        GameObject iconPrefab = MadAssets.TryLoadGameObject(IconPrefabGUID);
        GameObject slideLeftPrefab = MadAssets.TryLoadGameObject(SlideLeftPrefabGUID);
        GameObject slideRightPrefab = MadAssets.TryLoadGameObject(SlideRightPrefabGUID);

        if (MadGameObject.AnyNull(iconPrefab, slideLeftPrefab, slideRightPrefab)) {
            Debug.LogWarning("I cannot find all needed prefabs to create example templates. Have you removed Mad Level "
            + "Manager example prefabs?");
        }

        if (iconPrefab != null) {
            var obj = PrefabUtility.InstantiatePrefab(iconPrefab) as GameObject;
            obj.transform.parent = templates.transform;
            obj.name = "icon";

            obj.transform.localScale = Vector3.one;
            obj.transform.localPosition = new Vector2(-400, 150);
            icon = obj.GetComponent<MadLevelIcon>();
        } else {
            icon = null;
        }

        if (slideLeftPrefab != null) {
            var slide = PrefabUtility.InstantiatePrefab(slideLeftPrefab) as GameObject;
            slide.transform.parent = templates.transform;
            slide.name = "slide left";

            slide.transform.localScale = Vector3.one;
            slide.transform.localPosition = new Vector2(-400, 0);
            slideLeftSprite = slide.GetComponent<MadSprite>();
        } else {
            slideLeftSprite = null;
        }

        if (slideRightPrefab != null) {
            var slide = PrefabUtility.InstantiatePrefab(slideRightPrefab) as GameObject;
            slide.transform.parent = templates.transform;
            slide.name = "slide right";

            slide.transform.localScale = Vector3.one;
            slide.transform.localPosition = new Vector2(-400, -150);
            slideRightSprite = slide.GetComponent<MadSprite>();
        } else {
            slideRightSprite = null;
        }

        MadGameObject.SetActive(templates, false);
    }
Пример #28
0
    bool IsDragging(MadSprite sprite) {
        var dragHandler = sprite.FindParent<MadDraggable>();
        if (dragHandler != null) {
            if (dragHandler.dragging) {
                return true;
            }
        }

        return false;
    }
Пример #29
0
    bool CanBatch(MadSprite a, MadSprite b) {
        if (panel.renderMode == MadPanel.RenderMode.DepthBased) {
            if (a.guiDepth != b.guiDepth) {
                return false;
            }
        }

        var materialA = a.GetMaterial();
        var materialB = b.GetMaterial();
        
        return materialA.Equals(materialB);
    }
Пример #30
0
    private bool SpriteVisible(MadSprite sprite) {
        bool active =
#if UNITY_3_5
        sprite.gameObject.active;
#else
        sprite.gameObject.activeInHierarchy;
#endif
        if (!active) {
            return false;
        }

        if (!sprite.visible) {
            return false;
        }

        if (Mathf.Approximately(sprite.tint.a, 0)) {
            return false;
        }

        if (!sprite.CanDraw()) {
            return false;
        }

        if (panel.hideInvisibleSprites && Application.isPlaying) {
            // execute camera visiblity check only if playing (not working in the edit mode)

            sprite.GetWorldCorners(ref cornersWorker);
            var cam = panel.currentCamera;
            if (!VisibleOnCameraAny(cornersWorker, cam)) {
                return false;
            }
        }

        return true;
    }
Пример #31
0
 void NullAction(MadSprite s) {}
Пример #32
0
 bool CanBatch(MadSprite a, MadSprite b) {
     var materialA = a.GetMaterial();
     var materialB = b.GetMaterial();
     
     return materialA.Equals(materialB);
 }
Пример #33
0
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================

    void Start() {
        loadingScreen = FindObjectOfType(typeof(MadLevelLoadingScreen)) as MadLevelLoadingScreen;
        bar = GetComponent<MadSprite>();
    }
Пример #34
0
    private MadSprite BuildSlide(MadSprite template, string anchorName, bool left) {
        var slideAnchor = MadTransform.CreateChild<MadAnchor>(transform, anchorName);
        if (hideManagedObjects) {
            slideAnchor.gameObject.hideFlags = HideFlags.HideInHierarchy;
        }

        slideAnchor.position = left ? MadAnchor.Position.Left : MadAnchor.Position.Right;
        slideAnchor.Update(); // explict update call because position has changed

        var offset = MadTransform.CreateChild(slideAnchor.transform, "Offset");
        offset.transform.localPosition =
            new Vector3(left ? template.texture.width / 2 : -template.texture.width / 2, 0, 0);

        var slide = MadTransform.CreateChild<MadSprite>(offset.transform, "slide", template);
        slide.transform.localScale = Vector3.one;
        slide.transform.localPosition = Vector3.zero;
        slide.guiDepth = 50;

        return slide;
    }
Пример #35
0
    void InitTemplates(MadRootNode root, out MadLevelIcon icon, out MadSprite slideLeftSprite,
                       out MadSprite slideRightSprite)
    {
        var panel     = MadTransform.FindChild <MadPanel>(root.transform);
        var templates = MadTransform.CreateChild(panel.transform, "Templates");

        GameObject iconPrefab       = MadAssets.TryLoadGameObject(IconPrefabGUID);
        GameObject slideLeftPrefab  = MadAssets.TryLoadGameObject(SlideLeftPrefabGUID);
        GameObject slideRightPrefab = MadAssets.TryLoadGameObject(SlideRightPrefabGUID);

        if (MadGameObject.AnyNull(iconPrefab, slideLeftPrefab, slideRightPrefab))
        {
            Debug.LogWarning("I cannot find all needed prefabs to create example templates. Have you removed Mad Level "
                             + "Manager example prefabs?");
        }

        if (iconPrefab != null)
        {
            var obj = PrefabUtility.InstantiatePrefab(iconPrefab) as GameObject;
            obj.transform.parent = templates.transform;
            obj.name             = "icon";

            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = new Vector2(-400, 150);
            icon = obj.GetComponent <MadLevelIcon>();
        }
        else
        {
            icon = null;
        }

        if (slideLeftPrefab != null)
        {
            var slide = PrefabUtility.InstantiatePrefab(slideLeftPrefab) as GameObject;
            slide.transform.parent = templates.transform;
            slide.name             = "slide left";

            slide.transform.localScale    = Vector3.one;
            slide.transform.localPosition = new Vector2(-400, 0);
            slideLeftSprite = slide.GetComponent <MadSprite>();
        }
        else
        {
            slideLeftSprite = null;
        }

        if (slideRightPrefab != null)
        {
            var slide = PrefabUtility.InstantiatePrefab(slideRightPrefab) as GameObject;
            slide.transform.parent = templates.transform;
            slide.name             = "slide right";

            slide.transform.localScale    = Vector3.one;
            slide.transform.localPosition = new Vector2(-400, -150);
            slideRightSprite = slide.GetComponent <MadSprite>();
        }
        else
        {
            slideRightSprite = null;
        }

        MadGameObject.SetActive(templates, false);
    }
Пример #36
0
    public void PlayFinishAnimation(MadSprite chosenSprite, bool completed)
    {
        levelNameText.eventFlags = MadSprite.EventFlags.None;
        argumentsText.eventFlags = MadSprite.EventFlags.None;
        backToMenu.eventFlags    = MadSprite.EventFlags.None;

        Color transparent = new Color(1, 1, 1, 0);
        Color opaque      = new Color(1, 1, 1, 1);

        levelNameText.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
        argumentsText.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
        backToMenu.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);

        if (completed)
        {
            levelCompletedText.tint    = transparent;
            levelCompletedText.visible = true;
            levelCompletedText.AnimColorTo(opaque, 1, MadiTween.EaseType.linear);
        }
        else
        {
            levelNotCompletedText.tint    = transparent;
            levelNotCompletedText.visible = true;
            levelNotCompletedText.AnimColorTo(opaque, 1, MadiTween.EaseType.linear);
        }

        foreach (var sprite in other)
        {
            var children = MadTransform.FindChildren <MadSprite>(sprite.transform);

            sprite.eventFlags = MadSprite.EventFlags.None;
            foreach (var s in children)
            {
                s.eventFlags = MadSprite.EventFlags.None;
            }

            if (sprite != chosenSprite)
            {
                sprite.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);

                foreach (var s in children)
                {
                    s.AnimColorTo(transparent, 1, MadiTween.EaseType.linear);
                }
            }
        }

        chosenSprite.AnimMoveTo(new Vector3(), 1, MadiTween.EaseType.easeOutSine);

        MadiTween.ScaleTo(chosenSprite.gameObject, MadiTween.Hash(
                              "scale", new Vector3(7, 7, 7),
                              "time", 0.5f,
                              "easetype", MadiTween.EaseType.easeInQuint,
                              "delay", 1.5f
                              ));

        MadiTween.ValueTo(chosenSprite.gameObject, MadiTween.Hash(
                              "from", chosenSprite.tint,
                              "to", transparent,
                              "time", 0.5f,
                              "onupdate", "OnTintChange",
                              "easetype", MadiTween.EaseType.easeInQuint,
                              "delay", 1.5f
                              ));

        foreach (var s in MadTransform.FindChildren <MadSprite>(chosenSprite.transform))
        {
            MadiTween.ValueTo(s.gameObject, MadiTween.Hash(
                                  "from", s.tint,
                                  "to", transparent,
                                  "time", 0.5f,
                                  "onupdate", "OnTintChange",
                                  "easetype", MadiTween.EaseType.easeInQuint,
                                  "delay", 1.5f
                                  ));
        }
    }