Esempio n. 1
0
    private void Die()
    {
        if (!isAlive)
        {
            return;
        }
        isAlive = false;

        //Debug.Log("Died!");

        if (isSwitchingLane)
        {
            StopCoroutine(laneSwitchCoroutine);
            isSwitchingLane = false;
        }

        if (isCancellingSwitch)
        {
            StopCoroutine(cancelSwitchCoroutine);
            isCancellingSwitch = false;
        }

        GameObject deathEffect = Instantiate(deathEffectPrefab);

        deathEffect.transform.SetParent(currentLane.transform);
        deathEffect.transform.localPosition = playerObject.transform.localPosition;
        deathEffect.transform.localRotation = playerObject.transform.localRotation;
        trackObjectManager.AddObjectToTrack(deathEffect);

        Destroy(playerObject);
        gameOver.DoGameOver();
    }
    public override void Build(Lane lane, float startPosition, float sectionLength, TrackObjectManager trackObjectManager)
    {
        base.Build(lane, startPosition, sectionLength, trackObjectManager);

        GameObject newObject = Instantiate(prefab);

        newObject.transform.SetParent(lane.transform);
        newObject.transform.localPosition = Vector3.forward * (startPosition + sectionLength * 0.5f);
        trackObjectManager.AddObjectToTrack(newObject);
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        nextSceneryPosition -= trackObjectManager.MoveDelta;
        while (nextSceneryPosition < generateZ)
        {
            angle += 10;

            GameObject newColumn = Instantiate(sceneryPrefab);
            newColumn.transform.position = Vector3.forward * nextSceneryPosition;
            newColumn.transform.rotation = Quaternion.Euler(0, 0, angle);
            trackObjectManager.AddObjectToTrack(newColumn);

            nextSceneryPosition += scenerySpacing;
        }
    }