Esempio n. 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));
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 3
0
        public override void MapEventTriggered(bool isSuccess, BattlePlayerController bp)
        {
            if (isGoldTreasureBox)
            {
                MapEventsRecord.AddEventTriggeredRecord(mapIndex, transform.position);
            }

            base.MapEventTriggered(isSuccess, bp);
        }
        /// <summary>
        /// 记录日记已在指定地图序号上完成
        /// </summary>
        /// <param name="mapIndex">Map index.</param>
        public static void DiaryFinishAtMapIndex(int mapIndex)
        {
            MapEventsRecord mapEventsRecord = GameManager.Instance.gameDataCenter.mapEventsRecords.Find(delegate(MapEventsRecord obj)
            {
                return(obj.mapIndex == mapIndex);
            });

            mapEventsRecord.diaryFinish = true;
        }
Esempio n. 5
0
        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);
        }
        /// <summary>
        /// 添加事件触发记录
        /// </summary>
        /// <param name="mapIndex">Map index.</param>
        /// <param name="eventPos">Event position.</param>
        public static void AddEventTriggeredRecord(int mapIndex, Vector2 eventPos)
        {
            MapEventsRecord mapEventsRecord = GameManager.Instance.gameDataCenter.mapEventsRecords.Find(delegate(MapEventsRecord obj)
            {
                return(obj.mapIndex == mapIndex);
            });

            if (!mapEventsRecord.triggeredEventPositions.Contains(eventPos))
            {
                mapEventsRecord.triggeredEventPositions.Add(eventPos);
            }
        }
        /// <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);
                    });
                });
            }
        }
        /// <summary>
        /// 判断日记是否已经完成了
        /// </summary>
        /// <returns><c>true</c>, if diary finish was ised, <c>false</c> otherwise.</returns>
        /// <param name="mapIndex">Map index.</param>
        public static bool IsDiaryFinish(int mapIndex)
        {
            bool diaryFinish = false;

            MapEventsRecord mapEventsRecord = GameManager.Instance.gameDataCenter.mapEventsRecords.Find(delegate(MapEventsRecord obj)
            {
                return(obj.mapIndex == mapIndex);
            });

            diaryFinish = mapEventsRecord.diaryFinish;

            return(diaryFinish);
        }
Esempio n. 9
0
        public override void MapEventTriggered(bool isSuccess, BattlePlayerController bp)
        {
            if (bp.isInEvent)
            {
                return;
            }

            ExploreManager.Instance.expUICtr.SetUpDiaryView(diary);

            MapEventsRecord.DiaryFinishAtMapIndex(mapIndex);

            Destroy(this.gameObject, 0.3f);
        }
Esempio n. 10
0
        public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo)
        {
            this.mapIndex = mapIndex;

            transform.position = attachedInfo.position;

            isWordTrigger = false;
            isOpen        = false;

            direction = int.Parse(KVPair.GetPropertyStringWithKey("direction", attachedInfo.properties));

            unlockDifficulty = int.Parse(KVPair.GetPropertyStringWithKey("type", attachedInfo.properties));

            string pairDoorPosString = KVPair.GetPropertyStringWithKey("pairDoorPos", attachedInfo.properties);

            string[] posXY = pairDoorPosString.Split(new char[] { '_' }, System.StringSplitOptions.RemoveEmptyEntries);

            int posX = int.Parse(posXY[0]);
            int posY = mapHeight - int.Parse(posXY[1]) - 1;

            pairDoorPos = new Vector3(posX, posY, transform.position.z);


            if (MapEventsRecord.IsMapEventTriggered(mapIndex, attachedInfo.position))
            {
                mapItemRenderer.sprite = null;
                isOpen = true;
                //ExploreManager.Instance.newMapGenerator.ChangeMapEventStatusAtPosition(pairDoorPos);
            }

            if (!isOpen)
            {
                mapItemRenderer.enabled = true;
                mapItemRenderer.sprite  = doorCloseSprites[direction];
            }
            else
            {
                mapItemRenderer.sprite  = null;
                mapItemRenderer.enabled = false;
            }


            bc2d.enabled = true;
            SetSortingOrder(-(int)transform.position.y);

            int wordLength = unlockDifficulty + 3;

            keyDoorWord = GetWordOfLength(wordLength);
        }
Esempio n. 11
0
        public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo)
        {
            this.mapIndex = mapIndex;

            transform.position = attachedInfo.position;

            hasTriggered = MapEventsRecord.IsMapEventTriggered(mapIndex, attachedInfo.position);

            if (hasTriggered)
            {
                mapItemRenderer.sprite = pressSwitchOff;

                SetSortingOrder(-Mathf.RoundToInt(attachedInfo.position.y) - 1);

                hasTriggered = true;

                bc2d.enabled = true;

                tmPro.enabled = false;

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

                return;
            }
            else
            {
                mapItemRenderer.sprite = pressSwitchOn;
            }

            hasTriggered = false;

            string pairDoorPosString = KVPair.GetPropertyStringWithKey("pairEventPos", attachedInfo.properties);

            string[] posXY = pairDoorPosString.Split(new char[] { '_' }, System.StringSplitOptions.RemoveEmptyEntries);

            int posX = int.Parse(posXY [0]);
            int posY = mapHeight - int.Parse(posXY [1]) - 1;

            pairEventPos = new Vector2(posX, posY);


            bc2d.enabled = true;
            SetSortingOrder(-Mathf.RoundToInt(attachedInfo.position.y));

            CheckIsWordTriggeredAndShow();
        }
Esempio n. 12
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);
            }
        }
        /// <summary>
        /// 判断制定地图上的指定位置上的事件是否已经触发过
        /// </summary>
        /// <returns><c>true</c>, if map event triggered was ised, <c>false</c> otherwise.</returns>
        /// <param name="mapIndex">Map index.</param>
        /// <param name="eventPos">Event position.</param>
        public static bool IsMapEventTriggered(int mapIndex, Vector2 eventPos)
        {
            bool eventTriggered = false;

            MapEventsRecord mapEventsRecord = GameManager.Instance.gameDataCenter.mapEventsRecords.Find(delegate(MapEventsRecord obj)
            {
                return(obj.mapIndex == mapIndex);
            });

            for (int i = 0; i < mapEventsRecord.triggeredEventPositions.Count; i++)
            {
                Vector2 triggeredPos = mapEventsRecord.triggeredEventPositions[i];

                if (MyTool.ApproximatelySameIntPosition2D(eventPos, triggeredPos))
                {
                    eventTriggered = true;
                    break;
                }
            }


            return(eventTriggered);
        }
Esempio n. 14
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);
        }
Esempio n. 15
0
        public void OnGenerateButtonClick()
        {
            if (!IsSpellRight())
            {
                tintHUD.SetUpSingleTextTintHUD("当前组合错误");
                RefreshSpell();
                return;
            }

            Item generatedItem = spellItem.GenerateItem();

            //bool bagFull = Player.mainPlayer.CheckBagFull(generatedItem);

            //if(bagFull){
            //	ExploreManager.Instance.newMapGenerator.SetUpRewardInMap(generatedItem, ExploreManager.Instance.battlePlayerCtr.transform.position);
            //	return;
            //}

            //Player.mainPlayer.AddItem(generatedItem);

            //ExploreManager.Instance.expUICtr.UpdateBottomBar();

            itemDisplay.SetUpItemDisplayView(generatedItem);

            ExploreManager.Instance.expUICtr.ClearCharacterFragments();

            int mapIndex = Player.mainPlayer.mapIndexRecord[Player.mainPlayer.currentLevelIndex];

            MapEventsRecord.SpellFinishAtMapIndex(mapIndex);

            if (createSuccessCallBack != null)
            {
                createSuccessCallBack();
            }

            QuitSpellItemView();
        }
Esempio n. 16
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();
        }
Esempio n. 17
0
        public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo)
        {
            this.mapIndex = mapIndex;

            transform.position = attachedInfo.position;

            //this.hasPuzzle = true;
            this.hasPuzzle = false;


            isWordTrigger = bool.Parse(KVPair.GetPropertyStringWithKey("isWordTrigger", attachedInfo.properties));
            isOpen        = bool.Parse(KVPair.GetPropertyStringWithKey("isOpen", attachedInfo.properties));

            isSwitchControledDoor = !isWordTrigger && !isOpen;

            direction = int.Parse(KVPair.GetPropertyStringWithKey("direction", attachedInfo.properties));

            if (MapEventsRecord.IsMapEventTriggered(mapIndex, attachedInfo.position))
            {
                OpenTheDoor(false);
            }
            else if (GameManager.Instance.gameDataCenter.currentMapEventsRecord.IsMapEventTriggered(mapIndex, attachedInfo.position))
            {
                OpenTheDoor(false);
            }

            if (!isOpen)
            {
                mapItemRenderer.enabled = true;
                mapItemRenderer.sprite  = doorCloseSprites [direction];
            }
            else
            {
                mapItemRenderer.sprite  = null;
                mapItemRenderer.enabled = false;
            }

            string pairDoorPosString = KVPair.GetPropertyStringWithKey("pairDoorPos", attachedInfo.properties);

            string[] posXY = pairDoorPosString.Split(new char[] { '_' }, System.StringSplitOptions.RemoveEmptyEntries);

            int posX = int.Parse(posXY [0]);
            int posY = mapHeight - int.Parse(posXY [1]) - 1;

            pairDoorPos = new Vector3(posX, posY, transform.position.z);

            bc2d.enabled = true;
            SetSortingOrder(-(int)transform.position.y);

            if (isWordTrigger)
            {
                bool hasValidWord = false;
                for (int i = 0; i < wordsArray.Length; i++)
                {
                    if (wordsArray[i].spell.Length <= 7)
                    {
                        hasValidWord = true;
                        word         = wordsArray[i];
                        break;
                    }
                }

                if (!hasValidWord)
                {
                    word = GetAValidWord();
                }

                GameManager.Instance.pronounceManager.DownloadPronounceCache(word);
            }
        }
Esempio n. 18
0
        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);
        }