Exemplo n.º 1
0
    void Start()
    {
        GameObject player = Instantiate(playerPrefab, entrance.position, entrance.rotation) as GameObject;
        player.name = "Player";

        Transform entranceTop = transform.Find("EntranceTop");
        Transform closeEntrance = transform.Find("CloseEntrance");

        entranceRoof = entranceTop.gameObject.AddComponent<FadeTrigger>();
        TriggerRelay closeTrigger = closeEntrance.gameObject.AddComponent<TriggerRelay>();
        closeTrigger.target = entranceRoof;
        closeTrigger.setTo = false;

        GameObject gameControlObj = GameObject.Find ("GameControl");
        gameControl = gameControlObj.GetComponent<GameControl>();

        Invoke("CreateCamera", 0.01f);
    }
Exemplo n.º 2
0
 public void SetTarget(FadeTrigger newTarget, bool newSetTo)
 {
     target = newTarget;
     setTo = newSetTo;
 }
Exemplo n.º 3
0
        /// <summary>
        ///   This method allows an element's fade to trigger when another element undergoes a certain event as defined by the FadeTrigger.
        /// </summary>
        /// <param name="eventProcElements"> The list of elements whose events will proc the recieving element's fade. </param>
        /// <param name="eventRecieveElements"> The recieving elements. </param>
        /// <param name="state"> </param>
        public static void LinkOnewayFadeComponentTriggers(IUIElement[] eventProcElements, IUIElement[] eventRecieveElements, FadeTrigger state){
            switch (state){
                case FadeTrigger.EntryExit:
                    foreach (var pElement in eventProcElements){
                        if (!(pElement is IUIInteractiveElement)){
                            throw new Exception("Unable to link interactive element fade triggers; the event proc element is not interactive.");
                        }
                        foreach (var eElement in eventRecieveElements){
                            var procElement = (IUIInteractiveElement) pElement;

                            procElement.GetComponent<FadeComponent>().AddRecievingFadeComponent(
                                eElement.GetComponent<FadeComponent>()
                                );
                        }
                    }

                    break;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///   This method allows an element's fade to trigger when another element undergoes a certain event as defined by the FadeTrigger.
        /// </summary>
        /// <param name="eventProcElement"> The element whose events will proc the recieving element's fade. </param>
        /// <param name="eventRecieveElement"> The recieving element. </param>
        /// <param name="state"> </param>
        public static void LinkOnewayFadeComponentTriggers(IUIElement eventProcElement, IUIElement eventRecieveElement, FadeTrigger state){
            switch (state){
                case FadeTrigger.EntryExit:
                    if (!(eventProcElement is IUIInteractiveElement)){
                        throw new Exception("Unable to link interactive element fade triggers; the event proc element is not interactive.");
                    }
                    //cast to interactive
                    var e1 = (IUIInteractiveElement) eventProcElement;


                    e1.GetComponent<FadeComponent>().AddRecievingFadeComponent(
                        eventRecieveElement.GetComponent<FadeComponent>()
                        );

                    break;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///   This method links two elements together so that each element can proc the other's fade as defined by the FadeTrigger.
        /// </summary>
        /// <param name="element1"> </param>
        /// <param name="element2"> </param>
        /// <param name="state"> </param>
        public static void LinkFadeComponentTriggers(IUIElement element1, IUIElement element2, FadeTrigger state){
            switch (state){
                case FadeTrigger.EntryExit:
                    //first we check both elements to make sure they are both interactive. This check is specific for triggers that are interactive
                    if (!(element1 is IUIInteractiveElement) || !(element2 is IUIInteractiveElement)){
                        throw new Exception("Unable to link interactive element fade triggers; one of the elements is not interactive");
                    }
                    //cast to interactive
                    var e1 = (IUIInteractiveElement) element1;
                    var e2 = (IUIInteractiveElement) element2;

                    e1.GetComponent<FadeComponent>().AddRecievingFadeComponent(
                        e2.GetComponent<FadeComponent>()
                        );

                    e2.GetComponent<FadeComponent>().AddRecievingFadeComponent(
                        e1.GetComponent<FadeComponent>()
                        );

                    break;
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// </summary>
 /// <param name="defaultState"> default state of the parent object, faded or visible </param>
 /// <param name="trigger"> </param>
 /// <param name="fadeoutOpacity"> opacity level to fade out to. range 0-1f </param>
 /// <param name="fadeDuration"> the time it takes for sprite to fade out in milliseconds </param>
 /// <param name="identifier"> </param>
 public FadeComponent(FadeState defaultState, FadeTrigger trigger = DefaultTrigger, float fadeoutOpacity = DefaultFadeoutOpacity, float fadeDuration = DefaultFadeDuration, string identifier = ""){
     _fadeoutOpacity = fadeoutOpacity;
     _fadeDuration = fadeDuration*10000; //10k ticks in a millisecond
     _isInTransition = false;
     _isFadingOut = false;
     _prevUpdateTimeIndex = DateTime.Now.Ticks;
     _defaultState = defaultState;
     _fadeTrigger = trigger;
     _Enabled = true;
     Identifier = identifier;
 }