예제 #1
0
    void Start()
    {
        cam        = Camera.main;
        targetZoom = cam.orthographicSize;

        cps = GameObject.Find("CheckPoint").GetComponent <CheckPointScript>();
    }
예제 #2
0
    public void OnCheckPointPassed(CheckPointScript i_CheckPointScript)
    {
        if (isCheckPointPassable(i_CheckPointScript))
        {
            i_CheckPointScript.PassedCheckPointSound.Play();
            StartCoroutine(delayedDeactivateCheckpoint(1f, i_CheckPointScript));
            m_MainPlayerScript.OnCheckPointPassed(i_CheckPointScript);

            if (SceneManager.GetActiveScene().name == "Level1")
            {
                m_EnemiesManagerScript.SpawnEnemyInSpawnLocation(m_CurrentCheckPointIndex);
            }
            m_CurrentCheckPointIndex++;


            if (m_CurrentCheckPointIndex < m_CheckPoints.Length)
            {
                m_LightOfCurrentCheckPoint.transform.position = m_CheckPoints[m_CurrentCheckPointIndex].transform.position;
            }
            else
            {
                m_LevelCompleted = true;
                m_MainPlayerScript.OnLevelCompleted();
            }
        }
        else
        {
            m_FailedToPassCheckPointSound.Play();
        }
    }
    public void GetNextPath()
    {
        Vector3 positionToCurrentCheckPoint = (_currentCheckPoint.transform.position - transform.position);

        if (positionToCurrentCheckPoint.magnitude <= (Mathf.Max(_currentCheckPoint._cubeSize.x, _currentCheckPoint._cubeSize.z)/1.5f))
        {
            if (_currentCheckPointIndex < (_path.Count - 1))
            {
                ++_currentCheckPointIndex;
            }
            else
            {
                _currentCheckPointIndex = 0;
            }

            _previousCheckPoint = _currentCheckPoint;
            _currentCheckPoint = _path[_currentCheckPointIndex];

            if (_currentCheckPointIndex != (_path.Count - 1))
            {
                _nextCheckPoint = _path[_currentCheckPointIndex + 1];
            }
            else
            {
                _nextCheckPoint = _path[0];
            }
        }
    }
예제 #4
0
 void Awake()
 {
     Instance = this;
     Player   = GameObject.FindObjectOfType <PlayerScript>();
     Camera   = GameObject.FindObjectOfType <CameraScript>();
     AllCheckPoints.AddRange(GameObject.FindObjectsOfType <CheckPointScript>());
     CurrentCheckPoint = AllCheckPoints.First(cp => cp.IsSpawn);
 }
예제 #5
0
 // Start is called before the first frame update
 void Start()
 {
     timer             = 3;
     cps               = GameObject.FindGameObjectWithTag("picker").GetComponent <CheckPointScript>();
     uics              = GameObject.FindGameObjectWithTag("gamemanager").GetComponent <UiControllerScript>();
     targetPosPlatform = platform.position + new Vector3(0, 0.57f, 0);
     checker           = true;
     startCountdown    = false;
     newChecker        = true;
 }
예제 #6
0
 public void SetActive(CheckPointScript checkpoint)
 {
     for (int i = 0; i < checkPoints.Count; i++)
     {
         if (checkPoints[i] != checkpoint)
         {
             checkPoints[i].SetTriggered(false);
         }
     }
 }
예제 #7
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.CompareTag("Player"))
     {
         if (checkPoint != this)
         {
             checkPoint = this;
             Information.Instance.nameCheckPoint = gameObject.name;
             Information.Instance.SaveInfo();
         }
     }
 }
예제 #8
0
    // Update is called once per frame
    void Update()
    {
        float minDistance = Mathf.Min(Vector3.Distance(PlayersPosition1, transform.position),
                                      Vector3.Distance(PlayersPosition2, transform.position));

        if (minDistance < DIST)
        {
            lastVisited    = this;
            wizard.Health  = 100;
            warrior.Health = 100;

            Messenger.Broadcast(GameEvent.MAGE_HEALTH_CHANGED);
            Messenger.Broadcast(GameEvent.WARRIOT_HEALTH_CHANGED);
        }
    }
예제 #9
0
    public void setCurrentCheckpoint(CheckPointScript cps)
    {
        if (currentPoint != null)
        {
            currentPoint.setActive(false);
        }
        if (cps != null)
        {
            setCheckPointPos(cps.transform.position);
            PlayerPrefs.SetFloat("checkpoint", cps.getId());
        }
        else
        {
            setCheckPointPos(new Vector3());
        }

        PlayerPrefs.Save();
        currentPoint = cps;
    }
예제 #10
0
    void Awake()
    {
        Time.timeScale = 1;

        if (_instance == null)
        {
            _instance = new GameManagerScript();
        }

        GameObject[] gameManagers = GameObject.FindGameObjectsWithTag("GameManager");

        if (gameManagers.Length > 1)
        {
            Destroy(this.gameObject);
        }

        DontDestroyOnLoad(this.gameObject);

        spawnPosition = new Vector3(27f, -0.88f, 28.5f);

        gameOverScript = GameObject.FindGameObjectWithTag("GameOverManager").GetComponent<GameOverScript>();
        playerGameObject = GameObject.FindGameObjectWithTag("Player");
        checkpointScript = GameObject.FindGameObjectWithTag("Checkpoint").GetComponent<CheckPointScript>();

        if (gameOverScript != null)
        {
            gameOverScript.HideGameOverScreen();
        }

        if (checkpointScript.checkpointPassed)
        {
            spawnPosition = checkpointScript.initialSpawnPosition;
        }

        /*if (!CharacterThirdPerson.gameHasRestarted)
        {
            playerGameObject.transform.position = spawnPosition;
        }*/
    }
예제 #11
0
    private IEnumerator delayedDeactivateCheckpoint(float i_Time, CheckPointScript i_CheckPointScript)
    {
        yield return(new WaitForSeconds(i_Time));

        i_CheckPointScript.gameObject.SetActive(false);
    }
예제 #12
0
 private bool isCheckPointPassable(CheckPointScript i_CheckPointScript)
 {
     return(i_CheckPointScript.IndexID == m_CurrentCheckPointIndex);
 }
    public void GetNextPathSharableAI()
    {
        //Debug.Log("GET NEXT PATH SAI");
        Vector3 positionToCurrentCheckPoint = (_currentCheckPoint.transform.position - transform.position);

        // Met à jour les CheckPoints
        if (positionToCurrentCheckPoint.magnitude <= (Mathf.Max(_currentCheckPoint._cubeSize.x, _currentCheckPoint._cubeSize.z) / 1.5f))
        {
            if (_currentCheckPointIndex < (_path.Count - 1))
            {
                ++_currentCheckPointIndex;
            }
            else
            {
                _currentCheckPointIndex = 0;
            }

            _previousCheckPoint = _currentCheckPoint;
            _currentCheckPoint = _path[_currentCheckPointIndex];

            if (_currentCheckPointIndex != (_path.Count - 1))
            {
                _nextCheckPoint = _path[_currentCheckPointIndex + 1];
            }
            else
            {
                _nextCheckPoint = _path[0];
            }
        }

        if (patternRaceGame != null)
        {
            // Vérifie si on est dans un virage ou sur une ligne droite
            Vector3 positionToPreviousCheckPoint = (_previousCheckPoint.transform.position - transform.position);

            // Cas dans le virage
            if (positionToPreviousCheckPoint.magnitude <= (Mathf.Max(_currentCheckPoint._cubeSize.x, _currentCheckPoint._cubeSize.z) / 1.5f))
            {
                if (!isTurning)
                {
                    Debug.Log("ITS TURNING!");
                    isTurning = true;
                    _secondsBetweenRandom = 0.20f;
                    float randomSharpCurve = Random.Range(0.0f, 11.0f);

                    // Cas virage exterieur
                    if (randomSharpCurve > patternRaceGame._percentInsideTurn)
                    {
                        _sharpCurve = false;

                    }
                    // Cas virage interieur
                    else
                    {
                        _sharpCurve = true;
                    }
                }
            }
            // Cas Ligne droite
            else
            {
                if (isTurning)
                {
                    Debug.Log("ITS NOT TURNING!");
                    isTurning = false;
                    _secondsBetweenRandom = 1.0f;
                    float randomSharpCurve = Random.Range(0.0f, 11.0f);

                    // Cas ligne droite exterieur
                    if (randomSharpCurve > patternRaceGame._percentInsideStraightLine)
                    {
                        _sharpCurve = false;
                    }
                    // Cas ligne droite interieur
                    else
                    {
                        _sharpCurve = true;
                    }
                }
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        //_carControleScript._playerMove = false;
        _axeHorizontal = 0.0f;
        _path = _pathScript._path;

        if (_path.Count >= 3)
        {
            _previousCheckPoint = _path[_path.Count - 1];
            _currentCheckPoint = _path[0];
            _nextCheckPoint = _path[1];
        }

        if (isInTheLab)
        {
            Debug.Log("LAUCHING SHARABLE AI");
            ReadXmlRaceScript readXmlScript = new ReadXmlRaceScript();
            patternRaceGame = readXmlScript.ReadXmlFile(PlayerPrefs.GetString(_carControleScript.playerName));

            if(patternRaceGame != null)
            {
                Debug.Log("Pattern Loaded");
                _angleMaxRange = patternRaceGame._averageAngleInside;
            }
        }

        StartCoroutine(randomAngle());
    }
예제 #15
0
 public void SetCurrentCheckPoint(CheckPointScript checkPoint)
 {
     CurrentCheckPoint.SetTriggered(false);
     CurrentCheckPoint = checkPoint;
     CurrentCheckPoint.SetTriggered(true);
 }
    // Use this for initialization
    void Start()
    {
        //_moveScript._playerMove = false;

        _path = _pathScript._path;

        if (_path.Count >= 3)
        {
            _previousCheckPoint = _path[_path.Count - 1];
            _currentCheckPoint = _path[0];
            _nextCheckPoint = _path[1];
        }

        StartCoroutine(randomAngle());
    }