public override void InitEditor() { base.InitEditor(); //load data m_pEditingData = new CHumanoidDesc(); m_pEditingData.Load(); }
protected void BuildDesc(GameObject pEditing, bool bMerge) { CHumanoidDesc newDesc = new CHumanoidDesc(); CHumanoidDesc oldDesc = null; if (bMerge) { oldDesc = new CHumanoidDesc(); oldDesc.Load(); } foreach (MeshRenderer mesh in pEditing.GetComponentsInChildren <MeshRenderer>()) { CHumanoidDescElement element = newDesc.CreateElement(); if (!newDesc.ChangeName(element.m_sElementName, mesh.gameObject.name)) { CRuntimeLogger.LogError("名称重复了:" + mesh.gameObject.name); return; } element.m_sObjectPath = CommonFunctions.FindFullName(pEditing.gameObject, mesh.gameObject); element.m_sObjectPath = element.m_sObjectPath.Replace(pEditing.gameObject.name + "/", ""); if (null != oldDesc && null != oldDesc[element.m_sElementName]) { element.m_sTags = oldDesc[element.m_sElementName].m_sTags; element.m_iWeight = oldDesc[element.m_sElementName].m_iWeight; element.m_ePos = oldDesc[element.m_sElementName].m_ePos; element.m_eHumanSide = oldDesc[element.m_sElementName].m_eHumanSide; element.m_eHumanType = oldDesc[element.m_sElementName].m_eHumanType; element.m_eHumanWeapon = oldDesc[element.m_sElementName].m_eHumanWeapon; } else { element.m_iWeight = 1; #region Tags By Names #region Body if (element.m_sElementName.Contains("Body_F")) { element.m_ePos = EHumanoidComponentPos.ECP_Body; element.m_eHumanType = EHumanoidType.EHT_Female; element.m_sTags = new[] { "Body", "Female" }; } if (element.m_sElementName.Contains("Body_M")) { element.m_ePos = EHumanoidComponentPos.ECP_Body; element.m_eHumanType = EHumanoidType.EHT_Male; element.m_sTags = new[] { "Body", "Male" }; } #endregion #region Head if (element.m_sElementName.Contains("Head_F")) { element.m_ePos = EHumanoidComponentPos.ECP_Head; element.m_eHumanType = EHumanoidType.EHT_Female; element.m_sTags = new[] { "Head", "Female" }; if (!element.m_sElementName.Contains("Hat") && !element.m_sElementName.Contains("Glass")) { element.m_iWeight = 30; } else if (element.m_sElementName.Contains("Hat") && !element.m_sElementName.Contains("Glass")) { element.m_iWeight = 3; } else if (!element.m_sElementName.Contains("Hat") && element.m_sElementName.Contains("Glass")) { element.m_iWeight = 2; } else if (element.m_sElementName.Contains("Hat") && element.m_sElementName.Contains("Glass")) { element.m_iWeight = 1; } } if (element.m_sElementName.Contains("Head_M")) { element.m_ePos = EHumanoidComponentPos.ECP_Head; element.m_eHumanType = EHumanoidType.EHT_Male; element.m_sTags = new[] { "Head", "Male" }; } #endregion #region back, hand, foot, wing if (element.m_sElementName.Contains("_Back")) { element.m_ePos = EHumanoidComponentPos.ECP_Back; element.m_sTags = new[] { "Back", "Female", "Male" }; } if (element.m_sElementName.Contains("HandL")) { element.m_ePos = EHumanoidComponentPos.ECP_Hand; element.m_eHumanSide = EHumanoidSide.EHT_Left; element.m_sTags = new[] { "Hand", "Female", "Male" }; } if (element.m_sElementName.Contains("HandR")) { element.m_ePos = EHumanoidComponentPos.ECP_Hand; element.m_eHumanSide = EHumanoidSide.EHT_Right; element.m_sTags = new[] { "Hand", "Female", "Male", "Right" }; } if (element.m_sElementName.Contains("HandL")) { element.m_ePos = EHumanoidComponentPos.ECP_Hand; element.m_eHumanSide = EHumanoidSide.EHT_Left; element.m_sTags = new[] { "Hand", "Female", "Male", "Left" }; } if (element.m_sElementName.Contains("Feet_F") && element.m_sElementName.Contains("L")) { element.m_ePos = EHumanoidComponentPos.ECP_Feet; element.m_eHumanType = EHumanoidType.EHT_Female; element.m_eHumanSide = EHumanoidSide.EHT_Left; element.m_sTags = new[] { "Foot", "Female", "Left" }; } if (element.m_sElementName.Contains("Feet_F") && element.m_sElementName.Contains("R")) { element.m_ePos = EHumanoidComponentPos.ECP_Feet; element.m_eHumanType = EHumanoidType.EHT_Female; element.m_eHumanSide = EHumanoidSide.EHT_Right; element.m_sTags = new[] { "Foot", "Female", "Right" }; } if (element.m_sElementName.Contains("Feet_M") && element.m_sElementName.Contains("L")) { element.m_ePos = EHumanoidComponentPos.ECP_Feet; element.m_eHumanType = EHumanoidType.EHT_Male; element.m_eHumanSide = EHumanoidSide.EHT_Left; element.m_sTags = new[] { "Foot", "Male", "Left" }; } if (element.m_sElementName.Contains("Feet_M") && element.m_sElementName.Contains("R")) { element.m_ePos = EHumanoidComponentPos.ECP_Feet; element.m_eHumanType = EHumanoidType.EHT_Male; element.m_eHumanSide = EHumanoidSide.EHT_Right; element.m_sTags = new[] { "Foot", "Male", "Right" }; } if (element.m_sElementName.Contains("LWing")) { element.m_ePos = EHumanoidComponentPos.ECP_Wing; element.m_eHumanType = EHumanoidType.EHT_Both; element.m_eHumanSide = EHumanoidSide.EHT_Left; element.m_sTags = new[] { "Wing", "Female", "Male", "Left" }; } if (element.m_sElementName.Contains("RWing")) { element.m_ePos = EHumanoidComponentPos.ECP_Wing; element.m_eHumanType = EHumanoidType.EHT_Both; element.m_eHumanSide = EHumanoidSide.EHT_Right; element.m_sTags = new[] { "Wing", "Female", "Male", "Right" }; } #endregion #region Weapon //===================================================== //weapon if (element.m_sElementName.Contains("SHandWeapon_R")) { element.m_ePos = EHumanoidComponentPos.ECP_Weapon; element.m_eHumanType = EHumanoidType.EHT_Both; element.m_eHumanSide = EHumanoidSide.EHT_Right; element.m_eHumanWeapon = EHumanoidWeapon.EHT_SingleHand_Fight; if (element.m_sElementName.Contains("SHandWeapon_R_W")) { element.m_sTags = new[] { "Weapon", "SHand", "Wizard", "Female", "Male", "Right" }; } else { element.m_sTags = new[] { "Weapon", "SHand", "Fight", "Female", "Male", "Right" }; } } if (element.m_sElementName.Contains("Shoot_R")) { element.m_ePos = EHumanoidComponentPos.ECP_Weapon; element.m_eHumanType = EHumanoidType.EHT_Both; element.m_eHumanSide = EHumanoidSide.EHT_Right; element.m_eHumanWeapon = EHumanoidWeapon.EHT_Shoot; element.m_sTags = new[] { "Weapon", "Shoot", "Female", "Male", "Right" }; } if (element.m_sElementName.Contains("DHandWeapon_Sword")) { element.m_ePos = EHumanoidComponentPos.ECP_Weapon; element.m_eHumanType = EHumanoidType.EHT_Both; element.m_eHumanSide = EHumanoidSide.EHT_Right; element.m_eHumanWeapon = EHumanoidWeapon.EHT_DoubleHand_Fight; element.m_sTags = new[] { "Weapon", "DHand", "Fight", "Female", "Male", "Right" }; } if (element.m_sElementName.Contains("DHandWeapon_Stick")) { element.m_ePos = EHumanoidComponentPos.ECP_Weapon; element.m_eHumanType = EHumanoidType.EHT_Both; element.m_eHumanSide = EHumanoidSide.EHT_Right; element.m_eHumanWeapon = EHumanoidWeapon.EHT_DoubleHand_Wizard; element.m_sTags = new[] { "Weapon", "DHand", "Wizard", "Female", "Male", "Right" }; } if (element.m_sElementName.Contains("SHandWeapon_Shield")) { element.m_ePos = EHumanoidComponentPos.ECP_Weapon; element.m_eHumanType = EHumanoidType.EHT_Both; element.m_eHumanSide = EHumanoidSide.EHT_Left; element.m_eHumanWeapon = EHumanoidWeapon.EHT_SingleHand_Fight; element.m_sTags = new[] { "Weapon", "SHand", "Fight", "Wizard", "Female", "Male", "Left" }; } if (element.m_sElementName.Contains("SHandWeapon_L")) { element.m_ePos = EHumanoidComponentPos.ECP_Weapon; element.m_eHumanType = EHumanoidType.EHT_Both; element.m_eHumanSide = EHumanoidSide.EHT_Left; element.m_eHumanWeapon = EHumanoidWeapon.EHT_SingleHand_Fight; element.m_sTags = new[] { "Weapon", "SHand", "Fight", "Female", "Male", "Left" }; } if (element.m_sElementName.Contains("Weapon_Shoot_L")) { element.m_ePos = EHumanoidComponentPos.ECP_Weapon; element.m_eHumanType = EHumanoidType.EHT_Both; element.m_eHumanSide = EHumanoidSide.EHT_Left; element.m_eHumanWeapon = EHumanoidWeapon.EHT_Shoot; element.m_sTags = new[] { "Weapon", "Shoot", "Female", "Male", "Left" }; } #endregion #region etc if (element.m_sElementName.Contains("Shadow")) { element.m_ePos = EHumanoidComponentPos.ECP_Shadow; element.m_eHumanType = EHumanoidType.EHT_Both; element.m_eHumanSide = EHumanoidSide.EHT_Left; element.m_sTags = new[] { "Shadow" }; } if (element.m_sElementName.Contains("BloodLineFront")) { element.m_ePos = EHumanoidComponentPos.ECP_BloodLineFront; element.m_eHumanType = EHumanoidType.EHT_Both; element.m_eHumanSide = EHumanoidSide.EHT_Left; element.m_sTags = new[] { "BloodLineFront" }; } #endregion #endregion } } newDesc.Save(); m_pEditingData = newDesc; RefreshData(); }
public void EditorFix() { #region Find All List <GameObject> allGos = new List <GameObject>(); foreach (MeshRenderer renderers in GetComponentsInChildren <MeshRenderer>(true)) { allGos.Add(renderers.gameObject); } m_pAllComponents = allGos.ToArray(); if (m_pAllComponents.Length >= m_iMaxCount) { CRuntimeLogger.LogError("零件数量超出上限1000个!"); return; } #endregion m_pDesc = new CHumanoidDesc(); m_pDesc.Load(); #region Find hand, feet, wings, body, back, head m_pHands = FindPartWithTags(true, new[] { "Hand", "Left" }); m_pFemaleFeet = FindPartWithTags(true, new[] { "Foot", "Female", "Left" }); m_pMaleFeet = FindPartWithTags(true, new[] { "Foot", "Male", "Left" }); m_pWings = FindPartWithTags(true, new[] { "Wing", "Left" }); m_pFemaleBody = FindPartWithTags(false, new[] { "Body", "Female" }); m_pMaleBody = FindPartWithTags(false, new[] { "Body", "Male" }); m_pBacks = FindPartWithTags(false, new[] { "Back" }); m_pFemaleHead = FindPartWithTags(false, new[] { "Head", "Female" }); m_pMaleHead = FindPartWithTags(false, new[] { "Head", "Male" }); #endregion #region Find Weapons CHumanoidDescElement[] sHandFightRight = m_pDesc[new[] { "SHand", "Fight", "Right" }]; CHumanoidDescElement[] sHandWizardRight = m_pDesc[new[] { "SHand", "Wizard", "Right" }]; CHumanoidDescElement[] sHandFightLeft = m_pDesc[new[] { "SHand", "Fight", "Left" }]; CHumanoidDescElement[] sHandWizardLeft = m_pDesc[new[] { "SHand", "Wizard", "Left" }]; m_pAllPosibleSHandCombineFight = new int[sHandFightRight.Length + sHandFightRight.Length * sHandFightLeft.Length]; //Single Hand Fight for (int i = 0; i < sHandFightRight.Length; ++i) { m_pAllPosibleSHandCombineFight[i] = FindIndex(sHandFightRight[i].m_sObjectPath) + 1; } //Single Hand Fight 2 hands for (int i = 0; i < sHandFightRight.Length; ++i) { for (int j = 0; j < sHandFightLeft.Length; ++j) { m_pAllPosibleSHandCombineFight[sHandFightRight.Length + i * sHandFightLeft.Length + j] = FindIndex(sHandFightRight[i].m_sObjectPath) + 1 + m_iMaxCount * (FindIndex(sHandFightLeft[j].m_sObjectPath) + 1); } } m_pAllPosibleSHandCombineWizard = new int[sHandWizardRight.Length + sHandWizardRight.Length * sHandWizardLeft.Length]; //Single Hand Wizard for (int i = 0; i < sHandWizardRight.Length; ++i) { m_pAllPosibleSHandCombineWizard[i] = FindIndex(sHandWizardRight[i].m_sObjectPath) + 1; } //Single Hand Wizard 2 hands for (int i = 0; i < sHandWizardRight.Length; ++i) { for (int j = 0; j < sHandWizardLeft.Length; ++j) { m_pAllPosibleSHandCombineWizard[sHandWizardRight.Length + i * sHandWizardLeft.Length + j] = FindIndex(sHandWizardRight[i].m_sObjectPath) + 1 + m_iMaxCount * (FindIndex(sHandWizardLeft[j].m_sObjectPath) + 1); } } //Single Shoot CHumanoidDescElement[] sShoot = m_pDesc[new[] { "Shoot" }]; m_pAllPosibleShoot = new int[sShoot.Length]; for (int i = 0; i < sShoot.Length; ++i) { m_pAllPosibleShoot[i] = FindIndex(sShoot[i].m_sObjectPath) + 1; } //Single DHand Fight CHumanoidDescElement[] sDHandFight = m_pDesc[new[] { "DHand", "Fight" }]; m_pAllPosibleDHandCombineFight = new int[sDHandFight.Length]; for (int i = 0; i < sDHandFight.Length; ++i) { m_pAllPosibleDHandCombineFight[i] = FindIndex(sDHandFight[i].m_sObjectPath) + 1; } //Single DHand Wizard CHumanoidDescElement[] sDHandWizard = m_pDesc[new[] { "DHand", "Wizard" }]; m_pAllPosibleDHandCombineWizard = new int[sDHandWizard.Length]; for (int i = 0; i < sDHandWizard.Length; ++i) { m_pAllPosibleDHandCombineWizard[i] = FindIndex(sDHandWizard[i].m_sObjectPath) + 1; } #endregion #region Others m_pBoltPos = new GameObject[(int)EHumanoidWeapon.EHT_Max]; m_pBoltPos[(int)EHumanoidWeapon.EHW_BareHand] = CommonFunctions.FindChildrenByName(gameObject, "BHandBoltPos", true); m_pBoltPos[(int)EHumanoidWeapon.EHT_SingleHand_Fight] = CommonFunctions.FindChildrenByName(gameObject, "SHandBoltPos"); m_pBoltPos[(int)EHumanoidWeapon.EHT_SingleHand_Wizard] = CommonFunctions.FindChildrenByName(gameObject, "SHandBoltPos"); m_pBoltPos[(int)EHumanoidWeapon.EHT_Shoot] = CommonFunctions.FindChildrenByName(gameObject, "ShootBoltPos"); m_pBoltPos[(int)EHumanoidWeapon.EHT_DoubleHand_Fight] = CommonFunctions.FindChildrenByName(gameObject, "DHandBoltPos"); m_pBoltPos[(int)EHumanoidWeapon.EHT_DoubleHand_Wizard] = CommonFunctions.FindChildrenByName(gameObject, "DHandBoltPos"); m_pShadow = CommonFunctions.FindChildrenByName(gameObject, "Humanoid/Shadow"); m_pBloodLineShell = CommonFunctions.FindChildrenByName(gameObject, "Humanoid/BloodLineShell").transform; m_pBloodLineFront = new GameObject[8]; m_pBloodLineFront[0] = CommonFunctions.FindChildrenByName(gameObject, "Humanoid/BloodLineShell/BloodLineFront1"); m_pBloodLineFront[1] = CommonFunctions.FindChildrenByName(gameObject, "Humanoid/BloodLineShell/BloodLineFront2"); m_pBloodLineFront[2] = CommonFunctions.FindChildrenByName(gameObject, "Humanoid/BloodLineShell/BloodLineFront3"); m_pBloodLineFront[3] = CommonFunctions.FindChildrenByName(gameObject, "Humanoid/BloodLineShell/BloodLineFront4"); m_pBloodLineFront[4] = CommonFunctions.FindChildrenByName(gameObject, "Humanoid/BloodLineShell/BloodLineFront5"); m_pBloodLineFront[5] = CommonFunctions.FindChildrenByName(gameObject, "Humanoid/BloodLineShell/BloodLineFront6"); m_pBloodLineFront[6] = CommonFunctions.FindChildrenByName(gameObject, "Humanoid/BloodLineShell/BloodLineFront7"); m_pBloodLineFront[7] = CommonFunctions.FindChildrenByName(gameObject, "Humanoid/BloodLineShell/BloodLineFront8"); m_pOwner = gameObject.transform.parent.gameObject.GetComponent <ACharactor>(); m_pOwner.m_pModel = this; m_pAnim = GetComponent <ACharactorAnimation>(); m_pOwner.m_pAnim = m_pAnim; m_pAnim.m_pOwner = m_pOwner; m_pAnim.m_pModel = this; m_pAnim.m_pAnim = GetComponent <Animation>(); #endregion }