protected override void OnLoadedRes(string assetName, Object resObject) { this.m_entityObject = this.m_entityObject ?? new SceneItemEntityObject(this, resObject as GameObject); if (EntityData.itemPos.Count == 0) { Debug.LogError($"SceneItem no position data, ItemName:{EntityData.itemName} , ItemID:{EntityData.itemID}"); } //客户端自己随机放一个位置,mmp int randamLocationIndex = Random.Range(0, EntityData.itemPos.Count); ItemPosInfoJson itemLocationInfo = EntityData.itemPos[randamLocationIndex]; EntityData.itemPos.RemoveAt(randamLocationIndex); Confexhibit sceneItemConfig = Confexhibit.Get(EntityData.itemID); if (sceneItemConfig == null) { Debug.LogError($"no item :{EntityData.itemID}in exhibit "); } EntityPosition = new Vector3(itemLocationInfo.pos.x, itemLocationInfo.pos.y, itemLocationInfo.pos.z); EntityScale = new Vector3(itemLocationInfo.scale.x, itemLocationInfo.scale.y, itemLocationInfo.scale.z); EntityEulerRotation = new Vector3(itemLocationInfo.rotate.x, itemLocationInfo.rotate.y, itemLocationInfo.rotate.z); EntityLightInfo = new Vector4(itemLocationInfo.offsetX, itemLocationInfo.offsetY, itemLocationInfo.tilingX, itemLocationInfo.tilingY); EntityObject.SetColliderScale(sceneItemConfig.colliderScale); Vector3 finalPos = EntityObject.EntityTransform.rotation * EntityObject.entityCollider.center; centerPostion = EntityPosition + new Vector3(finalPos.x * EntityScale.x, finalPos.y * EntityScale.y, finalPos.z * EntityScale.z); CameraName = itemLocationInfo.cameraNode; }
private void InitUILogic() { if (m_reward_data == null || m_reward_data.ID == null) { Debug.LogError("no reward"); return; } if (m_reward_data.ID.Length > 4) { Debug.LogError("more reward"); } int rewardCount = m_reward_data.ID.Length; if (rewardCount == 1) { float centerY = (m_root_img[0].Y + m_root_img[2].Y) / 2f; layoutItem(new GameImage[] { m_root_img[0] }, m_root_img[0].X, centerY, m_root_img[1].X, centerY); } else if (rewardCount == 2) { float centerY = (m_root_img[0].Y + m_root_img[2].Y) / 2f; layoutItem(new GameImage[] { m_root_img[0], m_root_img[1] }, m_root_img[0].X, centerY, m_root_img[1].X, centerY); } else if (rewardCount == 3) { layoutItem(new GameImage[] { m_root_img[2] }, m_root_img[2].X, m_root_img[2].Y, m_root_img[3].X, m_root_img[3].Y); } for (int i = 0; i < 4; i++) { if (i < rewardCount) { Confexhibit conf = Confexhibit.Get(m_reward_data.ID[i]); if (conf != null) { m_reward_img[i].Sprite = conf.iconName; m_reward_lab[i].Text = LocalizeModule.Instance.GetString(conf.name); m_root_img[i].SetActive(true); } else { m_root_img[i].SetActive(false); } } else { m_root_img[i].SetActive(false); } } }
void GetIconAndName(long ItemID, out string icon, out string itemName, out int item_type) { icon = string.Empty; itemName = string.Empty; item_type = 0; if (ItemID >= 9999) { Confexhibit exhibitConfig = Confexhibit.Get(ItemID); icon = exhibitConfig.iconName; itemName = LocalizeModule.Instance.GetString(exhibitConfig.name); item_type = 1; } else { ConfProp itemConfig = ConfProp.Get(ItemID); icon = itemConfig.icon; itemName = LocalizeModule.Instance.GetString(itemConfig.name); } }
public override void OnShow(object param) { base.OnShow(param); GameEvents.UIEvents.UI_GameEntry_Event.OnMaskBGVisible.SafeInvoke(true); GameEvents.UIEvents.UI_GameEntry_Event.OnInfiniteVit += OnInfiniteVit; MessageHandler.RegisterMessageHandler(MessageDefine.SCSceneEnterResponse, OnScResponse); this.m_action_btn.AddClickCallBack(OnBtnStartGameClick); this.m_exp_reward_icon.AddPressDownCallBack(OnSceneGroupGiftPressDown); this.m_exp_reward_icon.AddPressUpCallBack(OnSceneGroupGiftPressUp); EnterSceneData enterSceneData = null; m_scene_id = -1; m_scene_group_id = -1; m_enter_msg = null; if (null != param) { enterSceneData = param as EnterSceneData; //this.m_scene_id = (int)enterSceneData.SceneID; this.m_taskConfID = enterSceneData.taskConfID; } if (-1 == m_taskConfID) { //不是从任务展示界面来的,不用翻转 BgShowAlpha(false); PanelDelayShowAlpha(0.0f); PanelDelayShowScale(0.0f); PanelTurnToOne(false); PanelGoDown(true); } else { //需要翻转 BgShowAlpha(true); PanelDelayShowAlpha(0.2f); PanelDelayShowScale(0.5f); PanelGoDown(false); PanelTurnToZero(false); PanelTurnToOne(true); } ConfTask task = null; if (this.m_taskConfID < 0) { //build top 进入 this.m_scene_group_id = FindObjSceneDataManager.ConvertSceneIdToSceneGroupId(enterSceneData.SceneID); m_group_data = new FindObjSceneData(this.m_scene_group_id, 1, 0); BuildTopCreateSceneByDifficult(this.m_scene_group_id); } else { task = ConfTask.Get(m_taskConfID); long tsk_scene_id = null != task ? task.conditionSceneId : enterSceneData.SceneID; m_special_scene_id = 0; //初始化一个默认的group data; m_group_data = new FindObjSceneData(FindObjSceneDataManager.ConvertSceneIdToSceneGroupId(tsk_scene_id), 1, 0); this.m_scene_group_id = FindObjSceneDataManager.ConvertSceneIdToSceneGroupId(tsk_scene_id); var temp_data = FindObjSceneDataManager.Instance.GetDataBySceneGroupID(m_scene_group_id); if (null != temp_data) { m_group_data = temp_data; } if (tsk_scene_id > 99999) { //配置的场景id if (1 == ConfScene.Get(tsk_scene_id).keyExhibit) { //关键证据关卡 CreateSceneBySpecial(tsk_scene_id); } else { //非关键关卡 //读取难度表 TaskCreateSceneByDifficult(this.m_taskConfID); } } else { //配置的场景组id,一定是非关键线索关卡 TaskCreateSceneByDifficult(this.m_taskConfID); } } m_play_mode_img.Sprite = this.GetModeIconName(m_scene_id); m_scene_tex.TextureName = m_s_info.thumbnail; m_scene_name_label.Text = LocalizeModule.Instance.GetString(m_s_info.name); this.ShowOutPut(m_s_info.outputExp, m_s_info.outputMoney, m_s_info.outputCash, m_s_info.outputVit); List <long> ids = CommonHelper.GetDropOuts(m_s_info.dropId); var props = from id in ids select new DropWrapper() { DropType = ENUM_DROP_TYPE.PROP, ItemID = id, ItemNum = 0, Icon = ConfProp.Get(id).icon, }; List <DropWrapper> totalToShow = new List <DropWrapper>(); if (null != task && task.conditionExhibits.Length > 0) { var exhibits = from id in task.conditionExhibits select new DropWrapper() { DropType = ENUM_DROP_TYPE.EXHABIT, ItemID = id, ItemNum = 0, Icon = Confexhibit.Get(id).iconName, }; totalToShow.AddRange(exhibits); } //DropWrapper te = new DropWrapper() //{ // DropType = ENUM_DROP_TYPE.EXHABIT, // ItemID = 10972, // ItemNum = 0, // Icon = Confexhibit.Get(10972).iconName, //}; //totalToShow.Add(te); totalToShow.AddRange(props); m_drop_grid.EnsureSize <DropItemIconEffect>(totalToShow.Count); for (int i = 0; i < m_drop_grid.ChildCount; ++i) { var show = totalToShow[i]; DropItemIconEffect di = m_drop_grid.GetChild <DropItemIconEffect>(i); m_drop_grid.GetChild <DropItemIconEffect>(i).InitSprite(show.Icon, show.ItemNum, show.ItemID, ENUM_DROP_TYPE.EXHABIT == show.DropType); if (ENUM_DROP_TYPE.PROP == show.DropType) { m_drop_grid.GetChild <DropItemIconEffect>(i).EnableTips(true); m_drop_grid.GetChild <DropItemIconEffect>(i).InitToolTipOffset(new Vector2(-280.0f, 0.0f)); } else { m_drop_grid.GetChild <DropItemIconEffect>(i).EnableTips(false); } m_drop_grid.GetChild <DropItemIconEffect>(i).Visible = true; } m_drop_grid.Visible = false; long scene_difficult_id = FindObjSceneDataManager.GetSceneDifficultID(m_scene_group_id, m_group_data.m_lvl); ConfSceneDifficulty difficult_data = ConfSceneDifficulty.Get(scene_difficult_id); m_gifts = new List <GroupToolTipsData>(); for (int i = 0; i < difficult_data.rewards.Length; ++i) { GroupToolTipsData reward = new GroupToolTipsData() { ItemID = difficult_data.rewards[i], CurCount = difficult_data.rewardNums[i], }; m_gifts.Add(reward); } m_difficult_icon.Sprite = ConfPoliceRankIcon.Get(m_group_data.m_lvl).icon; m_difficlut_step.Text = LocalizeModule.Instance.GetString(difficult_data.name); m_exp_progress.Value = (float)m_group_data.m_exp / (float)m_group_data.m_full_exp; m_exp_txt.Text = $"{m_group_data.m_exp}/{m_group_data.m_full_exp}"; Debug.Log($"关卡进入 关卡组id{m_group_data.m_scene_group_id}"); m_cost_time_num_label.Text = CommonTools.SecondToStringMMSS(this.m_time_cost_value); SetVitLabel(); m_is_action_btn_touched = false; this.m_action_btn.Enable = true; Dictionary <UBSParamKeyName, object> _params = new Dictionary <UBSParamKeyName, object>() { { UBSParamKeyName.Success, 1 }, { UBSParamKeyName.SceneID, this.m_scene_id }, }; UserBehaviorStatisticsModules.Instance.LogEvent(UBSEventKeyName.game_start, null, _params); }
/// <summary> /// 载入场景物件 /// </summary> /// <param name="decoratorList"></param> /// <param name="taskObjectList"></param> protected virtual void LoadSceneObjects(IList <long> decoratorList, IList <long> taskObjectList) { EngineCoreEvents.ResourceEvent.GetAssetEvent.SafeInvoke(this.m_sceneData.exhibitGroupId, (assetName, assetObject) => { m_sceneInfo = JSON.ToObject <SceneItemJson>(assetObject.ToString()); EngineCoreEvents.ResourceEvent.ReleaseAssetEvent.SafeInvoke(m_sceneData.exhibitGroupId, assetObject); Dictionary <long, ItemInfoJson> sceneItemConfigDict = new Dictionary <long, ItemInfoJson>(); //临时修改加载lightmap GOGUI.GOGUITools.GetAssetAction.SafeInvoke(m_sceneInfo.lightMapName, (prefabName, obj) => { this.m_isLightMapReady = true; //Texture lightTex = null; if (StringUtils.IsNullEmptyOrWhiteSpace(m_sceneInfo.lightMapName) || obj == null) { Debug.LogWarning($"can't find lightmap in {assetName}"); } if (obj != null) { this.m_sceneExtraLightTex = obj as Texture; } for (int i = 0; i < m_sceneInfo.items.Count; ++i) { ItemInfoJson itemInfo = m_sceneInfo.items[i]; if (!sceneItemConfigDict.ContainsKey(itemInfo.itemID)) { sceneItemConfigDict.Add(itemInfo.itemID, itemInfo); } else { Debug.LogError("item id duplicate ,item id:" + itemInfo.itemID + ", config info :" + assetName); } } //todo:之后重构 2018-7-26 20:25:39 for (int i = 0; i < decoratorList.Count; ++i) { long itemID = decoratorList[i]; if (!sceneItemConfigDict.ContainsKey(itemID)) { Debug.LogError("no item :" + itemID + " in " + assetName); } ItemInfoJson itemInfo = sceneItemConfigDict[itemID]; EntityBase sceneItemEntity = EntityManager.Instance.AllocEntity(EntityType.Scene_Decoration); Confexhibit confItem = Confexhibit.Get(itemInfo.itemID); if (confItem == null || string.IsNullOrEmpty(confItem.assetName)) { Debug.Log("can't find item:" + itemInfo.itemID); continue; } sceneItemEntity.SetAssetName(confItem.assetName); sceneItemEntity.SetEntityData(itemInfo); sceneItemEntity.SetLightTexture(m_sceneExtraLightTex); sceneItemEntity.PreloadAsset(); AddSceneEntity(sceneItemEntity); } for (int i = 0; i < taskObjectList.Count; ++i) { long itemID = taskObjectList[i]; if (!sceneItemConfigDict.ContainsKey(itemID)) { Debug.LogError("no item :" + itemID + " in " + assetName); } ItemInfoJson itemInfo = sceneItemConfigDict[itemID]; EntityBase sceneItemEntity = EntityManager.Instance.AllocEntity(EntityType.Scene_Object); Confexhibit confItem = Confexhibit.Get(itemInfo.itemID); if (confItem == null || string.IsNullOrEmpty(confItem.assetName)) { Debug.Log("can't find item:" + itemInfo.itemID); continue; } sceneItemEntity.SetAssetName(confItem.assetName); sceneItemEntity.SetEntityData(itemInfo); sceneItemEntity.SetLightTexture(m_sceneExtraLightTex); sceneItemEntity.PreloadAsset(); AddSceneEntity(sceneItemEntity); } InitFindingEntityItems(); }, LoadPriority.Default); /////// }, LoadPriority.Prior); }