コード例 #1
0
        public override void MapEventTriggered(bool isSuccess, BattlePlayerController bp)
        {
            bp.isInEvent = false;

            if (hasTriggered)
            {
                return;
            }

            if (isSuccess)
            {
                mapItemRenderer.sprite = pressSwitchOff;
                GameManager.Instance.soundManager.PlayAudioClip(CommonData.switchAudioName);

                ExploreManager.Instance.newMapGenerator.ChangeMapEventStatusAtPosition(pairEventPos);

                SetSortingOrder(mapItemRenderer.sortingOrder - 1);

                hasTriggered = true;

                bc2d.enabled = true;

                tmPro.enabled = false;

                ExploreManager.Instance.newMapGenerator.mapWalkableInfoArray [Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y)] = 0;

                int posX = Mathf.RoundToInt(this.transform.position.x);
                int posY = Mathf.RoundToInt(this.transform.position.y);

                MapEventsRecord.AddEventTriggeredRecord(mapIndex, new Vector2(posX, posY));
            }
        }
コード例 #2
0
        public virtual void OpenTheDoor(bool playAudio = true)
        {
            if (isOpen)
            {
                return;
            }

            if (isSwitchControledDoor)
            {
                MapEventsRecord.AddEventTriggeredRecord(mapIndex, transform.position);
                MapEventsRecord.AddEventTriggeredRecord(mapIndex, pairDoorPos);
            }
            else
            {
                GameManager.Instance.gameDataCenter.currentMapEventsRecord.AddEventTriggeredRecord(mapIndex, transform.position);
                GameManager.Instance.gameDataCenter.currentMapEventsRecord.AddEventTriggeredRecord(mapIndex, pairDoorPos);
            }


            mapItemRenderer.sprite = null;
            isOpen = true;
            ExploreManager.Instance.newMapGenerator.ChangeMapEventStatusAtPosition(pairDoorPos);
            if (playAudio)
            {
                GameManager.Instance.soundManager.PlayAudioClip(CommonData.doorAudioName);
            }
        }
コード例 #3
0
        public override void MapEventTriggered(bool isSuccess, BattlePlayerController bp)
        {
            if (isGoldTreasureBox)
            {
                MapEventsRecord.AddEventTriggeredRecord(mapIndex, transform.position);
            }

            base.MapEventTriggered(isSuccess, bp);
        }
コード例 #4
0
ファイル: KeyDoor.cs プロジェクト: stephenhou2/NewWordJourney
        public override void OpenTheDoor(bool playAudio = true)
        {
            base.OpenTheDoor(playAudio);

            int posX = Mathf.RoundToInt(this.transform.position.x);
            int posY = Mathf.RoundToInt(this.transform.position.y);

            MapEventsRecord.AddEventTriggeredRecord(mapIndex, new Vector2(posX, posY));
            MapEventsRecord.AddEventTriggeredRecord(mapIndex, pairDoorPos);
        }
コード例 #5
0
        /// <summary>
        /// 进入下个对话按钮
        /// </summary>
        public void OnNextDialogButtonClick()
        {
            dialogIndex++;

            // 来到最后一段对话
            if (dialogIndex == finalDialogs.Length)
            {
                int posX = Mathf.RoundToInt(npcTrans.position.x);
                int posY = Mathf.RoundToInt(npcTrans.position.y);

                // npc的位置改为可行走
                ExploreManager.Instance.newMapGenerator.mapWalkableEventInfoArray[posX, posY] = 1;
                // 记录npc已经触发过
                MapEventsRecord.AddEventTriggeredRecord(50, npcTrans.position);

                npcTrans.gameObject.SetActive(false);

                // 回收npc
                ExploreManager.Instance.newMapGenerator.allNPCsInMap.Clear();

                Destroy(npcTrans.gameObject, 0.3f);

                ExploreManager.Instance.EnableExploreInteractivity();

                QuitFinalDialogHUD();

                ExploreManager.Instance.battlePlayerCtr.boxCollider.enabled = true;

                return;
            }


            // 如果不是倒数第三个对话,直接显示对话内容
            if (dialogIndex != finalDialogs.Length - 2)
            {
                dialogText.text = finalDialogs[dialogIndex];
            }
            else
            {
                dialogHUD.gameObject.SetActive(false);

                // 倒数第三个对话的时候显示分享界面
                GameManager.Instance.UIManager.SetUpCanvasWith(CommonData.shareCanvasBundleName, "ShareCanvas", delegate
                {
                    TransformManager.FindTransform("ShareCanvas").GetComponent <ShareViewController>().SetUpShareView(ShareType.WeChat, null, null, delegate {
                        dialogText.text = finalDialogs[dialogIndex];
                        nextDialogButton.interactable = true;
                        dialogHUD.gameObject.SetActive(true);
                    });
                });
            }
        }
コード例 #6
0
        /// <summary>
        /// 地图事件触发
        /// </summary>
        /// <param name="isSuccess">If set to <c>true</c> is success.</param>
        /// <param name="bp">Bp.</param>
        public override void MapEventTriggered(bool isSuccess, BattlePlayerController bp)
        {
            bp.isInEvent = false;

            if (isSuccess)
            {
                int posX = Mathf.RoundToInt(oriPosX);
                int posY = Mathf.RoundToInt(oriPosY);

                ExploreManager.Instance.newMapGenerator.mapWalkableInfoArray[posX, posY] = 1;

                ExploreManager.Instance.newMapGenerator.SetUpRewardInMap(item, transform.position);

                MapEventsRecord.AddEventTriggeredRecord(mapIndex, new Vector2(posX, posY));

                AddToPool(ExploreManager.Instance.newMapGenerator.mapEventsPool);
            }
        }
コード例 #7
0
        public override void ChangeStatus()
        {
            if (isOpen)
            {
                return;
            }

            if (isSwitchControledDoor)
            {
                MapEventsRecord.AddEventTriggeredRecord(mapIndex, transform.position);
                MapEventsRecord.AddEventTriggeredRecord(mapIndex, pairDoorPos);
            }
            else
            {
                GameManager.Instance.gameDataCenter.currentMapEventsRecord.AddEventTriggeredRecord(mapIndex, transform.position);
                GameManager.Instance.gameDataCenter.currentMapEventsRecord.AddEventTriggeredRecord(mapIndex, pairDoorPos);
            }


            mapItemRenderer.sprite = null;
            isOpen = true;
            ExploreManager.Instance.newMapGenerator.ChangeMapEventStatusAtPosition(pairDoorPos);
        }
コード例 #8
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();
        }