Ejemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     rend           = GetComponent <SpriteRenderer>();
     controller     = FindObjectOfType <CheckpointController>();
     inactiveSprite = rend.sprite;
     _id            = transform.position.sqrMagnitude;
 }
Ejemplo n.º 2
0
 void Start()
 {
     cars         = new List <CarCheckpointController>(FindObjectsOfType <CarCheckpointController>());
     cpController = FindObjectOfType <CheckpointController>();
     lapText      = FindObjectOfType <GameManager>().lapText;
     lapText.text = "Lap: 1";
 }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        playerTransform      = GameObject.FindGameObjectWithTag("Player").transform;
        checkpointController = playerTransform.GetComponent <CheckpointController> ();

        enemyTransform = GameObject.FindGameObjectWithTag("Enemy").transform;
    }
Ejemplo n.º 4
0
 void Awake()
 {
     spikes = GameObject.Find ("SpikeController").GetComponent<SpikeController> ();
     checkPoints = GameObject.Find ("CheckpointController").GetComponent<CheckpointController> ();
     shatters = GameObject.Find ("ShatterBoxController").GetComponent<ShatterBoxController> ();
     slopes = GameObject.Find ("SlopeController").GetComponent<SlopeController> ();
     bool stop = false;
 }
Ejemplo n.º 5
0
 public CheckpointController GetCheckpointController()
 {
     if (this.checkpointController == null)
     {
         this.checkpointController = GameObject.FindObjectOfType <CheckpointController> ();
     }
     return(this.checkpointController);
 }
Ejemplo n.º 6
0
 void Awake()
 {
     spikes      = GameObject.Find("SpikeController").GetComponent <SpikeController> ();
     checkPoints = GameObject.Find("CheckpointController").GetComponent <CheckpointController> ();
     shatters    = GameObject.Find("ShatterBoxController").GetComponent <ShatterBoxController> ();
     slopes      = GameObject.Find("SlopeController").GetComponent <SlopeController> ();
     bool stop = false;
 }
Ejemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     angCont = FindObjectOfType <AngleController> ();
     checkpointController = FindObjectOfType <CheckpointController> ();
     rend     = GetComponent <SpriteRenderer> ();
     textRend = transform.Find("Text").GetComponent <SpriteRenderer> ();
     transform.localEulerAngles = angCont.GetAngle(transform.position, myPlanet);
 }
Ejemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     respawned            = false;
     checkpointController = FindObjectOfType <CheckpointController> ();
     player         = GameObject.Find("Player");
     contextualText = player.GetComponentInChildren <MeshRenderer> ();
     boss           = FindObjectOfType <CannibalAlien> ();
     frameCount     = 0;
 }
Ejemplo n.º 9
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player" && !done)
     {
         done = true;
         poleRenderer.enabled = false;
         CheckpointController.SetCheckpoint();
     }
 }
Ejemplo n.º 10
0
    public float distanceFromCheckpoint()
    {
        CheckpointController cpc = m_lastCheckpoint.GetComponent <CheckpointController>();
        Vector3 dir = transform.position - m_lastCheckpoint.position;
        float   dot = Vector3.Dot(dir.normalized, cpc.forward);
        float   mag = dir.sqrMagnitude;

        return(mag * dot);
    }
    private void Awake()
    {
        gameStatus     = FindObjectOfType <GameStatus>();
        target         = GameObject.Find("PlayerShip");
        cpController   = FindObjectOfType <CheckpointController>();
        targetRb       = target.GetComponent <Rigidbody>();
        targetLHandler = target.GetComponent <LandingHandler>();

        cam = GetComponent <Camera>();
    }
Ejemplo n.º 12
0
    private void Start()
    {
        currentCheckpoint = GetComponent <CheckpointController>();
        playerStats       = PlayerManager.instance.Player.GetComponent <CharacterStats>();

        foreach (var spawn in spawns)
        {
            spawn.SpawnMobs();
        }
    }
Ejemplo n.º 13
0
    private void Awake()
    {
        playerObject         = GameObject.Find("Player");
        checkpointController = GameObject.Find("CheckpointController").GetComponent <CheckpointController>();

        if (playerObject == null || checkpointController == null)
        {
            Debug.LogWarning("Checkpoint cannot find valid Player or CheckpointController. Are these game objects in scene, with correct spelling?");
        }
    }
Ejemplo n.º 14
0
 private void Start()
 {
     canvas = GameObject.Find("CanvasPanels");
     if (canvas != null)
     {
         losePanel = canvas.transform.GetChild(1).gameObject;
     }
     checkpointController = FindObjectOfType <CheckpointController>();
     gameInfoController   = FindObjectOfType <GameInfoController>();
 }
Ejemplo n.º 15
0
 private int findCPIndex(CheckpointController cp)
 {
     for (int i = 0; i < cpTracker.checkpoints.Length; i++)
     {
         if (cp == cpTracker.checkpoints[i].GetComponent <CheckpointController>())
         {
             return(i);
         }
     }
     return(-1);
 }
Ejemplo n.º 16
0
    void Die(bool outOfBounds, bool restarted)
    {
        // play death sound
        if (!restarted)
        {
            triggeredSFX.Play("death");
        }

        if (respawning || levelScript.rotating)
        {
            return;
        }

        if (!lastCheckpoint)
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            return;
        }

        respawning = true;
        velocity   = Vector2.zero;

        CheckpointController checkpointScript = lastCheckpoint.GetComponent <CheckpointController>();


        shadowCollider.GetComponent <BoxCollider2D>().enabled = false;

        GetComponent <SpriteRenderer>().enabled = false;
        GetComponent <BoxCollider2D>().enabled  = false;
        //levelScript.flipDuration *= 0.5f;
        if (checkpointScript.flipSide != levelScript.flipSide)
        {
            levelScript.rotating  = true;
            levelScript.currDir  *= -1;
            levelScript.flipSide *= -1;



            //levelScript.instantFlip();

            // Wait a bit to allow the world to flip (it's supposed to be instant, but the values take a bit to update)
            //Debug.Log(Time.deltaTime);


            Invoke("resetPosToCheckpoint", levelScript.flipDuration);
        }
        else
        {
            resetPosToCheckpoint();
        }
        keys = checkpointScript.numKeys;
        checkpointScript.activatePickups();
    }
Ejemplo n.º 17
0
        internal void Awake()
        {
            volume              = MusicList[0].volume;
            transitioning       = false;
            endTransition       = false;
            playerOneCheckpoint = GameObject.FindGameObjectWithTag("PlayerOne").GetComponent <CheckpointController>();
            GameObject playerTwo = GameObject.FindGameObjectWithTag("PlayerTwo");

            if (playerTwo != null)
            {
                playerTwoCheckpoint = playerTwo.GetComponent <CheckpointController>();
            }
        }
Ejemplo n.º 18
0
    public void StartFromCheckpoint()
    {
        CheckpointController checkpointController = Checkpoints[gameInfoController.checkpoint - 1];
        float move = checkpointController.transform.position.x - player.transform.position.y;

        grid.transform.position            = new Vector3(grid.transform.position.x - move, grid.transform.position.y, grid.transform.position.z);
        autoPlayObjects.transform.position = new Vector3(autoPlayObjects.transform.position.x - move, autoPlayObjects.transform.position.y, autoPlayObjects.transform.position.z);
        winBorder.transform.position       = new Vector3(winBorder.transform.position.x - move, winBorder.transform.position.y, winBorder.transform.position.z);
        items.transform.position           = new Vector3(items.transform.position.x - move, items.transform.position.y, items.transform.position.z);
        foreach (CheckpointController ckpc in Checkpoints)
        {
            ckpc.transform.position = new Vector3(ckpc.transform.position.x - move, ckpc.transform.position.y, ckpc.transform.position.z);
        }
    }
Ejemplo n.º 19
0
    void Start()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(instance);
        }
        else
        {
            Destroy(gameObject);
        }

        playerObject = GameObject.FindGameObjectWithTag("Player");
    }
Ejemplo n.º 20
0
        internal void Awake()
        {
            checkpoints = new GameObject[CheckpointParent.transform.childCount];
            for (int i = 0; i < CheckpointParent.transform.childCount; ++i)
            {
                checkpoints[i] = CheckpointParent.transform.GetChild(i).gameObject;
            }
            checkpointP1      = PlayerOne.GetComponent <CheckpointController>();
            playerOnePosition = PlayerOnePosition.GetComponent <Text>();

            if (PlayerTwo != null)
            {
                checkpointP2      = PlayerTwo.GetComponent <CheckpointController>();
                playerTwoPosition = PlayerTwoPosition.GetComponent <Text>();
            }
        }
Ejemplo n.º 21
0
    // Start is called before the first frame update
    void Start()
    {
        //For each checkpoint, the designer has to specify which cutscenes are impacted by which checkpoint. He can use the public variable "cutsceneToAffect" to do so.
        checkpointController = GameObject.Find("CheckpointController").GetComponent <CheckpointController>();
        cutsceneToReplay     = new StartCutsceneScript[cutsceneToAffect.Length];
        cutsceneToStops      = new PlayableDirector[cutsceneToAffect.Length];
        for (int i = 0; i < cutsceneToAffect.Length; i++)
        {
            cutsceneToReplay[i] = cutsceneToAffect[i].GetComponent <StartCutsceneScript>();
            cutsceneToStops[i]  = cutsceneToAffect[i].GetComponent <PlayableDirector>();
        }


        characterScript          = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterControllerScript>();
        characterScript.onDeath += OnCharacterDeath;
    }
Ejemplo n.º 22
0
    private float mouseX;                               // Input storage for mouse rotation
    #endregion

    #region system voids
    void Start()
    {
        // Initialization
        rb            = GetComponent <Rigidbody> ();
        startPosition = rb.position;
        jetCount      = 0;
        checkControl  = checkpointManager.GetComponent <CheckpointController> ();
        checkCount    = 0;
        endGame       = false;
        mouseX        = 0f;

        // Hide cursor
        Cursor.visible = false;

        // Save current level
        PlayerPrefs.SetString("Current_Level", Application.loadedLevelName);
    }
Ejemplo n.º 23
0
 void Update()
 {
     if (checkpointController == null)
     {
         checkpointController = FindObjectOfType <CheckpointController> ();
     }
     if (checkpointController.currentCheckpoint == gameObject && !active)
     {
         rend.sprite = shipActive;
         active      = true;
     }
     else if (active && checkpointController.currentCheckpoint != gameObject)
     {
         rend.sprite = shipInactive;
         active      = false;
     }
 }
Ejemplo n.º 24
0
    private void Awake()
    {
        setupPlayer          = GetComponent <SetupPlayer>();
        playerInfo           = GetComponent <PlayerInfo>();
        playerController     = GetComponent <PlayerController>();
        mirrorManager        = GetComponent <MirrorManager>();
        checkPointController = GetComponent <CheckpointController>();


        //Si esto da problemas, llevarlo al Start
        //polePositionManager = FindObjectOfType<PolePositionManager>();
        //networkController = FindObjectOfType<NetworkController>();
        //UIManager = FindObjectOfType<UIManager>();



        print("ScriptManager SETUP");
    }
Ejemplo n.º 25
0
    public float UpdateScore()
    {
        if (!PauseGame())
        {
            CheckpointController checkpoint = GameObject.FindGameObjectWithTag("Checkpoint").GetComponent <CheckpointController>();
            text.fontStyle = FontStyle.Bold;

            float a = 0.5f * Time.deltaTime;

            timeLeft -= a;

            text.text = "Time Left:" + Mathf.Round(timeLeft).ToString();

            if (timeLeft <= 120.1 && timeLeft >= 120)
            {
                checkpoint.timeDecreased();
            }
            else if (timeLeft <= 60.1 && timeLeft >= 60)
            {
                checkpoint.timeDecreased();
            }

            if (timeLeft < 30 && timeLeft > 0)
            {
                text.color = new Color(139, 0, 0);
            }

            if (timeLeft <= 0)
            {
                timeLeft         = 0;
                gameOver.enabled = true;

                waitTime -= a;

                if (waitTime <= 0)
                {
                    gameOver.enabled = false;
                    GameOver();
                }
                return(timeLeft);
            }
        }
        return(timeLeft);
    }
Ejemplo n.º 26
0
    public void RemovePointFromlist(CheckpointController point)
    {
        passedCheckpointCount++;

        checkPoints.Remove(point);
        survivalManager.GetEnemyScore();
        if (checkPoints.Count == 0)
        {
            Debug.Log("All checkPoint Passed");
            survivalManager.CleanGame();
            survivalManager.SetRoom();
            survivalManager.CalculateScore();
            passedCheckpointCount = 0;
        }
        else
        {
            AddRingToAllCheckpoints();
        }
    }
Ejemplo n.º 27
0
 private void OnTrigger(RaycastHit2D hit)
 {
     // Debug.Log("Trigger: " + hit.collider.tag);
     if (hit.collider.tag == "Checkpoint")
     {
         CheckpointController checkpoint = hit.collider.gameObject.GetComponent <CheckpointController>();
         if (checkpoint.active)
         {
             checkpoint.Disable();
             this.UpdateRespawnPoint(checkpoint);
         }
     }
     if (hit.collider.tag == "Pearl")
     {
         GameObject pearl = hit.collider.gameObject;
         pearl.SetActive(false);
     }
     if (hit.collider.tag == "End")
     {
         CheckpointController checkpoint = hit.collider.gameObject.GetComponent <CheckpointController>();
         if (!checkpoint.interactive || this.actionRequested)
         {
             this.levelController.LoadNextLevel();
             // SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
         }
     }
     if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Dangers"))
     {
         DangerController danger = hit.collider.gameObject.GetComponent <DangerController>();
         if (!danger || danger.active)
         {
             Die();
         }
     }
     if (hit.collider.tag == "Lever" && this.actionRequested)
     {
         hit.collider.gameObject.GetComponent <LeverController>().Toggle();
     }
 }
Ejemplo n.º 28
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.isTrigger)
        {
            return;
        }
        if (!other.gameObject.CompareTag("Player"))
        {
            return;
        }

        if (CheckpointCam != null)
        {
            var cam       = CheckpointCam.GetComponent <CinemachineVirtualCamera>();
            var activecam = Camera.main.GetComponent <CinemachineBrain>()?.ActiveVirtualCamera;

            if (cam != null && activecam != null)
            {
                if ((object)activecam != cam)
                {
                    activecam.Priority = 1;
                    cam.Priority       = 100;
                }
            }
        }

        if (indicator != null)
        {
            indicator.ResetTrigger("Deactivate");
            indicator.SetTrigger("Activate");
        }

        CheckpointController.activateCheckpoint(this.gameObject, other.gameObject.GetComponent <Character>().ForwardDirection);
        Debug.Log($"Player reached {this.gameObject.name}");
        if (PausePlayerOnReaching)
        {
            other.gameObject.GetComponent <Character>().Pause(10);
        }
    }
Ejemplo n.º 29
0
    public void CreateCheckPoints()
    {
        radius = survivalManager.gameRadius - 2;

        ChoosecheckPointCount();
        CheckpointsToCreate();
        for (int i = 0; i < checkPointCount; i++)
        {
            CheckpointController check = Instantiate(checkPointsToCreate[ChooseCheckpointType()], ChooseRandomLocation(), Quaternion.identity).GetComponent <CheckpointController>();
            check.transform.SetParent(checkpointParent.transform);
            Color c = Random.ColorHSV(0, 1, 1, 1, 1, 1);

            check.up.material.SetColor("_EmissionColor", c);
            check.down.material.SetColor("_EmissionColor", c);

            if (check.rightParticle != null)
            {
                var col2 = check.rightParticle.colorOverLifetime;
                col2.enabled = true;
                Gradient grad = new Gradient();
                grad.SetKeys(new GradientColorKey[] {
                    new GradientColorKey(c, 0.0f), new GradientColorKey(c, 1.0f)
                },
                             new GradientAlphaKey[] {
                    new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(0.0f, 1.0f)
                });
                col2.color = grad;

                if (check.leftParticle != null)
                {
                    var col = check.leftParticle.colorOverLifetime;
                    col.enabled = true;
                    col.color   = grad;
                }
            }
            checkPoints.Add(check);
        }
    }
Ejemplo n.º 30
0
 //public int currentLevelX { get; set; }
 //public int currentLevelY {  get; set; }
 // Use this for initialization
 void Start()
 {
     if (instance == null)
     {
         instance             = this;
         player               = FindObjectOfType <Dude2D>();
         currentCheckpointPos = new Vector3();
         allcheckpoints       = FindObjectsOfType <CheckPointScript>();
         foreach (CheckPointScript s in allcheckpoints)
         {
             print("Checkpoint with ID: " + s.getId());
             if (s.getId() == PlayerPrefs.GetFloat("checkpoint"))
             {
                 setCurrentCheckpoint(s);
                 currentPoint.setActive(true);
                 player.setSpawnPosition(currentPoint.transform.position);
             }
         }
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 31
0
 private void Awake()
 {
     instance = this;
 }
Ejemplo n.º 32
0
	private void Awake () {
        checkpointController = GetComponent<CheckpointController>();

        for (int i = 0; i < GlobalSelectedCharacters.instance.chosenCharacters.Length; i++)
        {
            GameObject racerObject = GameObject.Find("snail" + i);

            if (GlobalSelectedCharacters.instance.chosenCharacters[i] == GlobalSelectedCharacters.CharacterType.None)
            {
                GameObject coverview = GameObject.Instantiate(ResourceLoader._instance.GetAsset<GameObject>("OverviewCamera"));
                Camera cCamera = coverview.GetComponent<Camera>();

                switch (i)
                {
                    case 0:
                        cCamera.rect = new Rect(0, 0.5f, 0.5f, 0.5f);
                        break;
                    case 1:
                        cCamera.rect = new Rect(0.5f, 0.5f, 0.5f, 0.5f);
                        break;
                    case 2:
                        cCamera.rect = new Rect(0, 0, 0.5f, 0.5f);
                        break;
                    case 3:
                        cCamera.rect = new Rect(0.5f, 0, 0.5f, 0.5f);
                        break;
                }

                GameObject.Destroy(racerObject);
                continue;
            }

            Racer racer = racerObject.GetComponent<Racer>();
            racer.name = GlobalSelectedCharacters.instance.chosenCharacters[i].ToString();

            racer.Initialize(this, i + 1);
            racersData.Add(new RacerData(racer));

            racers.Add(racer);
        }

        //GameObject racerObject = GameObject.Find("snail0");
        //Racer racer = racerObject.GetComponent<Racer>();
        //racer.name = "Daan";
        //racer.Initialize(this, 1);
        //racersData.Add(new RacerData(racer));

        //GameObject racerObject1 = GameObject.Find("snail1");
        //Racer racer1 = racerObject1.GetComponent<Racer>();
        //racer1.name = "Inge";
        //racer1.Initialize(this, 2);
        //racersData.Add(new RacerData(racer1));

        //GameObject racerObject2 = GameObject.Find("snail2");
        //Racer racer2 = racerObject2.GetComponent<Racer>();
        //racer2.name = "Saskia";
        //racer2.Initialize(this, 3);
        //racersData.Add(new RacerData(racer2));

        //GameObject racerObject3 = GameObject.Find("snail3");
        //Racer racer3 = racerObject3.GetComponent<Racer>();
        //racer3.name = "Thom";
        //racer3.Initialize(this, 4);
        //racersData.Add(new RacerData(racer3));

        StartRace();
	}