public static void GainSkill(SkillName name) { var skill = LearnedSkills.FirstOrDefault(x => x.Name == name); //新技能 if (skill == null) { skill = ActivedSkills.FirstOrDefault(x => x.Name == name).Clone(); SkillUpdater.NewSkill(skill); LearnedSkills.Add(skill); BattleUpdater.UpdateMessage("学会" + ((skill.RareDegree == SkillRareDegree.Rare) ? "稀有" : "") + "技能:" + skill.DisplayName); } else { if (skill.Level != 3) { skill.LevelUp(); SkillUpdater.UpgradeSkill(skill); BattleUpdater.UpdateMessage("技能 " + skill.DisplayName + " 提升至" + skill.Level.ToString() + "级"); } else { Hero.GetExp(15); BattleUpdater.UpdateMessage("技能已提升至满级,转化为15点经验值"); } } }
/// <summary> /// 新的关卡 /// </summary> public static void NewStage() { Day++; BattleUpdater.UpdateStageInfo(); //ShopUpdater.Refresh(); //BattleCanvasSetter.SwitchBattleScene(BattleSceneType.EventDialog); //return; if (Day % 20 == 1) { EventHelper.UpdateCurrentStageEvents(); } //如果三天没有选择战斗事件,则强制生成三个普通怪物 if (!ThreeDayNotInBattle()) { var stageType1 = EventHelper.GetRandomGameEventType(); var stageType2 = EventHelper.GetRandomGameEventType(); var stageType3 = EventHelper.GetRandomGameEventType(); BattleUpdater.UpdateEvent(stageType1, stageType2, stageType3); } else { BattleUpdater.UpdateEvent(GameEventType.NormalMonster, GameEventType.NormalMonster, GameEventType.NormalMonster); } BattleCanvasSetter.Scenes.Enqueue(BattleSceneType.ChooseEvent); BattleCanvasSetter.SwitchBattleScene(); }
/// <summary> /// 获取经验值 /// </summary> /// <param name="n"></param> public static void GetExp(float n) { var currentExp = Exp + n; if (currentExp >= MaxExp) { currentExp = currentExp - MaxExp; LevelUp(); BattleUpdater.UpdateStageInfo(); } PropertyPanelUpdater.Update(); }
void InitButtonEvents() { #region 结束回合 Button btnEndTurn = GameObject.Find("SubCanvasBattling/BtnEndTurn").GetComponent <Button>(); btnEndTurn.onClick.AddListener(delegate() { BattleUpdater.UpdateMessage("战斗胜利!\n获得15经验值,15金币"); GameInfo.Money += 15; Hero.GetExp(15); Hero.RecoverHealth(-10); GameInfo.NewStage(); }); #endregion }
public static void GenerateHotelEvent(BaseEvent e) { e.Title = "荒原酒馆"; e.Description = "花费金币休息有可能得到意外的惊喜!"; e.Choose1Name = "驻足"; e.Choose2Name = "大吃一顿"; e.Choose3Name = "住宿休息"; e.Choose1Desc = "恢复最大生命值和魔法值的20%"; e.Choose2Desc = "花费50金币\n恢复最大生命值和魔法值的50%"; e.Choose3Desc = "花费100金币\n恢复所有生命值和魔法值"; e.Sprite = SpriteHelper.GetEventSprite(e.Type); e.Choose1 = () => { Hero.Health = Math.Min(Hero.MaxHealth, Hero.Health + Hero.MaxHealth * 0.2f); Hero.Mana = Math.Min(Hero.MaxMana, Hero.Mana + Hero.MaxMana * 0.2f); PropertyPanelUpdater.Update(); GameInfo.NewStage(); }; e.Choose2 = () => { if (GameInfo.Money < 50) { BattleUpdater.UpdateMessage("别逗我,你太穷了"); return; } GameInfo.Money -= 50; Hero.RecoverHealth(Hero.MaxHealth * 0.5f); Hero.RecoverMana(Hero.MaxMana * 0.5f); BattleUpdater.UpdateStageInfo(); GameInfo.NewStage(); }; e.Choose3 = () => { if (GameInfo.Money < 100) { BattleUpdater.UpdateMessage("别逗我,你太穷了"); return; } GameInfo.Money -= 100; Hero.RecoverHealth(Hero.MaxHealth); Hero.RecoverMana(Hero.MaxMana); BattleUpdater.UpdateStageInfo(); GameInfo.NewStage(); }; }
/// <summary> /// 开始一场新的对局 /// </summary> public static void NewGame() { CurrentScene = SceneType.BattleMain; EndType = GameEndType.None; ActivedProps = new List <BaseProp>(); GainedProps = new List <PropName>(); ActivedSkills = new List <BaseSkill>(); LearnedSkills = new List <BaseSkill>(); EventList = new List <BaseEvent>(); OccurredEvents = new List <BaseEvent>(); CurrentStageEvents = new List <BaseEvent>(); HeroRoleList = new List <BaseHeroRole>(); Day = 0; Money = 1200; //初始化照相机信息 CameraSetter.Init(); //初始化宝物信息 PropIniter.Init(); //初始化技能信息 SkillIniter.Init(Role); //初始化事件信息 EventIniter.Init(); //初始化怪物列表 MonsterIniter.Init(); //初始化职业信息 HeroRoleIniter.Init(); //初始化英雄属性 Hero.New(Role); Hero.Health = 40; Hero.Mana = 1; //更新英雄属性面板 PropertyPanelUpdater.Update(); //更新关卡信息面板 BattleUpdater.UpdateStageInfo(); BattleUpdater.UpdateMessage("欢迎来到荒原之城!"); BattleCanvasSetter.Scenes.Enqueue(BattleSceneType.ChooseEvent); BattleCanvasSetter.SwitchBattleScene(); NewStage(); }
static void RandomEventInit() { { var e = new BaseEvent(); e.Type = GameEventType.RandomEvent; e.Title = "苹果树"; e.Name = RandomEvent.苹果树; e.Description = "你遇到了一颗长满果实的苹果树"; e.Choose1Name = "采摘"; e.Choose1Desc = "回复40点生命值及10点魔法值"; e.MinStage = 1; e.MaxStage = 20; e.Sprite = SpriteHelper.GetRandomEventSprite(RandomEvent.苹果树); e.Choose1 = () => { Hero.RecoverHealth(40); Hero.RecoverMana(10); MessagePageUpdater.Update("一顿忙碌后,终于摘到了不少苹果,并饱餐一顿\n\n回复40点生命值及10点魔法值"); BattleCanvasSetter.Scenes.Enqueue(BattleSceneType.Message); BattleCanvasSetter.SwitchBattleScene(); }; e.Choose2 = e.Choose3 = null; GameInfo.EventList.Add(e); } { var e = new BaseEvent(); e.Type = GameEventType.RandomEvent; e.Title = "捕兽夹"; e.Name = RandomEvent.捕兽夹; e.Description = "前方有一个被遗弃的捕兽夹,如果不管它可能会伤害到其他的冒险者"; e.Choose1Name = "尝试拆除"; e.Choose1Desc = "这个陷阱看起来很劣质,我有把握拆除它"; e.MinStage = 1; e.MaxStage = 40; e.Sprite = SpriteHelper.GetRandomEventSprite(RandomEvent.捕兽夹); e.Choose1 = () => { var seed = NumberHelper.GetRandom(0, 3); if (seed == 2) { Hero.RecoverHealth(-30); MessagePageUpdater.Update("一阵忙碌后,不仅没有拆除陷阱,自己还被划伤了\n\n损失30点生命值"); } else { Hero.PhysicalArmor += 5; Hero.MagicArmor += 5; MessagePageUpdater.Update("成功的拆除了陷阱,提升了自身的战斗抗性\n\n增加5点物理防御力与法术防御力"); } BattleCanvasSetter.Scenes.Enqueue(BattleSceneType.Message); BattleCanvasSetter.SwitchBattleScene(); }; e.Choose2 = e.Choose3 = null; GameInfo.EventList.Add(e); } { var e = new BaseEvent(); e.Type = GameEventType.RandomEvent; e.Title = "游荡学者"; e.Name = RandomEvent.游荡学者; e.Description = "你碰到了一个满脸书生气的"; e.Choose1Name = "请教"; e.Choose1Desc = "活到老学到老,向前辈请教"; e.Choose2Name = "抢劫"; e.Choose2Desc = "柿子要挑软的捏,看看这人身上有什么宝贝"; e.MinStage = 1; e.MaxStage = 40; e.Sprite = SpriteHelper.GetRandomEventSprite(RandomEvent.游荡学者); e.Choose1 = () => { var skillName = SkillHelper.UpgradeRandomSkill(); if (string.IsNullOrEmpty(skillName)) { MessagePageUpdater.Update("学者对你说,你已经足够强大了,我没有什么能够教你的"); } else { MessagePageUpdater.Update("虚心请教后,你确实感觉学到了不少东西\n\n" + skillName + "提升一级"); } BattleCanvasSetter.Scenes.Enqueue(BattleSceneType.Message); BattleCanvasSetter.SwitchBattleScene(); }; e.Choose2 = () => { var seed = NumberHelper.GetRandom(0, 3); if (seed == 2) { MessagePageUpdater.Update("没想到看似柔弱的书生是个高手,被揍的遍体鳞伤\n\n损失40%当前生命值"); Hero.RecoverHealth(Hero.Health * -0.4f); } else { MessagePageUpdater.Update("书生主动求饶,并交出了他的所有财产\n\n获得150金币"); GameInfo.Money += 150; BattleUpdater.UpdateStageInfo(); } BattleCanvasSetter.Scenes.Enqueue(BattleSceneType.Message); BattleCanvasSetter.SwitchBattleScene(); }; e.Choose3 = null; GameInfo.EventList.Add(e); } }