public static void Upload(string fileName, UType uType = UType.CurrentFolder) { /*byte[] response = webClient.UploadFile( * new Uri(ulUrl+"?uploadTo=" + uploadTo), * ulDirectory+"/"+fileName * ); * * Console.WriteLine(Encoding.ASCII.GetString(response));*/ //Async totalBytes = new FileInfo(ulDirectory + "/" + fileName).Length; string curUrl = ulUrl + "?uploadTo=" + uploadTo; string[] pathArgs = fileName.Split("/"); curUrl += "&folder=/" + fileName.Substring(0, fileName.Length - pathArgs[pathArgs.Length - 1].Length - 1); Console.WriteLine(curUrl); webClient.UploadFileAsync( new Uri(curUrl), ulDirectory + "/" + fileName ); /* * totalBytes = new FileInfo(ulDirectory + "/" + fileName).Length; * ulUrl = FixUri(ulUrl); * string curUrl = ulUrl + "?uploadTo=" + uploadTo; * string[] pathArgs = fileName.Split("/"); * curUrl += "&folder=" + HttpUtility.UrlEncode(fileName.Substring(0, fileName.Length - pathArgs[pathArgs.Length - 1].Length - 1)); * webClient.UploadFileAsync( * new Uri(ulUrl), * ulDirectory + "/" + fileName * ); */ }
public ActionResult EditCustomer(Customer s) { if (getCustomers.ContainsKey(((User)Session["user"]).Username)) { int p = getCustomers[s.Username].Points; UType ut = getCustomers[s.Username].UType; if (((User)Session["user"]).Username.Equals(s.Username)) { getCustomers.Remove(((User)Session["user"]).Username); } s.Points = p; s.UType = ut; s.Role = Role.Customer; s.BirthDate = s.BirthDate.ToString(); getCustomers[s.Username] = s; Session["user"] = getCustomers[s.Username]; PrintCustomers(); return(View("Index")); } else { ViewBag.Error = "You dont have permision to edit customer!"; return(View("Index")); } }
// Start is called before the first frame update private async UniTask Start() { int type = 1; if (RandomUtype) { type = UnityEngine.Random.Range(0, 20); if (type < 7) { //utype = UType.Hummer; } else if (type > 6 && type < 11) { utype = UType.Shooter01; } else if (type > 10 && 16 < type) { utype = UType.Guner; } else if (type > 15 && type < 18) { utype = UType.Bomber; } else { utype = UType.Hummer; } } if (utype != UType.Guner) { WaterGun.SetActive(false); } int m = UnityEngine.Random.Range(0, 3); if (m == 0) { MoveF = "Move_A"; } else if (m == 1) { MoveF = "Move_B"; } else if (m == 2) { MoveF = "Move_C"; } FLAGS = new bool[FLAGS_NUM]; for (int i = 0; i < FLAGS.Length; i++) { FLAGS[i] = true; } Rb = GetComponent <Rigidbody>(); Anim = GetComponent <Animator>(); ES = GetComponent <EnemyStatus>(); }
public UserState(string ircString) { _colorHex = ircString.Split(';')[0].Contains("#") ? ircString.Split(';')[0].Split('#')[1] : ""; _displayName = ircString.Split(';')[1].Split('=')[1]; _emoteSet = ircString.Split(';')[2].Split('=')[1]; if (ircString.Split(';')[3].Split('=')[1] == "1") { _subscriber = true; } if (ircString.Split(';')[4].Split('=')[1] == "1") { _turbo = true; } switch (ircString.Split('=')[6].Split(' ')[0]) { case "mod": _userType = UType.Moderator; break; case "global_mod": _userType = UType.GlobalModerator; break; case "admin": _userType = UType.Admin; break; case "staff": _userType = UType.Staff; break; default: _userType = UType.Viewer; break; } _channel = ircString.Split(' ')[3].Replace("#", ""); }
//@color=#CC00C9;display-name=astickgamer;emotes=70803:6-11;sent-ts=1447446917994;subscriber=1;tmi-sent-ts=1447446957359;turbo=0;user-id=24549902;user-type= :[email protected] PRIVMSG #cohhcarnage :cjb2, cohhHi public ChatMessage(string ircString) { _rawIrcMessage = ircString; //@color=asd;display-name=Swiftyspiffyv4;emotes=;subscriber=0;turbo=0;user-id=103325214;user-type=asd :[email protected] PRIVMSG #burkeblack :this is a test lol foreach (var part in ircString.Split(';')) { if (part.Contains("!")) { if (_channel == null) { _channel = part.Split('#')[1].Split(' ')[0]; } if (_username == null) { _username = part.Split('!')[1].Split('@')[0]; } } else if (part.Contains("@color=")) { if (_colorHex == null) { _colorHex = part.Split('=')[1]; } } else if (part.Contains("display-name")) { if (_displayName == null) { _displayName = part.Split('=')[1]; } } else if (part.Contains("emotes=")) { if (_emoteSet == null) { _emoteSet = part.Split('=')[1]; } } else if (part.Contains("subscriber=")) { _subscriber = part.Split('=')[1] == "1"; } else if (part.Contains("turbo=")) { _turbo = part.Split('=')[1] == "1"; } else if (part.Contains("user-id=")) { _userId = int.Parse(part.Split('=')[1]); } else if (part.Contains("user-type=")) { switch (part.Split('=')[1].Split(' ')[0]) { case "mod": _userType = UType.Moderator; break; case "global_mod": _userType = UType.GlobalModerator; break; case "admin": _userType = UType.Admin; break; case "staff": _userType = UType.Staff; break; default: _userType = UType.Viewer; break; } } else if (part.Contains("mod=")) { _modFlag = part.Split('=')[1] == "1"; } } _message = ircString.Split(new[] { $" PRIVMSG #{_channel} :" }, StringSplitOptions.None)[1]; }
public void ExecuteInstruction(int instr) { //MonoBehaviour.print(pc); //MonoBehaviour.print(System.Convert.ToString(instr, 16)); //MonoBehaviour.print(System.Convert.ToString(instr, 2)); int opcode = instr & 0x7f; if (opcode == 0x37) // LUI { UType args = new UType(instr); WriteReg(args.rd, (args.imm << 12) | (ReadReg(args.rd) & 0xfff)); } else if (opcode == 0x17) // AUIPC { UType args = new UType(instr); WriteReg(args.rd, (args.imm << 12) + pc); } else if (opcode == 0x6f) // JAL { JType args = new JType(instr); WriteReg(args.rd, pc + 4); pc += SignExtend(args.imm, 20) / 4 - 1; } else if (opcode == 0x67) // JALR { IType args = new IType(instr); WriteReg(args.rd, pc + 4); pc = ((ReadReg(args.rs1) + pc) >> 1) << 1; } else if (opcode == 0x63) // branch { BType args = new BType(instr); /*MonoBehaviour.print("branch"); * MonoBehaviour.print(args.imm); * MonoBehaviour.print(SignExtend(args.imm, 12));*/ bool jump; if (args.funct3 == 0x0) // BEQ { jump = (ReadReg(args.rs1) == ReadReg(args.rs2)); } else if (args.funct3 == 0x1) // BNE { jump = (ReadReg(args.rs1) != ReadReg(args.rs2)); } else if (args.funct3 == 0x4) // BLT { jump = (ReadReg(args.rs1) < ReadReg(args.rs2)); } else if (args.funct3 == 0x5) // BGE { jump = (ReadReg(args.rs1) >= ReadReg(args.rs2)); } else if (args.funct3 == 0x6) // BLTU { jump = (((uint)ReadReg(args.rs1)) < ((uint)ReadReg(args.rs2))); } else if (args.funct3 == 0x7) // BGEU { jump = (((uint)ReadReg(args.rs1)) >= ((uint)ReadReg(args.rs2))); } else // unrecognized { jump = false; } if (jump) { pc += SignExtend(args.imm, 12) / 4 - 1; } } else if (opcode == 0x03) // load { IType args = new IType(instr); if (args.funct3 == 0x0) // LB { // unimplemented } else if (args.funct3 == 0x1) // LH { // unimplemented } else if (args.funct3 == 0x2) // LW { WriteReg(args.rd, LoadMemory(SignExtend(args.imm, 12) + ReadReg(args.rs1))); } else if (args.funct3 == 0x4) // LBU { // unimplemented } else if (args.funct3 == 0x5) // LHU { // unimplemented } else { // unrecognized } } else if (opcode == 0x23) // store { SType args = new SType(instr); if (args.funct3 == 0x0) // SB { // unimplemented } else if (args.funct3 == 0x1) // SH { // unimplemented } else if (args.funct3 == 0x2) // SW { StoreMemory(SignExtend(args.imm, 12) + ReadReg(args.rs1), ReadReg(args.rs2)); } else { // unrecognized } } else if (opcode == 0x13) // immediate { IType args = new IType(instr); args.imm = SignExtend(args.imm, 11); int value; if (args.funct3 == 0x0) // ADDI { value = ReadReg(args.rs1) + args.imm; } else if (args.funct3 == 0x2) // SLTI { value = (ReadReg(args.rs1) < args.imm) ? 1 : 0; } else if (args.funct3 == 0x3) // SLTIU { value = (((uint)ReadReg(args.rs1)) < ((uint)args.imm)) ? 1 : 0; } else if (args.funct3 == 0x4) // XORI { value = ReadReg(args.rs1) ^ args.imm; } else if (args.funct3 == 0x6) // ORI { value = ReadReg(args.rs1) | args.imm; } else if (args.funct3 == 0x7) // ANDI { value = ReadReg(args.rs1) & args.imm; } else // unrecognized { value = 0; } WriteReg(args.rd, value); } else if (opcode == 0x33) // arithmetic { RType args = new RType(instr); int value; int rs1 = ReadReg(args.rs1); int rs2 = ReadReg(args.rs2); if (args.funct3 == 0x0) { if (args.funct7 == 0x00) // ADD { value = rs1 + rs2; } else if (args.funct7 == 0x20) // SUB { value = rs1 - rs2; } else // unrecognized { value = 0; } } else if (args.funct3 == 0x1) { if (args.funct7 == 0x00) // SLL { value = rs1 << rs2; } else { value = 0; } } else if (args.funct3 == 0x2) { if (args.funct7 == 0x00) // SLT { value = (rs1 < rs2) ? 1 : 0; } else { value = 0; } } else if (args.funct3 == 0x3) { if (args.funct7 == 0x00) // SLTU { value = (((uint)rs1) < ((uint)rs2)) ? 1 : 0; } else { value = 0; } } else if (args.funct3 == 0x4) { if (args.funct7 == 0x00) // XOR { value = rs1 ^ rs2; } else { value = 0; } } else if (args.funct3 == 0x5) { if (args.funct7 == 0x00) // SRL { value = (int)(((uint)rs1) >> rs2); } else if (args.funct7 == 0x20) // SRA { value = rs1 >> rs2; } else { value = 0; } } else if (args.funct3 == 0x6) { if (args.funct7 == 0x00) // OR { value = rs1 | rs2; } else { value = 0; } } else if (args.funct3 == 0x7) { if (args.funct7 == 0x00) // AND { value = rs1 & rs2; } else { value = 0; } } else { value = 0; } WriteReg(args.rd, value); } else if (opcode == 0x0f) // fence { // unimplemented } else if (opcode == 0x73) // environment { IType args = new IType(instr); if (args.funct3 == 0x0) // system { if (args.imm == 0x000) { if (instr == 0x00000073) // ECALL { // unimplemented } else { // unrecognized } } else if (args.imm == 0x001) { if (instr == 0x00100073) // EBREAK { isRunning = false; } else { // unrecognized } } else { // unrecognized } } else if (args.funct3 == 0x1) // CSRRW { WriteReg(args.imm, controller.ReadCSR(args.rd)); controller.WriteCSR(args.imm, ReadReg(args.rs1)); } else if (args.funct3 == 0x2) // CSRRS { int csr = controller.ReadCSR(args.rd); WriteReg(args.imm, csr); int mask = ReadReg(args.rs1); controller.WriteCSR(args.imm, mask | csr); } else if (args.funct3 == 0x3) // CSRRC { int csr = controller.ReadCSR(args.rd); WriteReg(args.imm, csr); int mask = ~ReadReg(args.rs1); controller.WriteCSR(args.imm, mask & csr); } else if (args.funct3 == 0x5) // CSRRWI { WriteReg(args.imm, controller.ReadCSR(args.rd)); controller.WriteCSR(args.imm, args.rs1); } else if (args.funct3 == 0x6) // CSRRSI { int csr = controller.ReadCSR(args.rd); WriteReg(args.imm, csr); int mask = args.rs1; controller.WriteCSR(args.imm, mask | csr); } else if (args.funct3 == 0x7) // CSRRCI { int csr = controller.ReadCSR(args.rd); WriteReg(args.imm, csr); int mask = ~args.rs1; controller.WriteCSR(args.imm, mask & csr); } else { // unrecognized } } else // unrecognized { if (instr != 0) // nop { MonoBehaviour.print("Unrecognized instruction:"); MonoBehaviour.print(System.Convert.ToString(instr, 16)); } } pc++; }
public Chatter(string username, UType userType) { _username = username; _userType = userType; }
public Unit GetUnit(UType unitType) { return baseStats [unitType]; }
public Unit(UType pUnitType, TechManager techManager) { unitType = pUnitType; switch (unitType) { case UType.GroundForce: cost = 1; buys = 2; battle = 8; shots = 1; fleetSupply = UFSupply.Never; ship = false; carries = UCarry.Nothing; break; case UType.SpaceDock: cost = 4; buys = 1; fleetSupply = UFSupply.Never; ship = false; carries = UCarry.Fighters; capacity = 3; abilities = new UAbility[1]{UAbility.Production}; maxQuantity = 3; break; case UType.Carrier: cost = 3; buys = 1; move = 1; battle = 9; shots = 1; fleetSupply = UFSupply.Always; ship = true; carries = UCarry.Anything; capacity = 6; maxQuantity = 4; break; case UType.PDS: cost = 2; buys = 1; battle = 6; shots = 0; fleetSupply = UFSupply.Never; ship = false; carries = UCarry.Nothing; abilities = new UAbility[1]{UAbility.PlanetaryShield}; maxQuantity = 6; break; case UType.Fighter: cost = 1; buys = 2; battle = 9; shots = 1; fleetSupply = UFSupply.Never; ship = true; carries = UCarry.Leaders; break; case UType.Cruiser: cost = 2; buys = 1; battle = 7; shots = 1; fleetSupply = UFSupply.Always; ship = true; carries = UCarry.Leaders; maxQuantity = 8; break; case UType.Destroyer: cost = 1; buys = 1; move = 1; battle = 9; shots = 1; fleetSupply = UFSupply.Always; ship = true; carries = UCarry.Leaders; maxQuantity = 8; abilities = new UAbility[1]{UAbility.AntiFighterBarrage}; break; case UType.Dreadnought: cost = 5; buys = 1; move = 1; battle = 5; shots = 1; fleetSupply = UFSupply.Always; ship = true; carries = UCarry.Leaders; abilities = new UAbility[2]{UAbility.SustainDamage, UAbility.Bombardment}; maxQuantity = 5; break; case UType.WarSun: cost = 12; buys = 1; move = 2; battle = 3; shots = 3; fleetSupply = UFSupply.Always; ship = true; carries = UCarry.Anything; maxQuantity = 2; prereqs = new Tech[]{techManager.GetTech ("War Sun")}; break; case UType.MechanizedUnit: cost = 2; buys = 1; battle = 6; shots = 2; fleetSupply = UFSupply.Never; ship = false; carries = UCarry.Nothing; abilities = new UAbility[1]{UAbility.SustainDamage}; maxQuantity = 4; break; } }
public string UTypeToString(UType unitType) { return uTypeTo [unitType]; }
public void compileUTypeStruct(string str, UType inst) { }