Beispiel #1
0
 protected virtual void Start()
 {
     rend = this.GetComponent <Renderer>();
     transitionManager = this.GetComponent <TransitionManager>();
     transitionManager.UseMaterial(rend.material);
     checkResources();
 }
Beispiel #2
0
        // Use this for initialization
        protected void Start()
        {
            this.gameObject.name   = SceneData.getId();
            this.transitionManager = GetComponent <TransitionManager>();

            RenderScene();
        }
Beispiel #3
0
        protected void Start()
        {
            started = true;
            GameState.OnGameResume();
            uAdventureRaycaster = FindObjectOfType <uAdventureRaycaster>();
            if (!uAdventureRaycaster)
            {
                Debug.LogError("No uAdventureRaycaster was found in the scene!");
            }
            else
            {
                // When clicks are out, i capture them
                uAdventureRaycaster.Base = this.gameObject;
            }

            transitionManager = GetComponent <TransitionManager>();
            if (!transitionManager)
            {
                Debug.LogError("No TransitionManager was found in the scene!");
            }

            RunTarget(forceScene ? scene_name : GameState.CurrentTarget);
            gameExtensions.ForEach(g => g.OnAfterGameLoad());
            uAdventureInputModule.LookingForTarget = null;

            TimerController.Instance.Timers = GameState.GetTimers();
            TimerController.Instance.Run();
        }
Beispiel #4
0
 protected virtual void Start()
 {
     rend = this.GetComponent <Renderer>();
     transitionManager = this.GetComponent <TransitionManager>();
     transitionManager.UseMaterial(rend.material);
     Game.Instance.GameState.OnConditionChanged += OnConditionChanged;
     OnConditionChanged(null, 0);
 }
        protected void Awake()
        {
            var comparer = new HeightLayerComparer();

            heights                = new Dictionary <ScenePositioner, float>();
            finalOrder             = new SortedList <ScenePositioner, float>(comparer);
            comparer.Heights       = heights;
            this.transitionManager = GetComponent <TransitionManager>();
            Game.Instance.GameState.OnConditionChanged += OnConditionChanged;
        }
Beispiel #6
0
        public void CopyFrom(TransitionManager otherTransitionManager)
        {
            if (transitionRoutine != null || otherTransitionManager.transitionRoutine != null)
            {
                Debug.LogError("The other transition manager is already doing a transition!");
                return;
            }

            this.transitionMaterial = otherTransitionManager.transitionMaterial;
            this.transitionTexture  = otherTransitionManager.transitionTexture;
            this.renderTexture      = otherTransitionManager.renderTexture;
            this.transitioning      = otherTransitionManager.transitioning;
            this.transition         = otherTransitionManager.transition;
        }
Beispiel #7
0
        protected void Update()
        {
            if (waitingRunTarget && runnerTarget.IsReady)
            {
                waitingRunTarget  = false;
                waitingTransition = true;
                System.Action <Transition, Texture> afterTransition = (transition, texture) =>
                {
                    waitingTransition = false;
                    if (uAdventureRaycaster.Instance)
                    {
                        uAdventureRaycaster.Instance.Override = null;
                    }
                    Interacted();
                };

                if (TransitionManager)
                {
                    TransitionManager.DoTransition(afterTransition);
                }
                else
                {
                    afterTransition(null, null);
                }
            }

            if (doTimeOut)
            {
                elapsedTime += Time.deltaTime;
            }

            if (Input.GetMouseButtonDown(1))
            {
                MenuMB.Instance.hide();
            }
            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                if (Time.timeScale == 0)
                {
                    Time.timeScale = 1;
                    GUIManager.Instance.ShowConfigMenu();
                }
                else if (!isSomethingRunning())
                {
                    Time.timeScale = 0;
                    GUIManager.Instance.ShowConfigMenu();
                }
            }
        }
Beispiel #8
0
        protected void Update()
        {
            if (waitingRunTarget && runnerTarget.IsReady)
            {
                Debug.Log("[UPDATE] Target Ready!");
                waitingRunTarget  = false;
                waitingTransition = true;
                System.Action <Transition, Texture> afterTransition = (transition, texture) =>
                {
                    Debug.Log("[UPDATE] Transition done.");
                    waitingTransition = false;
                    if (uAdventureRaycaster.Instance)
                    {
                        uAdventureRaycaster.Instance.Override = null;
                    }
                    Debug.Log("[UPDATE] Continue execution...");
                    Interacted();
                };

                if (TransitionManager)
                {
                    Debug.Log("[UPDATE] Doing transition...");
                    TransitionManager.DoTransition(afterTransition);
                }
                else
                {
                    afterTransition(null, null);
                }
            }

            if (doTimeOut)
            {
                elapsedTime += Time.deltaTime;
            }

            if (Input.GetMouseButtonDown(1))
            {
                MenuMB.Instance.hide();
            }
            else if (Input.GetKeyDown(KeyCode.Escape) || (Input.touchCount != previousTouchCount && Input.touchCount == 4))
            {
                if (!isSomethingRunning())
                {
                    GUIManager.Instance.ShowConfigMenu();
                }
            }
            previousTouchCount = Input.touchCount;
        }
Beispiel #9
0
        protected void Start()
        {
            uAdventureRaycaster = FindObjectOfType <uAdventureRaycaster>();
            if (!uAdventureRaycaster)
            {
                Debug.LogError("No uAdventureRaycaster was found in the scene!");
            }
            else
            {
                // When clicks are out, i capture them
                uAdventureRaycaster.Base = this.gameObject;
            }

            transitionManager = GetComponent <TransitionManager>();
            if (!transitionManager)
            {
                Debug.LogError("No TransitionManager was found in the scene!");
            }

            RunTarget(forceScene ? scene_name : GameState.InitialChapterTarget.getId());

            TimerController.Instance.Timers = GameState.GetTimers();
            TimerController.Instance.Run();
        }
Beispiel #10
0
        public IRunnerChapterTarget RunTarget(string scene_id, int transition_time = 0, TransitionType transition_type = 0, Interactuable notifyObject = null, bool trace = true)
        {
            Debug.Log("Run target: " + scene_id);
            if (GUIManager.Instance)
            {
                GUIManager.Instance.ShowHand(false);
            }
            if (MenuMB.Instance)
            {
                MenuMB.Instance.hide(true);
            }

            IChapterTarget target = GameState.GetChapterTarget(scene_id);

            if (TransitionManager != null)
            {
                var transition = new Transition();
                transition.setTime(transition_time);
                transition.setType(transition_type);
                TransitionManager.PrepareTransition(transition);
            }

            if (runnerTarget != null && runnerTarget.Data == target && scene_id == GameState.CurrentTarget)
            {
                runnerTarget.RenderScene();
                waitingRunTarget = true;
            }
            else
            {
                waitingTargetDestroy = true;
                System.Action runTarget = () =>
                {
                    waitingTargetDestroy = false;
                    waitingRunTarget     = true;
                    if (trace)
                    {
                        GameState.CurrentTarget = target.getId();
                    }
                    runnerTarget.RenderScene();

                    if (trace && OnTargetChanged != null)
                    {
                        OnTargetChanged(target);
                    }
                };

                var oldTarget = runnerTarget;

                // Here we connect with the IChapterTargetFactory and create an IRunnerChapterTarget
                runnerTarget      = RunnerChapterTargetFactory.Instance.Instantiate(target);
                runnerTarget.Data = target;
                Debug.Log("Target gameobject: " + runnerTarget.gameObject);
                DontDestroyOnLoad(runnerTarget.gameObject);
                Debug.Log("Target creado: " + runnerTarget);

                System.Action afterChapterLoad = () =>
                {
                    if (oldTarget != null)
                    {
                        oldTarget.Destroy(0f, runTarget);
                    }
                    else
                    {
                        runTarget();
                    }
                };

                if (loadedChapter != GameState.CurrentChapter)
                {
                    LoadChapter(GameState.CurrentChapter)
                    .Then(() =>
                    {
                        loadedChapter = GameState.CurrentChapter;
                        afterChapterLoad();
                    })
                    .Catch(ex =>
                    {
                        Debug.LogError(ex);
                    });
                }
                else
                {
                    afterChapterLoad();
                }
            }

            if (notifyObject != null)
            {
                executeStack.Push(new KeyValuePair <Interactuable, ExecutionEvent>(notifyObject, null));
            }

            if (uAdventureRaycaster.Instance)
            {
                uAdventureRaycaster.Instance.Override = this.gameObject;
            }

            return(runnerTarget);
        }