public static void Init(Vector3 spawn, Vector3 forw, InventoryItem weapon, AttackDes att, MeteorUnit owner) { GameObject dartObj = GameObject.Instantiate(ResMng.LoadPrefab("DartLoader"), spawn, Quaternion.identity, null) as GameObject; dartObj.layer = LayerMask.NameToLayer("Flight"); DartLoader dart = dartObj.GetComponent <DartLoader>(); dart.LoadAttack(weapon, forw, att, owner); }
public override void OnRefresh(int message, object param) { switch (message) { case ADD: ServerInfo info = param as ServerInfo; GameObject prefab = ResMng.LoadPrefab("SelectListItem") as GameObject; InsertServerItem(info, prefab); break; } }
void Init() { ServerListRoot = Control("ServerListRoot"); GameObject prefab = ResMng.LoadPrefab("SelectListItem") as GameObject; for (int i = 0; i < serverList.Count; i++) { GameObject.Destroy(serverList[i]); } serverList.Clear(); for (int i = 0; i < Main.Ins.GameStateMgr.gameStatus.ServerList.Count; i++) { InsertServerItem(Main.Ins.GameStateMgr.gameStatus.ServerList[i], prefab); } GameObject defaultServer = Control("SelectListItem"); Text text = Control("Text", defaultServer).GetComponent <Text>(); Control("Delete").GetComponent <Button>().onClick.AddListener(() => { //不能删除默认 if (selectServer != null) { int selectServerId = Main.Ins.GameStateMgr.gameStatus.ServerList.IndexOf(selectServer); if (selectServerId != -1) { GameObject.Destroy(serverList[selectServerId]); serverList.RemoveAt(selectServerId); Main.Ins.CombatData.OnServiceChanged(-1, Main.Ins.GameStateMgr.gameStatus.ServerList[selectServerId]); Main.Ins.GameStateMgr.gameStatus.ServerList.RemoveAt(selectServerId); } if (selectServerId >= serverList.Count) { selectServerId = 0; } selectServer = Main.Ins.GameStateMgr.gameStatus.ServerList[selectServerId]; selectedBtn = null; } }); Control("Close").GetComponent <Button>().onClick.AddListener(() => { OnPreviousPress(); }); Control("AddHost").GetComponent <Button>().onClick.AddListener(() => { Main.Ins.DialogStateManager.ChangeState(Main.Ins.DialogStateManager.HostEditDialogState); }); text.text = Main.Ins.CombatData.Server.ServerName + string.Format(":{0}", Main.Ins.CombatData.Server.ServerPort); }
void Init() { weaponSubType = EquipWeaponType.Sword; if (CameraForWeapon == null) { CameraForWeapon = GameObject.Instantiate(ResMng.LoadPrefab("CameraForWeapon")) as GameObject; CameraForWeapon.Identity(null); WeaponModelParent = Control("WeaponParent", CameraForWeapon); wload = WeaponModelParent.GetComponent <WeaponLoader>(); wload.Init(); } WeaponRoot = Control("WeaponRoot"); Control("Equip").GetComponent <Button>().onClick.AddListener(() => { ChangeWeaponCode(); }); Control("Close").GetComponent <Button>().onClick.AddListener(OnBackPress); for (int i = 0; i < 12; i++) { string control = string.Format("Tab{0}", i); Control(control).GetComponent <UITab>().onValueChanged.AddListener(ChangeWeaponType); } if (load == null) { load = Main.Ins.StartCoroutine(AddWeapon()); } }
//把飞镖显示出来.尺寸*2,否则看不清 public void LoadWeapon() { InventoryItem item = Weapon; if (item.Info().MainType == (int)EquipType.Weapon) { float scale = 2.0f; WeaponDatas.WeaponDatas weaponProperty = U3D.GetWeaponProperty(item.Info().UnitId); string weaponR = ""; weaponR = weaponProperty.WeaponR; if (!string.IsNullOrEmpty(weaponR)) { GameObject weaponPrefab = ResMng.LoadPrefab(weaponR) as GameObject; if (weaponPrefab == null) { GMCFile fGmcL = Main.Ins.GMCLoader.Load(weaponR); DesFile fDesL = Main.Ins.DesLoader.Load(weaponR); if (fGmcL != null && fDesL != null) { GenerateWeaponModel(weaponR, fGmcL, fDesL, scale, weaponProperty.TextureL); } else if (fGmcL == null && fDesL != null) { GMBFile fGmbL = Main.Ins.GMBLoader.Load(weaponR); GenerateWeaponModel(weaponR, fGmbL, fDesL, scale, weaponProperty.TextureL); } } else { if (R != null) { DestroyImmediate(R); } GameObject objWeapon = GameObject.Instantiate(weaponPrefab); objWeapon.layer = LayerMask.NameToLayer("Flight"); R = objWeapon.transform; //L = new GameObject().transform; R.SetParent(WeaponRoot); R.localPosition = Vector3.zero; //这种导入来的模型,需要Y轴旋转180,与原系统的物件坐标系存在一些问题 R.localRotation = new Quaternion(0, 1, 0, 0); R.name = weaponR; R.localScale = Vector3.one; //每个武器只能有一个碰撞盒 BoxCollider box = R.GetComponentInChildren <BoxCollider>(); if (box != null) { box.enabled = false; //box.gameObject.tag = "Flight"; box.gameObject.layer = LayerMask.NameToLayer("Flight"); } else { Debug.LogError("新增武器上找不到碰撞盒[除了暗器火枪飞轮外都应该有碰撞盒]"); } } } } }