private void addMonster(Vector3 pPos, bool isMonster) { if (isMonster == false) { pPos.x += 0.2f; pPos.z += 0.2f; } GameObject tmpMonster = Instantiate(monsterPrefab, pPos, Quaternion.identity, monsterManagerTrans); tmpMonster.name = "monster_" + monsterID.ToString(); monsterID++; roleProperty tmpPro = tmpMonster.GetComponent <roleProperty>(); if (isMonster) { tmpPro.InitData(camerTransform, canvasTransform, 0); CapsuleCollider tmpColl = tmpMonster.GetComponent <CapsuleCollider>(); //tmpColl.isTrigger = true; tmpMonster.AddComponent <monsterNormalAI>(); } else { tmpPro.InitData(camerTransform, canvasTransform, 1); followRole tmpFollow = tmpMonster.AddComponent <followRole>(); //tmpFollow.mainObj = friendRole; friendRole = tmpMonster; } //go.GetComponent<MeshRenderer>().material = material; //go.name = roomName + nameIndex.ToString() + "_" + placeIndex.ToString(); }
public void initData(Transform pCameraTransform, Transform pRoleTranform, Vector3 pPos, Canvas pCanvas) { App.Game.character = this; mainRoleState = new RoleStateMgr(); mainRoleState.initData(roleInstance); mainRoleState.setJumpTime(csJumpUpTime * 2); jumpCheck = roleInstance.transform.GetComponent <jumpColider>(); jumpCheck.jumpDownOver = jumpDownOver; jumpCheck.isUse = false; rolePosCamer = new RolePosAndCamerMgr(); rolePosCamer.initData(roleInstance, pCameraTransform, pRoleTranform, pPos, pCanvas); mainPro = roleInstance.transform.GetComponent <roleProperty>(); mainPro.InitData(pCameraTransform, pCanvas.transform); //计算跳跃的加速度 //s=0.5*a*t*t a= s/0.5/t/t jumpA = csJumpHeightMax / 0.5f / csJumpUpTime / csJumpUpTime; updateGravity(); // setJumpDownRigidBody(); // test(); //testGrav(); sceneAlpha = null; attackMonster = null; isStart = true; roleIsAttack = false; roleIsEscape = false; roleIsDie = false; }
// Start is called before the first frame update void Start() { addRolePro(roleTransform.gameObject); roleProperty tmpPro = roleTransform.GetComponent <roleProperty>(); tmpPro.InitData(CamerTransform, CanvasTransform); tmpPro.showUI(); }
private void addMonster(Vector3 pPos, bool isMonster) { if (isMonster == false) { pPos.x += 0.2f; pPos.z += 0.2f; } int roleID = LevMonsterTab.getRandomMonsterID(); string strPre = RoleInfoTable.GetPrefab(roleID); Object tmpPre = Resources.Load("Prefab/Model/" + strPre); if (tmpPre == null) { Debug.LogError("role prefab not find roleID:" + roleID.ToString()); } GameObject tmpMonster = GameObject.Instantiate(tmpPre, pPos, Quaternion.identity, monsterManagerTrans) as GameObject; tmpMonster.name = "monster_" + monsterID.ToString(); monsterID++; GameObjCommon.skinUpdate(roleID, tmpMonster.transform); setMonsterTagLayer(tmpMonster); addRigidbody(tmpMonster); //addMonsterColliderCode(tmpMonster); //addAniControl(tmpMonster); tmpMonster.AddComponent <monsterCollider>(); tmpMonster.AddComponent <modelAnimatorControl>(); roleProperty tmpPro = addRolePro(tmpMonster, roleID); if (isMonster) { tmpPro.InitData(camerTransform, canvasTransform, 0); CapsuleCollider tmpColl = tmpMonster.GetComponent <CapsuleCollider>(); //tmpColl.isTrigger = true; tmpMonster.AddComponent <monsterNormalAI>(); } /* * else * { * tmpPro.InitData(camerTransform, canvasTransform, 1); * followRole tmpFollow = tmpMonster.AddComponent<followRole>(); * //tmpFollow.mainObj = friendRole; * friendRole = tmpMonster; * } */ //go.GetComponent<MeshRenderer>().material = material; //go.name = roomName + nameIndex.ToString() + "_" + placeIndex.ToString(); }
private void addMonster(Vector3 pPos) { GameObject go = Instantiate(monsterPrefab, pPos, Quaternion.identity, monsterManagerTrans); go.name = "monster_" + monsterID.ToString(); monsterID++; roleProperty tmpPro = go.GetComponent <roleProperty>(); tmpPro.InitData(camerTransform, canvasTransform); //go.GetComponent<MeshRenderer>().material = material; //go.name = roomName + nameIndex.ToString() + "_" + placeIndex.ToString(); }
public void initData(Transform pCameraTransform, Transform pRoleTranform, Vector3 pPos, Canvas pCanvas, Transform pMapCamerTransform, //Transform pRoleFlagTrans, Transform pMonsterParent) { App.Game.character = this; //mainRoleState = new RoleStateMgr(); //mainRoleState = roleInstance.transform.GetComponent<RoleStateMgr>(); //mainRoleState.initData(roleInstance); monsterParent = pMonsterParent; mainRoleState = roleInstance.transform.GetComponent <roleAI>(); mainRoleState.AIInitData(roleInstance); rolePosCamer = new RolePosAndCamerMgr(); rolePosCamer.initData(roleInstance, pCameraTransform, pRoleTranform, pPos, pCanvas, pMapCamerTransform); mainPro = roleInstance.transform.GetComponent <roleProperty>(); mainPro.InitData(pCameraTransform, pCanvas.transform, 1); //计算跳跃的加速度 //s=0.5*a*t*t a= s/0.5/t/t jumpA = csJumpHeightMax / 0.5f / csJumpUpTime / csJumpUpTime; updateGravity(); // setJumpDownRigidBody(); // test(); //testGrav(); sceneAlpha = null; attackMonster = null; isStart = true; roleIsAttack = false; roleIsEscape = false; roleIsDie = false; skillInit(); }