0% found this document useful (0 votes)
25 views5 pages

Новый текстовый документ

The document contains code for cycling through a list of weapons. It increments and decrements an index variable and checks for certain weapon names and availability flags before switching weapons after a delay.

Uploaded by

venzapp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views5 pages

Новый текстовый документ

The document contains code for cycling through a list of weapons. It increments and decrements an index variable and checks for certain weapon names and availability flags before switching weapons after a delay.

Uploaded by

venzapp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

index --;

if (index < 0)
{
index = weapons.Length-1;

for (int i = index; i <= 4; i--)


{
Debug.Log(i);
if (weapons[i].name == "Knife" && Knife_Have == 1)
{
index = i;
break;
}
else if (weapons[i].name == "Plasmatron" && Plasmatron_Have ==
1)
{

index = i;
break;
}
else if (weapons[i].name == "Mezoscolari" && Mezoscolari_Have
== 1)
{
index = i;
break;
}
else if (weapons[i].name == "Plasmarion" && Plasmarion_Have ==
1)
{
index = i;
break;
}
}

index++;
if (index >= weapons.Length)
{
index = 0;

}
bool stop = false;

while (stop == false){


if (weapons[index].name == "Knife" && Knife_Have == 1){
stop=true;
}
if (weapons[index].name == "Plasmatron" && Plasmatron_Have == 1){
stop=true;
}
if (weapons[index].name == "Mezoscolari" && Mezoscolari_Have == 1){
stop=true;
}
if (weapons[index].name == "Plasmarion" && Plasmarion_Have == 1){
stop=true;
}
else{
index++;
}
}
StartCoroutine(SwitchAfterDelay(index));

if (index < 0)
{

index = weapons.Length -1;


bool stop = false;
while (stop == false){

if (weapons[index].name == "Knife" && Knife_Have == 1){


stop=true;
}
if (weapons[index].name == "Plasmatron" && Plasmatron_Have ==
1){
stop=true;
}
if (weapons[index].name == "Mezoscolari" && Mezoscolari_Have ==
1){
stop=true;
}
if (weapons[index].name == "Plasmarion" && Plasmarion_Have ==
1){
stop=true;
}
index = weapons.Length -1;
}
Debug.Log(weapons[index]);
}
Debug.Log("Changes");
StartCoroutine(SwitchAfterDelay(index));

if (weapons[i].name == "Knife" && Knife_Have == 1)


{
index = i;
break;
}
else if (weapons[i].name == "Plasmatron" && Plasmatron_Have ==
1)
{

index = i;
break;
}
else if (weapons[i].name == "Mezoscolari" && Mezoscolari_Have
== 1)
{
index = i;
break;
}
else if (weapons[i].name == "Plasmarion" && Plasmarion_Have ==
1)
{
index = i;
break;
}

weapons = new GameObject[3];


for (int i=0; i < Listweapons.Length; i++){
string wename= Listweapons[i].name;
if (wename == "Knife" && Knife_Have == 1)
{
weapons[i]=Listweapons[i];
}
else if (wename == "Plasmatron" && Plasmatron_Have == 1)
{
weapons[i]=Listweapons[i];
}
else if (wename == "Mezoscolari" && Mezoscolari_Have == 1)
{
weapons[i]=Listweapons[i];
}
else if (wename == "Plasmarion" && Plasmarion_Have == 1)
{
weapons[i]=Listweapons[i];
}

if (Input.GetAxis("Mouse ScrollWheel") > 0 && !isSwitching)


{
index ++;
for (int i = index; i < weapons.Length; i++)
{
if (weapons[i].name == "Knife" && Knife_Have == 1)
{
index = i;
break;
}
else if (weapons[i].name == "Plasmatron" && Plasmatron_Have == 1)
{
index = i;
break;
}
else if (weapons[i].name == "Mezoscolari" && Mezoscolari_Have == 1)
{
index = i;
break;
}
else if (weapons[i].name == "Plasmarion" && Plasmarion_Have == 1)
{
index = i;
break;
}
}
Debug.Log(index);
// Wrap around if no suitable weapon found
if (index >= weapons.Length)
{
index = 0;
}

StartCoroutine(SwitchAfterDelay(index));

}
else if (Input.GetAxis("Mouse ScrollWheel") < 0 && !isSwitching)
{
index ++;
for (int i = index; i < weapons.Length; i++)
{

if (weapons[i].name == "Knife" && Knife_Have == 1)


{
index = i;
break;
}
else if (weapons[i].name == "Plasmatron" && Plasmatron_Have == 1)
{
index = i;
break;
}
else if (weapons[i].name == "Mezoscolari" && Mezoscolari_Have == 1)
{
index = i;
break;
}
else if (weapons[i].name == "Plasmarion" && Plasmarion_Have == 1)
{
index = i;
break;
}
}
Debug.Log(index);
// Wrap around if no suitable weapon found
if (index >= weapons.Length)
{
index = 0;
}

StartCoroutine(SwitchAfterDelay(index));
}

You might also like