Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1))
        {
            target = getTarget();

            Vector3 endPos;

            if (target == null)
            {
                endPos = getMousePosition();
                int[] coords = Map.map.worldToMapPoint(endPos);

                if (Map.map.tiles[coords[0], coords[1]] == 1)
                {
                    findPath(endPos);
                }
            }

            if (target != null && target.tag == "Enemy")
            {
                enemyHealth = target.GetComponent <HealthBar>();

                Enemy1 e = target as Enemy1;
                if (e.isDead())
                {
                    e.IAmBeingEaten = true;
                    AudioSource.PlayClipAtPoint(suckClip, Camera.main.transform.position);
                }
            }
            else
            {
                enemyHealth = null;
            }
        }

        moveUnit();

        playerTryToAttack();
    }