/// <summary> /// 显示3D模型 /// </summary> /// <param name="card"></param> public void Show3DModel() { ModelCear(); m_Point = GameObject.Find("pos").transform; ArtresourceTemplate m_Artresourcedata = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(m_Card.GetHeroData().GetHeroViewID()); GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(m_Artresourcedata.getArtresources()); if (_AssetRes != null) { if (_AssetRes.GetComponent <NavMeshAgent>() != null) { _AssetRes.GetComponent <NavMeshAgent>().enabled = false; } m_Card3Dmodel = Instantiate(_AssetRes, m_Point.position, m_Point.rotation) as GameObject; float _zoom = m_Artresourcedata.getArtresources_zoom(); m_Card3Dmodel.transform.localScale = new UnityEngine.Vector3(_zoom, _zoom, _zoom); m_Card3Dmodel.transform.parent = m_Point; ////设置3D模型摩擦力 //m_Card3Dmodel.rigidbody.angularDrag = 2.8f; //m_Card3Dmodel.rigidbody.mass = 1.5f; Animation anim = m_Card3Dmodel.GetComponent <Animation>(); if (anim == null) { return; } m_Card3Dmodel.GetComponent <Animation>().Play("Nidle1"); m_Card3Dmodel.GetComponent <Animation>().wrapMode = WrapMode.Loop; } }
/// <summary> /// 显示3D模型 /// </summary> /// <param name="card"></param> IEnumerator Show3DModel() { ArtresourceTemplate m_Artresourcedata = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(mObjectCard.GetHeroData().GetHeroViewID()); GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(m_Artresourcedata.getArtresources()); while (AssetLoader.Inst.IsReadyOver == false) { yield return(1); } ClearModel(); GameObject go = GameObject.Find("pos"); if (go == null) { GameObject ModelViewRoom = GameObject.Find("ModelViewRoom"); if (ModelViewRoom == null) { Vector3 _pos = new Vector3(5000, 0, 0); ModelViewRoom = Instantiate(Resources.Load("UI/Prefabs/UI_Home/MainHome/ModelViewRoom"), _pos, Quaternion.identity) as GameObject; ModelViewRoom.name = "ModelViewRoom"; } m_Point = ModelViewRoom.transform.FindChild("pos"); m_Point.localPosition = new Vector3(m_Point.localPosition.x + 0.2f, m_Point.localPosition.y, m_Point.localPosition.z); GameObject camObj = m_Point.FindChild("Camera").gameObject; camObj.SetActive(true); } else { m_Point = GameObject.Find("pos").transform; } if (_AssetRes != null) { if (_AssetRes.GetComponent <NavMeshAgent>() != null) { _AssetRes.GetComponent <NavMeshAgent>().enabled = false; } m_Card3Dmodel = Instantiate(_AssetRes, m_Point.position, m_Point.rotation) as GameObject; float _zoom = m_Artresourcedata.getArtresources_zoom(); m_Card3Dmodel.transform.localScale = new UnityEngine.Vector3(_zoom, _zoom, _zoom); m_Card3Dmodel.transform.parent = m_Point; ////设置3D模型摩擦力 //m_Card3Dmodel.rigidbody.angularDrag = 2.8f; //m_Card3Dmodel.rigidbody.mass = 1.5f; Animation anim = m_Card3Dmodel.GetComponent <Animation>(); if (anim != null) { m_Card3Dmodel.GetComponent <Animation>().Play("Nidle1"); m_Card3Dmodel.GetComponent <Animation>().wrapMode = WrapMode.Loop; } } }
/// <summary> /// 显示3D模型 /// </summary> /// <param name="card"></param> public void Show3DModel(ObjectCard card, int resId = 0) { ModelCear(); if (m_Point == null) { //ModelViewRoom = Instantiate(Resources.Load("UI/Prefabs/UI_Home/ModelViewRoom"), new Vector3(-5000, 0, 0), Quaternion.identity) as GameObject; m_Point = GameObject.Find("pos").transform; } if (resId == 0) { m_heroShowID = card.GetHeroData().GetHeroViewID(); } else { m_heroShowID = resId; } m_Artresourcedata = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(m_heroShowID); GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(m_Artresourcedata.getArtresources()); if (_AssetRes == null) { return; } if (_AssetRes != null && _AssetRes.GetComponent <NavMeshAgent>() != null) { _AssetRes.GetComponent <NavMeshAgent>().enabled = false; } m_Card3Dmodel = Instantiate(_AssetRes, m_Point.position, m_Point.rotation) as GameObject; float _zoom = m_Artresourcedata.getArtresources_zoom(); m_Card3Dmodel.transform.localScale = new UnityEngine.Vector3(_zoom, _zoom, _zoom); m_Card3Dmodel.transform.parent = m_Point; //设置3D模型摩擦力 m_Card3Dmodel.rigidbody.angularDrag = 2.8f; m_Card3Dmodel.rigidbody.mass = 1.5f; Animation anim = m_Card3Dmodel.GetComponent <Animation>(); if (anim == null) { return; } m_Card3Dmodel.GetComponent <Animation>().Play("Nidle1"); m_Card3Dmodel.GetComponent <Animation>().wrapMode = WrapMode.Loop; }
private void OnEnemyOnDie(GameEvent ge) { CurrentMonsterDieCount++; for (int i = 0; i < CurrentAllMonsterdataList.Count; ++i) { if (CurrentAllMonsterdataList[i].MonsterPointdataList.Count <= 0) { continue; } if (CurrentAllMonsterdataList[i].MonsterPointdataList[0].Entertype == MonsterEnterType.Bench && CurrentAllMonsterdataList[i].MonsterPointdataList[0].BenchCount == CurrentMonsterDieCount) { int fightCount = ObjectSelf.GetInstance().IsLimitFight ? ObjectSelf.GetInstance().LimitFightMgr.m_RoundNum : CurrentFightCount; int id = SceneObjectManager.GetInstance().GetMosnterBundleRes(fightCount, i); MonsterTemplate pRow = (MonsterTemplate)DataTemplate.GetInstance().m_MonsterTable.getTableData(id); ArtresourceTemplate art = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(pRow.getArtresources()); string _res = art.getArtresources(); GameObject _Monster = AssetLoader.Inst.GetAssetRes(_res); GameObject obj = Instantiate(_Monster, CurrentAllMonsterdataList[i].MyPos, CurrentAllMonsterdataList[i].MyAngle) as GameObject; float _zoom = art.getArtresources_zoom() * pRow.getMonsterEnlarge(); obj.transform.localScale = new UnityEngine.Vector3(_zoom, _zoom, _zoom); MonsterObjList.Add(obj); SetMonsterBirthState(obj, CurrentAllMonsterdataList[i], false, i); } } //X_GUID monsterGuid = ge.data as X_GUID; //if (monsterGuid != null) //{ // //判断前排英雄是否消失; // //TODO::这里应该考虑到是否有支援怪物(和策划确认了不要支援怪物了2015/10/30/11.20); // //List<ObjectMonster> monsters = SceneObjectManager.GetInstance().GetSceneMonsterList(); // //if (monsters != null && monsters.Count > 0) // //{ // // //写死的阵型,前2后3; // // for (int i = 0; i < 2; i++) // // { // // } // //} // if (IsFrontRowDie()) // { // SceneObjectManager.GetInstance().ObjectHeroMoveTarget(); // } //} }
public void Show3DModel(ObjectCard _card) { ModelCear(); if (_Point == null) { //Vector3 _pos = gameObject.transform.parent.parent.Find("UI_Camera1").GetComponent<Camera>().ScreenToWorldPoint(_confirm.transform.localPosition); Vector3 _pos = new Vector3(5000, 0, 0); ModelViewRoom = Instantiate(Resources.Load("UI/Prefabs/UI_Home/MainHome/ModelViewRoom"), _pos, Quaternion.identity) as GameObject; ModelViewRoom.name = "ModelViewRoom"; _Point = ModelViewRoom.transform.FindChild("posPopUp"); _Point.localPosition = new Vector3(_Point.localPosition.x + 0.2f, _Point.localPosition.y, _Point.localPosition.z); } SetCameraActive(true); //通过英雄数据表中的资源数据表ID得到资源表数据 ArtresourceTemplate _Artresourcedata = new ArtresourceTemplate(); _Artresourcedata = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(_card.GetHeroData().GetHeroViewID()); //通过资源表获取到角色默认美术资源(名称) 通过该名称获取到动态加载数据返回一个对象 GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(_Artresourcedata.getArtresources()); //Debug.Log(_Artresourcedata.getArtresources()); //实例化该对象 if (_AssetRes != null) { Card3Dmodel = Instantiate(_AssetRes, _Point.position, _Point.rotation) as GameObject; float _zoom = _Artresourcedata.getArtresources_zoom(); Card3Dmodel.transform.localScale = new UnityEngine.Vector3(_zoom, _zoom, _zoom); Card3Dmodel.transform.parent = _Point; //设置3D模型摩擦力 Card3Dmodel.rigidbody.angularDrag = 1; Card3Dmodel.rigidbody.mass = 1; //_obj.transform.localScale = new Vector3(1.3f,1.3f,1.3f); Animation anim = Card3Dmodel.GetComponent <Animation>(); if (anim == null) { return; } Card3Dmodel.GetComponent <Animation>().Play("Nidle1"); Card3Dmodel.GetComponent <Animation>().wrapMode = WrapMode.Loop; } }
/// <summary> /// 设置显示队伍 /// </summary> /// <param name="teamPos"></param> private void SetShowTram(Transform teamPos) { ClearTramModel(); for (int i = 0; i < teamPos.childCount; i++) { OtherHeroInfo _info = null; bool isNull = m_HeroAttribute.TryGetValue((i + 1), out _info); if (isNull == false) { continue; } int _artResId = _info.m_HeroViewId; ArtresourceTemplate _artRes = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(_artResId); GameObject _assetRes = AssetLoader.Inst.GetAssetRes(_artRes.getArtresources()); GameObject _go = Instantiate(_assetRes, teamPos.GetChild(i).position, teamPos.GetChild(i).rotation) as GameObject; if (_go != null) { float _zoom = _artRes.getArtresources_zoom(); _go.transform.localScale = new Vector3(_zoom, _zoom, _zoom); Animation _anim = _go.GetComponent <Animation>(); if (_anim != null) { if (_go.GetComponent <Animation>()["Idle1"] != null) { _go.GetComponent <Animation>().CrossFade("Idle1"); } else if (_go.GetComponent <Animation>()["Nidle1"] != null) { _go.GetComponent <Animation>().CrossFade("Nidle1"); } _go.GetComponent <Animation>().wrapMode = WrapMode.Loop; } } m_GoList.Add(_go); } }
/// <summary> /// 创建模型 /// </summary> private void CreateModel() { for (int i = 0; i < m_HeroAdvances.Count; i++) { int _heroID = m_HeroAdvances[i].getArtresources(); ArtresourceTemplate _res = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(_heroID); if (_res == null) { continue; } GameObject _resModel = AssetLoader.Inst.GetAssetRes(_res.getArtresources()); if (_resModel != null) { if (_resModel.GetComponent <NavMeshAgent>() != null) { _resModel.GetComponent <NavMeshAgent>().enabled = false; } GameObject _go = Instantiate(_resModel, m_Group.GetChild(i).position, m_Group.GetChild(i).rotation) as GameObject; float _zoom = _res.getArtresources_zoom(); _go.transform.localScale = new UnityEngine.Vector3(_zoom, _zoom, _zoom); _go.transform.parent = m_Group.GetChild(i); Animation _anim = _go.GetComponent <Animation>(); if (_anim != null) { if (_go.GetComponent <Animation>()["Idle1"] != null) { _go.GetComponent <Animation>().CrossFade("Idle1"); } else if (_go.GetComponent <Animation>()["Nidle1"] != null) { _go.GetComponent <Animation>().CrossFade("Nidle1"); } _go.GetComponent <Animation>().wrapMode = WrapMode.Loop; } } } }
//实例化怪物 [1/20/2015 Zmy] private void InstantiateMonsterObj() { int MonsterNum = FightEditorContrler.GetInstantiate().GetMonsterGroupEditorData(m_RoundInScene).Count; FightEditorContrler.GetInstantiate().SetMonsterTroopType(ObjectSelf.GetInstance().LimitFightMgr.m_MonsterTroopType); FightEditorContrler.GetInstantiate().SetBeginFightCount(ObjectSelf.GetInstance().LimitFightMgr.m_RoundNum); for (int i = 0; i < MonsterNum; ++i) { int nTableID = SceneObjectManager.GetInstance().GetMosnterBundleRes(m_RoundInTotal, i); MonsterTemplate pRow = (MonsterTemplate)DataTemplate.GetInstance().m_MonsterTable.getTableData(nTableID); ArtresourceTemplate art = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(pRow.getArtresources()); string _res = art.getArtresources(); GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(_res); GameObject obj = Instantiate(_AssetRes, FightEditorContrler.GetInstantiate().GetMonsterGroupEditorData(m_RoundInScene)[i].MyPos, FightEditorContrler.GetInstantiate().GetMonsterGroupEditorData(m_RoundInScene)[i].MyAngle) as GameObject; GameUtils.SetLayerRecursively(obj, FightEditorContrler.GetInstantiate().GetShadowCullMaskLayer()); float _zoom = art.getArtresources_zoom() * pRow.getMonsterEnlarge(); obj.transform.localScale = new UnityEngine.Vector3(_zoom, _zoom, _zoom); FightEditorContrler.GetInstantiate().SetMonsterBirthState(obj, FightEditorContrler.GetInstantiate().GetMonsterGroupEditorData(m_RoundInScene)[i], false); SceneObjectManager.GetInstance().SceneObjectAddMonster(obj, m_RoundInTotal, i); //Transform _body = null; //_body = obj.transform.FindChild("Body"); //if (_body != null) //{ // _body.gameObject.SetActive(false); // StartCoroutine(OnShowMonsterObj(_body)); //} for (int m = 0, n = obj.transform.childCount; m < n; m++) { obj.transform.GetChild(m).gameObject.SetActive(false); } StartCoroutine(OnShowMonsterObj(obj.transform)); //怪物入场怒气加成 [10/17/2015 Zmy] AngertableTemplate _data = (AngertableTemplate)DataTemplate.GetInstance().m_AngerTable.getTableData(pRow.getFuryId()); if (_data == null) { continue; } m_EnemyPower.OnUpdatePowerValue(_data.getStartFury()); } // //每波怪物初始化时候,初始敌方怒气值 [3/3/2015 Zmy] // if (m_RoundInScene - 1 >= 0 && m_RoundInScene - 1 < m_StageRow.m_waveFury.Length) // { // int nValue = m_StageRow.m_waveFury[m_RoundInScene - 1]; // m_EnemyPower.OnUpdatePowerValue(nValue); // } //初始化释放怪物的被动技能 [7/31/2015 Zmy] SceneObjectManager.GetInstance().OnMonsterFreePassiveSpell(); // add by zcd SetFightState(FightState.prepareEnemy_over); }
//刷新3D显示英雄位置 private void Init3DHeros() { List <GameObject> PointList = new List <GameObject>(); //int type = ObjectSelf.GetInstance().Teams.GetFormationType(); //if (type == 1) //{ for (int i = 0; i < Herogroup1.transform.childCount; ++i) { PointList.Add(Herogroup1.transform.GetChild(i).gameObject); } //} //if (type == 2) //{ // for (int i = 0; i < Herogroup2.transform.childCount; ++i) // { // PointList.Add(Herogroup2.transform.GetChild(i).gameObject); // } //} int GroupCount = ObjectSelf.GetInstance().Teams.GetDefaultGroup(); int HeroCount = ObjectSelf.GetInstance().Teams.m_Matrix.GetLength(1); for (int i = 0; i < HeroCount; ++i) { ObjectCard temp = ObjectSelf.GetInstance().HeroContainerBag.FindHero(ObjectSelf.GetInstance().Teams.m_Matrix[GroupCount, i]); if (temp == null) { continue; } ArtresourceTemplate _Artresourcedata = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(temp.GetHeroData().GetHeroViewID()); GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(_Artresourcedata.getArtresources()); if (_AssetRes != null) { if (_AssetRes.GetComponent <NavMeshAgent>() != null) { _AssetRes.GetComponent <NavMeshAgent>().enabled = false; } int nGroup = ObjectSelf.GetInstance().Teams.GetDefaultGroup(); X_GUID pMemberGuiD = ObjectSelf.GetInstance().Teams.m_Matrix[nGroup, i]; GameObject _obj = Instantiate(_AssetRes, PointList[i].transform.position, PointList[i].transform.rotation) as GameObject; float _zoom = _Artresourcedata.getArtresources_zoom(); _obj.transform.localScale = new UnityEngine.Vector3(_zoom, _zoom, _zoom); HeroObjs3D.Add(_obj); Animation anim = _obj.GetComponent <Animation>(); if (anim != null) { if (anim["Nidle1"] != null) { anim.CrossFade("Nidle1"); } else if (anim["Idle1"] != null) { anim.CrossFade("Idle1"); } anim.wrapMode = WrapMode.Loop; } } } }
//刷新2D显示人物 public void Init2DHeros() { //int type = ObjectSelf.GetInstance().Teams.GetFormationType(); //if (type == 1) //{ TeamViewRoomTeam1.SetActive(true); TeamViewRoomTeam2.SetActive(false); CurrentViewRoomTeam = TeamViewRoomTeam1.transform; //} //else //{ // TeamViewRoomTeam1.SetActive(false); // TeamViewRoomTeam2.SetActive(true); // CurrentViewRoomTeam = TeamViewRoomTeam2.transform; //} int GroupCount = ObjectSelf.GetInstance().Teams.GetDefaultGroup(); int HeroCount = ObjectSelf.GetInstance().Teams.m_Matrix.GetLength(1); for (int i = 0; i < HeroCount; ++i) { X_GUID pMemberGuiD = ObjectSelf.GetInstance().Teams.m_Matrix[GroupCount, i]; GameObject _obj = null; if (pMemberGuiD.IsValid()) { ObjectCard temp = ObjectSelf.GetInstance().HeroContainerBag.FindHero(ObjectSelf.GetInstance().Teams.m_Matrix[GroupCount, i]); if (temp == null) { continue; } HeroTemplate _HeroData = temp.GetHeroRow(); ArtresourceTemplate _Artresourcedata = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(temp.GetHeroData().GetHeroViewID()); GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(_Artresourcedata.getArtresources()); if (_AssetRes != null) { if (_AssetRes.GetComponent <NavMeshAgent>() != null) { _AssetRes.GetComponent <NavMeshAgent>().enabled = false; } _obj = Instantiate(_AssetRes, CurrentViewRoomTeam.GetChild(i).position, CurrentViewRoomTeam.GetChild(i).rotation) as GameObject; float _zoom = _Artresourcedata.getArtresources_zoom(); _obj.transform.localScale = new UnityEngine.Vector3(_zoom, _zoom, _zoom); } } // else // { // //GameObject _DefRes = AssetLoader.Inst.GetAssetRes("ElementBody02"); // GameObject _DefRes = Resources.Load(common.EleBody + "ElementBody02") as GameObject; // if (_DefRes != null) // _obj = Instantiate(_DefRes, CurrentViewRoomTeam.GetChild(i).position, CurrentViewRoomTeam.GetChild(i).rotation) as GameObject; // } if (_obj != null) { HeroObjs2D.Add(_obj); Animation anim = _obj.GetComponent <Animation>(); if (anim != null) { if (anim["Nidle1"] != null) { anim.CrossFade("Nidle1", 0.5f); } else if (anim["Idle1"] != null) { anim.CrossFade("Idle1", 0.5f); } anim.wrapMode = WrapMode.Loop; } } } }