Exemplo n.º 1
0
    //method for the archers attack
    protected override void Attack()
    {
        Vector2 arrowSpawnPoint;

        //if the hero is facing right spawn the arrow at the right side of their sprite
        if (facingRight)
        {
            arrowSpawnPoint = new Vector3(transform.position.x + edgeCol.bounds.extents.x + projectile.GetComponent <SpriteRenderer>().sprite.bounds.extents.x, transform.position.y, transform.position.z);
        }
        //if the hero is facing left spawn an arrow at the left side of their sprite
        else
        {
            arrowSpawnPoint = new Vector3(transform.position.x - edgeCol.bounds.extents.x - projectile.GetComponent <SpriteRenderer>().sprite.bounds.extents.x, transform.position.y, transform.position.z);
        }

        //call the arc method to get the velocity for the arrow
        Vector2 arrowVelocity = HelperFunctions.Arc(bow.GetComponent <Transform>()) * stats.attackSpeed;

        //negate the velocity if the hero is facing left
        if (!facingRight)
        {
            arrowVelocity.x *= -1;
        }

        //call the shoot arrow method
        ShootArrow(arrowSpawnPoint, arrowVelocity);

        //call the shoot arrow method over the network
        if (photonView.isMine)
        {
            photonView.RPC("ShootArrow", PhotonTargets.Others, arrowSpawnPoint, arrowVelocity);
        }
    }