/// <summary>
        /// 清理引用
        /// </summary>
        public void ClearReference()
        {
            enterMonster = null;
            enterNpc     = null;
//			enterWorkBench = null;
            enterCrystal     = null;
            enterTreasureBox = null;
            enterObstacle    = null;
            enterTrapSwitch  = null;
            enterDoor        = null;
            enterBillboard   = null;
            enterHole        = null;
            enterMovableBox  = null;
            enterTransport   = null;
            enterPlant       = null;

            ClearAllEffectStatesAndSkillCallBacks();

//			trapTriggered = null;
            bmCtr = null;

//			playerLoseCallBack = null;

            bpUICtr = null;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 遭遇怪物时的响应方法
        /// </summary>
        /// <param name="monsterTrans">Monster trans.</param>
        public void EnterMonster(Transform monsterTrans)
        {
            DisableInteractivity();

            monsterEntered = monsterTrans;

            battlePlayerCtr.isInFight = true;

            battleMonsterCtr = monsterTrans.GetComponent <BattleMonsterController> ();

            battleMonsterCtr.InitMonster(monsterTrans);

            SetUpForFight();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 遭遇怪物时的响应方法
        /// </summary>
        /// <param name="monsterTrans">Monster trans.</param>
        public void EnterFight(Transform monsterTrans)
        {
            // 禁止寻路点击
            DisableAllInteractivity();


            battleMonsterCtr = monsterTrans.GetComponent <BattleMonsterController> ();
            // 初始化怪物
            battleMonsterCtr.InitMonster(monsterTrans);

            // 设置敌人
            battlePlayerCtr.SetEnemy(battleMonsterCtr);
            battleMonsterCtr.SetEnemy(battlePlayerCtr);
        }
        /// <summary>
        /// Starts the fight.
        /// </summary>
        /// <param name="bmCtr">怪物控制器</param>
        public void StartFight(BattleMonsterController bmCtr)
        {
            this.bmCtr = bmCtr;

            // 初始化玩家战斗UI(技能界面)
//			bpUICtr.SetUpPlayerSkillPlane (agent as Player);

            if (autoFight)
            {
                // 默认玩家在战斗中将先出招,首次攻击不用等待
                currentSkill = InteligentAttackSkill();
                UseSkill(currentSkill);
            }
            else
            {
                PlayRoleAnim("wait", 0, null);
            }
        }
Ejemplo n.º 5
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();
        }