コード例 #1
0
ファイル: SnakeLikeMovement.cs プロジェクト: Rankhole/CG
    // Start is called before the first frame update
    void Start()
    {
        AudioPlayer.PlayGameplayMusic();

        // get Score script from text object and set score and time to 0
        scoreScript = scoreText.GetComponent <Score>();
        Score.score = 0;
        Score.time  = 0f;
        scoreText.GetComponent <TMPro.TextMeshProUGUI>().SetText(Score.score.ToString());
        scoreText.GetComponent <TMPro.TextMeshProUGUI>().SetText(Score.time.ToString("F2"));

        spawnAsteroidsScript = this.GetComponent <SpawnAsteroids>();

        // initialize arrays for tracking spaceship movement over time
        trailpath     = new Vector3[maxTrailSize];
        trailrotation = new Quaternion[maxTrailSize];
        velocities    = new Vector3[maxTrailSize];

        // head of our "tail" is the spaceship
        asteroidTail.Add(spaceship);

        // add first position of our trailpath and rotation
        trailpath[0]     = asteroidTail[0].position;
        trailrotation[0] = asteroidTail[0].rotation;

        // call method to record spaceship transformation every 1 second
        InvokeRepeating("UpdateSpaceshipPath", 0f, 1f);  //1s delay, repeat every 1s

        // optionally add beginSize many Asteroids to tail
        for (int i = 0; i < beginSize - 1; i++)
        {
            addAsteroidToTail();
        }
    }
コード例 #2
0
    public void StartGame()
    {
        IsGameActive = true;
        titleScreen.SetActive(false);
        gameOverScreen.SetActive(false);

        Instantiate(player, Vector2.zero, Quaternion.identity);

        audioSource = this.AddAudio(gameObject, 0.5f);

        asteroidsSpawner = FindObjectOfType <SpawnAsteroids>();
        ufoSpawner       = FindObjectOfType <SpawnUfo>();

        cam             = Camera.main;
        screenBorders   = cam.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height));
        horizontalBound = screenBorders.x;
        verticalBound   = screenBorders.y;

        this.AddLives(initLifesCount);
        this.UpdateScore(0);

        StartCoroutine(HandleWaves());
    }
コード例 #3
0
    private SpawnAsteroids spawnAsteroidsClassReference;        //Referencia a la clase SpawnAsteroids.


    void Awake()
    {
        spawnAsteroidsClassReference = GetComponent <SpawnAsteroids> ();                //Referencia a la clase que controla la generacion de asteroides.
    }
 // Start is called before the first frame update
 void Start()
 {
     cm = GameObject.FindGameObjectWithTag("Canvas").GetComponent <Canva_Manager>();
     sa = GameObject.FindGameObjectWithTag("Spawner").GetComponent <SpawnAsteroids>();
 }
コード例 #5
0
 void Start()
 {
     gameManager = FindObjectOfType <GameManager>();
     spawner     = FindObjectOfType <SpawnAsteroids>();
 }
コード例 #6
0
    private SpawnAsteroids spawnAsteroidsClassReference;                //Referencia a la clase "UXController".

    void Awake()
    {
        spawnAsteroidsClassReference = GameObject.FindWithTag("GameController").GetComponent <SpawnAsteroids> ();
    }