Ejemplo n.º 1
0
    // pops corresponding popup and calls transition event
    public void Pop(GamePopup popup)
    {
        if (!initialized)
        {
            Debug.LogError(debugableInterface.debugLabel + "Not initialized");
            return;
        }

        Type type = GetTypeFromPopup(popup);

        if (type == null)
        {
            Debug.LogError(debugableInterface.debugLabel + "Couln't find type for GamePopup " + popup.ToString());
            return;
        }
        else
        {
            Popup selected = scenePopups.Find(item => { return(item.GetType() == type); });

            if (selected == null)
            {
                Debug.LogError(debugableInterface.debugLabel + "Couldn't find Popup for GamePopup " + popup.ToString());
                return;
            }
            else
            {
                selected.Activate(this);
                actualPopup = popup;
                // FadeMusicIn.Invoke();
            }
        }
    }
Ejemplo n.º 2
0
    PopupEventSubscription GetSubscriptionEvent(GamePopup popup)
    {
        PopupEventSubscription popupEvent = popupsSubscriptions.Find(item => { return(item.popup == popup); });

        if (popupEvent == null)
        {
            Debug.LogWarning(debugableInterface.debugLabel + "Couldn't find PopupEventSubscription for popup " + popup.ToString());
            return(null);
        }

        return(popupEvent);
    }
Ejemplo n.º 3
0
    // call this when you get on a new scene (like an Init but every time you change scenes)
    public void GetAllScenePopups()
    {
        scenePopups = new List <Popup>();
        scenePopups.AddRange(Resources.FindObjectsOfTypeAll <Popup>());

        scenePopups.ForEach(item =>
        {
            item.Init(
                fadeDuration, alphaComparisonThreshold,
                () => { actualPopup = item.popup; },
                () => GetSubscriptionEvent(item.popup).CallEvent()
                );
        });
    }
Ejemplo n.º 4
0
    public void SubscribeEvent(GamePopup popup, Action callback)
    {
        if (!initialized)
        {
            Debug.LogError(debugableInterface.debugLabel + "Not initialized");
            return;
        }

        PopupEventSubscription eventSubscription = GetSubscriptionEvent(popup);

        if (callback != null)
        {
            eventSubscription.AddEvent(callback);
        }
    }
Ejemplo n.º 5
0
    public void Init(Action fadeMusicOut)
    {
        actualPopup = GamePopup.EMPTY;

        FadeMusicOut = fadeMusicOut;

        popupsSubscriptions = new List <PopupEventSubscription>();

        // init all event subscriptions (we can then subscribe events)
        foreach (GamePopup popup in Enum.GetValues(typeof(GamePopup)))
        {
            popupsSubscriptions.Add(new PopupEventSubscription(popup));
        }

        initializableInterface.InitInternal();
    }
Ejemplo n.º 6
0
    Type GetTypeFromPopup(GamePopup popup)
    {
        switch (popup)
        {
        case GamePopup.EMPTY:
            return(null);

        case GamePopup.TITLE_SETTINGS:
            return(null);

        case GamePopup.SHOGUN_DEDUCTION:
            return(typeof(ShogunPopup));
        }

        return(null);
    }
Ejemplo n.º 7
0
 public PopupEventSubscription(GamePopup popup)
 {
     this.popup = popup;
 }