Ejemplo n.º 1
0
        protected virtual void OnBackButton()
        {
            BackButton.Register(OnBackButton);

            if (TabChangedEvents.Count == 0)
            {
                return;
            }

            var tabChangedEvent = TabChangedEvents.Pop();

            if (tabChangedEvent.Item1 == CurrentSection)
            {
                TabSelector.Select(this, tabChangedEvent.Item2);
                return;
            }

            tabChangedEvent.Item1.Data.SetCurrentTab(tabChangedEvent.Item2.SelectedTab.Data);
            SectionSelector.Select(this, new UserSectionSelectedEventArgs(tabChangedEvent.Item1, tabChangedEvent.Item2.ChangeType));
        }
 public override void Display(object sender, UserTabSelectedEventArgs eventArgs)
 {
     SectionValue.SelectedSection.SetCurrentTab(eventArgs.SelectedTab.Data);
     SectionSelector.Select(sender, UserSectionValue);
 }
 public override void Display(object sender, UserSectionSelectedEventArgs eventArgs)
 => SectionSelector.Select(sender, eventArgs);
Ejemplo n.º 4
0
    private void InitializeSections(ColorableInstance colorableInstance, GameObject colorableObject)
    {
        int depth = 10;

        Sprite[]     sectionColorLayers = GetSectionColorLayers(colorableInstance.Colorable);
        GameObject[] layerObjects       = new GameObject[sectionColorLayers.Length];

        Colorable colorable = colorableInstance.Colorable;

        List <ColorableSectionInstance> sectionInstances = new List <ColorableSectionInstance>();

        SectionSelector sectionSelector = null;

        for (int i = 0; i < sectionColorLayers.Length; i++)
        {
            if (sectionColorLayers[i] == null)
            {
                layerObjects[i] = null;
                continue;
            }

            GameObject gameObject = new GameObject();
            gameObject.name = "Section: " + i;

            gameObject.AddComponent <ColorChanger>();

            // Create the 2D box collider, add it to Collision Sprite Renderer

            /*if (i == 0)
             * {
             *  sectionSelector = gameObject.AddComponent<SectionSelector>();
             * }*/

            // Create sprite renderer
            SpriteRenderer spriteRenderer = gameObject.AddComponent <SpriteRenderer>();
            spriteRenderer.sprite       = sectionColorLayers[i];
            gameObject.transform.parent = colorableObject.transform;

            ColorableSectionInstance sectionInstance = gameObject.AddComponent <ColorableSectionInstance>();
            sectionInstance.ColorableSection = colorableInstance.Colorable.Sections[i];
            sectionInstances.Add(sectionInstance);

            // Collision object

            GameObject collisionGameObject = new GameObject();
            collisionGameObject.name = "Collision: " + i;

            // Create sprite renderer
            SpriteRenderer collisionSpriteRenderer = collisionGameObject.AddComponent <SpriteRenderer>();
            collisionSpriteRenderer.sprite       = colorableInstance.Colorable.Sections[i].SelectionLayer;
            collisionGameObject.transform.parent = gameObject.transform;
            collisionSpriteRenderer.enabled      = false;

            BoxCollider2D meshCollider = collisionGameObject.AddComponent <BoxCollider2D>();

            // Change the depth
            Vector3 newPosition = gameObject.transform.localPosition;
            newPosition.z = depth;
            depth--;
            gameObject.transform.localPosition = newPosition;

            layerObjects[i] = gameObject;
        }

        colorableInstance.InitializeSectionInstances(sectionInstances.ToArray());
    }