Exemplo n.º 1
0
 public void AssignCrossHairPosition(Vector3 crossHairPosition)
 {
     foreach (GameObject gun in this.CurrentGuns)
     {
         AimAtTarget aimAtTarget = gun.GetComponent <AimAtTarget>();
         if (aimAtTarget != null)
         {
             aimAtTarget.UpdateFiringDirection(crossHairPosition);
         }
     }
 }
Exemplo n.º 2
0
    private void assignNewGun(Transform hardpoint, int newGunIndex, int gunToReplaceIndex)
    {
        // Store some properties of the current gun.
        GameObject gunToReplace = CurrentGuns[gunToReplaceIndex];

        Destroy(gunToReplace);

        // Create the new gun, and assign the stored properties to it.
        GameObject newGun = (GameObject)Instantiate(Guns[newGunIndex], hardpoint.position, hardpoint.rotation);

        // Make sure the new gun IS scaled with the hardpoint
        Vector3 initialScale = newGun.transform.localScale;

        newGun.transform.parent     = hardpoint;
        newGun.transform.localScale = initialScale;

        newGun.layer = hardpoint.gameObject.layer;

        if (Network.peerType != NetworkPeerType.Disconnected)
        {
            Player  owner   = this.GetComponent <ObjectSync>().Owner;
            Shooter shooter = newGun.GetComponent <Shooter>();
            shooter.Owner = owner;
        }

        AimAtTarget aimAtTarget = newGun.GetComponent <AimAtTarget>();

        aimAtTarget.GunSwitcher = this;

        newGun.GetComponent <Shooter>().HumanControlled = HumanControlledGuns;
        aimAtTarget.HumanControlled = HumanControlledGuns;

        //if (HumanControlledGuns)
        aimAtTarget.Crosshair = Crosshair;

        CurrentGuns[gunToReplaceIndex] = newGun;
    }