void Start()
    {
        PlayerPrefs.DeleteAll();
        gameOverBoard = GameObject.Find(CommandWords.GAMEOVERBOARD);

        loadSprites("Ground", 4, groundSprites);
        loadSprites("Cloud", 3, cloudSprites);
        loadSprites("Bush", 3, bushSprites);

        g            = GameObject.Find(CommandWords.PLAYEROBJECT);
        playerScript = g.GetComponent <Player>();
        airPlane     = GameObject.Find("Airplane").GetComponent <Animator>();
        scoreText    = GameObject.Find("ScoreObject").GetComponent <TextMesh>();

        float[] positions = { -3.5f, 7.75f, 19 };
        foreach (float positionX in positions)
        {
            GameObjectCreator.createSprite(new Vector2(positionX, -2.9f), groundSprites[0], true);
        }

        listener = new KeywordRecognizer(words);
        listener.OnPhraseRecognized += recognize;
        listener.Start();
        colorMap.Add(CommandWords.YELLOW, Color.yellow);
        colorMap.Add(CommandWords.RED, Color.red);
        colorMap.Add(CommandWords.PURPLE, Color.magenta);
        colorMap.Add(CommandWords.PINK, new Color(1, 0, 0.5f));
        colorMap.Add(CommandWords.BROWN, new Color(0.56f, 0.43f, 0.3f));

        highScore = PlayerPrefs.GetInt(CommandWords.HIGHSCORE + "1", 0);
    }
Beispiel #2
0
 // Update is called once per frame
 void Update()
 {
     timer++;
     if (timer == 150)
     {
         mainScript.start();
         Destroy(parent);
         Destroy(this);
     }
     if (hasJumped && hasDucked && timer > 150)
     {
         timer = 0;
         return;
     }
     if (playerScript.isJumping == true && !hasJumped)
     {
         hasJumped = true;
         GameObjectCreator.createSprite(new Vector2(6.7f, 1.1f), checkBox, false).transform.parent = parent.transform;
     }
     if (playerScript.isDucking == true && !hasDucked)
     {
         hasDucked = true;
         GameObjectCreator.createSprite(new Vector2(7.1f, 0.1f), checkBox, false).transform.parent = parent.transform;
     }
 }
    private void spawnObstacle()
    {
        int action = Random.Range(0, 4);

        if (action == 3)
        {
            airPlane.SetTrigger("AIRPLANE");
            spawnObstacleTimer += 500;
        }
        else
        {
            int amountOfObstacles = Random.Range(1, 3);
            for (int i = 0; i < amountOfObstacles; i++)
            {
                GameObject  g    = GameObjectCreator.createSprite(new Vector2(10 + i * 2, -1.83f), bushSprites[action], true);
                Rigidbody2D body = g.AddComponent <Rigidbody2D>();
                body.isKinematic = true;
                g.AddComponent <BoxCollider2D>();
            }
            spawnObstacleTimer += Random.Range(150, 250);
        }
    }
 private void spawnGround()
 {
     GameObjectCreator.createSprite(new Vector2(19f, -2.9f), groundSprites[Random.Range(0, 4)], true);
 }
 private void spawnCloud()
 {
     GameObjectCreator.createSprite(new Vector2(19f, 2.5f), cloudSprites[Random.Range(0, 3)], true);
     cloudSpawnTimer += Random.Range(30, 70);
 }