void Update()
        {
            Text            interactionText  = GetComponent <Text>();
            BeamInteraction beamInteraction  = GameObject.FindGameObjectWithTag("Beam").GetComponent <BeamInteraction>();
            float           interactionsLeft = beamInteraction.GetRemainingInteractions();

            if (interactionsLeft < 0)
            {
                interactionText.text = "Interactions: " + 0;
            }
            else
            {
                interactionText.text = "Interactions: " + interactionsLeft.ToString();
            }
        }
Example #2
0
        public void Load()
        {
            // Stop any actions in the previous level
            Level currentLevel = transform.parent.GetComponent <LevelManager>().CurrentLevel();

            if (currentLevel && currentLevel.gameObject.GetComponent <SpecialLevel>())
            {
                currentLevel.gameObject.GetComponent <SpecialLevel>().StopSpecialLevelActions();
            }

            // Set up the level properties
            BeamInteraction beamInteraction = GameObject.FindGameObjectWithTag("Beam").GetComponent <BeamInteraction>();

            beamInteraction.SetMaxInteractions(GetComponent <MaxInteractions>().GetMaxInteractions());
            beamInteraction.SetCanBeFired(true);
            currentState = State.active;

            // Animate level transition
            StartCoroutine(DisplayLevelText());
            SpecialLevel specialLevel = GetComponent <SpecialLevel>();

            // Move the player and camera to the level
            player.transform.position      = playerStartPosition;
            Camera.main.transform.position = defaultCamPosObj.transform.position;
            Camera.main.transform.rotation = defaultCamPosObj.transform.rotation;
            CamSnapPos defaultCamPos = defaultCamPosObj.GetComponent <CamSnapPos>();

            Camera.main.gameObject.GetComponent <CameraController>().SetSnapPos(defaultCamPos);

            // Perform any special level actions for this level
            if (specialLevel != null)
            {
                specialLevel.StartSpecialAction();
            }

            // Play particle system
            detectorParticles.Play();
        }