public void selectTool(int item) { if (!gameObject.activeSelf) { toSel = item; return; } else { toSel = -1; } currentTool = GameObject.Instantiate(items.itemObjects[item].prefab, transform.position, Quaternion.identity); currentToolTool = currentTool.GetComponent <tool>(); if (rightOri) { right(); } else { left(); } currentToolTool.instantiate(this, item); currentTool.transform.localScale = Vector3.one; }
private static tool NextTool(char currentType, char nextType, tool currentTool) { if (currentType == nextType) { return(currentTool); } else if (currentType == '.' && nextType == '=') { return(tool.climbingGear); } else if (currentType == '.' && nextType == '|') { return(tool.torch); } else if (currentType == '=' && nextType == '.') { return(tool.climbingGear); } else if (currentType == '=' && nextType == '|') { return(tool.none); } else if (currentType == '|' && nextType == '.') { return(tool.torch); } else { return(tool.none); } }
public void changeTool(tool t) { switch(t) { case tool.crayon: toolWidth = 40; break; case tool.marker: toolWidth = 20; break; case tool.pencil: toolWidth = 10; break; case tool.eraser: toolWidth = 40; break; default: break; } colors = new Color[toolWidth*toolWidth]; }
private void button2_Click(object sender, EventArgs e) { pencil = tool.rectangle; }
private void button1_Click(object sender, EventArgs e) { pencil = tool.pen; pen.Color = Color.Black; }
private void button5_Click(object sender, EventArgs e) { pen.Color = Color.White; pencil = tool.pen; }
Encoding Encoding is something of a hard-coded process. This is because I have no idea what your data is! It would be great if this were some sort of interface for taking an entire class and encoding it's number/string fields, but it's not. I've come up with a few clever ways of using loops and/or recursive methods to cut down of the amount of code I have to write when I use this tool, but they're pretty project-specific.
void ResetTool() { currentTool = tool.Hand; }
private void highlvtool_Click(object sender, EventArgs e) { toolname.Text = "High Lv Enemy Spawn"; curenttool = tool.HIGLV; }
private void breakablewalltool_Click(object sender, EventArgs e) { toolname.Text = "Breakable Wall"; curenttool = tool.BWALL; }
private void bosstool_Click(object sender, EventArgs e) { toolname.Text = "Boss Class Enemy Spawn"; curenttool = tool.BOSS; }
private void walltool_Click(object sender, EventArgs e) { toolname.Text = "Wall"; curenttool = tool.WALL; }
private void torchtool_Click(object sender, EventArgs e) { toolname.Text = "LightSource"; curenttool = tool.TORCH; }
private void trapfloortool_Click(object sender, EventArgs e) { toolname.Text = "Damage Tile"; curenttool = tool.TRAP; }
private void pottool_Click(object sender, EventArgs e) { toolname.Text = "Breakable Loot"; curenttool = tool.POT; }
private void midlvtool_Click(object sender, EventArgs e) { toolname.Text = "Mid Lv Enemy Spawn"; curenttool = tool.MIDLV; }
private void lowlvtool_Click(object sender, EventArgs e) { toolname.Text = "Low Lv Enemy Spawn"; curenttool = tool.LOWLV; }
private void button3_Click(object sender, EventArgs e) { pencil = tool.ellipse; }
private void watertool_Click(object sender, EventArgs e) { toolname.Text = "Impassable Non-Wall"; curenttool = tool.WATE; }
private void treasurechesttool_Click(object sender, EventArgs e) { toolname.Text = "Treasure Chest"; curenttool = tool.TREAS; }
private void FloorTool_Click(object sender, EventArgs e) { toolname.Text = "Floor"; curenttool = tool.FLOOR; }