예제 #1
0
    public void Damage()
    {
        remainingHP -= player.damage;
        healthBar.SetHealth(remainingHP);

        anim.SetTrigger("Hit");
        isHit = true;
        anim.SetBool("inCombat", true);

        if (remainingHP < 1)
        {
            Destroy(this.gameObject);
            coinSpawner.Spawn(gems);
            remainingHP = 0;
        }

        Debug.Log("HP:" + remainingHP);
    }
예제 #2
0
    void Die()
    {
        audioManager.PlayDeathSFX();

        isDead = true;
        myAnimator.SetBool("isDead", true);

        GetComponent <Collider2D>().enabled = false;

        Rigidbody2D myRigidBody = GetComponent <Rigidbody2D>();

        myRigidBody.velocity = new Vector2(10f, 20f);

        CoinSpawner mySpawner = GetComponent <CoinSpawner>();

        if (mySpawner)
        {
            mySpawner.Spawn(myRigidBody.position.x, myRigidBody.position.y, 1f);
        }
    }
예제 #3
0
    private void BeginGame()
    {
        // Create a maze and initialize it.
        maze      = Instantiate(mazePrefab) as Maze;
        maze.name = "Maze";
        maze.Initialize();

        // Initialize the coin spawner
        coinSpawner      = Instantiate(coinSpawnerPrefab) as CoinSpawner;
        coinSpawner.name = "Spawned coins";
        coinSpawner.Spawn(maze);

        // Initialize the enemy spawner
        enemySpawner      = Instantiate(enemySpawnerPrefab) as EnemySpawner;
        enemySpawner.name = "Spawned enemies";
        enemySpawner.setTarget(GameObject.FindGameObjectWithTag("Player").transform);
        enemySpawner.setPlayerController(playercontroller);
        enemySpawner.Spawn(maze);

        playercontroller.setCoinList(coinSpawner.spawnedCoins.Count);
    }