IEnumerator RunAttendance(WWW www) { yield return(www); UtilMgr.DismissLoading(); if (www.error != null) { DialogueMgr.ShowDialogue("attendance error", www.error, DialogueMgr.DIALOGUE_TYPE.Alert, null); } else { Debug.Log("www : " + www.text); if (www.text != null && www.text.Length > 0) { // mWebview.SetActive(true); // mWebview.GetComponent<ScriptGameWebview>().GoTo(www.text); DailyReward dReward = Newtonsoft.Json.JsonConvert.DeserializeObject <DailyReward>(www.text); if (dReward.result == 200) { DialogueMgr.ShowDialogue("접속보상", dReward.message, DialogueMgr.DIALOGUE_TYPE.Alert, null); Debug.Log("add"); if (Application.loadedLevelName.Equals("SceneMain")) { Debug.Log("add Main"); transform.root.FindChild("GameObject").FindChild("Top").FindChild("Panel").FindChild("BtnPost").GetComponent <PostButton>().YellowOn(); } } } else { // Debug.Log("Attendance is already done"); } } }
public void Rehearsal() { var action = new DailyReward { avatarAddress = _avatarAddress, }; var nextState = action.Execute(new ActionContext { BlockIndex = 0, PreviousStates = new State(), Random = new TestRandom(), Rehearsal = true, Signer = _agentAddress, }); var updatedAddresses = new List <Address> { _avatarAddress, _avatarAddress.Derive(LegacyInventoryKey), _avatarAddress.Derive(LegacyWorldInformationKey), _avatarAddress.Derive(LegacyQuestListKey), }; Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); }
private DailyRewardModel GetSpecialDailyRewardModel(int[] qtSpecialList, DailyReward reward, int[] qtOwnerList, int[] qtOthersList, QuizzOverviewModel item) { DailyRewardModel model = new DailyRewardModel { DailyRewardId = reward.Id, IsTaken = false, Points = 0, AvailablePoints = _svcContainer.QuizzPointsSvc.GetPointsFor(QuizzPointsEnum.DailySpecialQuizz) };; bool qtSpecialListHasId = qtSpecialList.Contains(reward.Id); if (qtSpecialList.Length < QuizzPointsService.MaxDailySpecialQuizzTake) { model.IsTaken = qtSpecialListHasId; } else { if (qtSpecialListHasId) { model.IsTaken = true; } else { model = GetNormalDailRewardModel(qtOwnerList, qtOthersList, item); } } return(model); }
private void GiveReward(DailyRewardBundle rewardBundle) { if (rewardBundle == null) { return; } List <DailyReward> list = rewardBundle.GetRewards(RewardSystem.CurrentRewardStatus.PendingRewardLevel); if (list == null) { return; } for (int i = 0; i < list.Count; i++) { DailyReward dailyReward = list[i]; string customTypeOfGain = "Odyssey daily reward"; switch (dailyReward.prize) { case PrizeType.SuperGlue: GameProgress.AddSuperGlue(dailyReward.prizeCount); if (Singleton <IapManager> .Instance != null) { Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.SuperGlueSingle, dailyReward.prizeCount, customTypeOfGain); } break; case PrizeType.SuperMagnet: GameProgress.AddSuperMagnet(dailyReward.prizeCount); if (Singleton <IapManager> .Instance != null) { Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.SuperMagnetSingle, dailyReward.prizeCount, customTypeOfGain); } break; case PrizeType.TurboCharge: GameProgress.AddTurboCharge(dailyReward.prizeCount); if (Singleton <IapManager> .Instance != null) { Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.TurboChargeSingle, dailyReward.prizeCount, customTypeOfGain); } break; case PrizeType.SuperMechanic: GameProgress.AddBluePrints(dailyReward.prizeCount); if (Singleton <IapManager> .Instance != null) { Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.BlueprintSingle, dailyReward.prizeCount, customTypeOfGain); } break; case PrizeType.NightVision: GameProgress.AddNightVision(dailyReward.prizeCount); if (Singleton <IapManager> .Instance != null) { Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.NightVisionSingle, dailyReward.prizeCount, customTypeOfGain); } break; } } }
public void Execute(ItemType itemType, string guid, long requiredBlockIndex, bool contain) { var avatarState = _initialState.GetAvatarState(_avatarAddress); INonFungibleItem nonFungibleItem; Guid itemId = new Guid(guid); if (itemType == ItemType.Equipment) { var itemUsable = ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); nonFungibleItem = itemUsable; } else { var costume = ItemFactory.CreateCostume(_tableSheets.CostumeItemSheet.First, itemId); costume.Update(requiredBlockIndex); nonFungibleItem = costume; } if (contain) { avatarState.inventory.AddItem((ItemBase)nonFungibleItem); } var result = new DailyReward.DailyRewardResult() { id = default,
public void Execute() { var dailyRewardAction = new DailyReward { avatarAddress = _avatarAddress, }; var nextState = dailyRewardAction.Execute(new ActionContext { BlockIndex = 0, PreviousStates = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, }); var gameConfigState = nextState.GetGameConfigState(); var nextAvatarState = nextState.GetAvatarState(_avatarAddress); Assert.Equal(gameConfigState.ActionPointMax, nextAvatarState.actionPoint); Assert.Single(nextAvatarState.mailBox); var mail = nextAvatarState.mailBox.First(); var rewardMail = mail as DailyRewardMail; Assert.NotNull(rewardMail); var rewardResult = rewardMail.attachment as DailyReward.DailyRewardResult; Assert.NotNull(rewardResult); Assert.Single(rewardResult.materials); var material = rewardResult.materials.First(); Assert.Equal(400000, material.Key.Id); Assert.Equal(10, material.Value); }
IEnumerator RunAttendance(WWW www) { yield return(www); UtilMgr.DismissLoading(); if (www.error != null) { DialogueMgr.ShowDialogue("attendance error", www.error, DialogueMgr.DIALOGUE_TYPE.Alert, null); } else { Debug.Log("Attendance : " + www.text); if (www.text != null && www.text.Length > 0) { // mWebview.SetActive(true); // mWebview.GetComponent<ScriptGameWebview>().GoTo(www.text); DailyReward dReward = Newtonsoft.Json.JsonConvert.DeserializeObject <DailyReward>(www.text); if (dReward.result == 200) { DialogueMgr.ShowDialogue("접속보상", dReward.message, DialogueMgr.DIALOGUE_TYPE.Alert, CheckRecent); Debug.Log("add"); if (Application.loadedLevelName.Equals("SceneMain 1")) { Debug.Log("add Main"); transform.root.FindChild("GameObject").FindChild("Top").FindChild("Panel").FindChild("BtnPost").GetComponent <PostButton>().YellowOn(); } } else { CheckRecentMaessga(); } if (dReward.legend != null && dReward.legend.Length > 0) { //show n link url UserMgr.legend = dReward.legend; } else { //unshow // transform.root.FindChild("Scroll").FindChild("Main").FindChild("Nomal Contest") // .FindChild("EventPanel").gameObject.SetActive(false); // transform.root.FindChild("Scroll").FindChild("Main").FindChild("Nomal Contest").FindChild("Scroll View2") // .GetComponent<UIPanel>().SetRect(720f,1038f); // transform.root.FindChild("Scroll").FindChild("Main").FindChild("Nomal Contest").FindChild("Scroll View2") // .localPosition += new Vector3(0,75f,0); // transform.root.FindChild("Scroll").FindChild("Main").FindChild("Nomal Contest").FindChild("Scroll View2") // .GetComponent<UIDraggablePanel2>().ResetPosition(); } } else { // Debug.Log("Attendance is already done"); } } }
private void OnValidate() { if (dailyPanel == null) { dailyPanel = GetComponentInChildren <DailyPanel>(); } if (dailyReward == null) { dailyReward = GetComponentInChildren <DailyReward>(); } }
private void Awake() { Screen.sleepTimeout = SleepTimeout.NeverSleep; questManager = FindObjectOfType <QuestManager>(); userData = FindObjectOfType <UserData>(); colorPaletteHolder = FindObjectOfType <ColorPalleteHolder>(); encyclopedia = FindObjectOfType <Encyclopedia>(); characterManager = FindObjectOfType <CharacterManager>(); dailyReward = FindObjectOfType <DailyReward>(); realTimeHandler = FindObjectOfType <RealTimeHandler>(); }
public void ExecuteThrowFailedLoadStateException() { var action = new DailyReward { avatarAddress = _avatarAddress, }; Assert.Throws <FailedLoadStateException>(() => action.Execute(new ActionContext() { PreviousStates = new State(), Signer = _agentAddress, BlockIndex = 0, }) ); }
private IAccountStateDelta ExecuteInternal(IAccountStateDelta previousStates, long blockIndex = 0) { var dailyRewardAction = new DailyReward { avatarAddress = _avatarAddress, }; return(dailyRewardAction.Execute(new ActionContext { BlockIndex = blockIndex, PreviousStates = previousStates, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, })); }
private bool CreateDailyReward( int category, List <DailyReward> list, DailyRewardLevel currentUserLevel, QuizzGradeLevelEnum min, QuizzGradeLevelEnum max, DateTime today) { int qzCount = _uow.Quizzes.GetAll() .Where(q => q.Category == category && q.IsLive == true && ( (min >= q.GradeLevelMin && min <= q.GradeLevelMax && max >= q.GradeLevelMin && max <= q.GradeLevelMax) || (min >= q.GradeLevelMin && min <= q.GradeLevelMax && max >= q.GradeLevelMin && max >= q.GradeLevelMax) || (min <= q.GradeLevelMin && min <= q.GradeLevelMax && max >= q.GradeLevelMin && max <= q.GradeLevelMax) || (min <= q.GradeLevelMin && min <= q.GradeLevelMax && max >= q.GradeLevelMin && max >= q.GradeLevelMax))) .Count(); if (qzCount == 0) { return(false); } int quizzIdx = _random.Next(qzCount); int quizzId = _uow.Quizzes.GetAll() .Where(q => q.Category == category && q.IsLive == true && ( (min >= q.GradeLevelMin && min <= q.GradeLevelMax && max >= q.GradeLevelMin && max <= q.GradeLevelMax) || (min >= q.GradeLevelMin && min <= q.GradeLevelMax && max >= q.GradeLevelMin && max >= q.GradeLevelMax) || (min <= q.GradeLevelMin && min <= q.GradeLevelMax && max >= q.GradeLevelMin && max <= q.GradeLevelMax) || (min <= q.GradeLevelMin && min <= q.GradeLevelMax && max >= q.GradeLevelMin && max >= q.GradeLevelMax))) .OrderByDescending(q => q.Modified) .Skip(quizzIdx) .Take(1) .Select(q => q.Id) .FirstOrDefault(); if (quizzId == 0) { return(false); } DailyReward reward = new DailyReward { ForDate = today, Level = currentUserLevel, QuizzId = quizzId }; _uow.DailyRewards.Add(reward); list.Add(reward); return(true); }
public void Execute() { var dailyRewardAction = new DailyReward { avatarAddress = _avatarAddress, }; var nextState = dailyRewardAction.Execute(new ActionContext { BlockIndex = 0, PreviousStates = _initialState, Rehearsal = false, Signer = _agentAddress, }); var gameConfigState = nextState.GetGameConfigState(); var nextAvatarState = nextState.GetAvatarState(_avatarAddress); Assert.Equal(gameConfigState.ActionPointMax, nextAvatarState.actionPoint); }
public IObservable <ActionBase.ActionEvaluation <DailyReward> > DailyReward() { // NOTE: 이곳에서 하는 것이 바람직 하지만, 연출 타이밍을 위해 밖에서 한다. // var avatarAddress = States.Instance.CurrentAvatarState.address; // LocalLayerModifier.ModifyAvatarDailyRewardReceivedIndex(avatarAddress, true); // LocalLayerModifier.ModifyAvatarActionPoint(avatarAddress, GameConfig.ActionPointMax); var action = new DailyReward { avatarAddress = States.Instance.CurrentAvatarState.address, }; ProcessAction(action); return(_renderer.EveryRender <DailyReward>() .Where(eval => eval.Action.Id.Equals(action.Id)) .Take(1) .Last() .ObserveOnMainThread() .Timeout(ActionTimeout) .DoOnError(e => HandleException(action.Id, e))); }
private void CheckAddSpecialDailyReward(TestLogModel testLog, DailyReward reward, bool callSaveChanges) { var rewardIdList = HelperUtil.GetIntArrayFromString(_currentUser.DailySpecialPointsQuizzStrList); User user = null; bool qtRewardListHasId = rewardIdList.Contains(reward.Id); if (qtRewardListHasId == false) { if (rewardIdList.Length < QuizzPointsService.MaxDailySpecialQuizzTake) { var points = ComputRewardPonts(testLog.Score, testLog.Total); if (points != 0) { user = _svcContainer.QuizzPointsSvc.AddCurrentUserPoints(QuizzPointsEnum.DailySpecialQuizz, callSaveChanges); } else { user = _uow.Users.GetById(_currentUser.Id); } user.DailySpecialPointsQuizzStrList = _currentUser.DailySpecialPointsQuizzStrList = user.DailySpecialPointsQuizzStrList + reward.Id.ToString() + ","; _uow.Users.Update(user); _svcContainer.UserSvc.UpdateCurrentUserInSession(); if (callSaveChanges) { _uow.SaveChanges(); } } else { CheckAddNormalDailyReward(testLog, callSaveChanges); } } }
public ActionMutation() { Field <NonNullGraphType <BooleanGraphType> >("createAvatar", resolve: context => { try { NineChroniclesNodeService service = context.Source; PrivateKey privatekey = service.PrivateKey; BlockChain <NineChroniclesActionType> blockChain = service.Swarm.BlockChain; Address userAddress = privatekey.PublicKey.ToAddress(); Address avatarAddress = userAddress.Derive("avatar_0"); var action = new CreateAvatar { avatarAddress = avatarAddress, index = 0, hair = 0, lens = 0, ear = 0, tail = 0, name = "createbymutation", }; var actions = new PolymorphicAction <ActionBase>[] { action }; blockChain.MakeTransaction(privatekey, actions); } catch (Exception e) { var msg = $"Unexpected exception occurred during {typeof(ActionMutation)}: {e}"; context.Errors.Add(new ExecutionError(msg, e)); Log.Error(msg, e); return(false); } return(true); }); Field <NonNullGraphType <BooleanGraphType> >("hackAndSlash", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "weeklyArenaAddress", }, new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "rankingArenaAddress", }), resolve: context => { try { NineChroniclesNodeService service = context.Source; PrivateKey privatekey = service.PrivateKey; BlockChain <NineChroniclesActionType> blockChain = service.Swarm.BlockChain; Address userAddress = privatekey.PublicKey.ToAddress(); Address avatarAddress = userAddress.Derive("avatar_0"); Address weeklyArenaAddress = new Address(context.GetArgument <string>("weeklyArenaAddress")); Address rankingArenaAddress = new Address(context.GetArgument <string>("rankingArenaAddress")); var action = new HackAndSlash { avatarAddress = avatarAddress, worldId = 1, stageId = 1, WeeklyArenaAddress = weeklyArenaAddress, RankingMapAddress = rankingArenaAddress, costumes = new List <int>(), equipments = new List <Guid>(), foods = new List <Guid>(), }; var actions = new PolymorphicAction <ActionBase>[] { action }; blockChain.MakeTransaction(privatekey, actions); } catch (Exception e) { var msg = $"Unexpected exception occurred during {typeof(ActionMutation)}: {e}"; context.Errors.Add(new ExecutionError(msg, e)); Log.Error(msg, e); return(false); } return(true); }); Field <NonNullGraphType <BooleanGraphType> >("combinationEquipment", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <DecimalGraphType> > { Name = "recipeId", }, new QueryArgument <NonNullGraphType <DecimalGraphType> > { Name = "slotIndex", }, new QueryArgument <DecimalGraphType> { Name = "subRecipeId", }), resolve: context => { try { NineChroniclesNodeService service = context.Source; PrivateKey privatekey = service.PrivateKey; BlockChain <NineChroniclesActionType> blockChain = service.Swarm.BlockChain; Address userAddress = privatekey.PublicKey.ToAddress(); Address avatarAddress = userAddress.Derive("avatar_0"); int recipeId = context.GetArgument <int>("recipeId"); int slotIndex = context.GetArgument <int>("slotIndex"); int?subRecipeId = context.GetArgument <int>("subRecipeId"); var action = new CombinationEquipment { AvatarAddress = avatarAddress, RecipeId = recipeId, SlotIndex = slotIndex, SubRecipeId = subRecipeId }; var actions = new PolymorphicAction <ActionBase>[] { action }; blockChain.MakeTransaction(privatekey, actions); } catch (Exception e) { var msg = $"Unexpected exception occurred during {typeof(ActionMutation)}: {e}"; context.Errors.Add(new ExecutionError(msg, e)); Log.Error(msg, e); return(false); } return(true); }); Field <NonNullGraphType <BooleanGraphType> >("itemEnhancement", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "itemId", }, new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "materialIds", }), resolve: context => { try { NineChroniclesNodeService service = context.Source; PrivateKey privatekey = service.PrivateKey; BlockChain <NineChroniclesActionType> blockChain = service.Swarm.BlockChain; Address userAddress = privatekey.PublicKey.ToAddress(); Address avatarAddress = userAddress.Derive("avatar_0"); Guid itemId = Guid.Parse(context.GetArgument <string>("itemId")); Guid materialId = Guid.Parse(context.GetArgument <string>("materialIds")); var action = new ItemEnhancement { avatarAddress = avatarAddress, slotIndex = 0, itemId = itemId, materialIds = new[] { materialId } }; var actions = new PolymorphicAction <ActionBase>[] { action }; blockChain.MakeTransaction(privatekey, actions); } catch (Exception e) { var msg = $"Unexpected exception occurred during {typeof(ActionMutation)}: {e}"; context.Errors.Add(new ExecutionError(msg, e)); Log.Error(msg, e); return(false); } return(true); }); Field <NonNullGraphType <BooleanGraphType> >("buy", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "sellerAgentAddress", }, new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "sellerAvatarAddress", }, new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "productId", }), resolve: context => { try { NineChroniclesNodeService service = context.Source; PrivateKey privatekey = service.PrivateKey; BlockChain <NineChroniclesActionType> blockChain = service.Swarm.BlockChain; Address userAddress = privatekey.PublicKey.ToAddress(); Address avatarAddress = userAddress.Derive("avatar_0"); Address sellerAgentAddress = new Address(context.GetArgument <string>("sellerAgentAddress")); Address sellerAvatarAddress = new Address(context.GetArgument <string>("sellerAvatarAddress")); Guid productId = Guid.Parse(context.GetArgument <string>("productId")); var action = new Buy { buyerAvatarAddress = avatarAddress, sellerAgentAddress = sellerAgentAddress, sellerAvatarAddress = sellerAvatarAddress, productId = productId, }; var actions = new PolymorphicAction <ActionBase>[] { action }; blockChain.MakeTransaction(privatekey, actions); } catch (Exception e) { var msg = $"Unexpected exception occurred during {typeof(ActionMutation)}: {e}"; context.Errors.Add(new ExecutionError(msg, e)); Log.Error(msg, e); return(false); } return(true); }); Field <NonNullGraphType <BooleanGraphType> >("sell", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "sellerAvatarAddress", }, new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "productId", }, new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "itemId", }, new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "price", }), resolve: context => { try { NineChroniclesNodeService service = context.Source; PrivateKey privatekey = service.PrivateKey; BlockChain <NineChroniclesActionType> blockChain = service.Swarm.BlockChain; Address sellerAvatarAddress = new Address(context.GetArgument <string>("sellerAvatarAddress")); Guid itemId = Guid.Parse(context.GetArgument <string>("itemId")); var currency = new GoldCurrencyState( (Dictionary)blockChain.GetState(GoldCurrencyState.Address) ).Currency; FungibleAssetValue price = FungibleAssetValue.Parse(currency, context.GetArgument <string>("price")); var action = new Sell { sellerAvatarAddress = sellerAvatarAddress, itemId = itemId, price = price }; var actions = new PolymorphicAction <ActionBase>[] { action }; blockChain.MakeTransaction(privatekey, actions); } catch (Exception e) { var msg = $"Unexpected exception occurred during {typeof(ActionMutation)}: {e}"; context.Errors.Add(new ExecutionError(msg, e)); Log.Error(msg, e); return(false); } return(true); }); Field <NonNullGraphType <BooleanGraphType> >("dailyReward", resolve: context => { try { NineChroniclesNodeService service = context.Source; PrivateKey privatekey = service.PrivateKey; BlockChain <NineChroniclesActionType> blockChain = service.Swarm.BlockChain; Address userAddress = privatekey.PublicKey.ToAddress(); Address avatarAddress = userAddress.Derive("avatar_0"); var action = new DailyReward { avatarAddress = avatarAddress }; var actions = new PolymorphicAction <ActionBase>[] { action }; blockChain.MakeTransaction(privatekey, actions); } catch (Exception e) { var msg = $"Unexpected exception occurred during {typeof(ActionMutation)}: {e}"; context.Errors.Add(new ExecutionError(msg, e)); Log.Error(msg, e); return(false); } return(true); }); }
private void Start() { // Get the current prize index int index = PlayerPrefsFast.GetInt(this.RewardIndexKey, 0); // Get the last time a reward was given string lastDateString = PlayerPrefsFast.GetString(this.LastDateRewardKey, string.Empty); DateTime lastDate; bool parsed = DateTime.TryParse(lastDateString, out lastDate); if (parsed) { // Give reward after 1 day if (lastDate.AddDays(1) <= DateTime.Now) { // Give reward, and then set it to the next index index++; List <Transform> childRewards = this.RewardsGrid.GetChildList(); // Make sure we don't give more rewards that we hvae set up if (index <= childRewards.Count) { foreach (Transform child in childRewards) { DailyReward dailyReward = child.GetComponent <DailyReward>(); if (dailyReward != null) { dailyReward.SetCurrentReward(index); if (dailyReward.Day == index) { this.centerOnChildTarget = child.GetComponent <UICenterOnChild>(); } } } PlayerPrefsFast.SetInt(this.RewardIndexKey, index); PlayerPrefsFast.SetString(this.LastDateRewardKey, DateTime.Now.ToString()); PlayerPrefsFast.Flush(); this.RewardsGrid.enabled = true; this.RewardsGrid.repositionNow = true; this.refreshGrid = true; } else { this.gameObject.SetActive(false); } } else { this.gameObject.SetActive(false); } } else { // It's the first time, so set the date as now PlayerPrefsFast.SetString(this.LastDateRewardKey, DateTime.Now.ToString()); PlayerPrefsFast.Flush(); this.gameObject.SetActive(false); } }
private void Awake() { dailyReward = FindObjectOfType <DailyReward>(); questManager = FindObjectOfType <QuestManager>(); }
// Start is called before the first frame update void Start() { instance = this; }
public void OnEnable() { it = (DailyReward)target; }