- 1
- 2
- 3
- 4
- 5
- 6
- 7
private bool CheckBool(string value)
{
if (value == "on")
return true;
else
return false;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−1
private bool CheckBool(string value)
{
if (value == "on")
return true;
else
return false;
}
////
0
public static int[] GetRandomComStats(int level)
{
int[] stats = new int[3] { -1, -1, -1 };
int summ = (int)(1.2f * level);
int minStat = level / 3f - (level+ 1) / 10 < 0 ? 0 : (int)(level / 3f - (level + 1) / 10);
int maxStat = (int)(level / 3f + (level + 1) / 10);
Debug.Log("level: " + level + " min stat: " + minStat + " max stat: " + maxStat + " summ: " + summ);
int fr = Random.Range(0, 2);
int f2 = Random.Range(0, 3);
int f1 = 0;
stats[f2] = Random.Range(minStat, maxStat + 1);
for (int i = 0; i < 3; i++)
{
if (fr == 1 && stats[i] == -1)
{
if (summ - stats[f2] > maxStat) stats[i] = Random.Range(minStat, maxStat + 1);
else if (summ - stats[f2] < 0) stats[i] = 0;
else stats[i] = Random.Range(minStat, summ - stats[f2] + 1);
f1 = i;
goto label;
}
fr = 1;
}
label:
for (int i = 0; i < 3; i++)
{
if (stats[i] == -1)
{
if (summ < stats[f1] + stats[f2]) stats[i] = 0;
else if (summ - stats[f1] - stats[f2] > maxStat) stats[i] = maxStat;
else stats[i] = summ - stats[f1] - stats[f2];
Debug.Log(f1 + ": " + stats[f1]+ " " + f2 + ": " + stats[f2] + " " + i + ": " + stats[i]);
}
}
return stats;
}
Генерация рандомных стат персонажей в зависимости от уровня.
0
public bool isUnderpayment(double paymentValue)
{
if (paymentValue > 0)
return true;
return false;
}
Пятница, смеркалось.
−2
for (int i = 0; i < components.Length; i++)
{
if (components[i]) components[i].GetComponent<ComponentScript>().ChangeComponent(CalculateCircuitScript.ComponentDataArray[components[i].GetComponent<ComponentScript>().lineNumber, components[i].GetComponent<ComponentScript>().elementNumber]);
}
Конструктор трёхфазных цепей на Unity3D
−1
protected void ASPxUploadControl1_FilesUploadComplete(object sender, DevExpress.Web.ASPxUploadControl.FilesUploadCompleteEventArgs e)
{
if (Request.Cookies["LID"] != null)
{
int ListId = Convert.ToInt32(Request.Cookies["LID"].Value);
Response.Cookies["LID"].Expires = DateTime.Now.AddDays(-1);
foreach (DevExpress.Web.ASPxUploadControl.UploadedFile uf in ASPxUploadControl1.UploadedFiles)
{
uf.SaveAs(@"C:\TEMP\ListUploads\" + uf.FileName, true);
ListInfo.ImportList(Convert.ToInt16(ListId), @"C:\TEMP\ListUploads\" + uf.FileName);
}
}
}
блять, это же каким инвалидом надо быть, чтобы так сделать загрузку файла в базу?
0
OleDbCommand command = new OleDbCommand("select * from Прейскурант where ID = 1", bd);
OleDbDataReader dataReader1 = command.ExecuteReader();
string st;
dataReader1.Read();
int i = 0;
while (i < dataReader1.FieldCount)
{
st = dataReader1.GetValue(i).ToString();
switch (i)
{
case 0:
textBox1.Text = st;
break;
case 1:
textBox2.Text = st;
break;
case 2:
textBox3.Text = st;
break;
case 3:
textBox4.Text = st;
break;
case 4:
textBox5.Text = st;
break;
case 5:
textBox6.Text = st;
break;
case 6:
textBox7.Text = st;
break;
case 7:
textBox8.Text = st;
break;
case 8:
textBox9.Text = st;
break;
case 9:
textBox10.Text = st;
break;
case 10:
textBox11.Text = st;
break;
case 11:
textBox12.Text = st;
break;
case 12:
textBox13.Text = st;
break;
case 13:
textBox14.Text = st;
break;
case 14:
textBox15.Text = st;
break;
}
i++;
}
dataReader1.Close();
bd.Close();
Заполнение текстбоксов WinForms данными из бд. Пацан на 4-м курсе.
0
GUI.backgroundColor = Color.magenta;
prop = parametersObject.GetIterator();
var skip = true;
while (prop.NextVisible(true))
{
//Script object Field
if (skip)
{
skip = false;
continue;
}
if (prop.depth == 0)
{
position.height = propertyHeight;
EditorGUI.PropertyField(position, prop);
position.y += propertyWithSpaceHeight;
}
}
if (EditorGUI.EndChangeCheck())
{
if (parametersObject != null && parametersObject.targetObject != null)
{
parametersObject.ApplyModifiedProperties();
EditorUtility.SetDirty(parametersObject.targetObject);
}
}
parametersProperty.stringValue = JsonUtility.ToJson(parametersObject.targetObject);
GUI.backgroundColor = Color.white;
//Код исполняется 60 раз в секунду ((((
−2
GUI.backgroundColor = Color.magenta;
prop = parametersObject.GetIterator();
var skip = true;
while (prop.NextVisible(true))
{
//Script object Field
if (skip)
{
skip = false;
continue;
}
if (prop.depth == 0)
{
position.height = propertyHeight;
EditorGUI.PropertyField(position, prop);
position.y += propertyWithSpaceHeight;
}
}
if (EditorGUI.EndChangeCheck())
{
if (parametersObject != null && parametersObject.targetObject != null)
{
parametersObject.ApplyModifiedProperties();
EditorUtility.SetDirty(parametersObject.targetObject);
}
}
parametersProperty.stringValue = JsonUtility.ToJson(parametersObject.targetObject);
GUI.backgroundColor = Color.white;
//Код исполняется 60 раз в секунду ((((
−1
if (this.btn1.Content.ToString() == this.currentSide.ToString() && this.btn2.Content.ToString() == this.currentSide.ToString() && this.btn3.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn4.Content.ToString() == this.currentSide.ToString() && this.btn5.Content.ToString() == this.currentSide.ToString() && this.btn6.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn7.Content.ToString() == this.currentSide.ToString() && this.btn8.Content.ToString() == this.currentSide.ToString() && this.btn9.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn1.Content.ToString() == this.currentSide.ToString() && this.btn4.Content.ToString() == this.currentSide.ToString() && this.btn7.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn2.Content.ToString() == this.currentSide.ToString() && this.btn5.Content.ToString() == this.currentSide.ToString() && this.btn8.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn3.Content.ToString() == this.currentSide.ToString() && this.btn6.Content.ToString() == this.currentSide.ToString() && this.btn9.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn1.Content.ToString() == this.currentSide.ToString() && this.btn5.Content.ToString() == this.currentSide.ToString() && this.btn9.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn3.Content.ToString() == this.currentSide.ToString() && this.btn5.Content.ToString() == this.currentSide.ToString() && this.btn7.Content.ToString() == this.currentSide.ToString())
this.Victory();
Проверка на победу в крестиках-ноликах.
+1412
counter++;
if (counter == 10)
{
Console.WriteLine();
counter = 0;
}
Не сразу понял, что делает этот код.