コード例 #1
0
    private void setGunUI(int jValue)
    {
        int j = jValue;

        foreach (GameObject gun in containers)
        {
            GunContainer gunContainer = gun.GetComponent <GunContainer>();
            if (gunContainer.index == j)
            {
                containersOrdered[j] = gunContainer;
                j++;
            }
        }

        if (j < containers.Length)
        {
            setGunUI(j);
        }
        else
        {
            gunsBullets = new int[allGuns.Length];
            int i = 0;
            foreach (Gun gun in allGuns)
            {
                gunsBullets[i] = gun.projectilesPerMag;

                containersOrdered[i].setImage(gun.image);
                i++;
            }
        }

        updateGunUISelect();
    }
コード例 #2
0
    public void DropCurrentWeapon()
    {
        GunContainer dropGunContainer = ((GameObject)Instantiate(gunContainerPrefab, GetSpawnLocation(), new Quaternion())).GetComponent <GunContainer>();

        dropGunContainer.SetContainedGun(currentWeapon);

        currentWeapon = null;
    }
コード例 #3
0
    public void SpawnWeapon()
    {
        GameObject   gunContainer       = (GameObject)Instantiate(containerPrefab, transform.position, new Quaternion());
        GunContainer gunContainerScript = gunContainer.GetComponent <GunContainer>();

        gunContainerScript.SetContainedGun(((GameObject)Instantiate(weapon)).GetComponent <IWeapon>());

        //NetworkServer.Spawn(gunContainer);
    }
コード例 #4
0
ファイル: GunController.cs プロジェクト: Creator13/Color-Run
    private void Start()
    {
        container = magazine.GetComponent <GunContainer>();
        container.SetFillPercentage(0);

        timeSinceLastEmpty = _emptyingTimeout;

        audioSource = GetComponent <AudioSource>();
    }
コード例 #5
0
ファイル: GunController.cs プロジェクト: Creator13/Color-Run
    private void UpdateContainer()
    {
        container = magazine.GetComponent <GunContainer>();
        container.SetFillPercentage(containerFill);

        if (colorInContainer != null)
        {
            container.SetColor(colorInContainer.Value);
        }
    }
コード例 #6
0
    public void SwapGun()
    {
        DropCurrentWeapon();

        GunContainer pickupGunContainer = swapableGunContainer;

        SetWeapon(pickupGunContainer.GetContainedGun());

        pickupGunContainer.DestroyContainer();

        //RpcUpdatePlayerGun(GetComponent<NetworkIdentity>().netId, newGun.GetComponent<NetworkIdentity>().netId, newGunScript.ammoData);
        //RpcUpdateContainerGun(newGunContainer.GetComponent<NetworkIdentity>().netId, oldGun.GetComponent<NetworkIdentity>().netId, oldGunScript.ammoData);
    }
コード例 #7
0
    //[Command]
    //public void CmdDropCurrentWeapon()
    //{
    //    GameObject newGunContainer = (GameObject)Instantiate(this.gunContainerPrefab, GetBulletSpawnLocation(), new Quaternion());
    //    GunContainer newGunContainerScript = newGunContainer.GetComponent<GunContainer>();

    //    GameObject oldGun = currentGunObject;
    //    IGun oldGunScript = oldGun.GetComponent<IGun>();

    //    //newGunContainerScript.SetContainedGun(oldGun);

    //    NetworkServer.Spawn(newGunContainer);

    //    currentGunObject = null;
    //    currentGun = null;

    //    //RpcUpdateContainerGun(newGunContainer.GetComponent<NetworkIdentity>().netId, oldGun.GetComponent<NetworkIdentity>().netId, oldGunScript.ammoData);
    //}

    //=================================================================================================
    //Client Functions
    //=================================================================================================


    //[ClientRpc]
    //public void RpcUpdatePlayerGun(NetworkInstanceId gunID)
    //{
    //    if (isServer)
    //        return;

    //    SetPlayersGun(ClientScene.FindLocalObject(gunID));
    //}

    //[ClientRpc]
    //public void RpcUpdateContainerGun(NetworkInstanceId containerID, NetworkInstanceId gunID, GunBase.AmmoData ammoData)
    //{
    //    if (isServer)
    //        return;

    //    GameObject gunContainerPrefab = ClientScene.FindLocalObject(containerID);
    //    GunContainer gunContainerScript = gunContainerPrefab.GetComponent<GunContainer>();

    //    gunContainerScript.SetContainedGun(ClientScene.FindLocalObject(gunID));

    //    GunBase containerGunScript = gunContainerScript.containedGun.GetComponent<GunBase>();
    //    containerGunScript.ammoData = ammoData;

    //}

    //Sets the gun container that the player is currently able to pick up
    public void SetSwappableGunContainer(GunContainer gunContainer)
    {
        this.swapableGunContainer = gunContainer;
        if (gunContainer == null || gunContainer.GetContainedGun() == null)
        {
            //Debug.LogWarning("Container: " + gunContainer);
            //Debug.LogWarning("Gun: " + gunContainer.GetContainedGun().GetWeaponName());

            playerHud.ClearWeaponPickupName();
        }
        else
        {
            playerHud.SetWeaponPickupName(gunContainer.GetContainedGun().GetWeaponName());
        }
    }
コード例 #8
0
ファイル: Enemy.cs プロジェクト: jdgbas/he
 protected override void Init()
 {
     target = PlayerMovement.Instance.transform;
     if (gunNr == -1)
     {
         gun = GunContainer.GetRandomGun();
     }
     else
     {
         gun = GunContainer.GetGun(gunNr);
     }
     bias        = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)) * biasStrength;
     readyToFire = false;
     Invoke(nameof(FireCooldown), gun.GetFireRate() * GetFirerateMultiplier());
     health += Game.Instance.GetEnemyHealth();
     GenerateDungeon.Instance.objects.Add(gameObject);
 }
コード例 #9
0
ファイル: GunContainer.cs プロジェクト: atahan-git/CA
 void Awake()
 {
     s = this;
 }
コード例 #10
0
 private void Start()
 {
     gun = GunContainer.GetGun(gunNr);
 }