Exemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     gunSwitcher = GetComponent <GunSwitcher>();
     sprite      = GetComponent <SpriteRenderer>();
     gunSwitcher.gunSwitched.Invoke();
     isReloading = false;
 }
Exemplo n.º 2
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Player")
     {
         GunSwitcher switcher = other.gameObject.GetComponentInChildren <GunSwitcher>();
         if (!switcher.avalableGuns.Contains(gun))
         {
             switcher.avalableGuns.Add(gun);
             switcher.selectedGun = switcher.avalableGuns.Count - 1;
             switcher.gunSwitched.Invoke();
             Debug.Log("added" + gun.displayName);
         }
         Destroy(gameObject);
     }
 }
Exemplo n.º 3
0
    private void FireWeaponRPC(NetworkViewID playerID, bool fire)
    {
        GameObject playerShip = base.GetPlayerShip(playerID);

        GunSwitcher gunSwitcher = playerShip.GetComponent <GunSwitcher>();

        foreach (GameObject gun in gunSwitcher.CurrentGuns)
        {
            Shooter shooter = gun.GetComponent <Shooter>();
            shooter.KeepFiring = fire;
        }

        if (Network.isServer)
        {
            FireWeapon(base.Players[playerID], fire);
        }
    }
Exemplo n.º 4
0
    private void FiringDirectionRPC(NetworkViewID playerID, Vector3 direction)
    {
        // Ignore own shooting direction RPCs echoed by server to all players.
        if (base.NetworkControl.ThisPlayer.ID == playerID)
        {
            return;
        }

        GameObject playerShip = base.GetPlayerShip(playerID);

        GunSwitcher gunSwitcher = playerShip.GetComponent <GunSwitcher>();

        gunSwitcher.AssignCrossHairPosition(direction);

        if (Network.isServer)
        {
            FiringDirection(base.Players[playerID], direction);
        }
    }