private static void OnCoreGameCompelte() { var sliceRow = StaticDataLite.GetRow("pice_slice", lastSliceId.ToString()); var gold = sliceRow.Get <int>("gold"); var exp = sliceRow.Get <int>("exp"); HeadBarFloating.instance.AutoRefresh = false; PlayerStatus.exp += 10; PlayerStatus.gold += 10; PlayerStatus.completeCount++; // 更新记录 var record = PlayerStatus.GetCompleteInfoOfPicId(lastPicId); if (record == null || record.sliceId < lastSliceId) { var info = new CompleteInfo(); info.pid = lastPicId; info.sliceId = lastSliceId; PlayerStatus.completeDic[lastPicId.ToString()] = info; } // 如果这张图有中途存档,则删除存档 PlayerStatus.RemoveUncompleteInfoOfPicId(lastPicId); PlayerStatus.Save(); LevelCompletePage.goldParam = gold; LevelCompletePage.expParam = exp; var admin = new Admission_FadeInNewPage(); UIEngine.Forward <LevelCompletePage>(null, admin); }
void Start() { Application.logMessageReceived += OnUnityLog; UnityEngine.Random.InitState(DateTime.UtcNow.Second); StaticDataLite.Init(); UIEngine.Init(); PlayerStatus.Read(); UIEngine.Forward("LoadingPage", null, new Admission_None()); //UIEngine.Forward<LevelCompletePage>(); if (GameInfo.ForceDeveloper) { var commandline = UIEngine.ShowFloating <CommandLineFloating>(null, UIDepth.Top); } if (GameInfo.ForceRemoveAd) { PlayerStatus.removeAd = true; } PushManager.ResetNotification(); // 摄像机渲染区域默认根据高去调整宽 // 但是这里需要根据宽调整高 // 因此需要手动设置摄像机的渲染高度,达到宽度固定 1080 效果 heightScale = CameraUtil.SetCameraSizeByDecisionRevelutionAndFixAtWidth(1080, 1920); var silence = GameManifestFinal.Get("silence", "false"); if (silence == "true") { AudioManager.Volume = 0; } }
void SetItem(PictruePage_Item item, PictruePage_ItemData data) { item.data = data; item.name = data.picRow.TryGet <string>("id", "none-id"); if (item.name == "1") { pic1 = item; } switch (data.status) { case PicturePage_ItemStatus.Locked: item.IsShowPuzzleMask = true; item.IsShowUnlockLayer = true; item.IsShowPice = false; var unlockGold = data.picRow.Get <int>("cost"); var unlockButotnText = unlockGold + "金币解锁"; item.UnlockButtonText = unlockButotnText; break; case PicturePage_ItemStatus.Unlocked: { item.IsShowPuzzleMask = true; item.IsShowUnlockLayer = false; var picId = data.picRow.Get <int>("id"); var info = PlayerStatus.TryGetUncompleteOfPicId(picId); if (info != null) { var sliceCount = StaticDataLite.GetCell <int>("pice_slice", info.sliceId.ToString(), "count"); item.PiceCount = sliceCount; item.IsShowPice = true; } else { item.IsShowPice = false; } break; } case PicturePage_ItemStatus.Complete: { item.IsShowPuzzleMask = false; item.IsShowUnlockLayer = false; item.IsShowPice = true; var picId = data.picRow.Get <int>("id"); var info = PlayerStatus.GetCompleteInfoOfPicId(picId); if (info != null) { var sliceCount = StaticDataLite.GetCell <int>("pice_slice", info.sliceId.ToString(), "count"); item.PiceCount = sliceCount; } break; } } item.LabelText = data.picRow.Get <string>("name"); var file = data.picRow.Get <string>("file"); var sprite = PicLibrary.LoadContentSprite(file); item.Sprite = sprite; }
public static bool IsPictureUnlocked(string id) { var defaultUnlocked = StaticDataLite.GetCell <bool>("pic", id, "unlock"); var unlock = PlayerPrefs.GetInt("levelstorage.unlock." + id, 0); return(defaultUnlocked || unlock == 1); }
public static void ResetNotification() { LocalNotification.ClearNotifications(); var now = DateTime.Now; var sheet = StaticDataLite.GetSheet("push"); var dataList = new List <PushData>(); foreach (string key in sheet.Keys) { var row = sheet[key]; var data = new PushData(); data.row = row; var h = row.Get <int>("h"); var m = row.Get <int>("m"); var s = row.Get <int>("s"); data.shike = new DateTime(now.Year, now.Month, now.Day, h, m, s); dataList.Add(data); } for (int i = 0; i < 5; i++) { foreach (var data in dataList) { data.shike = data.shike.AddDays(1); var delay = data.shike - now; var title = data.row.Get <string>("title"); var text = data.row.Get <string>("text"); LocalNotification.SendNotification(delay, title, text, new Color32(0xff, 0x44, 0x44, 255)); Debug.Log("set notification at: " + data.shike); } } }
public static void EnterCore(int picId, int sliceId) { // save status lastPicId = picId; lastSliceId = sliceId; // hide bg and show core page UIEngine.HideFlaoting <BackgroundFloating>(); UIEngineHelper.WateAdmissionComplete(() => { UIEngine.Forward <CorePage>(); }); // load picture which player select var picFile = StaticDataLite.GetCell <string>("pic", picId.ToString(), "file"); var contentSprite = PicLibrary.LoadContentSprite(picFile); // load slice info var piceSize = StaticDataLite.GetCell <int>("pice_slice", sliceId.ToString(), "cell_size"); // test code // piceSize = 400; // start core game Puzzle.Instance.StartPuzzle(contentSprite, piceSize); // when compelte Puzzle.Instance.Complete += OnCoreGameCompelte; //LocalNotification.SendNotification(1, 5000, "Title", "Long message text", new Color32(0xff, 0x44, 0x44, 255)); }
public static void Pay(int goodsId, Action <bool> onComplete = null) { var row = StaticDataLite.GetRow("shop", goodsId.ToString()); var productName = row.Get <string>("product_name"); var productDesc = row.Get <string>("product_desc"); var price_yuan = row.Get <float>("price"); var gold = row.Get <int>("gold"); var func = row.Get <string>("func"); var itemId = goodsId; var price_fen = price_yuan * 100; var jd = new JsonData(); jd["productName"] = productName; jd["productDesc"] = productDesc; jd["price_fen"] = price_fen; jd["price_yuan"] = price_yuan; jd["itemId"] = itemId; jd["gold"] = gold; var json = jd.ToJson(); // NativeBridge.InvokeCall("NativeSDKManager", "Pay", json, result => // { // if(result == "SUCCESS") // { // Log.Scrren("SUCCESS"); // Helper.AddGold(gold); // if(!string.IsNullOrEmpty(func)) // { // if(func == "REMOVE_AD") // { // PlayerStatus.removeAd = true; // } // } // PlayerStatus.Save(); // if(onComplete != null) // { // onComplete(true); // } // } // else if(result == "FAIL") // { // Log.Scrren("FAIL"); // if(onComplete != null) // { // onComplete(false); // } // } // else if(result == "CANCEL") // { // Log.Scrren("CANCEL"); // if(onComplete != null) // { // onComplete(false); // } // } // }); }
public static string Get(string key) { var language = StaticDataLite.GetCell <string>("msglist", key, "cn"); if (language == null) { return(key); } return(language); }
public static JsonData FindFirstRowOfType(string findType) { var sheet = StaticDataLite.GetSheet("pic"); foreach (string id in sheet.Keys) { var row = sheet[id]; var type = row.Get <string>("type"); if (findType == type) { return(row); } } return(null); }
private void Refresh() { // rebuild item list itemList.Clear(); TransformUtil.DestroyAllChildren(transform_listRoot); // add ad item first { var tr = GameObject.Instantiate(prefab_ad_item); tr.parent = transform_listRoot; tr.transform.localScale = Vector2.one; tr.gameObject.SetActive(true); var item = tr.GetComponent <ShopPage_Item>(); itemList.Add(item); adItem = item as ShopPage_AdItem; } // add iap items var sheet = StaticDataLite.GetSheet("shop"); foreach (string id in sheet.Keys) { var row = sheet[id]; var tr = GameObject.Instantiate(prefab_ipa_item); tr.parent = transform_listRoot; tr.transform.localScale = Vector2.one; tr.gameObject.SetActive(true); var item = tr.GetComponent <ShopPage_IapItem>(); item.Init(row); itemList.Add(item); } var itemHeight = prefab_ad_item.GetComponent <RectTransform>().rect.height; var gl = transform_listRoot.GetComponent <UnityEngine.UI.VerticalLayoutGroup>(); var spaceingY = gl.spacing; var listInset = 487; var extra = 200; var rowCount = itemList.Count; var scrollContentHeight = itemHeight * rowCount + (rowCount - 1) * spaceingY + listInset + extra; var rt = scrollViewContent.GetComponent <RectTransform>(); rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scrollContentHeight); }
public override void OnPush() { // read slice type from static data var sheet = StaticDataLite.GetSheet("pice_slice"); var rowList = new List <JsonData>(); foreach (string id in sheet.Keys) { var row = sheet[id]; rowList.Add(row); //dataList.Add("x" + row["cell_size"]); } sampleizeScrollRect.ChangeData(rowList.ToArray()); // resize content var layout = sampleizeScrollRect.layout as HorizontalLayoutGroup; var ItemListLength = rowList.Count * sampleizeScrollRect.sample.rect.width + (rowList.Count - 1) * layout.spacing; var preExtra = 500; var postExtra = 500; var contentLength = preExtra + ItemListLength + postExtra; sampleizeScrollRect.Content.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, contentLength); OnRotateSelection(); lostTime = 0; first = true; // 检查是否有已经开始的拼图 // var picId = PicId; // var b = HasUncompleteGame(picId); // if(b) // { // } // if(info == null) // { // button_continue.gameObject.SetActive(false); // } // else // { // button_continue.gameObject.SetActive(true); // } }
private void Refrehs() { // create data list form static data var sheet = StaticDataLite.GetSheet("pictype"); var dataList = new List <MainPage_ItemData>(); foreach (string key in sheet.Keys) { var row = sheet[key]; var data = new MainPage_ItemData { row = row, visible = true, }; dataList.Add(data); } // 检查是否有未完成拼图 { var count = PlayerStatus.uncompletePuzzle.Count; var data = new MainPage_ItemData() { pageType = PicturePageType.Uncomplete, visible = count > 0, }; dataList.Insert(0, data); } // 检查是否有已完成的拼图 { var count = PlayerStatus.completeDic.Count; var data = new MainPage_ItemData() { pageType = PicturePageType.Complete, visible = count > 0, }; dataList.Insert(0, data); } SetDataList(dataList); }
public override void OnParamChanged() { this.p = param as PicturePageParam; if (p.pageType == PicturePageType.Uncomplete) { this.text_title.text = "未完成"; this.text_des.text = "共 " + PlayerStatus.uncompletePuzzle.Count + " 张"; } else if (p.pageType == PicturePageType.Pictype) { var pictype = p.picTypeId; var name = StaticDataLite.GetCell <string>("pictype", pictype, "display_name"); var des = StaticDataLite.GetCell <string>("pictype", pictype, "des"); this.text_title.text = name; this.text_des.text = des; } else if (p.pageType == PicturePageType.Complete) { this.text_title.text = "已完成"; this.text_des.text = "共 " + PlayerStatus.completeDic.Count + " 张"; } }
public override void OnPush() { // 如果要显示的是某个图片分类 if (p.pageType == PicturePageType.Pictype) { // 从 pic 表中找出所有 type 是 param 的数据行 // 并且包装成 PicturePage_ItemData var sheet = StaticDataLite.GetSheet("pic"); var pictype = this.p.picTypeId; var dataList = new List <PictruePage_ItemData>(); foreach (string key in sheet.Keys) { var row = sheet[key]; if (row.Get <string>("type") == pictype) { var data = new PictruePage_ItemData { picRow = row, }; // check unlock info var unlocked = LevelStorage.IsPictureUnlocked(key); var complete = PlayerStatus.IsPictureComplete(int.Parse(key)); var status = PicturePage_ItemStatus.Locked; if (complete) { status = PicturePage_ItemStatus.Complete; } else if (unlocked) { status = PicturePage_ItemStatus.Unlocked; } data.status = status; dataList.Add(data); } } this.setDataList(dataList); // set picture count var completePictureCount = 0; var pictureCount = dataList.Count; foreach (var data in dataList) { if (data.status == PicturePage_ItemStatus.Complete) { completePictureCount++; } } text_pictureCount.text = completePictureCount + "/" + pictureCount; } // 如果要显示的是未完成的拼图 if (p.pageType == PicturePageType.Uncomplete) { var dataList = new List <PictruePage_ItemData>(); foreach (var kv in PlayerStatus.uncompletePuzzle) { var info = kv.Value; var picRow = StaticDataLite.GetRow("pic", info.picId.ToString()); var data = new PictruePage_ItemData { picRow = picRow, }; data.status = PicturePage_ItemStatus.Unlocked; dataList.Add(data); } this.setDataList(dataList); text_pictureCount.text = PlayerStatus.uncompletePuzzle.Count.ToString(); } // 如果要显示已完成的图片 if (p.pageType == PicturePageType.Complete) { var dataList = new List <PictruePage_ItemData>(); foreach (var kv in PlayerStatus.completeDic) { var info = kv.Value; var picId = info.pid; var picRow = StaticDataLite.GetRow("pic", picId.ToString()); var data = new PictruePage_ItemData { picRow = picRow, }; data.status = PicturePage_ItemStatus.Complete; dataList.Add(data); } text_pictureCount.text = dataList.Count.ToString(); this.setDataList(dataList); } }
int GetGoldOfDay(int day) { return(StaticDataLite.GetCell <int>("sign", day.ToString(), "gold")); }
string GetTitleOfDay(int day) { return(StaticDataLite.GetCell <string>("sign", day.ToString(), "title")); }
public static JsonData LoadDataRow(int id) { return(StaticDataLite.GetRow("pic", id.ToString())); }
void SetData(MainPage_Item item, MainPage_ItemData data) { // var sw = new Stopwatch(); // sw.Start(); item.data = data; item.gameObject.SetActive(data.visible); if (data.pageType == PicturePageType.Uncomplete) { uncompleteItem = item; } else if (data.pageType == PicturePageType.Complete) { completeItem = item; } if (!data.visible) { return; } // 如果是一个图片分类 if (data.pageType == PicturePageType.Pictype) { item.label.text = data.row.Get <string>("display_name"); var picType = data.row.Get <string>("id"); var row = PicLibrary.FindFirstRowOfType(picType); var file = row?.Get <string>("file"); var sprite = PicLibrary.LoadContentSprite(file); item.Facade = sprite; item.name = data.row.TryGet <string>("id", "no_id"); if (item.name == "animal") { animal = item; } } // 如果是未完成的拼图 if (data.pageType == PicturePageType.Uncomplete) { item.label.text = "未完成"; if (PlayerStatus.uncompletePuzzle.Count > 0) { var firstCoreInfo = PlayerStatus.FirstUncompletePuzzleInfo; var picId = firstCoreInfo.picId; var picRow = StaticDataLite.GetRow("pic", picId.ToString()); var fileName = picRow.Get <string>("file"); var sprite = PicLibrary.LoadContentSprite(fileName); item.Facade = sprite; } } // 如果是已完成的拼图 if (data.pageType == PicturePageType.Complete) { item.label.text = "已完成"; CompleteInfo firstInfo = null; foreach (var kv in PlayerStatus.completeDic) { firstInfo = kv.Value; break; } var picId = firstInfo.pid; var picRow = StaticDataLite.GetRow("pic", picId.ToString()); var fileName = picRow.Get <string>("file"); var sprite = PicLibrary.LoadContentSprite(fileName); item.Facade = sprite; } // sw.Stop(); // Debug.Log("set item: " + sw.Elapsed.TotalSeconds); }