/* * static Movers operator +(Movers append1, Movers append2): * Function: Returns a List of movers that has the movers of both. * Usefulness: To quickly combine different list of movers into one. * */ public static Movers operator +(Movers append1, Movers append2) { Movers mv = new Movers(append1); mv.AddRange(append2); return(mv); }
/* * Movers Inverse (params AuxCoord[] inverses): * Function: Creates a duplicate of the List of movers and all their gameObjects, * and then applies a scale that inverts their position for the quoted coordinates. Their names change to be "i<" + name + ">". * Usefulness: To create a mirrored or opposite Mover to combine. * */ public Movers Inverse(params AuxCoord[] inverses) { Transform tr = null; Movers mvs = new Movers(this, true); Vector3 inverse = new Vector3(inverses.Contains(AuxCoord.x) ? -1 : 1, inverses.Contains(AuxCoord.y) ? -1 : 1, inverses.Contains(AuxCoord.z) ? -1 : 1); foreach (string name in mvs.Names) { tr = null; foreach (Mover mv in mvs) { if (mv.name == name) { if (tr == null) { tr = mv.getObject.Duplicate(true); } mv.getObject = tr; } } } mvs.Scale(inverse, Mover.MovType.position); mvs.AppendString("i<", ">"); return(mvs); }
void Start() { holder = GameObject.Find("Top"); otherSettings = GameObject.Find("Other"); moversComponent = GameObject.Find("XZ").GetComponent <Movers>(); humanManager = GameObject.Find("Humans").GetComponent <HumanManager>(); slideManager = GameObject.Find("Slides").GetComponent <SlideManager>(); lightsHolder = GameObject.Find("Lights"); for (int i = 0; i < lightsHolder.transform.childCount; i++) { lightsHolder.transform.GetChild(i).gameObject.SetActive(false); } player = GameObject.Find("Player"); settingsAll = Instantiate(toggler, new Vector3(0, 0, 0), Quaternion.Euler(-135, 0, 0), holder.transform) as GameObject; settingsAll.transform.localPosition = new Vector3(0, 1.5f, 0.3f); settingsAll.name = "Settings"; settingsText = settingsAll.transform.GetChild(0).transform.GetChild(0).GetComponent <TextMesh>(); settingsText.text = "Баптамалар"; }
void Start() { //octopi for (int i = 0; i < OctopusCount; i++) { octopus = new chapter1Creature(); octopi.Add(octopus); } //wisps for (int i = 0; i < WispCount; i++) { Vector3 randomLocation = new Vector3(Random.Range(0, 100), Random.Range(3, 100), Random.Range(0, 100)); Vector3 randomVelocity = new Vector3(Random.Range(-2f, 2f), Random.Range(-2f, 2f), Random.Range(-2f, 2f)); Mover2_7 m = new Mover2_7(Random.Range(0.2f, .5f), randomVelocity, randomLocation); //Each Mover is initialized randomly. movers.Add(m); } a = new Attractor2_7(); //worms for (int i = 0; i < WormCount; i++) { float x = Random.Range(0, 100); float z = Random.Range(0, 100); float y = ExtensionMethods.Remap(Mathf.PerlinNoise(x * .06f, z * .06f), 0f, 1f, 0f, 7f); worms.Add(new baton(new Vector3(x, y - 1f, z))); } //fish for (int i = 0; i < FishCount; i++) { Vector3 randomLocation = new Vector3(Random.Range(50f, 100f), Random.Range(50f, 100f), Random.Range(50f, 20f)); Vector3 randomVelocity = new Vector3(Random.Range(0f, 3f), Random.Range(0f, 3f), Random.Range(0f, 3f)); Movers m = new Movers(Random.Range(0.2f, 1f), randomVelocity, randomLocation); //Each Mover is initialized randomly. fish.Add(m); } fishLead = new fishLead(); //randomFish for (int i = 0; i < randomFishCount; i++) { randomFish a = new randomFish(); fishR.Add(a); } //squid randomFish2 = new randomFish2(); while (oscillate.Count < SquidCount) { oscillator o = new oscillator(new Vector3(2f, 2f, 2f)); o.oGameObject.transform.SetParent(randomFish2.body.transform); oscillate.Add(o); Debug.Log("Squid instantiated"); squid.Add(randomFish2); } }
// Start is called before the first frame update void Start() { int numberOfMovers = 10; for (int i = 0; i < numberOfMovers; i++) { Vector3 randomLocation = new Vector3(Random.Range(-5f, 5f), Random.Range(-5f, 5f), Random.Range(-5f, 5f)); Vector3 randomVelocity = new Vector3(Random.Range(0f, 3f), Random.Range(0f, 3f), Random.Range(0f, 3f)); Movers m = new Movers(Random.Range(0.2f, 1f), randomVelocity, randomLocation); //Each Mover is initialized randomly. movers.Add(m); } a = new fishLead(); }
public Movers(Movers movers, bool overload = false) : this() { if (overload) { foreach (Mover mv in movers) { Add(new Mover(mv)); } } else { AddRange(movers); } }
private static Movers p_LoadSML(string text, string id, Dictionary <string, Transform> vars, params GameObjectDelegate[] template) { GameObject tr; Movers mv = new Movers(); string method = Auxf.SML.i.GetMethod(text, id); if (method == null) { return(null); } foreach (string str in Auxf.SML.i.SplitLines(method)) { string[] tt; List <string> sep = new List <string>(Auxf.SML.i.SplitWords(str)); if (sep.Count < 2 || !sep.Cut(1, 0).IsAll(Auxf.SML.i.FormatParts)) { return(null); } string nameVariable = sep[0]; sep = sep.Cut(1, 0); //Create Object: tt = Auxf.SML.i.SplitParts(sep[0]); if (tt[0] == "cr") { int a = int.Parse(tt[1]); if (!a.Between(0, template.Length - 1)) { return(null); } tr = template[a](); tr.name = nameVariable; sep = sep.Cut(1, 0); } else if (vars == null || !vars.ContainsKey(nameVariable)) { return(null); } else { tr = vars[nameVariable].gameObject; } //Asign Material: tt = Auxf.SML.i.SplitParts(sep[0]); if (tt[0] == "mt" && (Auxg.i.GetMaterial(tt[1]) != null || "-+".IsAny(tt[1][0].Equals))) { int a; if ("-+".IsAny(tt[1][0].Equals)) { a = int.Parse(tt[1].Substring(1)); if (a < 1) { return(null); } else if (a > 1) { var compl = tr.AddComponent <Complement>().complement; while (a > 1) { Debug.Log(a); compl.Add(tr.Duplicate()); a--; } } tt[1] = tt[1].SubstringIndex(0, 0); } foreach (GameObject go in tr.GetRecursive <GameObject>()) { go.Set(Auxg.i.GetMaterial(tt[1])); } sep = sep.Cut(1, 0); } if (!sep.IsAll <string, string>(Auxf.SML.i.FormatName, Mover.types.IsAny) || !sep.IsAll(Auxf.SML.i.FormatSubs, allowableCode)) { return(null); } foreach (string com in sep) { mv.Add(nameVariable, tr.transform); string[] parts = Auxf.SML.i.SplitParts(com); foreach (string sub in Auxf.SML.i.SplitSubs(parts[1])) { var dict = Auxf.SML.i.Dictionary(sub, allowableCode); if (dict.ContainsKey(obligatory)) { if (restCode.IsAny(dict.ContainsKey)) { mv.GetLast.Add(parts[0], mv.GetVector(dict), dict[obligatory]); } else { mv.GetLast.Add(Mover.typeNothing, Vector3.zero, dict[obligatory]); } } else if (restCode.IsAny(dict.ContainsKey)) { mv.GetLast.Add(parts[0], mv.GetVector(dict), 0f); } else { return(null); } } } } return(mv); }
public Movers GetNationalMarketMovers() { const string WEBSERVICE_URL = "https://homebroker-api.gbm.com/GBMP/api/Market/GetLowRiseIssuesByBenchmark"; try { var myHttpWebRequest = (HttpWebRequest)WebRequest.Create(WEBSERVICE_URL); myHttpWebRequest.UserAgent = "okhttp/3.10.0"; myHttpWebRequest.ContentType = "application/json"; myHttpWebRequest.ContentLength = 13; myHttpWebRequest.Method = "POST"; myHttpWebRequest.Accept = "application/json"; myHttpWebRequest.Headers.Add("Authorization", "Bearer " + this.BearerKey); myHttpWebRequest.Headers.Add("Accept-Encoding", "gzip"); myHttpWebRequest.Headers.Add("Mobile-platform", "android"); string postData = "{\"request\":1}"; ASCIIEncoding encoding = new ASCIIEncoding(); byte[] byte1 = encoding.GetBytes(postData); Stream newStream = myHttpWebRequest.GetRequestStream(); newStream.Write(byte1, 0, byte1.Length); HttpWebResponse WebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); if (WebResponse.StatusDescription == "OK") { Stream responseStream = WebResponse.GetResponseStream(); if (WebResponse.ContentEncoding.ToLower().Contains("gzip")) { responseStream = new GZipStream(responseStream, CompressionMode.Decompress); } else if (WebResponse.ContentEncoding.ToLower().Contains("deflate")) { responseStream = new DeflateStream(responseStream, CompressionMode.Decompress); } StreamReader Reader = new StreamReader(responseStream, Encoding.Default); string Html = Reader.ReadToEnd(); var JsonData = JsonConvert.DeserializeObject <List <Ticker> >(Html); var Losers = JsonData.GetRange(0, 10); var Winers = JsonData.GetRange(10, 10); var Movers_ = JsonData.GetRange(20, 10); var MoverString = Movers_.Select(item => item.issueId).ToList(); //dynamic data = JObject.Parse(Html); responseStream.Close(); var Moc = new Movers(); Moc.Lossers = Losers; Moc.Winers = Winers; Moc.Volume = Movers_; return(Moc); } WebResponse.Close(); } catch (System.Net.WebException UnautorizedException) { this.Autenthicate(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(null); }