Enumerator, podawanie co drugiego elementu

0

Witam. Mam kolejkę typu Queque<T> i mam pytanie. Jak zaimplementować enumarator<T>, żeby enumerator podawał co drugi element z kolejki. Z góry dziękuję za jakąkolwiek pomoc.

0

public Sprite idlePistol;
public Sprite shotPistol;
public float pistolDamage;
public float pistolRange;
public AudioClip shotSound;
public AudioClip reloadIntroSound;
public AudioClip emptyGunSound;
public AudioClip oneReloadSound;
public AudioClip outroRealoadSound;

public Text ammoText;

public int ammoAmount;
public int ammoClipSize;

public GameObject bulletHole;

int ammoLeft;
int ammoClipLeft;

bool isShot;
bool isReloading;

AudioSource source;

void Awake()
{
source = GetComponent<AudioSource>();
ammoLeft = ammoAmount;
ammoClipLeft = ammoClipSize;
}

void Update()
{
ammoText.text = " " + ammoClipLeft + "\n" + ammoLeft;

if (Input.GetButtonDown("Fire1") && isReloading == false)
    isShot = true;
if (Input.GetKeyDown(KeyCode.R) && isReloading == false)
{
    Reload();
}

}

void FixedUpdate()
{

Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (isShot == true && ammoClipLeft > 0 && isReloading == false)
{
    isShot = false;
    ammoClipLeft--;
    source.PlayOneShot(shotSound);
    StartCoroutine("shot");

    if (Physics.Raycast(ray, out hit, pistolRange))
    {
        Debug.Log("Wszedlem w kolizje z " + hit.collider.gameObject.name);

        hit.collider.gameObject.SendMessage("pistolHit", pistolDamage, SendMessageOptions.DontRequireReceiver);

        Instantiate(bulletHole, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal));
    }
}
else if (isShot == true && ammoClipLeft <= 0 && isReloading == false)
{

    isShot = false;
    Reload();
}

}

void Reload()
{

int bulletsToReload = ammoClipSize - ammoClipLeft;
if (ammoLeft >= bulletsToReload)
{
    isReloading = true;
    StartCoroutine("ReloadWeapon");
    source.PlayOneShot(reloadIntroSound);
    yield return new WaitForSeconds(0.5f);
    do
    {

        ammoLeft--;
        ammoClipLeft++;
        source.PlayOneShot(oneReloadSound);
        yield return new WaitForSeconds(0.25f);

    }
    while (ammoClipLeft == 5 || ammoLeft == 0);
    source.PlayOneShot(outroRealoadSound);
    isReloading = false;

}
else if (ammoLeft <= 0)
{
    source.PlayOneShot(emptyGunSound);
}

}

IEnumerator Shot()
{
GetComponent<SpriteRenderer>().sprite = shotPistol;
yield return new WaitForSeconds(0.1f);
GetComponent<SpriteRenderer>().sprite = idlePistol;
}

0
0

Kolego w 3 wersie jest błąd

1 użytkowników online, w tym zalogowanych: 0, gości: 1