/// <summary> /// 在targetPostion周围选取合适的位置, 进行创建. /// </summary> /// <param name="summonerAttr">创建者的属性</param> /// <param name="creationResID">creation资源ID</param> /// <param name="targetPosition">创造点(最终创造点会随creation表格的数据调整)</param> /// <param name="dir">初始朝向(最终朝向会随creation表格的数据调整)</param> /// <returns></returns> public static ErrorCode CreateCreationAround(AttackerAttr summonerAttr, uint creationResID, Vector3 targetPosition, float dir) { if (creationResID == uint.MaxValue) { return(ErrorCode.Succeeded); } BaseScene scn = SceneManager.Instance.GetCurScene(); if (scn == null) { return(ErrorCode.LogicError); } ErrorCode err = ErrorCode.Succeeded; SkillCreationTableItem creationRes = DataManager.CreationTable[creationResID] as SkillCreationTableItem; for (uint i = 0; (i < SkillCreationTableItem.CreationCount && err == ErrorCode.Succeeded); ++i) { SkillCreationItem item = creationRes.items[i]; if (item.creationType == CreationType.Invalid) { break; } Vector3 spawnPosition = Utility.MoveVector3Towards(targetPosition, dir, item.spDistOffset); spawnPosition = Utility.RotateVectorByRadian(spawnPosition, item.spAngleOffset, targetPosition); // 如果计算出来的位置为不可行走区域, 那么, 直接创建在原始位置. if (!scn.IsInWalkableRegion(spawnPosition)) { spawnPosition = targetPosition; } err = createCreationAt(spawnPosition, summonerAttr, item.creationType, item.creatureID, item.lifeTime); } return(err); }
private bool checkCreation() { DataType myName = DataType.DATA_SKILL_CREATION; IDictionaryEnumerator itr = DataManager.CreationTable.GetEnumerator(); while (itr.MoveNext()) { SkillCreationTableItem item = itr.Value as SkillCreationTableItem; for (uint i = 0; i < SkillCreationTableItem.CreationCount; ++i) { SkillCreationItem subItem = item.items[i]; CreationType creationType = subItem.creationType; uint creatureID = subItem.creatureID; switch (creationType) { case CreationType.Invalid: break; case CreationType.Npc: if (!checkLink(myName, item.resID, DataType.DATA_NPC, creatureID)) { return(false); } break; case CreationType.Trap: if (!checkLink(myName, item.resID, DataType.DATA_TRAP, creatureID)) { return(false); } break; default: checkParam(false, myName, item.resID, "召唤物类型"); return(false); } } } // foreach (int key in DataManager.CreationTable.Keys) // { // SkillCreationTableItem item = DataManager.CreationTable[key] as SkillCreationTableItem; // // for (uint i = 0; i < SkillCreationTableItem.CreationCount; ++i) // { // SkillCreationItem subItem = item.items[i]; // // CreationType creationType = subItem.creationType; // uint creatureID = subItem.creatureID; // switch (creationType) // { // case CreationType.Invalid: // break; // case CreationType.Npc: // if (!checkLink(myName, key, DataType.DATA_NPC, creatureID)) // return false; // break; // case CreationType.Trap: // if (!checkLink(myName, key, DataType.DATA_TRAP, creatureID)) // return false; // break; // default: // checkParam(false, myName, key, "召唤物类型"); // return false; // } // } // } return(true); }