Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            GetTiles();
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            NextColor();
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            PrevColor();
        }
        if (Input.GetKeyDown(KeyCode.G))
        {
            UseBoost();
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            CreateWeapon();
        }
        if (Input.GetKeyDown(KeyCode.H))
        {
            hitBox = Instantiate(hitboxPrefab);
        }
        if (Input.GetKeyDown(KeyCode.W))
        {
            CreateRounds();
        }
        if (Input.GetKeyDown(KeyCode.Q))
        {
            FireRound();
        }
        if (Input.GetKey(KeyCode.A))
        {
            position.x -= .5f * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.D))
        {
            position.x += .5f * Time.deltaTime;
        }

        HitBox enemyAttack = FindObjectOfType <HitBox>();

        if (enemyAttack != null)
        {
            int attackDamage = enemyAttack.DealDamage();
            health -= attackDamage;

            Debug.Log("Player takes " + attackDamage + " damage and has " + health + " health left");
        }

        transform.position = position;
    }