public void ThrowIfNotNullOrEmpty() { const string TempObject = ""; TempObject.ThrowIfNotNullOrEmpty("TempName"); TempObject.ThrowIfNotNullOrEmpty(new ArgumentNullException("TempName")); }
private void ChartRefresh() { while (true) { if (TerminalQueues.plcreadqueue.Count > 0) { TempObject tempObject = new TempObject(); TerminalQueues.plcreadqueue.TryDequeue(out tempObject); if (tempObject == null) { continue; } if (dataTable.Rows.Count > 100) { dataTable.Rows.RemoveAt(0); } Random rd = new Random(); double rand = rd.Next(-5, 5) + rd.NextDouble(); dataTable.Rows.Add(tempObject.data_time.ToLongTimeString(), tempObject.temp + (float)rand); delegete1 task = new delegete1(ChartCurve.ChartCurveUpdate); this.Invoke(task, dataTable, this); UploadToSQL(tempObject.data_time, tempObject.temp); } } }
public IEnumerator ActivateCompanion(Enemy e, int i) { // random delay before starting routine yield return(new WaitForSeconds(Random.Range(0f, 0.5f))); // randomize the orientation of the sprite a bit (flip, position) SpriteRenderer sr = companions[i].GetComponent <SpriteRenderer> (); float f = UtilMethods.RandSign(); Vector3 position = e.transform.position + new Vector3(f * 0.5f, 0); // offset sprite sr.flipX = f > 0; TempObject tempObj = companions[i].GetComponent <TempObject> (); SimpleAnimationPlayer anim = companions[i].GetComponent <SimpleAnimationPlayer> (); anim.anim = companionAnimations [Random.Range(0, companionAnimations.Length)]; tempObj.Init(Quaternion.identity, position, anim.anim.frames [0]); anim.Play(); yield return(new WaitForSeconds(0.2f)); DamageEnemy(e, 1); }
/// <summary> /// Repopulates fields according to changes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Object_Or_Augment_Changed(object sender, EventArgs e) { RespawnTempObject(); TempObject.Object = (Models.BaseObject)Type_Combo.SelectedValue; TempObject.Augmentations = Augment_List.SelectedItems.OfType <Models.Base_Augmentation>().ToList(); TempObject.ActiveResource = (Models.BaseResource)Focus_Combo.SelectedValue; TempObject.Paid = PaidCheck.Checked; TempObject.Quantity = String.IsNullOrWhiteSpace(qtyNum.Value.ToString()) ? 1 : (int)qtyNum.Value; Income_Text.Text = TempObject.BuildIncome(); Costs_Text.Text = TempObject.BuildCosts(); Size_Text.Text = BuildSizeText();//TempObject.Size_Range; Aug_Max_Text.Text = MaxSizeText(); if (Aug_Max_Text.Text == "None") { Aug_Max_Text.BackColor = System.Drawing.Color.Empty; } else { Aug_Max_Text.BackColor = System.Drawing.Color.Red; } Time_Text.Text = TempObject.TotalDays.ToString(); Benefit_Text.Text = TempObject.Object.Benefit; Description_Text.Text = BuildDescription(); }
public void ThrowIfNullOrEmpty() { const string TempObject = ""; Assert.Throws <ArgumentNullException>(() => TempObject.ThrowIfNullOrEmpty("TempName")); Assert.Throws <ArgumentNullException>(() => TempObject.ThrowIfNullOrEmpty(new ArgumentNullException("TempName"))); }
public IHttpActionResult GetTestMessage() { var tempObject = new TempObject { timeNow = DateTime.Now, }; return(Content <string>(HttpStatusCode.OK, "OK")); //return Content<TempObject>(HttpStatusCode.OK, tempObject); }
public void AddAsset(string assetName, TempObject asset) { if (nameAssetDict.ContainsKey(assetName)) { Debug.LogWarning("此 " + assetName + "已经加载"); return; } //加入字典缓存 nameAssetDict.Add(assetName, asset); }
/// <summary> /// 获取带有子物体的资源 /// </summary> /// <param name="assetName"></param> /// <returns>所有资源</returns> public Object[] LoadAssetWithSubAssets(string bundleName, string assetName) { //if (!nameBundleDic.ContainsKey(bundleName)) //{ // Debug.LogError("当前" + bundleName + "包没有加载,无法获取资源!"); // return null; //} //return nameBundleDic[bundleName].LoadAssetWithSubAssets(assetName); // 1.先判断缓存没缓存? if (nameCacheDic.ContainsKey(bundleName)) { Object[] assets = nameCacheDic[bundleName].GetAsset(assetName); if (assets != null) { return(assets); } } // 2.当前包有没有被加载 if (!nameBundleDic.ContainsKey(bundleName)) { Debug.LogError("当前" + bundleName + "包没有加载,无法获取资源!"); return(null); } // 3.当前包已经被加载了, Object[] asset = nameBundleDic[bundleName].LoadAssetWithSubAssets(assetName); TempObject tempAsset = new TempObject(); // 有这个缓存层,里面也有资源 , 但是这次获取资源的名字,是以前没缓存过的 if (nameCacheDic.ContainsKey(bundleName)) { // 直接加进去 nameCacheDic[bundleName].AddAsset(assetName, tempAsset); } else { // 当前包已经被加载了,但是 是第一次获取这个包里的资源 // 创建一个新的缓存层 AssetCaching caching = new AssetCaching(); caching.AddAsset(assetName, tempAsset); // 保存,下次使用 nameCacheDic.Add(bundleName, caching); } return(asset); }
/// <summary> /// 获取带有子物体的资源 /// </summary> /// <param name="assetName">资源名称</param> /// <returns>所有资源</returns> public Object[] LoadAssetWithSubAssets(string bundleName, string assetName) { //if (!nameBundleDict.ContainsKey(bundleName)) //{ // Debug.LogError("当前 " + bundleName + " 包没有加载,无法获取资源"); // return null; //} //return nameBundleDict[bundleName].LoadAssetWithSubAssets(assetName); //------------------------------------------------------------------- //先判断缓存没缓存 if (nameCacheDict.ContainsKey(bundleName)) { Object[] assets = nameCacheDict[bundleName].GetAsset(assetName); //安全校验 if (assets != null) { return(assets); } } //当前包有没有被加载 if (!nameBundleDict.ContainsKey(bundleName)) { Debug.LogError("当前 " + bundleName + " 包没有加载,无法获取资源"); return(null); } //当前的包已经被加载了 Object[] asset = nameBundleDict[bundleName].LoadAssetWithSubAssets(assetName); TempObject tmpAsset = new TempObject(asset); //有这个缓存层 里面也有资源 但是 这次获取的资源名字 是以前没缓存过的 if (nameCacheDict.ContainsKey(bundleName)) { //直接加进去 nameCacheDict[bundleName].AddAsset(assetName, tmpAsset); } else { // 但是 第一次获取这个包里面的资源 //创建一个新的缓存层 AssetCaching caching = new AssetCaching(); caching.AddAsset(assetName, tmpAsset); //保存到字典里面 方便下次使用 nameCacheDict.Add(bundleName, caching); } return(asset); }
/// <summary> /// 添加缓存 /// </summary> /// <param name="assetName"></param> /// <param name="asset"></param> public void AddAsset(string assetName, TempObject asset) { if (nameAssetDic.ContainsKey(assetName)) { Debug.LogError("此" + assetName + "资源已经加载!"); return; } // 缓存起来 nameAssetDic.Add(assetName, asset); }
private void SpawnSmoke() { TempObject smoke = effectsPool.GetPooledObject().GetComponent <TempObject>(); TempObjectInfo info = new TempObjectInfo(true, 0.2f, lifetime / 2f, lifetime / 2f, new Color(1, 1, 1, 0.5f)); smoke.Init( Quaternion.Euler(0, 0, Random.Range(0, 360f)), transform.position, smokeSprites [Random.Range(0, smokeSprites.Length)], info ); }
/// <summary> /// 添加缓存 /// </summary> /// <param name="assetname">资源名字</param> /// <param name="asset">资源</param> public void AddAsset(string assetname, TempObject asset) { if (NameAndAssetDict.ContainsKey(assetname)) { Debug.LogError("此" + assetname + "资源已经被加载!"); return; } else { //缓存资源 NameAndAssetDict.Add(assetname, asset); } }
public static IntPtr GetIntPtrOnHeap() { TempObject to = new TempObject(); s_o = to; unsafe { fixed(int *pFld = &to.field) { return(new IntPtr(pFld)); } } }
public static void PlayEffect(SimpleAnimation toPlay, Vector3 position, TempObjectInfo info) { GameObject o = instance.GetPooledObject(); SimpleAnimationPlayer anim = o.GetComponent <SimpleAnimationPlayer>(); TempObject tempObj = o.GetComponent <TempObject>(); tempObj.info = info; anim.anim = toPlay; tempObj.Init(Quaternion.identity, position, toPlay.frames[0]); anim.Play(); }
public static TempObject <T> TakeFirstUnused <T>(TempObject <T>[] entries) { for (int i = 0; i < entries.Length; ++i) { TempObject <T> obj = entries[i]; if (!obj.inUse) { obj.Take(); return(obj); } } throw new Exception("No more temporary objects available"); }
public static void ReturnUsed <T>(TempObject <T>[] entries, TempObject <T> obj) { for (int i = 0; i < entries.Length; ++i) { var entry = entries[i]; if (entry == obj) { entry.Return(); return; } } throw new Exception("Tried returning unknown object"); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { var dict = new Dictionary <String, TempObject>(); var oldDict = value as Dictionary <String, ModelObject>; foreach (var val in oldDict) { var temp = new TempObject(); temp.PrefabObject = val.Value as PrefabObject; temp.DefaultObject = val.Value as DefaultObject; dict.Add(val.Key, temp); } serializer.Serialize(writer, dict); }
private void PlayDeathEffect(Vector3 position, SimpleAnimation effect) { GameObject o = EffectPooler.instance.GetPooledObject(); SimpleAnimationPlayer animPlayer = o.GetComponent <SimpleAnimationPlayer>(); TempObject tempObj = o.GetComponent <TempObject>(); tempObj.GetComponent <SpriteRenderer>().sortingLayerName = "UI"; tempObj.info = new TempObjectInfo(true, 0f, effect.TimeLength - 2f, 1f); animPlayer.anim = effect; tempObj.Init(Quaternion.identity, position, effect.frames[0]); animPlayer.ignoreTimeScaling = true; animPlayer.Play(); }
/// <summary> /// 获取单个资源 /// </summary> /// <param name="assetName">资源名字</param> /// <returns>Obj类型的资源</returns> public Object LoadAsset(string bundleName, string assetName) { // 第一次加载 : 层层加载,并存到字典里; // 第二次加载 : 到字典里找,有就用,没有就再层层加载; // 1.先判断缓存没缓存? if (nameCacheDic.ContainsKey(bundleName)) { Object[] assets = nameCacheDic[bundleName].GetAsset(assetName); if (assets != null) { return(assets[0]); //获取单个嘛,肯定就一个 } } // 2.当前包有没有被加载 if (!nameBundleDic.ContainsKey(bundleName)) { Debug.LogError("当前" + bundleName + "包没有加载,无法获取资源!"); return(null); } // 3.当前包已经被加载了, Object asset = nameBundleDic[bundleName].LoadAsset(assetName); TempObject tempAsset = new TempObject(); // 有这个缓存层,里面也有资源 , 但是这次获取资源的名字,是以前没缓存过的 if (nameCacheDic.ContainsKey(bundleName)) { // 直接加进去 nameCacheDic[bundleName].AddAsset(assetName, tempAsset); } else { // 当前包已经被加载了,但是 是第一次获取这个包里的资源 // 创建一个新的缓存层 AssetCaching caching = new AssetCaching(); caching.AddAsset(assetName, tempAsset); // 保存,下次使用 nameCacheDic.Add(bundleName, caching); } return(asset); }
private void S7200Read() { while (true) { Client.DBRead(1, 4000, 2, buffer); byte[] bytes = new byte[2]; Array.Copy(buffer, 0, bytes, 0, 2); Array.Reverse(bytes); float temp = BitConverter.ToInt16(bytes, 0) / 10.0f; TempObject tempObject = new TempObject(); tempObject.temp = temp; tempObject.data_time = DateTime.Now; TerminalQueues.plcreadqueue.Enqueue(tempObject); Thread.Sleep(1500); //string json = Newtonsoft.Json.JsonConvert.SerializeObject(); } }
protected override void DoAction() { // Set the rotation for the effect Quaternion rot = GetRotation(); // Initialize the effect properties TempObjectInfo info = new TempObjectInfo(); info.targetColor = color; if (duration < 0) { duration = effect.TimeLength; } info.lifeTime = duration; info.fadeOutTime = 0.1f; lastPlayedEffect = EffectPooler.PlayEffect(effect, position, info); }
/// <summary> /// 获取带有子物体的资源 /// </summary> /// <param name="assetname">资源名称</param> /// <returns>所有资源</returns> public Object[] LoadAssetWithSubAssets(string assetbundlename, string assetname) { //先判断缓存层有没有缓存 if (NameAndCacheDict.ContainsKey(assetbundlename)) { //有缓存直接获取资源 Object[] assets = NameAndCacheDict[assetbundlename].GetAsset(assetname); //安全校验,排除缓存层存在但是资源不存在的情况 if (assets != null) { return(assets);//因为是获取带有子物体的资源,所以返回Object数组 } } //当前AB包没有被加载 if (!NameAndBundleDict.ContainsKey(assetbundlename)) { Debug.LogError("当前" + assetbundlename + "包没有加载,无法获取资源"); return(null); } else { //当前AB包已经被加载了,则获取带有子物体的资源数组 Object[] asset = NameAndBundleDict[assetbundlename].LoadAssetWithSubAssets(assetname); //封装该资源 TempObject tempAsset = new TempObject(asset); //缓存层已经被创建,缓存层里也有资源,但是我们要获取的那个资源不存在缓存层中 if (NameAndCacheDict.ContainsKey(assetbundlename)) { //直接把资源加入缓存层中 NameAndCacheDict[assetbundlename].AddAsset(assetname, tempAsset); } else { //第一次获取AB包里的资源,缓存层没有被创建,则新建一个缓存层 AssetCache cache = new AssetCache(); //把资源加入缓存层中 cache.AddAsset(assetname, tempAsset); //将缓存层保存到字典里 NameAndCacheDict.Add(assetbundlename, cache); } //返回带有子物体的资源数组 return(asset); } }
private void SmokeEffect() { TempObject smokeBomb = effectsPool.GetPooledObject().GetComponent <TempObject> (); TempObjectInfo info = new TempObjectInfo(true, 0f, smokeBombEffect.TimeLength * 0.9f, smokeBombEffect.TimeLength * 0.1f, new Color(1, 1, 1, 0.7f)); SimpleAnimationPlayer animPlayer = smokeBomb.GetComponent <SimpleAnimationPlayer> (); animPlayer.anim = smokeBombEffect; smokeBomb.Init( Quaternion.identity, transform.position, smokeBombEffect.frames[0], info ); animPlayer.Play(); }
private GameObject createItem(Item item) { GameObject TempObject; text.text = item.getName(); quantityText.text = "x" + item.getQuantity(); if (inventoryScript.GetComponent <Inventory>().isInHotbar(item) != 0) { hotbarNumberText.text = inventoryScript.GetComponent <Inventory>().isInHotbar(item).ToString(); } else { hotbarNumberText.text = ""; } TempObject = Instantiate(ExampleInventoryItem) as GameObject; TempObject.transform.parent = grid.transform; TempObject.transform.localScale = new Vector3(1f, 1f, 1f); TempObject.GetComponent <Button>().onClick.AddListener(() => ButtonClicked(item)); TempObject.SetActive(true); return(TempObject); }
/// <summary> /// 获取带有子物体的资源 /// </summary> /// <param name="bundleName"></param> /// <param name="assetName">资源名称</param> /// <returns></returns> public Object[] LoadAssetWithSubAssets(string bundleName, string assetName) { //先到缓存查找 if (nameCacheDict.ContainsKey(bundleName)) { Object[] assets = nameCacheDict[bundleName].GetAsset(assetName); //有可能比没有加入缓存,但资源已经加载 if (assets != null) { return(assets); } } //当前包没有被加载 if (!nameBundleDict.ContainsKey(bundleName)) { Debug.LogError("当前 " + bundleName + "包没有被加载,无法获取资源!"); return(null); } //当前包已经被加载 Object[] asset = nameBundleDict[bundleName].LoadAssetWithSubAssets(assetName); TempObject tmpAsset = new TempObject(asset); //有这个缓存层,并且里面有资源,但是这次获取的资源是之前没有缓存过的 //直接添加 if (nameCacheDict.ContainsKey(bundleName)) { nameCacheDict[bundleName].AddAsset(assetName, tmpAsset); } else { //第一次获取这个包里面的资源 AssetCaching catching = new AssetCaching(); catching.AddAsset(assetName, tmpAsset); //保存到字典 nameCacheDict.Add(bundleName, catching); } return(asset); }
public static void PlayEffect(SimpleAnimation toPlay, Vector3 position, bool randRotation = false, float fadeOutTime = 0f) { GameObject o = instance.GetPooledObject(); SimpleAnimationPlayer anim = o.GetComponent <SimpleAnimationPlayer>(); TempObject tempObj = o.GetComponent <TempObject>(); tempObj.info = new TempObjectInfo(true, 0f, toPlay.TimeLength - fadeOutTime, fadeOutTime, new Color(1, 1, 1, 0.8f)); anim.anim = toPlay; Quaternion rot; if (randRotation) { rot = Quaternion.Euler(0, 0, Random.Range(0, 360)); } else { rot = Quaternion.identity; } tempObj.Init(rot, position, toPlay.frames[0]); anim.Play(); }
/// <summary> /// Change Income and Cost displays when paid for /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PaidCheck_CheckedChanged(object sender, EventArgs e) { TempObject.Paid = PaidCheck.Checked; Income_Text.Text = TempObject.BuildIncome(); Costs_Text.Text = TempObject.BuildCosts(); }
// Update is called once per frame void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Input.GetMouseButton(0)) { Debug.Log("Pressed left click."); if (0.0f > m_fLastShot) { Debug.Log(m_fLastShot); m_fLastShot = m_fFireDelay; RaycastHit HitPos; if (Physics.Raycast(ray, out HitPos)) { Debug.Log("Raycast"); if (null != HitPos.point) { Debug.Log("Hit!"); GameObject TempObject; switch (m_iWeapon) { case 0: { TempObject = Instantiate(m_pCube0); } break; case 1: { TempObject = Instantiate(m_pCube1); } break; case 2: { TempObject = Instantiate(m_pCube2); } break; case 3: { TempObject = Instantiate(m_pCube3); } break; default: { TempObject = Instantiate(m_pCube0); } break; } TempObject.transform.position = m_Player.transform.position; TempObject.transform.rotation = m_Player.transform.rotation; TempObject.GetComponent <ProjectileScript>().SetDirection(Vector3.Normalize(new Vector3(HitPos.point.x - m_Player.transform.position.x, 0.0f, HitPos.point.z - m_Player.transform.position.z)), (m_fDamage * ((float)m_iSwapCombo % 10.0f) + 1.0f)); //sound effect for bullet FindObjectOfType <AudioManager>().Play("Laser"); } } } } if (Input.GetMouseButton(1)) { Debug.Log("Pressed right click."); } if (Input.GetMouseButton(2)) { Debug.Log("Pressed middle click."); } m_fLastShot -= Time.deltaTime; m_fComboTimer -= Time.deltaTime; if (0.0f > m_fComboTimer) { m_iSwapCombo = -1; SetWeapon(m_iWeapon); } }
public void SetTempObject(TempObject temperature) { this.tempObjectInternal = temperature; }
public static List <SetObjectHeroes> GetHeroesLayoutFromINI(string fileName) { string[] file = File.ReadAllLines(fileName); List <SetObjectHeroes> list = new List <SetObjectHeroes>(); SetObjectHeroes TempObject = new SetObjectHeroes(0, 0, Vector3.Zero, Vector3.Zero, 0, 10, new byte[8]); foreach (string s in file) { if (s.StartsWith("obj ")) { if (!(TempObject.List == 0 & TempObject.Type == 0)) { TempObject.CreateTransformMatrix(); list.Add(TempObject); } TempObject = null; TempObject = new SetObjectHeroes(Convert.ToByte(s.Substring(4, 2), 16), Convert.ToByte(s.Substring(6, 2), 16), Vector3.Zero, Vector3.Zero, 0, 10); } else if (s.StartsWith("link ")) { TempObject.Link = Convert.ToByte(s.Substring(5, 2)); } else if (s.StartsWith("rend ")) { TempObject.Rend = Convert.ToByte(s.Substring(5, 2)); } else if (s.StartsWith("v ")) { string[] j = s.Split(' '); TempObject.Position.X = Convert.ToSingle(j[1]); TempObject.Position.Y = Convert.ToSingle(j[2]); TempObject.Position.Z = Convert.ToSingle(j[3]); } else if (s.StartsWith("r ")) { string[] j = s.Split(' '); TempObject.Rotation.X = Convert.ToInt32(j[1]); TempObject.Rotation.Y = Convert.ToInt32(j[2]); TempObject.Rotation.Z = Convert.ToInt32(j[3]); } else if (s.StartsWith("b ")) { string[] j = s.Split(' '); TempObject.UnkBytes[0] = Convert.ToByte(j[1]); TempObject.UnkBytes[1] = Convert.ToByte(j[2]); TempObject.UnkBytes[2] = Convert.ToByte(j[3]); TempObject.UnkBytes[3] = Convert.ToByte(j[4]); TempObject.UnkBytes[4] = Convert.ToByte(j[5]); TempObject.UnkBytes[5] = Convert.ToByte(j[6]); TempObject.UnkBytes[6] = Convert.ToByte(j[7]); TempObject.UnkBytes[7] = Convert.ToByte(j[8]); } else if (s.StartsWith("misc ")) { if (s.Length == 9 * 9 + 4) { string NewMiscString = Regex.Replace(s.Substring(5), @"\s+", "");; List <byte> NewMiscSettings = new List <byte>(); for (int j = 0; j < 8 * 9; j += 2) { string byteasstring = new string(new char[] { NewMiscString[j], NewMiscString[j + 1] }); NewMiscSettings.Add(Convert.ToByte(byteasstring, 16)); } TempObject.MiscSettings = NewMiscSettings.ToArray(); } else { TempObject.HasMiscSettings = false; } } else if (s == "EndOfFile") { if (!(TempObject.List == 0 & TempObject.Type == 0)) { TempObject.CreateTransformMatrix(); list.Add(TempObject); } TempObject = null; } } return(list); }