EyeBossManager.fireTurret C# (CSharp) Method

fireTurret() public method

public fireTurret ( ) : void
return void
    void fireTurret()
    {
        int targetPlayer = PickTarget();
        if (targetPlayer != -1) {
            GameObject character = GameObject.Find("Character" + targetPlayer);
            // Fire from a random cannon each time
            int index = Random.Range(0, cannons.Length);
            GameObject cannon = cannons[index];
            Vector3 fireDirection = character.transform.position - cannon.transform.position;
            Vector3 force = fireDirection.normalized * forceMultiplier * typeForceMultiplier;
            fireDirection.y = Random.Range(fireDirection.y - 5f, fireDirection.y + 5f);
            Transform bullet = (Transform)Network.Instantiate(bulletPrefab, cannon.transform.position, cannon.transform.rotation, 200);
            NetworkViewID bulletID = bullet.networkView.viewID;

            // Play the turret animation on all of the clients
            //networkView.RPC("turretAnimation", RPCMode.All, index);

            NetworkViewID targetID = character.GetComponent<NetworkView>().viewID;
            networkView.RPC("fireBullet", RPCMode.All, cannon.transform.position, cannon.transform.rotation, targetID, bulletID, fireDirection, force);
        }
    }