private void Awake() { Audio1 = GlobalTools.GetGameObjectByName(AudioName); DontDestroyOnLoad(Audio1); ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.CHANGE_TEMP_AUDIO, ChangeTempAudio); ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.CHANGE_AUDIO, ChangeAudio); }
void ChangSuiDaoJiGuanAndGuai() { //出弹射地板 GameObject _db = null; float __x = 0; float __y = 0; if (GlobalTools.GetRandomNum() > 80) { _db = GlobalTools.GetGameObjectByName("DB_tanshe_1"); __x = DingDBPosL.transform.position.x + 3f + GlobalTools.GetRandomDistanceNums(1); __y = tl.position.y + 4.4f + GlobalTools.GetRandomDistanceNums(1); } else { _db = GlobalTools.GetGameObjectByName("DB_chang_1"); __x = DingDBPosL.transform.position.x + GetWidth() * 0.5F - 1 + GlobalTools.GetRandomDistanceNums(1); __y = tl.position.y + 4.4f + GlobalTools.GetRandomDistanceNums(1); } if (_db == null) { return; } _db.transform.position = new Vector2(__x, __y - xiajiangNums - GlobalTools.GetRandomDistanceNums(0.7f)); _db.transform.parent = maps.transform; }
GameObject GetGKImgAndPosition(string _name, float px = 0, float py = 0) { GameObject gkImg = GlobalTools.GetGameObjectByName("gkImg"); gkImg.transform.parent = _canva.transform; gkImg.transform.position = new Vector2(px, py); gkImg.name = _name; string _zb = GetCurrentMapZBByName(_name); if (GlobalMapDate.IsSpeMapByName(_name)) { gkImg.GetComponent <gkImgTextTest>().GetText("<color=#ff1111>speMap</color> " + _zb); } else { gkImg.GetComponent <gkImgTextTest>().GetText("<color=#000000>speMap</color> " + _zb); } imgMapObjArr.Add(gkImg); return(gkImg); }
//生成 爆炸特效 protected void Baozha() { //GameObject obj = GlobalTools.GetGameObjectInObjPoolByName(BaozhaName); GameObject obj = GlobalTools.GetGameObjectByName(BaozhaName); //print(" obj "+obj.name); //注意 命名后 再存入 对象池 避免出现数字 id bug obj.name = BaozhaName; print(" name " + obj.name + " pos " + obj.transform.position + " xianshi " + obj.gameObject.activeSelf + " --thisPos " + this.transform.position); //obj.GetComponent<TX_removeSelf>().GetStart(); obj.gameObject.SetActive(true); if (obj == null) { return; } //obj.transform.position = new Vector2(this.gameObject.transform.position.x, this.gameObject.transform.position.y+2); obj.transform.position = this.gameObject.transform.position; obj.transform.parent = this.gameObject.transform.parent; //obj.GetComponent<JN_base>().GetAtkObjIn(AtkObj); //obj.GetComponent<ParticleSystem>().Stop(); obj.GetComponent <ParticleSystem>().Simulate(0, true); obj.GetComponent <ParticleSystem>().Play(); //print(" ----> 粒子数 "+obj.GetComponent<ParticleSystem>().particleCount); jishiNums = 0; IsHasBaozha = true; }
void GetTest(string objName, float _x = 0, float _y = 0) { GameObject obj = GlobalTools.GetGameObjectByName(objName); if (obj != null) { obj.transform.position = new Vector3(_x, _y, obj.transform.position.z); } //print("_w "+obj.GetComponent<MeshFilter>().mesh.bounds.size.x); SpriteRenderer objRen = obj.GetComponent <SpriteRenderer>(); print("w> " + objRen.bounds.size + " order " + objRen.sortingOrder); objRen.sortingOrder = 28; //objRen.bounds.size = new Vector3(60, 60, 0.2f); print("w2> " + objRen.bounds.size + " order " + objRen.sortingOrder); GameObject diban = GlobalTools.FindObjByName("diban1"); print(">>>> " + diban.GetComponent <Terrain>()); GameObject jing = GlobalTools.FindObjByName("jing_cao_2"); print("jing " + jing); print("--------------> " + GlobalTools.GetJingW(jing)); print(GlobalTools.GetPointWorldPosByName(GlobalTools.FindObjByName("yj_shu_1"), "tl")); }
void GetJiguang() { Jiguang = GlobalTools.GetGameObjectByName("Skill_JiguangSaoshe"); Jiguang.gameObject.SetActive(true); Jiguang.transform.position = zidanDian1.position; Jiguang.transform.localEulerAngles = new Vector3(0, 0, 0); }
void GetSkill(UEvent e) { List <RectTransform> hzs = (List <RectTransform>)e.eventParams; if (_obj != null) { GetSkillOut(_obj); } skill = null; for (var i = 0; i < hzs.Count; i++) { if (i == this.boxNum - 1) { if (hzs[i] == null) { continue; } skill = hzs[i]; string jnName = "jn_" + hzs[i].GetComponent <HZDate>().objName; //if (Globals.isDebug) print("name "+jnName+" "+ hzs[i].GetComponent<HZDate>()._cd); _obj = GlobalTools.GetGameObjectByName(jnName); GetSkillIn(_obj); } } }
void OverOutObj() { if (!OutObjPos) { return; } if (!IsOverOutObj || OverOutObjName == "") { //显示 闪光之类的 GameObject shanguang = GlobalTools.GetGameObjectByName("TX_HZchuxianXingXing"); shanguang.transform.position = OutObjPos.position; shanguang.transform.parent = this.transform.parent.parent; return; } //播声音 print("OverOutObjName " + OverOutObjName); GameObject outObj = GlobalTools.GetGameObjectByName(OverOutObjName); if (outObj == null) { return; } outObj.transform.position = OutObjPos.position; print(" ------obj " + outObj.name); outObj.transform.parent = this.transform.parent.parent; }
protected virtual void SetDBPos() { if (IsHasSetDB) { return; } IsHasSetDB = true; if (maps == null) { maps = GlobalTools.FindObjByName("maps"); } if (maps == null) { return; } //print("*******************************************跳跃地板"); string tiaoyuediban = "tiaoyueDBD_" + Globals.mapTypeNums; List <string> tiaoyuedibanDArr = GetDateByName.GetInstance().GetListByName(tiaoyuediban, MapNames.GetInstance()); GameObject dibanD = GlobalTools.GetGameObjectByName(tiaoyuedibanDArr[GlobalTools.GetRandomNum(tiaoyuedibanDArr.Count)]); float _x1 = tl.position.x + 5; float _x2 = rd.position.x - 5; float _x = _x1 + GlobalTools.GetRandomDistanceNums(Mathf.Abs(_x2 - _x1)); float _y = tl.position.y - 4 + GlobalTools.GetRandomDistanceNums(8); dibanD.transform.position = new Vector3(_x, _y, 0); dibanD.transform.parent = maps.transform; //if (IsPenSheZiDanJG) GetPenSheZiDanJG(); }
void ShowPlotStr(int strId = 1) { //根据 nextId获取 相应的 对话内容 string _msgNR = GetStrByStrId(strId); if (_msgNR == "") { PlotOver(); return; } //根据 内容 获取 各个键值 GetStrMsg(_msgNR); if (_choseType == "dan") { //找到 对话框 哪个 GetTalkBar(); } else { //做多选 _cBar.GetComponent <UI_talkBar>().StopCanClick(); //_cBar.GetComponent<UI_talkBar>().BgImgColorChange(); //显示 选择题 GameObject ui_choseBar = GlobalTools.GetGameObjectByName("UI_talkChoseBar"); ui_choseBar.transform.position = new Vector2(player.transform.position.x + 3.6f * player.transform.localScale.x, player.transform.position.y); //player.transform.position; ui_choseBar.GetComponent <UI_talkChose>().GetStrMsg(_msg); } }
void GuaiOut() { if (GuaiList.Count == 0) { return; } float _x = 0; float _y = this.transform.position.y + posY; for (int i = 0; i < GuaiList.Count; i++) { if (i % 2 == 0) { _x = this.transform.position.x + ToCenterDis + GlobalTools.GetRandomDistanceNums(3); } else { _x = this.transform.position.x - ToCenterDis - GlobalTools.GetRandomDistanceNums(3); } _y += GlobalTools.GetRandomDistanceNums(4); Vector2 pos = new Vector2(_x, _y); GameObject guai = GlobalTools.GetGameObjectByName(GuaiList[i]); guai.transform.position = pos; if (GlobalTools.FindObjByName("MainCamera") != null) { GlobalTools.FindObjByName("MainCamera").GetComponent <GameControl>().GuaiList.Add(guai); } } }
public void GetTX(string txName) { tx = null; tx = GlobalTools.GetGameObjectByName(txName); Vector2 v = this.GetComponent<GameBody>().groundCheck.position; //tx.transform.parent = this.transform; //print(this.transform.localScale); tx.transform.position = new Vector2(v.x, v.y - 0.2f); if (tx.GetComponent<JN_TXgensui>()) { tx.GetComponent<JN_TXgensui>().GetGenSuiObj(this.gameObject); } //if (this.transform.localScale.x == -1) //{ // tx.transform.position = new Vector2(v.x, v.y - 0.6f); //} //else { // tx.transform.position = new Vector2(v.x, v.y); //} ;//new Vector2(0, -3); //print("tx.transform.position "+ tx.transform.position); //tx.transform.position = new Vector2(0,-3); //print("position "+tx.transform.position); //if(this.gameObject!=null && this.gameObject.activeSelf) print("this player "+this.gameObject.name+" "+ this.gameObject.activeSelf); //if(this.gameObject.activeInHierarchy) if (this.gameObject != null && this.gameObject.activeSelf) { if (this.gameObject.activeSelf) StartCoroutine(IEDestory2ByTime(tx, 0.8f)); } }
void GetJingAndPosByJingName(string JingName, string type = "") { GameObject jing = GlobalTools.GetGameObjectByName(JingName); jing.name = JingName; float __x = TLPos.position.x + GlobalTools.GetRandomDistanceNums(GetWidth()); float __y = TLPos.position.y - 1 + GlobalTools.GetRandomDistanceNums(2); float __z = jing.transform.position.z; if (type == "qian") { if (jing.GetComponent <ParticleSystem>()) { jing.GetComponent <ParticleSystemRenderer>().sortingOrder = 250; __z = -2 - GlobalTools.GetRandomDistanceNums(4); //__y += -6 + GlobalTools.GetRandomDistanceNums(10); __y = TLPos.position.y - GlobalTools.GetRandomDistanceNums(8); } } else if (type == "bei") { if (jing.GetComponent <ParticleSystem>()) { jing.GetComponent <ParticleSystemRenderer>().sortingOrder = -160; __y = TLPos.position.y - 2 + GlobalTools.GetRandomDistanceNums(6); __z = 6 + GlobalTools.GetRandomDistanceNums(4); } } jing.transform.position = new Vector3(__x, __y, __z); jing.transform.parent = this.transform; }
void LianXianMaps(GameObject currentMap, GameObject gkImg, string fx) { GameObject xian = null; if (fx == "u") { xian = GlobalTools.GetGameObjectByName("map_xian2"); xian.transform.position = new Vector2(currentMap.transform.position.x, currentMap.transform.position.y + currentMap.GetComponent <RectTransform>().rect.height *0.5f + xian.GetComponent <RectTransform>().rect.height *0.4f); } else if (fx == "d") { xian = GlobalTools.GetGameObjectByName("map_xian2"); xian.transform.position = new Vector2(currentMap.transform.position.x, currentMap.transform.position.y - currentMap.GetComponent <RectTransform>().rect.height * 0.5f - xian.GetComponent <RectTransform>().rect.height * 0.4f); } else if (fx == "r") { xian = GlobalTools.GetGameObjectByName("map_xian1"); xian.transform.position = new Vector2(currentMap.transform.position.x + currentMap.GetComponent <RectTransform>().rect.width * 0.5f + xian.GetComponent <RectTransform>().rect.width * 0.4f, currentMap.transform.position.y); } else if (fx == "l") { xian = GlobalTools.GetGameObjectByName("map_xian1"); xian.transform.position = new Vector2(currentMap.transform.position.x - currentMap.GetComponent <RectTransform>().rect.width * 0.5f - xian.GetComponent <RectTransform>().rect.width * 0.4f, currentMap.transform.position.y); } xian.name = currentMap.name + "#" + fx; xian.transform.parent = _canva.transform; xian.GetComponent <GKMapXian>().LianJieMap(currentMap.name, gkImg.name); }
void GetWu(string wuName, Vector2 qidian, Vector2 zhongdian, int SDOrder, Color color) { string _wuName = "wu_1_1"; GameObject _wu = GlobalTools.GetGameObjectByName(_wuName); //补的雾 看后面的需求 //GameObject _wu2 = GlobalTools.GetGameObjectByName(_wuName); _wu.transform.parent = GlobalTools.FindObjByName("maps").transform; float _w = GlobalTools.GetJingW(_wu); float _h = GlobalTools.GetJingH(_wu); float _w2 = Mathf.Abs(zhongdian.x - qidian.x); float _h2 = Mathf.Abs(zhongdian.y - qidian.y) + 5; _wu.transform.localScale = new Vector3(_w2 / _w + 0.6f, _h2 / _h * 3, 1); _wu.transform.position = new Vector2(qidian.x + _w2 * 0.5f + (_w2 - GlobalTools.GetJingW(_wu)) * 0.5f, zhongdian.y + GlobalTools.GetJingH(_wu) * 0.5f + 2); //print(">????????????????????????????????????????????????????????????? "+ _w+" >-缩放后 " +GlobalTools.GetJingW(_wu)); GlobalTools.SetMapObjOrder(_wu, SDOrder); //print("雾的宽度 "+_w+" _w2宽度 "+_w2+" 宽度缩放比例 "+_w2/_w+" weizhi "+_wu.transform.position); //print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+_wu.transform.position+" 起点 "+qidian+" 终点 "+zhongdian); //改变雾的颜色 _wu.GetComponent <SpriteRenderer>().color = color;// new Color(0.1f,1f,1f,0.5f);//new Color((129 / 255)f, (69 / 255)f, (69 / 255)f, (255 / 255)f); //Color.red; }
void ShowBullets() { if (ShowBulletsAudio && !ShowBulletsAudio.isPlaying) { ShowBulletsAudio.Play(); } float radian = 3.14f * 2 / BulletNums; float r = R; Vector2 v2 = new Vector2(this.transform.position.x, this.transform.position.y); for (int i = 0; i < BulletNums; i++) { GameObject _bullet = GlobalTools.GetGameObjectByName(BulletName); //_bullet.transform.position = new Vector2(1000, 1000); if (_bullet) { _bullet.GetComponent <JN_Date>().team = roleDate.team; BulletsList.Add(_bullet); //_bullet.transform.position = GetDateByName.GetInstance().GetTransformByName("pos" + i, this).transform.position; _bullet.transform.position = GetXYPosByRadian(i, radian * i, r) + v2; if (_bullet.GetComponent <JN_ZidanWeirao>()) { _bullet.GetComponent <JN_ZidanWeirao>().GetTheCenterObj(this.gameObject); } } } }
private void GetZYBJCaopi() { //throw new NotImplementedException(); int nums = 1 + GlobalTools.GetRandomNum(3); if (nums == 0) { return; } // 数组名字 ZYBJCaopi_1 string ListName = "ZYBJCaopi_1"; List <string> CaopiArr = GetDateByName.GetInstance().GetListByName(ListName, MapNames.GetInstance()); for (int i = 0; i < nums; i++) { string jingName = CaopiArr[GlobalTools.GetRandomNum(CaopiArr.Count)]; //print("-----------------> 啥啊 "+jingName); GameObject jing = GlobalTools.GetGameObjectByName(jingName); jing.transform.parent = maps.transform; float W = GlobalTools.GetJingW(jing); float __x = tl.position.x + W * 0.5f - 1 + GlobalTools.GetRandomDistanceNums((GetWidth() - W + 2)); float __y = tl.position.y - 2.5f + GlobalTools.GetRandomDistanceNums(0.5f); float __z = 2.5f + 0.4f * i; jing.GetComponent <SpriteRenderer>().sortingOrder = -30 - i % 3; jing.transform.position = new Vector3(__x, __y, __z); } }
void Zhugandao() { //简单型 1 2 3 //GameObject zhugandao = ObjectPools.GetInstance().SwpanObject2(); //GlobalTools.GetGameObjectByName("diban_1_1"); GameObject zhugandao = GlobalTools.GetGameObjectByName("diban_1_1"); zhugandao.transform.position = Vector3.zero; //做还是不做哦 好烦躁啊 }
void ZhaoHuan() { print("zhaohuan " + ZhaohuanName); if (ZhaohuanName != "") { GameObject guai = GlobalTools.GetGameObjectByName(ZhaohuanName); guai.transform.position = ZhaohuanOutPos.position; } }
void PlayBGAudio() { BGAudio = GlobalTools.GetGameObjectByName("AudioManager"); DontDestroyOnLoad(BGAudio); //if (BGAudio) //{ // BGAudio.GetComponent<AudioSource>().Play(); //} }
void GetPlayBag() { if (GlobalTools.FindObjByName("UI_Bag") == null) { //加载背包 GlobalTools.GetGameObjectByName("UI_Bag"); } //GlobalTools.FindObjByName("PlayerUI").GetComponent<PlayerUI>().skill_bar.GetComponent<UI_ShowPanel>().GetAllHZDate(); }
GameObject GetGKImgAndPosition(string _name, float px = 0, float py = 0) { GameObject gkImg = GlobalTools.GetGameObjectByName("gkImg"); gkImg.transform.parent = _canva.transform; gkImg.transform.position = new Vector2(px, py); gkImg.name = _name; return(gkImg); }
void DuTXDaShow() { GameObject duTX = GlobalTools.GetGameObjectByName(DuTXName); duTX.transform.position = this.transform.position; duTX.transform.parent = this.transform; duTX.transform.localScale = new Vector3(2, 2, 2); duTX.GetComponent <ParticleSystem>().Play(); }
void GetDBShuiMian() { if (ShuiMianDBNums == 0) { return; } List <string> db_shuimians = GetDateByName.GetInstance().GetListByName("db_shuimian_" + Globals.mapTypeNums.ToString(), MapNames.GetInstance()); //MapNames.GetInstance().GetCanRandomUSEJYGName("db_shuimian_"+ Globals.mapTypeNums.ToString()); //MapNames.GetInstance().db_shuimian+"_"+Globals.mapTypeNums.ToString(); if (db_shuimians.Count == 0) { return; } int duans = ShuiMianDBNums; //GameObject maps = GlobalTools if (ShuiMianDBNums == 100) { //=100的时候 根据 距离来生成 地板个数 int nums = (int)Mathf.Abs(thePos2.position.x - thePos1.position.x) / 10 - 2; if (nums < 0) { return; } duans = nums; } float _distances = Mathf.Abs(thePos2.position.x - thePos1.position.x) / duans; float __x = 0; float __y = 0; if (duans == 1) { _distances *= 0.5f; } for (int i = 0; i < duans; i++) { if (ShuiMianDBNums == 100 && i == duans - 1) { continue; } __x = thePos1.position.x + _distances * (i + 1) - 0.5f + GlobalTools.GetRandomDistanceNums(1); __y = thePos1.position.y - 1.9f; GameObject db_shuimian = GlobalTools.GetGameObjectByName(db_shuimians[GlobalTools.GetRandomNum(db_shuimians.Count)]); db_shuimian.transform.position = new Vector2(__x, __y); int _order = 6 + i % 6; GlobalTools.SetMapObjOrder(db_shuimian, _order); db_shuimian.transform.parent = maps.transform; } }
void Gaoraodan() { float __x = 5 + GlobalTools.GetRandomDistanceNums(9); float __y = 4 + GlobalTools.GetRandomDistanceNums(16); GameObject o = GlobalTools.GetGameObjectByName("TX_GanraoDan"); o.name = "TX_GanraoDan"; o.GetComponent <Rigidbody2D>().velocity = new Vector2(__x, __y); o.transform.position = GanraoDanPos.position; o.transform.parent = this.transform.parent; }
void GameOver(UEvent e) { isGameOver = true; if (dieScreen == null) { dieScreen = GlobalTools.GetGameObjectByName("DieScreen"); dieScreen.GetComponent <DieScreen>().StartAC(); isInFromSave = true; } //GetGameDateStart(); }
void GetJipao() { //JipaoFSPos; float __x = 140; float __y = 0; GameObject o = GlobalTools.GetGameObjectByName("TX_Jipao"); o.name = "TX_Jipao"; o.GetComponent <Rigidbody2D>().velocity = new Vector2(__x, __y); o.transform.position = new Vector3(JipaoFSPos.position.x + 1, JipaoFSPos.position.y + 0.3f - GlobalTools.GetRandomDistanceNums(0.6f), JipaoFSPos.position.z); //JipaoFSPos.position; o.transform.parent = this.transform.parent; }
void GetObjByNameInGezi(string ObjName, RectTransform gz) { print("###ObjName " + ObjName); //GameObject obj = Resources.Load(ObjName) as GameObject; //obj = Instantiate(obj); GameObject obj = GlobalTools.GetGameObjectByName(ObjName); //obj.transform.parent = this.transform; obj.transform.SetParent(this.transform); RectTransform hz = obj.GetComponent <RectTransform>(); gz.GetComponent <Gezi>().GetInObj(hz); }
void GetSetUI() { if (setUI == null) { setUI = GlobalTools.GetGameObjectByName("UI_set"); GlobalSetDate.instance.IsChangeScreening = true; } else { GlobalSetDate.instance.IsChangeScreening = false; DestroyImmediate(setUI, true); } }
void SetLiziByNums(int nums, List <string> liziList, float _x1, float _x2, float _y) { for (var i = 0; i < nums; i++) { //print("----------> "+jingNameTou); string jingName = liziList[GlobalTools.GetRandomNum(liziList.Count)]; //print("-----------------> 啥啊 "+jingName); GameObject jing = GlobalTools.GetGameObjectByName(jingName); jing.transform.parent = GlobalTools.FindObjByName("maps").transform; //public static void SetLizi(GameObject jingObj, float _x1, float _x2, float _y, int i, int nums) GlobalTools.SetLizi(jing, _x1, _x2, _y, i, nums); } }