Exemple #1
0
    /// <summary>
    /// 生成所有员工
    /// </summary>
    /// <param name="itemData"></param>
    public void CreateAllWorker(StoryInfoDetailsBean itemData)
    {
        GameDataBean         gameData          = GameDataHandler.Instance.manager.GetGameData();
        List <CharacterBean> listCharacterData = gameData.listWorkerCharacter;

        if (CheckUtil.ListIsNull(listCharacterData))
        {
            return;
        }
        if (itemData.horizontal == 0)
        {
            itemData.horizontal = 1;
        }
        int horizontalNumber     = listCharacterData.Count / itemData.horizontal;
        int tempHorizontalNumber = 0;

        for (int i = 0; i < listCharacterData.Count; i++)
        {
            CharacterBean characterData = listCharacterData[i];
            GameObject    objNpcModel   = StoryInfoHandler.Instance.manager.objNpcModel;
            GameObject    objNpc        = Instantiate(transform.gameObject, objNpcModel);

            int tempHorizontal = i / horizontalNumber;
            if (tempHorizontalNumber >= horizontalNumber)
            {
                tempHorizontalNumber = 0;
            }
            float positionX = itemData.position_x + tempHorizontalNumber * itemData.offset_x;
            float positionY = itemData.position_y + tempHorizontal * itemData.offset_y;

            tempHorizontalNumber++;

            objNpc.transform.localPosition = new Vector3(positionX, positionY);
            NpcAIStoryCpt aiNpc = objNpc.GetComponent <NpcAIStoryCpt>();
            //设置编号
            objNpc.name = "character_" + (i + 1001);
            aiNpc.SetCharacterData(characterData);
            aiNpc.SetCharacterFace(itemData.face);
            listNpcObj.Add(objNpc);
        }
    }
Exemple #2
0
    /// <summary>
    /// 生成NPC
    /// </summary>
    /// <param name="itemData"></param>
    public BaseNpcAI CreateNpc(StoryInfoDetailsBean itemData)
    {
        GameObject objNpcModel = StoryInfoHandler.Instance.manager.objNpcModel;
        GameObject objNpc      = Instantiate(transform.gameObject, objNpcModel);

        objNpc.transform.localPosition = new Vector3(itemData.position_x, itemData.position_y);
        listNpcObj.Add(objNpc);
        NpcAIStoryCpt aiNpc = objNpc.GetComponent <NpcAIStoryCpt>();
        CharacterBean characterData;

        if (itemData.npc_id == 0)
        {
            //使用自己的数据
            GameControlHandler.Instance.manager.GetControl <ControlForStoryCpt>(GameControlHandler.ControlEnum.Story).SetCameraFollowObj(objNpc);
            GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData();
            characterData = gameData.userCharacter;
        }
        else if (itemData.npc_id == -1)
        {
            // 使用妻子的数据
            GameDataBean   gameData   = GameDataHandler.Instance.manager.GetGameData();
            FamilyDataBean familyData = gameData.GetFamilyData();
            characterData = familyData.mateCharacter as CharacterBean;
        }
        else
        {
            characterData = NpcInfoHandler.Instance.manager.GetCharacterDataById(itemData.npc_id);
        }
        //设置编号
        objNpc.name = "character_" + itemData.num;
        CharacterBean copyCharacterData = ClassUtil.DeepCopyByBin <CharacterBean>(characterData);

        aiNpc.SetCharacterData(copyCharacterData);
        //默认设置NPC速度为1
        aiNpc.characterMoveCpt.SetMoveSpeed(1);
        return(aiNpc);
    }
Exemple #3
0
    public void HandleForNpcEquip(StoryInfoDetailsBean itemData)
    {
        //装备
        GameObject objItem = GetNpcByNpcNum(itemData.num);

        if (objItem != null)
        {
            NpcAIStoryCpt npcAIStory = objItem.GetComponent <NpcAIStoryCpt>();
            itemData.GetNpcEquip(npcAIStory.characterData.body.GetSex(), out long hatId, out long clothesId, out long shoesId);
            if (hatId != -1)
            {
                npcAIStory.characterData.equips.hatTFId = hatId;
            }
            if (clothesId != -1)
            {
                npcAIStory.characterData.equips.clothesTFId = clothesId;
            }
            if (shoesId != -1)
            {
                npcAIStory.characterData.equips.shoesTFId = shoesId;
            }
            npcAIStory.SetCharacterData(npcAIStory.characterData);
        }
    }