private int goodsPrice; // 商品价格 /// <summary> /// 获取商品 /// </summary> /// <returns>The goods item.</returns> public Item GetGoodsItem() { if (itemAsGoods != null) { return(itemAsGoods); } itemAsGoods = Item.NewItemWith(goodsId, 1); if (itemAsGoods.itemType == ItemType.Equipment) { Equipment equipment = itemAsGoods as Equipment; switch (equipmentQuality) { case 0: equipment.ResetPropertiesByQuality(EquipmentQuality.Gray); break; case 1: equipment.ResetPropertiesByQuality(EquipmentQuality.Blue); break; case 2: equipment.ResetPropertiesByQuality(EquipmentQuality.Gold); break; case 3: equipment.ResetPropertiesByQuality(EquipmentQuality.Purple); break; } } if (priceFloat <= float.Epsilon) { goodsPrice = itemAsGoods.price; } else { goodsPrice = Mathf.RoundToInt(itemAsGoods.price * priceFloat); } return(itemAsGoods); }
public void NextDialog() { if (dialogHasFinished) { return; } int nextDialogId = ++currentDialogId; if (nextDialogId < dialogGroup.dialogs.Count) { HLHDialog dialog = dialogGroup.dialogs[nextDialogId]; dialogText.text = dialog.dialogContent; return; } if (dialogGroup.isRewardTriggered) { HLHNPCReward reward = dialogGroup.reward; switch (reward.rewardType) { case HLHRewardType.Gold: int goldReward = reward.rewardValue; Player.mainPlayer.totalGold += goldReward; tintHUD.SetUpGoldTintHUD(goldReward); break; case HLHRewardType.Item: Item rewardItem = Item.NewItemWith(reward.rewardValue, reward.attachValue); if (rewardItem.itemType == ItemType.Equipment) { Equipment equipment = rewardItem as Equipment; if (equipment.defaultQuality.Equals(EquipmentDefaultQuality.Random)) { equipment.ResetPropertiesByQuality(EquipmentQuality.Gray); } } ExploreManager.Instance.newMapGenerator.SetUpRewardInMap(rewardItem, ExploreManager.Instance.battlePlayerCtr.transform.position); if (!Player.mainPlayer.CheckBagFull(rewardItem)) { Player.mainPlayer.AddItem(rewardItem); simpleItemDetail.SetupSimpleItemDetail(rewardItem); ExploreManager.Instance.expUICtr.UpdateBottomBar(); } break; } if (!dialogGroup.isMultiTimes) { List <HLHNPCChatRecord> chatRecords = GameManager.Instance.gameDataCenter.chatRecords; HLHNPCChatRecord chatRecord = new HLHNPCChatRecord(npc.npcId, dialogGroup.dialogGroupId); chatRecords.Add(chatRecord); //GameManager.Instance.persistDataManager.SaveCompletePlayerData(); } dialogHasFinished = true; QuitDialogPlane(); return; } //if(Player.mainPlayer.currentLevelIndex == CommonData.maxLevel && dialogGroup.triggerLevel == CommonData.maxLevel){ // this.gameObject.SetActive(false); // GameManager.Instance.UIManager.SetUpCanvasWith(CommonData.shareCanvasBundleName, "ShareCanvas", delegate // { // TransformManager.FindTransform("ShareCanvas").GetComponent<ShareViewController>().SetUpShareView(ShareType.WeChat, null, null, null); // }); // return; //} QuitDialogPlane(); }
public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo) { this.mapIndex = mapIndex; transform.position = attachedInfo.position; isGoldTreasureBox = false; if (KVPair.ContainsKey("type", attachedInfo.properties)) { string type = KVPair.GetPropertyStringWithKey("type", attachedInfo.properties); isGoldTreasureBox = type == "1"; } int rewardItemId = 0; if (!isGoldTreasureBox) { mapItemRenderer.sprite = normalTbSprite; treasureType = TreasureType.NormalTreasureBox; } else { mapItemRenderer.sprite = specialTbSprite; treasureType = TreasureType.GoldTreasureBox; } if (KVPair.ContainsKey("dropID", attachedInfo.properties)) { rewardItemId = int.Parse(KVPair.GetPropertyStringWithKey("dropID", attachedInfo.properties)); } else { rewardItemId = GetRandomItemIdFromGameLevelData(); } if (isGoldTreasureBox && MapEventsRecord.IsMapEventTriggered(mapIndex, attachedInfo.position)) { AddToPool(ExploreManager.Instance.newMapGenerator.mapEventsPool); } rewardItem = Item.NewItemWith(rewardItemId, 1); if (rewardItem.itemType == ItemType.Equipment) { Equipment eqp = rewardItem as Equipment; int randomSeed = Random.Range(0, 100); int graySeed = 0; int blueSeed = 0; // 物品品质概率 switch (Player.mainPlayer.luckInOpenTreasure) { case 0: graySeed = 65 - Player.mainPlayer.extraLuckInOpenTreasure; blueSeed = 95 - Player.mainPlayer.extraLuckInOpenTreasure; break; case 1: graySeed = 60 - Player.mainPlayer.extraLuckInOpenTreasure; blueSeed = 90 - Player.mainPlayer.extraLuckInOpenTreasure; break; } EquipmentQuality quality = EquipmentQuality.Gray; // 如果不是金色宝箱,则随机一种品质 if (!isGoldTreasureBox) { if (randomSeed < graySeed) { quality = EquipmentQuality.Gray; } else if (randomSeed < blueSeed) { quality = EquipmentQuality.Blue; } else { quality = EquipmentQuality.Gold; } } else { quality = EquipmentQuality.Gold; } eqp.ResetPropertiesByQuality(quality); } CheckIsWordTriggeredAndShow(); bc2d.enabled = true; //mapItemAnimator.gameObject.SetActive (false); mapItemRenderer.enabled = true; int sortingOrder = -(int)transform.position.y; SetSortingOrder(sortingOrder); //SetAnimationSortingOrder (sortingOrder); }
/// <summary> /// 玩家战斗胜利逻辑 /// </summary> /// <param name="monsterTransArray">Monster trans array.</param> public void BattlePlayerWin(Transform[] monsterTransArray) { // 如果没有传入敌人,直接返回 if (monsterTransArray.Length <= 0) { return; } // 记录击败的怪物数 Player.mainPlayer.totaldefeatMonsterCount++; // 重置角色骨骼动画速率 battlePlayerCtr.SetRoleAnimTimeScale(1.0f); battleMonsterCtr.SetRoleAnimTimeScale(1.0f); Transform trans = monsterTransArray [0]; BattleMonsterController bmCtr = trans.GetComponent <BattleMonsterController> (); Monster monster = trans.GetComponent <Monster> (); MapWalkableEvent walkableEvent = trans.GetComponent <MapWalkableEvent> (); Player player = Player.mainPlayer; // 执行战斗结束的回调 FightEndCallBacks(); // 重置所有技能产生的属性变化 battlePlayerCtr.agent.ClearPropertyChangesFromSkill(); // 重置角色属性【按照脱离战斗时持有装备的正常情况重新计算一遍人物属性】 battlePlayerCtr.agent.ResetBattleAgentProperties(false); // 怪物清空所有技能产生的属性变化 battleMonsterCtr.agent.ClearPropertyChangesFromSkill(); // 怪物重置属性 battleMonsterCtr.agent.ResetBattleAgentProperties(false); // 玩家位置修正到标准位置【整数点位置】 battlePlayerCtr.FixPositionToStandard(); // 玩家等待当前动作结束 battlePlayerCtr.ResetToWaitAfterCurrentRoleAnimEnd(); Vector3 monsterPos = trans.position; walkableEvent.RefreshWalkableInfoWhenQuit(true); MapMonster mm = bmCtr.GetComponent <MapMonster> (); if (mm != null) { // 生成奖励物品 Item rewardItem = mm.GenerateRewardItem(); if (rewardItem != null) { newMapGenerator.SetUpRewardInMap(rewardItem, trans.position); } if (mm.pairEventPos != -Vector3.one) { newMapGenerator.ChangeMapEventStatusAtPosition(mm.pairEventPos); } if (monster.isBoss) { MapEventsRecord.AddEventTriggeredRecord(mm.mapIndex, mm.oriPos); } } // 目前npc不参与战斗,下面的代码后续扩展可用 MapNPC mn = bmCtr.GetComponent <MapNPC> (); if (mn != null) { Item rewardItem = Item.NewItemWith(mn.fightReward.rewardValue, 1); if (rewardItem != null) { if (rewardItem.itemType == ItemType.Equipment) { Equipment eqp = rewardItem as Equipment; EquipmentQuality quality = (EquipmentQuality)mn.fightReward.attachValue; eqp.ResetPropertiesByQuality(quality); } newMapGenerator.SetUpRewardInMap(rewardItem, trans.position); } } // 开启屏幕行走点击 EnableExploreInteractivity(); // 标记不在战斗 battlePlayerCtr.isInFight = false; // 标记不再地图事件中 battlePlayerCtr.isInEvent = false; // 角色包围盒开启 battlePlayerCtr.boxCollider.enabled = true; // 清除敌方信息 battlePlayerCtr.enemy = null; //更新玩家金钱 int goldGain = monster.rewardGold + player.extraGold; player.totalGold += goldGain; GameManager.Instance.soundManager.PlayAudioClip(CommonData.goldAudioName); expUICtr.SetUpGoldGainTintHUD(goldGain); player.experience += monster.rewardExperience + player.extraExperience; //更新玩家经验值 bool isLevelUp = player.LevelUpIfExperienceEnough(); //判断是否升级 newMapGenerator.allMonstersInMap.Remove(mm); if (isLevelUp) { PlayLevelUpAnim();// 升级时播放升级动画 DisableExploreInteractivity(); expUICtr.ShowLevelUpPlane(); } else { MapWalkableEventsStartAction(); } // 更新角色状态栏 battlePlayerCtr.UpdateStatusPlane(); }