Beispiel #1
0
    void Update()
    {
        player = App.instance.GetPlayer();

        if (mapGenerator == null)
        {
            return;
        }

        if (player == null)
        {
            return;
        }

        if (onCooldown)
        {
            return;
        }

        PlatformerCharacter2D character = player.GetComponent <PlatformerCharacter2D>();

        if (Input.GetKeyUp(KeyCode.E) && digDamage > 0)
        {
            Vector3 pos       = player.transform.position;
            Vector2 direction = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")).normalized;
            Dig(pos, direction, player);
            StartCoroutine(Cooldown(digCooldown));
        }

        if (Input.GetKeyUp(KeyCode.F))
        {
            Vector3 pos       = player.transform.position;
            Vector2 direction = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")).normalized;
            MakeMaterial(pos, direction);
            StartCoroutine(Cooldown(digCooldown));
        }

        if (Input.GetKeyUp(KeyCode.Q) && bombDamage > 0)
        {
            Vector2 direction = new Vector2(character.GetFaceDirection(), Input.GetAxisRaw("Vertical")).normalized;
            Vector3 pos       = player.transform.position;

            pos.x += direction.x;

            StartCoroutine(PlantBomb(pos, direction));
            StartCoroutine(Cooldown(digCooldown));
        }
    }