示例#1
0
 // Start is called before the first frame update
 void Start()
 {
     gunSwitcher = GetComponent <GunSwitcher>();
     sprite      = GetComponent <SpriteRenderer>();
     gunSwitcher.gunSwitched.Invoke();
     isReloading = false;
 }
 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);
     }
 }
示例#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);
        }
    }
示例#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);
        }
    }