public void carry(vars.player_id pid) { Debug.Log(pid.ToString()); carried_by = pid; rd.useGravity = false; rd.rotation = init_rot; last_contact = pid; }
public void create_audio_source_to_object(vars.audio_name audio_file, GameObject obj) { GameObject tmp; tmp = audio_player_template; audio_player_template.GetComponent<audio_clip_state>().start(audio_file); GameObject igo = (GameObject)Instantiate(tmp,new Vector3(0.0f,0.0f,0.0f), Quaternion.identity); igo.transform.parent = obj.gameObject.transform; }
private void readData() { String varName, varname; while (CSMGEN.RD.hasNext()) { varName = CSMGEN.RD.next(); varname = varName.ToLower(); if (varName.Equals("#")) { CSMGEN.RD.nextLine(); continue; } try { //name = vars.valueOf(varname); name = (vars)System.Enum.Parse(typeof(vars), varname); } catch (Exception e) { UTIL.errorMsg("Variable name is not found: " + varName); } switch (name) { case vars.nlayers: nlayers = CSMGEN.RD.readInt(); break; case vars.rotate: //rotate = (CSMGEN.RD.next().equalsIgnoreCase("Y")); rotate = CSMGEN.RD.next().Equals("Y"); break; case vars.zlayers: zlayers = new double[2 * nlayers + 1]; for (int i = 0; i < 2 * nlayers + 1; i += 2) { zlayers[i] = CSMGEN.RD.readDouble(); } // Interpolation for 3D midside nodes for (int i = 1; i < 2 * nlayers; i += 2) { zlayers[i] = 0.5 * (zlayers[i - 1] + zlayers[i + 1]); } break; case vars.end: return; } } }
public void start(vars.audio_name audio_file) { asc = this.gameObject.GetComponent<AudioSource>(); switch (audio_file) { case vars.audio_name.bgmusic: ac = (AudioClip)Resources.Load(vars.audio_clip_info_bgmusic.audio_clip_path); type = vars.audio_clip_info_bgmusic.ptype; saved_vol = vars.audio_clip_info_bgmusic.volume; asc.priority = vars.audio_clip_info_bgmusic.priority; asc.pitch = vars.audio_clip_info_bgmusic.pitch; break; case vars.audio_name.ui_click: ac = (AudioClip)Resources.Load(vars.audio_clip_info_uiclick.audio_clip_path); type = vars.audio_clip_info_uiclick.ptype; saved_vol = vars.audio_clip_info_uiclick.volume ; asc.priority = vars.audio_clip_info_uiclick.priority; asc.pitch = vars.audio_clip_info_uiclick.pitch; break; default: ac = null; type = vars.audio_playback_type.none; asc.priority = 0; saved_vol = 0.0f; asc.pitch = 1.0f; break; } asc.volume = saved_vol; manage_vol(); this.name = "audio_playback_" + ac.name; asc.clip = ac; if(type == vars.audio_playback_type.music){ asc.loop = true; }else{ asc.loop = false; } asc.enabled = true; asc.Play(); }
public void add_to_storage(vars.ressource_type _type, float _amount) { switch (_type) { case vars.ressource_type.A: res_a_storage += _amount; if(res_a_storage > vars.max_storage_res_a){res_a_storage = vars.max_storage_res_a;} break; case vars.ressource_type.B: res_b_storage += _amount; if(res_b_storage > vars.max_storage_res_b){res_b_storage = vars.max_storage_res_b;} break; case vars.ressource_type.C: res_c_storage += _amount; if(res_c_storage > vars.max_storage_res_c){res_c_storage = vars.max_storage_res_c;} break; default: break; } }
// Use this for initialization void Start() { if (ButtonHandler == null) { ButtonHandler = GameObject.FindGameObjectWithTag("ButtonHandler").GetComponent <vars>(); } if (ButtonHandler == null) { Debug.LogError("No Button handler found"); } if (wl == null) { try { foreach (var webl in GameObject.FindGameObjectWithTag("GameController").GetComponents <WebLoader>()) { if (webl.isActiveAndEnabled) { wl = webl; break; } } } catch (System.Exception) { Debug.LogError("Did you forget to start the webloader?"); } } if (map == null) { try { map = GameObject.FindGameObjectWithTag("Map").GetComponent <AbstractMap>(); } catch (System.Exception) { } } }
private void readDataFile(FeScanner es) { vars name = vars.NONE; String s; Material mat; it = defDs.GetEnumerator(); while (es.hasNext()) { varName = es.next(); String varname = varName.ToLower(); if (varname.Equals("#")) { es.nextLine(); continue; } try { name = (vars)System.Enum.Parse(typeof(vars), varname);//vars.valueOf(varname); //Console.WriteLine("hmm"); } catch (Exception E) { UTIL.errorMsg("Variable name is not found: " + varName); } switch (name) { case vars.nel: nEl = es.readInt(); //Console.WriteLine("FEMODEL: "+nEl.ToString()); break; case vars.nnod: nNod = es.readInt(); //Console.WriteLine("FEMODEL: " + nNod.ToString()); break; case vars.ndim: nDim = es.readInt(); nDf = nDim; //Console.WriteLine("FEMODEL: " + nDf.ToString()); break; case vars.stressstate: s = es.next().ToLower(); try { stressState = (StrStates)System.Enum.Parse(typeof(StrStates), s); //StrStates.valueOf(s); } catch (Exception E) { UTIL.errorMsg("stressState has forbidden value: " + s); } if (stressState != StrStates.threed) { nDim = nDf = 2; } else { nDim = nDf = 3; } //Console.WriteLine("FEMODEL: " + stressState.ToString()); break; case vars.physlaw: s = es.next().ToLower(); try { physLaw = (PhysLaws)System.Enum.Parse(typeof(PhysLaws), s); //PhysLaws.valueOf(s); } catch (Exception E) { UTIL.errorMsg("physLaw has forbidden value: " + s); } //Console.WriteLine("FEMODEL: " + s.ToString()); break; case vars.solver: s = es.next().ToLower(); try { Solver.solver = (Solver.solvers)System.Enum.Parse(typeof(Solver.solvers), s); //Solver.solvers.valueOf(s); } catch (Exception E) { UTIL.errorMsg("solver has forbidden value: " + s); } //Console.WriteLine("FEMODEL: " + s.ToString()); break; case vars.elcon: readElemData(es); break; case vars.nodcoord: if (nNod == 0 || nDim == 0) { UTIL.errorMsg("nNod and nDim should be specified before nodCoord"); } nEq = nNod * nDim; // Nodal coordinates newCoordArray(); for (int i = 0; i < nNod; i++) { for (int j = 0; j < nDim; j++) { setNodeCoord(i, j, es.readDouble()); } } break; case vars.material: String matname = es.next(); mat = Material.newMaterial(physLaw.ToString(), stressState.ToString()); double e = es.readDouble(); double nu = es.readDouble(); double alpha = es.readDouble(); mat.setElasticProp(e, nu, alpha); if (physLaw == PhysLaws.elplastic) { double sY = es.readDouble(); double km = es.readDouble(); double mm = es.readDouble(); mat.setPlasticProp(sY, km, mm); } materials.Add(matname, mat); //Console.WriteLine("FEMODEL: " + matname); break; case vars.constrdispl: readConstrDisplacements(es); break; case vars.boxconstrdispl: createBoxConstrDisplacements(es); break; case vars.thermalloading: s = es.next(); if (s.ToLower().Equals("y")) { thermalLoading = true; } else if (s.ToLower().Equals("n")) { thermalLoading = false; } else { UTIL.errorMsg("thermalLoading should be y/n. Specified: " + s); } break; case vars.includefile: s = es.next(); FeScanner R = new FeScanner(s); readDataFile(R); break; case vars.trussarea: readTrussArea(es); break; case vars.end: return; } } }
private void readData() { String varName, varname; while (CSMGEN.RD.hasNext()) { varName = CSMGEN.RD.next(); varname = varName.ToLower(); if (varName.Equals("#")) { CSMGEN.RD.nextLine(); continue; } try { //name = vars.valueOf(varname); name = (vars)System.Enum.Parse(typeof(vars), varname); } catch (Exception e) { UTIL.errorMsg("Variable name is not found: " + varName); } switch (name) { case vars.nh: nh = CSMGEN.RD.readInt(); break; case vars.nv: nv = CSMGEN.RD.readInt(); break; case vars.res: for (int i = 0; i < 4; i++) { res[i] = CSMGEN.RD.readDouble(); } break; case vars.xyp: for (int i = 0; i < 8; i++) { xp[i] = CSMGEN.RD.readDouble(); yp[i] = CSMGEN.RD.readDouble(); } // Interpolation of macroelement midside // nodes if both coordinates are zeroes for (int i = 1; i < 8; i += 2) { if (xp[i] == 0.0 && yp[i] == 0.0) { xp[i] = 0.5 * (xp[i - 1] + xp[(i + 1) % 8]); yp[i] = 0.5 * (yp[i - 1] + yp[(i + 1) % 8]); } } break; case vars.mat: mat = CSMGEN.RD.next(); break; case vars.thick: t = CSMGEN.RD.readDouble(); break; case vars.end: return; } } }
static void readDataFile(FeScanner RD) { vars name = vars.none; while (RD.hasNext()) { String varName = RD.next(); String varNameLower = varName.ToLower(); if (varName.Equals("#")) { RD.nextLine(); continue; } try { name = (vars)System.Enum.Parse(typeof(vars), varNameLower); } catch (Exception e) { UTIL.errorMsg("Variable name is not found: " + varName); } switch (name) { case vars.meshfile: meshFile = RD.next(); break; case vars.resultfile: resultFile = RD.next(); break; case vars.parm: try { varName = RD.next(); parm = (parms)System.Enum.Parse(typeof(parms), varName.ToLower()); } catch (Exception e) { UTIL.errorMsg("No such result parameter: " + varName); } break; case vars.showedges: showEdges = RD.next().Equals("y"); break; case vars.shownodes: showNodes = RD.next().Equals("y"); break; case vars.ndivmin: nDivMin = RD.readInt(); break; case vars.ndivmax: nDivMax = RD.readInt(); break; case vars.fmin: fMin = RD.readDouble(); break; case vars.fmax: fMax = RD.readDouble(); break; case vars.ncontours: nContours = RD.readInt(); break; case vars.deformscale: deformScale = RD.readDouble(); break; case vars.end: return; default: return; } } }
static void Main(string[] args) { vars vars = new vars(); try { WebRequest wr = WebRequest.Create(vars.UpdateUrlBase + "version.txt"); WebResponse ws = wr.GetResponse(); StreamReader sr = new StreamReader(ws.GetResponseStream()); string currentversion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); string newversion = sr.ReadToEnd(); string[] Curints = currentversion.Split('.'); int CurIntRep = 0; string[] Newints = newversion.Split('.'); int NewIntRep = 0; foreach (string INTString in Curints) { CurIntRep += Convert.ToInt32(INTString); } foreach (string INTString in Newints) { NewIntRep += Convert.ToInt32(INTString); } if (CurIntRep >= NewIntRep) { } else { string url = vars.UpdateUrlBase + "update.zip"; string zippath = Path.Combine(vars.pathToDir, "update.zip"); new WebClient().DownloadFile(url, zippath); using (ZipArchive archive = ZipFile.OpenRead(zippath)) { foreach (ZipArchiveEntry entry in archive.Entries) { if (!entry.Name.Contains("Update.exe")) { // Gets the full path to ensure that relative segments are removed. string destinationPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), entry.FullName)); // Ordinal match is safest, case-sensitive volumes can be mounted within volumes that // are case-insensitive. entry.ExtractToFile(destinationPath, true); } else { entry.ExtractToFile(Path.Combine(vars.pathToDir, "NewUpdate.exe")); } } } File.Delete(Path.Combine(vars.pathToDir, "update.zip")); } if (File.ReadAllLines(vars.settingsName)[3] == "true") { wr = WebRequest.Create(vars.UpdateUrlBase + "PreVersion.txt"); ws = wr.GetResponse(); sr = new StreamReader(ws.GetResponseStream()); currentversion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); newversion = sr.ReadToEnd(); Curints = currentversion.Split('.'); CurIntRep = 0; Newints = newversion.Split('.'); NewIntRep = 0; foreach (string INTString in Curints) { CurIntRep += Convert.ToInt32(INTString); } foreach (string INTString in Newints) { NewIntRep += Convert.ToInt32(INTString); } if (CurIntRep >= NewIntRep) { } else { string url = vars.UpdateUrlBase + "PreUpdate.zip"; string zippath = Path.Combine(vars.pathToDir, "update.zip"); new WebClient().DownloadFile(url, zippath); using (ZipArchive archive = ZipFile.OpenRead(zippath)) { foreach (ZipArchiveEntry entry in archive.Entries) { if (!entry.Name.Contains("Update.exe")) { // Gets the full path to ensure that relative segments are removed. string destinationPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), entry.FullName)); // Ordinal match is safest, case-sensitive volumes can be mounted within volumes that // are case-insensitive. entry.ExtractToFile(destinationPath, true); } else { entry.ExtractToFile(Path.Combine(vars.pathToDir, "NewUpdate.exe")); } } } File.Delete(Path.Combine(vars.pathToDir, "update.zip")); } } WebRequest wr2 = WebRequest.Create(vars.ListsUrlBase + "versions.txt"); WebResponse ws2 = wr2.GetResponse(); StreamReader sr2 = new StreamReader(ws2.GetResponseStream()); string urlListsVersions = sr2.ReadToEnd(); string[] urlListsArray = urlListsVersions.Split('\n'); if (!File.Exists("URL.avf")) { File.WriteAllText("URL.avf", urlListsVersions); } string currentUrlListsVer = File.ReadAllText("URL.avf"); string[] currentUrlArray = currentUrlListsVer.Split('\n'); string[] CurrentSplitArray = urlListsArray[0].Split('.'); int CurrentIntRepres = 0; string[] NewSplitArray = urlListsArray[0].Split('.'); int NewIntRepres = 0; foreach (string INTString in CurrentSplitArray) { CurrentIntRepres += Convert.ToInt32(INTString); } foreach (string INTString in NewSplitArray) { NewIntRepres += Convert.ToInt32(INTString); } if (CurIntRep >= NewIntRep) { } else { string url = vars.nsfwUrl; string txtPath = vars.nsfwPath; new WebClient().DownloadFile(url, txtPath); File.WriteAllText("URL.avf", urlListsVersions); } CurrentSplitArray = urlListsArray[1].Split('.'); CurrentIntRepres = 0; NewSplitArray = urlListsArray[1].Split('.'); NewIntRepres = 0; foreach (string INTString in CurrentSplitArray) { CurrentIntRepres += Convert.ToInt32(INTString); } foreach (string INTString in NewSplitArray) { NewIntRepres += Convert.ToInt32(INTString); } if (CurIntRep >= NewIntRep) { } else { string url = vars.fineUrl; string txtPath = vars.finePath; new WebClient().DownloadFile(url, txtPath); File.WriteAllText("URL.avf", urlListsVersions); } Process.Start("ChangeBackgroundControlPanel.exe"); } catch { Process.Start("ChangeBackgroundControlPanel.exe"); } }
public void CreateAsteroids() { foreach (Transform child in go.transform) { if (child.tag == "Asteroid") { child.parent = null; GameObject.Destroy(child.gameObject); count--; } } count = 0; float stepSize = 1f / resolution; NoiseMethod method = Noise.noiseMethods[(int)type][dimensions - 1]; int scale = Mathf.FloorToInt(chunkSize * resolution); long scale3 = (long)Mathf.Pow(scale, 3f); if (chunkSize != 0f) { Vector3 point00 = transform.TransformPoint(new Vector3(-0.5f, -0.5f)); Vector3 point10 = transform.TransformPoint(new Vector3(0.5f, -0.5f)); Vector3 point01 = transform.TransformPoint(new Vector3(-0.5f, 0.5f)); Vector3 point11 = transform.TransformPoint(new Vector3(0.5f, 0.5f)); Vector3 zpoint0 = transform.TransformPoint(new Vector3(0, 0, -0.5f)); Vector3 zpoint1 = transform.TransformPoint(new Vector3(0, 0, 0.5f)); float sum = 0f; //long pos = (long)Mathf.Pow(resolution, 3f); //for (long currPos = 0; currPos < pos; currPos += scale3) //{ // long z = currPos % resolution; // long x = currPos % (long)Mathf.Pow(z, 2f); // long y = currPos % (long)Mathf.Pow(x, 3f); //} for (int y = 0; y < resolution; y += 1) { int yi = y % scale; Vector3 point0 = Vector3.Lerp(point00, point01, (y + 0.5f) * stepSize); Vector3 point1 = Vector3.Lerp(point10, point11, (y + 0.5f) * stepSize); for (int x = 0; x < resolution; x += 1) { int xi = x % scale; Vector3 point = Vector3.Lerp(point0, point1, (x + 0.5f) * stepSize); for (int z = 0; z < resolution; z += 1) { int zi = z % scale; Vector3 zpoint = Vector3.Lerp(zpoint0, zpoint1, (z + 0.5f) * stepSize); point += zpoint; point.z = (z + 0.5f) * stepSize; float sample = Noise.Sum(method, point * 1f, frequency, octaves, lacunarity, persistence).value; if (type != NoiseMethodType.Value) { sample = sample * 0.5f + 0.5f; } sum += sample; if ((sum > (threshold * (scale * scale * scale)) * largeAsteroidSize) || (yi == scale / 2 && xi == scale / 2 && zi == scale / 2)) { if (sum > threshold * (scale * scale * scale) && count < asteroidLimit) { //Debug.Log(sum); count++; int idx = (Random.Range(0, asteroids.Length)); GameObject tmp = Instantiate( asteroids[idx], // Random Asteroid new Vector3((x) * 1f, // Random Location (y) * 1f, (z) * 1f), Quaternion.identity, transform); // Same rotation tmp.tag = "Asteroid"; tmp.AddComponent <vars>(); tmp.name = tmp.name.Replace("(Clone)", (System.String.Format("({0})", count))).Trim(); vars v = tmp.GetComponent <vars>(); // Info v.idx = idx; v.go = tmp; v.main = transform.gameObject; v.exploded = exploded; // Transform tmp.transform.parent = go.transform; // Set as child of main tmp.transform.localScale *= (sum) * (1f / ((scale * scale * scale))); // Scale based on position // HP v.maxHP = (int)((sum) * (1f / ((scale * scale * scale))) * 1000); v.currHP = tmp.GetComponent <vars>().maxHP; // Mesh collider v.mc = tmp.AddComponent <MeshCollider>(); v.mc.convex = true; // Rigidbody v.rb = tmp.AddComponent <Rigidbody>(); v.rb.isKinematic = false; v.rb.angularVelocity = Random.insideUnitSphere * Random.Range(.01f, 1f); v.rb.drag = 0; v.rb.angularDrag = 0; v.rb.useGravity = false; v.rb.mass = v.maxHP; } sum = 0f; } if (count >= asteroidLimit) { break; } } if (count >= asteroidLimit) { break; } } if (count >= asteroidLimit) { break; } } } //texture.Apply(); }
// Read data fragment for load increment. // newLoad = true - beginning of new load, // = false - continuation of load. // returns true if load data has been read private bool readDataFile(FeScanner es, bool newLoad) { if (newLoad) { scaleLoad = 0; nodForces = new List <Dof>(); itnf = nodForces.GetEnumerator(); surForces = new List <ElemFaceLoad>(); itsf = surForces.GetEnumerator(); if (fem.thermalLoading) { for (int i = 0; i < dtemp.Length; i++) { dtemp[i] = 0.0; } } for (int i = 0; i < dDispl.Length; i++) { dDispl[i] = 0.0; } } if (!es.hasNext()) { return(false); // No load data } vars name = vars.NONE; String s; while (es.hasNext()) { String varName = es.next(); String varNameLower = varName.ToLower(); if (varName.Equals("#")) { es.nextLine(); continue; } try { name = (vars)System.Enum.Parse(typeof(vars), varNameLower); //vars.valueOf(varNameLower); } catch (Exception E) { UTIL.errorMsg("Variable name is not found: " + varName); } switch (name) { case vars.loadstep: loadStepName = es.next(); //Console.WriteLine("FELOAD " + loadStepName.ToString()); break; case vars.scaleload: scaleLoad = es.readDouble(); //Console.WriteLine("FELOAD " + scaleLoad.ToString()); break; case vars.residtolerance: residTolerance = es.readDouble(); //Console.WriteLine("FELOAD " + residTolerance.ToString()); break; case vars.maxiternumber: maxIterNumber = es.readInt(); //Console.WriteLine("FELOAD " + maxIterNumber.ToString()); break; case vars.nodforce: readNodalForces(es); break; case vars.surforce: readSurForces(es); break; case vars.boxsurforce: createBoxSurForces(es); break; case vars.nodtemp: dtemp = new double[fem.nNod]; for (int i = 0; i < fem.nNod; i++) { dtemp[i] = es.readDouble(); } break; case vars.includefile: s = es.next().ToLower(); FeScanner R = new FeScanner(s); readDataFile(R, false); break; case vars.anglesurforce: createAngleSurForce(es); break; case vars.surforcelist: createSurForceList(es); break; case vars.elemanglesurforce: createElemAngleSurForce(es); break; case vars.end: return(true); } } return(true); }
public TimTest() { vars vars = new vars(); // Import vars vars.connection.Open(); // Open SQL Connection string streg = "----------------------------------------------------------------------------------------------------"; Console.WriteLine(streg); //Fornavn(e) Console.WriteLine(" Indtast gæstens fornavn(e)"); string Fornavn = Console.ReadLine().ToUpper(); Console.Clear(); //Efternavn Console.WriteLine(" Indtast gæstens efternavn"); Console.WriteLine(streg); string Efternavn = Console.ReadLine().ToUpper(); Console.Clear(); //Adresse Console.WriteLine(" Indtast gæstens adresse (Vej og husnummer og Sal/Dør hvis nødvendigt)"); Console.WriteLine(streg); string Adresse = Console.ReadLine().ToUpper(); Console.Clear(); //Postnummer Console.WriteLine(" Indtast gæstens postnummer (Vi behøver ikke bynavn) "); Console.WriteLine(streg); int PostNr = Convert.ToInt32(Console.ReadLine().ToUpper()); Console.Clear(); //Telefonnummer Console.WriteLine(" Indtast gæstens telefon nummer (Dette må gerne være tomt) "); Console.WriteLine(streg); int TlfNummer = Convert.ToInt32(Console.ReadLine().ToUpper()); Console.Clear(); //Email Console.WriteLine(" Indtast gæstens email adresse (Dette felt må gerne være tomt)"); Console.WriteLine(streg); string Email = Console.ReadLine().ToUpper(); Console.Clear(); //Suite Console.WriteLine(" Vil gæsten opgraderes til en suite? "); Console.WriteLine(streg); string Suite = Console.ReadLine().ToUpper(); Console.Clear(); //Enmands seng Console.WriteLine(" Vil gæsten have et enkelt seng på værelset? Skriv JA | Nej "); Console.WriteLine(streg); string EnkeltSeng = Console.ReadLine().ToUpper(); Console.Clear(); //2x enmands seng Console.WriteLine(" Vil gæsten have 2 enkelt senge på værelset? Skriv Ja | Nej "); Console.WriteLine(streg); string ToSenge = Console.ReadLine().ToUpper(); Console.Clear(); //Dobbeltseng Console.WriteLine(" Vil gæsten have en dobbelt seng på værelset? Skriv Ja | Nej "); Console.WriteLine(streg); string DobbeltSeng = Console.ReadLine().ToUpper(); Console.Clear(); //Altan Console.WriteLine(" Vil gæsten have en altan tilknyttet sit værelse? Skriv Ja | Nej "); Console.WriteLine(streg); string Altan = Console.ReadLine().ToUpper(); Console.Clear(); //Køkken Console.WriteLine(" Vil gæsten have eget køkken? Skriv Ja | Nej "); Console.WriteLine(streg); string Køkken = Console.ReadLine().ToUpper(); Console.Clear(); //Badekar Console.WriteLine(" Vil gæsten have badekar på værelset? Skriv Ja | Nej "); Console.WriteLine(streg); string Badekar = Console.ReadLine().ToUpper(); Console.Clear(); //Jacuzzi Console.WriteLine(" Vil gæsten have spabad på værelset? skriv Ja | Nej "); Console.WriteLine(streg); string Jacuzzi = Console.ReadLine().ToUpper(); Console.Clear(); //Opholdets start Console.WriteLine(" Hvad dato vil gæsten starte sit ophold? "); Console.WriteLine(streg); DateTime StartDato = Convert.ToDateTime(Console.ReadLine()); List <int> values = new List <int>(); string SQL = "SELECT Pris FROM Vare;"; //SQL Command to execute using (SqlCommand command = new SqlCommand(SQL, vars.connection)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { values.Add(reader.GetInt16(0)); } } int prisTotal = 695; string[] array = new string[] { "GrundPrisPlaceholder", Suite, EnkeltSeng, ToSenge, DobbeltSeng, Altan, Køkken, Badekar, Jacuzzi }; for (int i = 1; i < array.Length; i++) { if (array[i] == "JA") { prisTotal += values[i]; } } Console.WriteLine("\n Den totale pris er: " + prisTotal); Console.WriteLine("Done."); } vars.connection.Close(); }
public void loose_percentage_value_of_storage(vars.ressource_type _type, int percentage) { float npercentage = percentage/100; npercentage = 1- npercentage; switch (_type) { case vars.ressource_type.A: res_a_storage = res_a_storage * npercentage; if(res_a_storage < 0.0f){res_a_storage = 0.0f;} break; case vars.ressource_type.B: res_a_storage = res_b_storage * npercentage; if(res_b_storage < 0.0f){res_b_storage = 0.0f;} break; case vars.ressource_type.C: res_a_storage = res_c_storage * npercentage; if(res_c_storage < 0.0f){res_c_storage = 0.0f;} break; default: break; } }
public bool btn_triggered(InputDevice idc, vars.player_controls pcts, bool last_state = false) { if (!last_state) { switch (pcts) { case vars.player_controls.punsh: return idc.GetControlByName(vars.player_control_punsh_trigger_name); case vars.player_controls.jump: return idc.GetControlByName(vars.player_control_jump_trigger_name); case vars.player_controls.menu: return idc.GetControlByName(vars.player_control_menu_trigger_name); case vars.player_controls.carry_up: return idc.GetControlByName(vars.player_control_carry_up_trigger_name); case vars.player_controls.carry_down: return idc.GetControlByName(vars.player_control_carry_down_trigger_name); default: return false; } } else { switch (pcts) { case vars.player_controls.punsh: return idc.GetControlByName(vars.player_control_punsh_trigger_name).LastState; case vars.player_controls.jump: return idc.GetControlByName(vars.player_control_jump_trigger_name).LastState; case vars.player_controls.menu: return idc.GetControlByName(vars.player_control_menu_trigger_name).LastState; case vars.player_controls.carry_up: return idc.GetControlByName(vars.player_control_carry_up_trigger_name).LastState; case vars.player_controls.carry_down: return idc.GetControlByName(vars.player_control_carry_down_trigger_name).LastState; default: return false; } } }
public void start(vars.audio_name audio_file) { asc = this.gameObject.GetComponent<AudioSource>(); switch (audio_file) { case vars.audio_name.bgmusic: ac = (AudioClip)Resources.Load(vars.audio_clip_info_bgmusic.audio_clip_path); type = vars.audio_clip_info_bgmusic.ptype; saved_vol = vars.audio_clip_info_bgmusic.volume; asc.priority = vars.audio_clip_info_bgmusic.priority; asc.pitch = vars.audio_clip_info_bgmusic.pitch; break; case vars.audio_name.bgmusic2: ac = (AudioClip)Resources.Load(vars.audio_clip_info_bgmusic2.audio_clip_path); type = vars.audio_clip_info_bgmusic2.ptype; saved_vol = vars.audio_clip_info_bgmusic2.volume; asc.priority = vars.audio_clip_info_bgmusic2.priority; asc.pitch = vars.audio_clip_info_bgmusic2.pitch; break; case vars.audio_name.ui_click: ac = (AudioClip)Resources.Load(vars.audio_clip_info_uiclick.audio_clip_path); type = vars.audio_clip_info_uiclick.ptype; saved_vol = vars.audio_clip_info_uiclick.volume ; asc.priority = vars.audio_clip_info_uiclick.priority; asc.pitch = vars.audio_clip_info_uiclick.pitch; break; case vars.audio_name.wp_add: ac = (AudioClip)Resources.Load(vars.audio_clip_info_wp_add.audio_clip_path); type = vars.audio_clip_info_wp_add.ptype; saved_vol = vars.audio_clip_info_wp_add.volume ; asc.priority = vars.audio_clip_info_wp_add.priority; asc.pitch = vars.audio_clip_info_wp_add.pitch; break; case vars.audio_name.wp_move: ac = (AudioClip)Resources.Load(vars.audio_clip_info_wp_move.audio_clip_path); type = vars.audio_clip_info_wp_move.ptype; saved_vol = vars.audio_clip_info_wp_move.volume ; asc.priority = vars.audio_clip_info_wp_move.priority; asc.pitch = vars.audio_clip_info_wp_move.pitch; break; case vars.audio_name.wp_connect: ac = (AudioClip)Resources.Load(vars.audio_clip_info_wp_connect.audio_clip_path); type = vars.audio_clip_info_wp_connect.ptype; saved_vol = vars.audio_clip_info_wp_connect.volume ; asc.priority = vars.audio_clip_info_wp_connect.priority; asc.pitch = vars.audio_clip_info_wp_connect.pitch; break; case vars.audio_name.wp_remove_connect: ac = (AudioClip)Resources.Load(vars.audio_clip_info_wp_remove_connect.audio_clip_path); type = vars.audio_clip_info_wp_remove_connect.ptype; saved_vol = vars.audio_clip_info_wp_remove_connect.volume ; asc.priority = vars.audio_clip_info_wp_remove_connect.priority; asc.pitch = vars.audio_clip_info_wp_remove_connect.pitch; break; case vars.audio_name.unit_move_1: ac = (AudioClip)Resources.Load(vars.audio_clip_info_unit_move_1.audio_clip_path); type = vars.audio_clip_info_unit_move_1.ptype; saved_vol = vars.audio_clip_info_unit_move_1.volume ; asc.priority = vars.audio_clip_info_unit_move_1.priority; asc.pitch = vars.audio_clip_info_unit_move_1.pitch; break; case vars.audio_name.unit_move_2: ac = (AudioClip)Resources.Load(vars.audio_clip_info_unit_move_2.audio_clip_path); type = vars.audio_clip_info_unit_move_2.ptype; saved_vol = vars.audio_clip_info_unit_move_2.volume ; asc.priority = vars.audio_clip_info_unit_move_2.priority; asc.pitch = vars.audio_clip_info_unit_move_2.pitch; break; case vars.audio_name.unit_move_3: ac = (AudioClip)Resources.Load(vars.audio_clip_info_unit_move_3.audio_clip_path); type = vars.audio_clip_info_unit_move_3.ptype; saved_vol = vars.audio_clip_info_unit_move_3.volume ; asc.priority = vars.audio_clip_info_unit_move_3.priority; asc.pitch = vars.audio_clip_info_unit_move_3.pitch; break; case vars.audio_name.unit_move_4: ac = (AudioClip)Resources.Load(vars.audio_clip_info_unit_move_4.audio_clip_path); type = vars.audio_clip_info_unit_move_4.ptype; saved_vol = vars.audio_clip_info_unit_move_4.volume ; asc.priority = vars.audio_clip_info_unit_move_4.priority; asc.pitch = vars.audio_clip_info_unit_move_4.pitch; break; case vars.audio_name.unit_back_move_1: ac = (AudioClip)Resources.Load(vars.audio_clip_info_unit_back_move_1.audio_clip_path); type = vars.audio_clip_info_unit_back_move_1.ptype; saved_vol = vars.audio_clip_info_unit_back_move_1.volume ; asc.priority = vars.audio_clip_info_unit_back_move_1.priority; asc.pitch = vars.audio_clip_info_unit_back_move_1.pitch; break; break; case vars.audio_name.unit_back_move_2: ac = (AudioClip)Resources.Load(vars.audio_clip_info_unit_back_move_2.audio_clip_path); type = vars.audio_clip_info_unit_back_move_2.ptype; saved_vol = vars.audio_clip_info_unit_back_move_2.volume ; asc.priority = vars.audio_clip_info_unit_back_move_2.priority; asc.pitch = vars.audio_clip_info_unit_back_move_2.pitch; break; case vars.audio_name.unit_attack_move_1: ac = (AudioClip)Resources.Load(vars.audio_clip_info_unit_attack_move_1.audio_clip_path); type = vars.audio_clip_info_unit_attack_move_1.ptype; saved_vol = vars.audio_clip_info_unit_attack_move_1.volume ; asc.priority = vars.audio_clip_info_unit_attack_move_1.priority; asc.pitch = vars.audio_clip_info_unit_attack_move_1.pitch; break; case vars.audio_name.unit_attack_move_2: ac = (AudioClip)Resources.Load(vars.audio_clip_info_unit_attack_move_2.audio_clip_path); type = vars.audio_clip_info_unit_attack_move_2.ptype; saved_vol = vars.audio_clip_info_unit_attack_move_2.volume ; asc.priority = vars.audio_clip_info_unit_attack_move_2.priority; asc.pitch = vars.audio_clip_info_unit_attack_move_2.pitch; break; case vars.audio_name.select_base_1: ac = (AudioClip)Resources.Load(vars.audio_clip_info_select_base_1.audio_clip_path); type = vars.audio_clip_info_select_base_1.ptype; saved_vol = vars.audio_clip_info_select_base_1.volume ; asc.priority = vars.audio_clip_info_select_base_1.priority; asc.pitch = vars.audio_clip_info_select_base_1.pitch; break; case vars.audio_name.select_base_2: ac = (AudioClip)Resources.Load(vars.audio_clip_info_select_base_2.audio_clip_path); type = vars.audio_clip_info_select_base_2.ptype; saved_vol = vars.audio_clip_info_select_base_2.volume ; asc.priority = vars.audio_clip_info_select_base_2.priority; asc.pitch = vars.audio_clip_info_select_base_2.pitch; break; case vars.audio_name.select_unit: ac = (AudioClip)Resources.Load(vars.audio_clip_info_select_unit.audio_clip_path); type = vars.audio_clip_info_select_unit.ptype; saved_vol = vars.audio_clip_info_select_unit.volume ; asc.priority = vars.audio_clip_info_select_unit.priority; asc.pitch = vars.audio_clip_info_select_unit.pitch; break; case vars.audio_name.select_ressource: ac = (AudioClip)Resources.Load(vars.audio_clip_info_select_ressource.audio_clip_path); type = vars.audio_clip_info_select_ressource.ptype; saved_vol = vars.audio_clip_info_select_ressource.volume ; asc.priority = vars.audio_clip_info_select_ressource.priority; asc.pitch = vars.audio_clip_info_select_ressource.pitch; break; case vars.audio_name.select_waypoint: ac = (AudioClip)Resources.Load(vars.audio_clip_info_select_waypoint.audio_clip_path); type = vars.audio_clip_info_select_waypoint.ptype; saved_vol = vars.audio_clip_info_select_waypoint.volume ; asc.priority = vars.audio_clip_info_select_waypoint.priority; asc.pitch = vars.audio_clip_info_select_waypoint.pitch; break; case vars.audio_name.not_enought_ressources: ac = (AudioClip)Resources.Load(vars.audio_clip_info_not_enought_ressources.audio_clip_path); type = vars.audio_clip_info_not_enought_ressources.ptype; saved_vol = vars.audio_clip_info_not_enought_ressources.volume ; asc.priority = vars.audio_clip_info_not_enought_ressources.priority; asc.pitch = vars.audio_clip_info_not_enought_ressources.pitch; break; case vars.audio_name.destroy_skorpion_base: ac = (AudioClip)Resources.Load(vars.audio_clip_info_destroy_skorpion_base.audio_clip_path); type = vars.audio_clip_info_destroy_skorpion_base.ptype; saved_vol = vars.audio_clip_info_destroy_skorpion_base.volume ; asc.priority = vars.audio_clip_info_destroy_skorpion_base.priority; asc.pitch = vars.audio_clip_info_destroy_skorpion_base.pitch; break; case vars.audio_name.destroy_base: ac = (AudioClip)Resources.Load(vars.audio_clip_info_destory_base.audio_clip_path); type = vars.audio_clip_info_destory_base.ptype; saved_vol = vars.audio_clip_info_destory_base.volume ; asc.priority = vars.audio_clip_info_destory_base.priority; asc.pitch = vars.audio_clip_info_destory_base.pitch; break; default: ac = null; type = vars.audio_playback_type.none; asc.priority = 0; saved_vol = 0.0f; asc.pitch = 1.0f; break; } if(ac != null){ asc.volume = saved_vol; manage_vol(); this.name = "audio_playback_" + ac.name; asc.clip = ac; if(type == vars.audio_playback_type.music){ asc.loop = true; }else{ asc.loop = false; } asc.enabled = true; asc.Play(); }else{ this.name = "audio_playback_" + "null"; } }
private void readData() { String varName, varname; while (CSMGEN.RD.hasNext()) { varName = CSMGEN.RD.next(); varname = varName.ToLower(); if (varName.Equals("#")) { CSMGEN.RD.nextLine(); continue; } try { //name = vars.valueOf(varname); name = (vars)System.Enum.Parse(typeof(vars), varname); } catch (Exception e) { UTIL.errorMsg("Variable name is not found: " + varName); } switch (name) { case vars.nx: nx = CSMGEN.RD.readInt(); break; case vars.ny: ny = CSMGEN.RD.readInt(); break; case vars.xs: xs = new double[nx + 1]; for (int i = 0; i <= nx; i++) { xs[i] = CSMGEN.RD.readDouble(); } break; case vars.ys: ys = new double[ny + 1]; for (int i = 0; i <= ny; i++) { ys[i] = CSMGEN.RD.readDouble(); } break; case vars.mat: mat = CSMGEN.RD.next(); break; case vars.thick: t = CSMGEN.RD.readDouble(); break; case vars.end: return; } } }
public void decarry_fly(vars.player_id pid, float _decarray_velocity_add) { rd.useGravity = false; Debug.Log("decarry fly"); carried_by = vars.player_id.none; // last_contact = pid; rd.velocity = new Vector3(-_decarray_velocity_add, 0.0f,0.0f) ; play_hit_animation(); }
private void findHandler() { Handler = GameObject.FindWithTag("ButtonHandler").GetComponent <vars>(); }
public transform() { String modelName = CSMGEN.RD.next(); CSMGEN.PR.WriteLine("Transform: {0}\n", modelName); if (CSMGEN.blocks.ContainsKey(modelName)) { m = (FeModel)CSMGEN.blocks[modelName]; } else { UTIL.errorMsg("No such mesh block: " + modelName); } while (CSMGEN.RD.hasNext()) { String name = CSMGEN.RD.next().ToLower(); if (name.Equals("#")) { CSMGEN.RD.nextLine(); continue; } if (name.Equals("end")) { break; } try { //opName = vars.valueOf(name); opName = (vars)System.Enum.Parse(typeof(vars), name); } catch (Exception e) { UTIL.errorMsg("Operation name is not found: " + name); } String Axis = CSMGEN.RD.next().ToLower(); axis = Axis[0];//.charAt(0); if (axis != 'x' && axis != 'y' && axis != 'z') { UTIL.errorMsg("Incorrect axis: " + axis); } value = CSMGEN.RD.readDouble(); CSMGEN.PR.WriteLine("{0,10} {1} {2,10:0.0000}\n", opName, Axis, value); switch (opName) { case vars.translate: doTranslate(); break; case vars.scale: doScale(); break; case vars.rotate: doRotate(); break; case vars.mirror: doMirror(); break; } } CSMGEN.PR.WriteLine("Mesh " + modelName + ": nEl = {0} nNod = {1}\n", m.nEl, m.nNod); }