Exemple #1
0
            static void Postfix(NpcAppearDBData npcAppearDBData, NpcAppearData appearData, Actor actor)
            {
                if (!enabled)
                {
                    return;
                }

                for (int i = 0; i < clothesChangers.Count; i++)
                {
                    //Dbgl($"changing for {i} {clothesChangers[i].name}");
                    if (clothesChangers[i].id == actor.InstanceId)
                    {
                        Dbgl($"actor: {actor.ActorName}");
                        Dictionary <int, AppearDBData> appearDbDatas = AccessTools.FieldRefAccess <NpcAppearModule, Dictionary <int, AppearDBData> >(Module <NpcAppearModule> .Self, "m_AppearDBDataDic");
                        NpcAppear component = actor.GetComponent <NpcAppear>();
                        if (component == null)
                        {
                            Dbgl("actor does not have npcappear");
                            return;
                        }
                        Dbgl($"i {i} hair setting {settings.hairs[i]} actor hair: {hairs[settings.hairs[i]]}");
                        //if(settings.hairs[i] != 0)
                        component.SetPart(appearDbDatas[hairs[settings.hairs[i]]]);
                        Dbgl($"actor clothes: {clothes[settings.clothes[i]]}");
                        //if (settings.clothes[i] != 0)
                        component.SetPart(appearDbDatas[clothes[settings.clothes[i]]]);
                    }
                }
            }
Exemple #2
0
	public void SetCreationData( NpcAppearData _data)
	{
		m_SessionId = _data.npcIdx_;
		sessionId_ = _data.npcIdx_;

		Tbl_Npc_Record npcRec = AsTableManager.Instance.GetTbl_Npc_Record( _data.tableIdx_);
		if( npcRec == null)
		{
			Debug.LogError( "AsNpcEntity::SetCreatioinData: NO npc table NPC RECORD");
			return;
		}

		m_iTableIdx = _data.tableIdx_;

		string nameHead = "";
		if( _data.nameHead_ != 0)
			nameHead = AsTableManager.Instance.GetTbl_String( _data.nameHead_);

		SetProperty( eComponentProperty.NAME, nameHead + " " + npcRec.NpcName);
		SetProperty( eComponentProperty.NPC_ID, npcRec.Id);
		SetProperty( eComponentProperty.NPC_TYPE, npcRec.NpcType);
		fCollisionRadius = npcRec.getCollisionRadius;

		switch( _data.npcType_)
		{
		case eNPCType.Monster:
			Tbl_Monster_Record monster = AsTableManager.Instance.GetTbl_Monster_Record( _data.tableIdx_);

			SetProperty( eComponentProperty.CLASS, monster.Class);
			SetProperty( eComponentProperty.ATTRIBUTE, monster.ElementalIndex);
			SetProperty( eComponentProperty.GRADE, monster.Grade);
			SetProperty( eComponentProperty.MONSTER_ID, monster.Id);
			SetProperty( eComponentProperty.MONSTER_ATTACK_TYPE, monster.AttackType);
			SetProperty( eComponentProperty.MONSTER_ATTACK_STYLE, monster.AttackStyle);
			SetProperty( eComponentProperty.MONSTER_KIND_ID, monster.Monster_Kind_ID);
			SetProperty( eComponentProperty.LEVEL, monster.Level);
			SetProperty( eComponentProperty.HP_CUR, _data.hpCur_);//follow data
			SetProperty( eComponentProperty.MP_CUR, _data.mpCur_);// "
//			SetProperty( eComponentProperty.HP_MAX, ( float)monster.HPMax);
//			SetProperty( eComponentProperty.MP_MAX, ( float)monster.MPMax);
			SetProperty( eComponentProperty.HP_MAX, _data.hpMax_);
			SetProperty( eComponentProperty.MP_MAX, _data.mpMax_);
//			SetProperty( eComponentProperty.ATTACK, monster.phy);
//			SetProperty( eComponentProperty.DEFENCE, monster.Defence);
//			SetProperty( eComponentProperty.MOVE_SPEED, monster.MoveSpeed);
			SetProperty( eComponentProperty.ATTACK_SPEED, _data.atkSpeed_);
			SetProperty( eComponentProperty.VIEW_DISTANCE, monster.ViewDistance * 0.01f);
			SetProperty( eComponentProperty.CHASE_DISTANCE, monster.ChaseDistance * 0.01f);
			SetProperty( eComponentProperty.DROP_EXP, monster.DropExp);
			SetProperty( eComponentProperty.DROP_ITEM, monster.DropItem);
			SetProperty( eComponentProperty.VIEW_HOLD, monster.ViewHold);
			break;
		case eNPCType.NPC:
			Tbl_NormalNpc_Record normal = AsTableManager.Instance.GetTbl_NormalNpc_Record( _data.tableIdx_);
			SetProperty( eComponentProperty.MOVE_SPEED, normal.MoveSpeed);
			SetProperty( eComponentProperty.NPC_LIVING, normal.LivingType);

			Tbl_NormalNpc_Record normalNpc = AsTableManager.Instance.GetTbl_NormalNpc_Record( _data.tableIdx_);
			if( null != normalNpc)
			{
				if( true == normalNpc.IsHaveMenuBtn( eNPCMenu.Event_npc))
					m_isEvent_npc = true;
			}
			break;
		case eNPCType.Object:
			Tbl_Object_Record data = AsTableManager.Instance.GetTbl_Object_Record( _data.tableIdx_);
			SetProperty( eComponentProperty.OBJ_TYPE, data.PropType);
			break;
		case eNPCType.Collection:
			Tbl_Collection_Record record = AsTableManager.Instance.getColletionTable.GetRecord( _data.tableIdx_);
			if( null != record)
			{
				SetProperty( eComponentProperty.LEVEL, record.level);
				SetProperty( eComponentProperty.HP_CUR, record.time);
				SetProperty( eComponentProperty.HP_MAX, record.time);

				switch( record.technic)
				{
				case eCOLLECTION_TECHNIC.MINERAL:
					SetProperty( eComponentProperty.COLLECTOR_TECHNIC_TYPE, ( int)eITEM_PRODUCT_TECHNIQUE_TYPE.MINERAL);
					break;
				case eCOLLECTION_TECHNIC.PLANTS:
					SetProperty( eComponentProperty.COLLECTOR_TECHNIC_TYPE, ( int)eITEM_PRODUCT_TECHNIQUE_TYPE.PLANTS);
					break;
				case eCOLLECTION_TECHNIC.SPIRIT:
					SetProperty( eComponentProperty.COLLECTOR_TECHNIC_TYPE, ( int)eITEM_PRODUCT_TECHNIQUE_TYPE.SPIRIT);
					break;
				case eCOLLECTION_TECHNIC.QUEST:
					SetProperty( eComponentProperty.COLLECTOR_TECHNIC_TYPE, ( int)eITEM_PRODUCT_TECHNIQUE_TYPE.QUEST);
					break;
				}
			}
			else
			{
				Debug.LogError( "AsNpcEntity::SetCreationData()[ null == Tbl_Collection_Record ] id : " + _data.tableIdx_);
			}
			break;
		default:
			Debug.Log( "Invalid npc type");
			break;
		}

//		Vector3 pos = _data.curPosition_; pos.y += 0.1f;
//		pos.y = TerrainMgr.GetTerrainHeight(characterController, _data.curPosition_);
//		transform.position = pos;

		SetRePosition(_data.curPosition_);
		transform.rotation = Quaternion.AngleAxis( _data.curRotate, Vector3.up);

		if( _data.nameHead_ != 0)// case of CHAMPION
		{
			Tbl_Monster_Record monster = AsTableManager.Instance.GetTbl_Monster_Record( _data.tableIdx_);
			Tbl_MonsterChampion_Record champion = AsTableManager.Instance.GetTbl_MonsterChampion_Record( monster.Champion);
			transform.localScale = new Vector3( champion.Scale, champion.Scale, champion.Scale);

			SetProperty( eComponentProperty.GRADE, eMonster_Grade.Champion);

            m_isChampion = true;
		}
		else
		{
			transform.localScale = new Vector3( npcRec.Scale, npcRec.Scale, npcRec.Scale); // ilmeda, 20120816
            m_isChampion = false;
		}

		AsEntityManager.Instance.RegisterNpcCharacter( this);
		
//		bool intangible = false;
		// destroy components
		if( _data.npcType_ == eNPCType.Monster)
		{
			Tbl_Monster_Record monster = AsTableManager.Instance.GetTbl_Monster_Record( _data.tableIdx_);
			if( monster.Grade == eMonster_Grade.Intangible)
			{
				DetachComponent( typeof( AsAnimation));
				DetachComponent( typeof( AsModel));
				DetachComponent( typeof( AsMover));
				
				m_IsIntangible = true;
//				intangible = true;
			}
			
			if( monster.Grade == eMonster_Grade.Trap)
			{
//				DetachComponent( typeof( AsMover));
				
				m_IsTrap = true;
				
//				namePanel.gameObject.SetActive( false);
			}
		}
		
//		if( intangible == false)
//			AsEntityManager.Instance.RegisterNpcCharacter( this);
	}
	public void NpcAppear( AS_SC_NPC_APPEAR_1 _appear)
	{
		List<AS_SC_NPC_APPEAR_2> listAppear = new List<AS_SC_NPC_APPEAR_2>();
		listAppear.AddRange( _appear.body);
		listAppear.Sort( AsUtil.DistanceCompare);

		foreach( AS_SC_NPC_APPEAR_2 apr in listAppear)
		{
			AS_SC_NPC_APPEAR_2 appear = apr;
			if( true == m_dicNpcEntity_SessionId.ContainsKey( appear.nNpcIdx))
			{
				Debug.LogError( "[AsEntityManager]NpcAppear: already created character. id = " + appear.nNpcIdx);
				continue;
			}

			// check in game event 
			if (AsInGameEventManager.instance.CheckEventViewNpc(apr.nNpcTableIdx))
			{
				if (AsInGameEventManager.instance.CheckRunningEventviewNpc(apr.nNpcTableIdx))
				{
					AsInGameEventManager.instance.AddNpcAppear(apr);
					continue;
				}
			}

			//create
			NpcAppearData creationData = new NpcAppearData( appear);

			switch( creationData.npcType_)
			{
			case eNPCType.Monster:
				AsEntityManager.Instance.CreateNpcEntity( "Monster", creationData);
				break;
			case eNPCType.NPC:
			case eNPCType.Portal:
				AsEntityManager.Instance.CreateNpcEntity( "Npc", creationData);
				break;
			case eNPCType.Object:
				{
					if( 0 == appear.nObjectStatus)
					{
						AsNpcEntity npcEntity = AsEntityManager.Instance.CreateNpcEntity( "Object", creationData);
						npcEntity.SetProperty( eComponentProperty.GROUP_INDEX, appear.nNpcGroupIdx);
						npcEntity.SetProperty( eComponentProperty.LINK_INDEX, appear.nNpcLinkIdx);

						if( ( 0 < appear.nNpcGroupIdx) && ( null != npcEntity))
							ObjSteppingMgr.Instance.InsertObjStepping( appear.nNpcGroupIdx, appear.nNpcLinkIdx, npcEntity);
					}
				}
				break;
			case eNPCType.Collection:
				{
					AsNpcEntity npcEntity = AsEntityManager.Instance.CreateNpcEntity( "Collection", creationData);
					npcEntity.SetProperty( eComponentProperty.COLLECTOR_IDX, appear.nCollector);
				}
				break;
			}
		}
	}
	public void NpcAppearForEvent(AS_SC_NPC_APPEAR_2 _appear)
	{
		if (true == m_dicNpcEntity_SessionId.ContainsKey(_appear.nNpcIdx))
		{
			Debug.LogError("[AsEntityManager]NpcAppear: already created character. id = " + _appear.nNpcIdx);
			return;
		}

		NpcAppearData creationData = new NpcAppearData(_appear);

		if (creationData.npcType_ == eNPCType.NPC)
			AsEntityManager.Instance.CreateNpcEntity( "Npc", creationData);
	}