Пример #1
0
 protected override void Awake()
 {
     base.Awake();
     audioSourceForMusic       = CptUtil.GetCptInChildrenByName <AudioSource>(Camera.main.gameObject, "Music");
     audioSourceForSound       = CptUtil.GetCptInChildrenByName <AudioSource>(Camera.main.gameObject, "Sound");
     audioSourceForEnvironment = CptUtil.GetCptInChildrenByName <AudioSource>(Camera.main.gameObject, "Environment");
 }
    /// <summary>
    /// 创建前置数据
    /// </summary>
    /// <param name="preData"></param>
    public void CreatePreDataItem(string preData)
    {
        List <PreTypeBean> listPreData = PreTypeEnumTools.GetListPreData(preData);
        GameDataBean       gameData    = GameDataHandler.Instance.manager.GetGameData();

        foreach (var itemData in listPreData)
        {
            GameObject objPre = Instantiate(objPreContainer, objPreModel);
            PreTypeEnumTools.GetPreDetails(itemData, gameData);
            //设置图标
            Sprite spIcon = itemData.spPreIcon;
            Image  ivIcon = CptUtil.GetCptInChildrenByName <Image>(objPre, "Icon");
            ivIcon.sprite = spIcon;
            //设置描述
            string preDes    = itemData.preDescribe;
            Text   tvContent = CptUtil.GetCptInChildrenByName <Text>(objPre, "Text");
            tvContent.text = preDes;
            //设置是否满足条件
            Image ivStatus = CptUtil.GetCptInChildrenByName <Image>(objPre, "Status");
            if (itemData.isPre)
            {
                ivStatus.sprite = spRePre;
                tvContent.color = colorPre;
            }
            else
            {
                isAllPre        = false;
                ivStatus.sprite = spUnPre;
                tvContent.color = colorUnPre;
            }
        }
        GameUtil.RefreshRectViewHight((RectTransform)objPreContainer.transform, true);
        GameUtil.RefreshRectViewHight((RectTransform)transform, true);
    }
Пример #3
0
    public void SetData(UserModelDataBean userModelData, ModelInfoBean modelInfo)
    {
        if (modelInfo == null)
        {
            return;
        }
        if (userModelData == null)
        {
            return;
        }
        dissolveAmountId = Shader.PropertyToID(m_DissolveAmount);
        mapMaterialForModel.Clear();
        Texture textureDisolveGuide = Resources.Load("Texture/noise_1") as Texture;

        if (!CheckUtil.ListIsNull(modelInfo.listPartData))
        {
            for (int i = 0; i < modelInfo.listPartData.Count; i++)
            {
                ModelPartInfoBean partInfo     = modelInfo.listPartData[i];
                Renderer          itemRenderer = CptUtil.GetCptInChildrenByName <Renderer>(gameObject, partInfo.part_name);
                //获取所有的Material
                List <Material> listMaterial = new List <Material>();
                itemRenderer.GetMaterials(listMaterial);
                //获取用户进度
                UserModelPartDataBean userModelPartData = userModelData.GetUserPartDataById(partInfo.id);
                float pro = 0;
                if (userModelPartData != null)
                {
                    pro = userModelPartData.GetProgress(partInfo.max_level);
                }
                //重新设置所有的shader
                foreach (Material itemMaterial in listMaterial)
                {
                    Texture itemTexture = itemMaterial.GetTexture("_MainTex");
                    if (itemTexture)
                    {
                        itemMaterial.shader = Shader.Find("ASESampleShaders/Community/DissolveBurnWithFire");
                        itemMaterial.SetTexture("_Albedo", itemTexture);
                        itemMaterial.SetTexture("_Normal", itemTexture);
                        itemMaterial.SetTexture("_BurnRamp", itemTexture);
                        itemMaterial.SetFloat("_MaskClipValue", 0.5f);
                    }
                    else
                    {
                        Color color = itemMaterial.GetColor("_Color");
                        itemMaterial.shader = Shader.Find("ASESampleShaders/Community/DissolveBurn_01");
                        itemMaterial.SetFloat("_Cutoff", 0.5f);
                        itemMaterial.SetColor("_MainColor", color);
                    }
                    itemMaterial.SetTexture("_DisolveGuide", textureDisolveGuide);
                    itemMaterial.SetFloat(dissolveAmountId, 1 - pro);
                }
                if (!mapMaterialForModel.ContainsKey(partInfo.part_name))
                {
                    mapMaterialForModel.Add(partInfo.part_name, listMaterial);
                }
            }
        }
    }
Пример #4
0
    /// <summary>
    /// 加载toast容器
    /// </summary>
    public void LoadToastListContainer()
    {
        //加载Toast容器
        GameObject toastListModel = LoadResourcesUtil.SyncLoadData <GameObject>("UI/ToastList");
        GameObject objToastList   = Instantiate(gameObject, toastListModel);

        objToastContainer = CptUtil.GetCptInChildrenByName <Transform>(objToastList, "Container").gameObject;
    }
Пример #5
0
 protected override void Awake()
 {
     base.Awake();
     audioListener             = Find <AudioListener>(ImportantTypeEnum.MainCamera);
     audioManager              = Find <AudioManager>(ImportantTypeEnum.AudioManager);
     audioSourceForMusic       = CptUtil.GetCptInChildrenByName <AudioSource>(Camera.main.gameObject, "Music");
     audioSourceForSound       = CptUtil.GetCptInChildrenByName <AudioSource>(Camera.main.gameObject, "Sound");
     audioSourceForEnvironment = CptUtil.GetCptInChildrenByName <AudioSource>(Camera.main.gameObject, "Environment");
 }
Пример #6
0
    private void CreateRewardItem(Sprite spIcon, float delay)
    {
        GameObject objReward = Instantiate(objRewardContent, objRewardModel);
        Image      ivIcon    = CptUtil.GetCptInChildrenByName <Image>(objReward, "Icon");

        if (ivIcon != null && spIcon != null)
        {
            ivIcon.sprite = spIcon;
        }
        objReward.transform.DOScale(new Vector3(0, 0, 0), 1).From().SetEase(Ease.OutBack).SetDelay(delay);
    }
Пример #7
0
 /// <summary>
 /// 设置奖励
 /// </summary>
 /// <param name="listReward"></param>
 public void SetReward(List <RewardTypeBean> listReward)
 {
     foreach (RewardTypeBean itemReward in listReward)
     {
         GameObject objReward = Instantiate(objRewardContainer, objRewardModel);
         Image      ivIcon    = CptUtil.GetCptInChildrenByName <Image>(objReward, "Icon");
         Text       tvNumber  = CptUtil.GetCptInChildrenByName <Text>(objReward, "Text");
         RewardTypeEnumTools.GetRewardDetails(itemReward);
         ivIcon.sprite = itemReward.spRewardIcon;
         tvNumber.text = "x" + itemReward.rewardNumber;
         if (itemReward.dataType == RewardTypeEnum.AddItems)
         {
             PopupItemsButton infoItemsPopup = objReward.GetComponent <PopupItemsButton>();
             ItemsInfoBean    itemsInfo      = GameItemsHandler.Instance.manager.GetItemsById(itemReward.rewardId);
             infoItemsPopup.SetData(itemsInfo, itemReward.spRewardIcon);
         }
     }
 }
Пример #8
0
    /// <summary>
    ///  展示NPC
    /// </summary>
    public static GameObject ShowNpc(GameObject objNpcContainer, GameObject objNpcModel, CharacterBean characterData)
    {
        CptUtil.RemoveChildsByActiveInEditor(objNpcContainer);
        GameObject objNpc = GameObject.Instantiate(objNpcModel, objNpcContainer.transform);

        objNpc.SetActive(true);
        objNpc.transform.position = new Vector3(characterData.npcInfoData.position_x, characterData.npcInfoData.position_y);

        BaseNpcAI baseNpcAI = objNpc.GetComponent <BaseNpcAI>();

        baseNpcAI.Awake();

        CharacterDressCpt characterDress = CptUtil.GetCptInChildrenByName <CharacterDressCpt>(baseNpcAI.gameObject, "Body");

        characterDress.Awake();

        baseNpcAI.SetCharacterData(characterData);
        return(objNpc);
    }
Пример #9
0
    /// <summary>
    /// 通过反射自动连接空间里数据
    /// </summary>
    /// <param name="obj">对象</param>
    /// <param name="markStr">标记文字</param>
    public static void AutoLinkDataForChild <T>(T obj, string markStr) where T : BaseMonoBehaviour
    {
        Type trueType = obj.GetType();

        FieldInfo[] fields = trueType.GetFields();
        for (int i = 0; i < fields.Length; i++)
        {
            var field = fields[i];
            if (!field.Name.Contains(markStr))
            {
                continue;
            }
            Component tmpCom = CptUtil.GetCptInChildrenByName(obj.gameObject, field.Name.Replace(markStr, ""), field.FieldType, true);
            if (tmpCom == null)
            {
                //Debug.LogWarning("window " + trueType.Name + ",can not find:" + field.Name.Replace(markStr, ""));
                continue;
            }
            field.SetValue(obj, tmpCom);
        }
    }
    /// <summary>
    /// 创建奖励数据
    /// </summary>
    /// <param name="rewardData"></param>
    public void CreateRewardDataItem(string rewardData)
    {
        List <RewardTypeBean> listRewardData = RewardTypeEnumTools.GetListRewardData(rewardData);

        foreach (var itemData in listRewardData)
        {
            GameObject objReward = Instantiate(objRewardContainer, objRewardModel);
            RewardTypeEnumTools.GetRewardDetails(itemData);
            //设置图标
            Sprite spIcon = itemData.spRewardIcon;
            Image  ivIcon = CptUtil.GetCptInChildrenByName <Image>(objReward, "Icon");
            ivIcon.sprite = spIcon;
            //设置描述
            string rewardDes = itemData.rewardDescribe;
            Text   tvContent = CptUtil.GetCptInChildrenByName <Text>(objReward, "Text");
            tvContent.text  = rewardDes;
            tvContent.color = colorPre;
        }
        GameUtil.RefreshRectViewHight((RectTransform)objRewardContainer.transform, true);
        GameUtil.RefreshRectViewHight((RectTransform)transform, true);
    }
Пример #11
0
    public GameObject CreateNpc(long createNpcId, Vector3 position, int number)
    {
        CharacterBean characterData = null;
        GameObject    objNpc        = null;

        if (createNpcId == 0)
        {
            characterData = new CharacterBean();
        }
        else
        {
            characterData = new CharacterBean(mapNpcInfo[createNpcId]);
        }

        if (characterData == null)
        {
            LogUtil.LogError("没有找到id为" + createNpcId + "的NPC");
            return(null);
        }

        objNpc = Instantiate(StoryInfoHandler.Instance.manager.objNpcModel, StoryInfoHandler.Instance.builderForStory.transform);
        BaseNpcAI baseNpcAI = objNpc.GetComponent <BaseNpcAI>();

        baseNpcAI.Awake();

        CharacterDressCpt characterDress = CptUtil.GetCptInChildrenByName <CharacterDressCpt>(baseNpcAI.gameObject, "Body");

        characterDress.Awake();

        baseNpcAI.transform.localPosition = position;
        baseNpcAI.SetCharacterData(characterData);
        baseNpcAI.name = "character_" + number;
        objNpc.SetActive(true);

        return(objNpc);
    }
Пример #12
0
    /// <summary>
    /// 刷新场景数据
    /// </summary>
    /// <param name="listData"></param>
    public void RefreshSceneData(List <StoryInfoDetailsBean> listData)
    {
        if (listData == null)
        {
            return;
        }
        if (listStoryTextInfo != null)
        {
            listStoryTextInfo.Clear();
        }
        listStoryTextInfo = null;
        foreach (StoryInfoDetailsBean itemData in listData)
        {
            StoryInfoDetailsBean.StoryInfoDetailsTypeEnum storyInfoDetailsType = itemData.GetStoryInfoDetailsType();
            if (storyInfoDetailsType == StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.NpcPosition)
            {
                GameObject objNpc = GetSceneObjByName("character_" + itemData.num);
                BaseNpcAI  npcAI  = null;
                if (objNpc != null)
                {
                    npcAI = objNpc.GetComponent <BaseNpcAI>();
                }

                if (npcAI == null)
                {
                    NpcInfoBean npcInfoBean;
                    if (itemData.npc_id == 0)
                    {
                        npcInfoBean = new NpcInfoBean();
                    }
                    else if (itemData.npc_id == -1)
                    {
                        npcInfoBean = new NpcInfoBean();
                    }
                    else
                    {
                        if (mapNpcInfo.TryGetValue(itemData.npc_id, out NpcInfoBean npcInfo))
                        {
                            npcInfoBean = npcInfo;
                        }
                        else
                        {
                            npcInfoBean = new NpcInfoBean();
                            LogUtil.LogError("创建NPC失败 找不到ID为" + itemData.npc_id + "的NPC信息");
                        }
                    }
                    objNpc = CreateNpc(npcInfoBean.npc_id, new Vector3(itemData.position_x, itemData.position_y), itemData.num);
                    npcAI  = objNpc.GetComponent <BaseNpcAI>();
                }
                npcAI.transform.localPosition = new Vector3(itemData.position_x, itemData.position_y);
                //设置朝向
                npcAI.SetCharacterFace(itemData.face);
            }
            else if (storyInfoDetailsType == StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.NpcEquip)
            {
                GameObject objNpc = GetSceneObjByName("character_" + itemData.num);
                if (objNpc == null)
                {
                    continue;
                }
                BaseNpcAI npcAI = objNpc.GetComponent <BaseNpcAI>();
                if (npcAI == null)
                {
                    continue;
                }
                SexEnum sex = npcAI.characterData.body.GetSex();
                itemData.GetNpcEquip(sex, out long hatId, out long clothesId, out long shoesId);
                if (hatId != -1)
                {
                    npcAI.characterData.equips.hatTFId = hatId;
                }
                if (clothesId != -1)
                {
                    npcAI.characterData.equips.clothesTFId = clothesId;
                }
                if (shoesId != -1)
                {
                    npcAI.characterData.equips.shoesTFId = shoesId;
                }
                npcAI.SetCharacterData(npcAI.characterData);
            }
            else if (storyInfoDetailsType == StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.PropPosition)
            {
                GameObject objProp = GetSceneObjByName("prop_" + itemData.num);
                if (objProp == null)
                {
                    GameObject objModel = StoryInfoHandler.Instance.manager.GetStoryPropModelByName(itemData.key_name);
                    objProp      = Instantiate(objModel, StoryInfoHandler.Instance.builderForStory.transform);
                    objProp.name = "prop_" + itemData.num;
                }
                //设置位置和朝向
                objProp.transform.localPosition = new Vector3(itemData.position_x, itemData.position_y);
                Vector3 bodyScale = objProp.transform.localScale;
                switch (itemData.face)
                {
                case 1:
                    bodyScale.x = -1;
                    break;

                case 2:
                    bodyScale.x = 1;
                    break;
                }
                objProp.transform.localScale = bodyScale;
            }
            //如果是对话 查询对话数据
            else if (storyInfoDetailsType == StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.Talk)
            {
                listStoryTextInfo = textInfoService.QueryDataByMarkId(TextEnum.Story, itemData.text_mark_id);
            }
            else if (storyInfoDetailsType == StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.NpcDestory)
            {
                int[] numList = StringUtil.SplitBySubstringForArrayInt(itemData.npc_destroy, ',');
                foreach (int num in numList)
                {
                    BaseNpcAI npcAI = CptUtil.GetCptInChildrenByName <BaseNpcAI>(StoryInfoHandler.Instance.builderForStory.gameObject, num + "");
                    DestroyImmediate(npcAI.gameObject);
                }
            }
            else if (storyInfoDetailsType == StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.CameraPosition)
            {
                Vector3 cameraWorldPosition = StoryInfoHandler.Instance.builderForStory.transform.TransformPoint(new Vector3(itemData.position_x, itemData.position_y, -10));

                GameCameraHandler.Instance.manager.camera2D.Follow             = null;
                GameCameraHandler.Instance.manager.camera2D.transform.position = cameraWorldPosition;
            }
            else if (itemData.type == (int)StoryInfoDetailsBean.StoryInfoDetailsTypeEnum.CameraFollowCharacter)
            {
                BaseNpcAI npcAI = CptUtil.GetCptInChildrenByName <BaseNpcAI>(StoryInfoHandler.Instance.builderForStory.gameObject, "character_" + itemData.num);
                GameCameraHandler.Instance.manager.camera2D.Follow = npcAI.transform;
            }
        }
    }
Пример #13
0
    /// <summary>
    /// 死亡
    /// </summary>
    public void Dead()
    {
        //获取所有的骨骼节点
        //List<Transform> listObjBone = CptUtil.GetAllCptInChildrenByContainName<Transform>(gameObject, "Bone");
        //for (int i = 0; i < listObjBone.Count; i++)
        //{
        //    Transform itemBone = listObjBone[i];
        //    Rigidbody boneRB = itemBone.AddComponentEX<Rigidbody>();
        //}
        Vector3 randomRotate;
        int     random = WorldRandTools.Range(0, 4);

        switch (random)
        {
        case 0:
            randomRotate = new Vector3(90, 0, 0);
            break;

        case 1:
            randomRotate = new Vector3(-90, 0, 0);
            break;

        case 2:
            randomRotate = new Vector3(0, 0, 90);
            break;

        case 3:
            randomRotate = new Vector3(0, 0, -90);
            break;

        default:
            randomRotate = new Vector3(-90, 0, 0);
            break;
        }
        //身体侧翻
        transform
        .DOLocalRotate(randomRotate, 0.5f, RotateMode.Fast)
        .OnComplete(() =>
        {
            //查询身体位置
            Transform bodyTF = CptUtil.GetCptInChildrenByName <Transform>(gameObject, "BoneBody");
            //消失烟雾
            EffectBean effectData     = new EffectBean();
            effectData.effectName     = EffectInfo.Effect_Dead_1;
            effectData.effectType     = EffectTypeEnum.Visual;
            effectData.timeForShow    = 5;
            effectData.effectPosition = bodyTF.position;
            EffectHandler.Instance.ShowEffect(effectData, (effect) => { effect.PlayEffect(); });
            //删除此物体
            Destroy(gameObject);
        });
        //关闭动画
        creatureAnim.EnabledAnim(false);
        //关闭刚体
        if (rbCreature != null)
        {
            rbCreature.isKinematic = true;
        }
        //关闭检测
        if (colliderCreature != null)
        {
            colliderCreature.enabled = false;
        }
    }
Пример #14
0
 public virtual void Awake()
 {
     characterBody  = CptUtil.GetCptInChildrenByName <CharacterBodyCpt>(gameObject, "Body");
     characterDress = CptUtil.GetCptInChildrenByName <CharacterDressCpt>(gameObject, "Body");
 }