示例#1
0
        /// <summary>
        /// 判断战斗是否结束
        /// </summary>
        public override bool CheckFightEnd()
        {
            if (agent.health <= 0)
            {
                AgentDie();
                return(true);
            }

            if (enemy == null)
            {
                return(true);
            }

            if (enemy.agent.health <= 0)
            {
                MapMonster mm = GetComponent <MapMonster>();
                if (mm != null)
                {
                    mm.isReadyToFight = false;
                }
                enemy.AgentDie();
                return(true);
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// 包围盒检测到trigger进入
        /// </summary>
        /// <param name="col">Col.</param>
        public void OnTriggerEnter2D(Collider2D col)
        {
            BattleAgentController ba = col.GetComponent <BattleAgentController> ();


            if (!(ba is BattlePlayerController))
            {
                return;
            }

            //Debug.Log("detect player");

            BattlePlayerController bp = ba as BattlePlayerController;

            if (bp.isInEvent)
            {
                return;
            }

            //Debug.Log("player is not in event");

            if (bp.isInFight)
            {
                return;
            }

            //Debug.Log("player is not in figth");

            MapMonster mm = mapMonster as MapMonster;

            mm.isReadyToFight = true;

            mm.DetectPlayer(bp);
        }
示例#3
0
        /// <summary>
        /// 所有地图上的可运动生命体【怪物,boss,npc】在本步行动结束后停止运动
        /// </summary>
        public void MapWalkableEventsStopAction()
        {
            for (int i = 0; i < newMapGenerator.allMonstersInMap.Count; i++)
            {
                MapMonster mapMonster = newMapGenerator.allMonstersInMap[i];
                mapMonster.StopMoveAtEndOfCurrentMove();
            }

            for (int i = 0; i < newMapGenerator.allNPCsInMap.Count; i++)
            {
                newMapGenerator.allNPCsInMap[i].StopMoveAtEndOfCurrentMove();
            }
        }
示例#4
0
        /// <summary>
        /// 所有地图上的可运动生命体【怪物,boss,npc】立刻停止运动
        /// </summary>
        public void MapWalkableEventsStopActionImmidiately()
        {
            for (int i = 0; i < newMapGenerator.allMonstersInMap.Count; i++)
            {
                MapMonster mapMonster = newMapGenerator.allMonstersInMap[i];
                mapMonster.StopMoveImmidiately();
            }

            for (int i = 0; i < newMapGenerator.allNPCsInMap.Count; i++)
            {
                newMapGenerator.allNPCsInMap[i].StopMoveImmidiately();
            }
        }
示例#5
0
        /// <summary>
        /// 怪物死亡
        /// </summary>
        override public void AgentDie()
        {
            // 防止死亡逻辑重复执行
            if (isDead)
            {
                return;
            }

            // 禁止屏幕点击
            exploreManager.DisableExploreInteractivity();

            isDead = true;

            if (enemy != null)
            {
                enemy.isIdle = true;
                enemy.QuitFight();
            }

            MapMonster mm = GetComponent <MapMonster>();

            // 禁止进行探测
            mm.DisableAllDetect();
            // 添加到本层事件记录中
            mm.AddToCurrentMapEventRecord();

            // 退出战斗
            QuitFight();

            // 战斗中玩家获胜
            exploreManager.BattlePlayerWin(new Transform[] { transform });

            // 退出战斗界面
            exploreManager.expUICtr.QuitFight();

            // 播放死亡动画及死亡逻辑
            IEnumerator latelyDieCoroutine = LatelyDie();

            StartCoroutine(latelyDieCoroutine);
        }
示例#6
0
        /// <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();
        }
示例#7
0
        public static void InitBoss()
        {
            string monsterDataPath = "/Users/houlianghong/Desktop/MyGameData/boss.csv";

            MonsterModel[] monsterModels = LoadMonsterModels(monsterDataPath);

            for (int i = 0; i < monsterModels.Length; i++)
            {
                MonsterModel mm = monsterModels[i];

                string monsterName = mm.monsterSkeName;

                Transform monster = TransformManager.FindTransform(monsterName);

                if (monster == null)
                {
                    Debug.LogFormat("未找到名为{0}的怪物", monsterName);
                    continue;
                }


                Monster monsterScript = monster.gameObject.GetComponent <Monster>();
                if (monsterScript == null)
                {
                    monsterScript = monster.gameObject.AddComponent <Monster>();
                }

                //BattleMonsterController bmcScript = monster.gameObject.GetComponent<BattleMonsterController>();

                MapMonster mmScript = monster.gameObject.GetComponent <MapMonster>();
                if (mmScript == null)
                {
                    mmScript = monster.gameObject.AddComponent <MapMonster>();
                }



                monsterScript.monsterId        = mm.monsterId;
                monsterScript.agentName        = mm.monsterName;
                monsterScript.agentLevel       = 1;
                monsterScript.rewardGold       = mm.gold;
                monsterScript.rewardExperience = mm.experience;

                monsterScript.originalMaxHealth = mm.maxHealth;
                monsterScript.health            = mm.maxHealth;
                monsterScript.maxHealth         = mm.maxHealth;
                monsterScript.health            = mm.maxHealth;

                monsterScript.mAttackInterval = mm.attackInterval;

                monsterScript.originalAttack = mm.attack;
                monsterScript.attack         = mm.attack;

                monsterScript.originalMagicAttack = mm.magicAttack;
                monsterScript.magicAttack         = mm.magicAttack;

                monsterScript.originalArmor = mm.armor;
                monsterScript.armor         = mm.armor;

                monsterScript.originalMagicResist = mm.magicResist;
                monsterScript.magicResist         = mm.magicResist;

                monsterScript.originalArmorDecrease = mm.armorDecrease;
                monsterScript.armorDecrease         = mm.armorDecrease;

                monsterScript.originalMagicResistDecrease = mm.magicResistDecrease;
                monsterScript.magicResistDecrease         = mm.magicResistDecrease;

                monsterScript.originalDodge = mm.dodge;
                monsterScript.dodge         = mm.dodge;

                monsterScript.originalCrit = mm.crit;
                monsterScript.crit         = mm.crit;

                monsterScript.originalCritHurtScaler = mm.critHurtScaler;
                monsterScript.critHurtScaler         = mm.critHurtScaler;

                monsterScript.originalPhysicalHurtScaler = 1f;
                monsterScript.physicalHurtScaler         = 1f;

                monsterScript.originalMagicalHurtScaler = 1f;
                monsterScript.magicalHurtScaler         = 1f;

                //monsterScript.extraPoisonHurt = 0;
            }

            Debug.Log("boss init finish");
        }