private void CreateMonster() { //if (m_CurrentCreateCount > 0) return; m_Index = UnityEngine.Random.Range(0, m_CurrentRegionMonsterList.Count); GameLevelMonsterEntity levelMonsterEntity = m_CurrentRegionMonsterList[m_Index]; SpriteEntity spriteEntity = SpriteDBModel.Instance.Get(levelMonsterEntity.SpriteId); if (spriteEntity == null || levelMonsterEntity == null) { return; } if (!monsterCreateDic.ContainsKey(m_Index)) { monsterCreateDic[m_Index] = levelMonsterEntity.SpriteCount; } string prefabName = spriteEntity.PrefabName; monsterCreateDic[m_Index]--; if (monsterCreateDic[m_Index]-- < 0) { monsterCreateDic.Remove(m_Index); } Transform obj = m_Pool.Spawn(prefabName); obj.position = m_CurRegionCtrl.GetMonsterBornPos; obj.localEulerAngles = Vector3.zero; obj.localScale = Vector3.one; RoleCtrl ctrl = obj.GetComponent <RoleCtrl>(); ctrl.OnRoleDie = OnRoleDieCallBack; ctrl.OnRoleDestory = OnRoleDestoryCallBack; RoleInfoMonster info = new RoleInfoMonster(spriteEntity); info.RoleId = ++m_TempIndex; info.RoleNickName = spriteEntity.Name; info.Level = spriteEntity.Level; //info.Exp = spriteEntity.RewardExp; info.MaxHP = spriteEntity.HP; info.CurrentHP = spriteEntity.HP; info.MaxMP = spriteEntity.MP; info.CurrentMP = spriteEntity.MP; info.Attack = spriteEntity.Attack; info.Defense = spriteEntity.Defense; info.Hit = spriteEntity.Hit; info.Dodge = spriteEntity.Dodge; info.Res = spriteEntity.Res; info.Cri = spriteEntity.Cri; info.Fighting = spriteEntity.Fighting * 100; ctrl.Init(RoleType.Monster, info, new GameLevel_RoleMonsterAI(ctrl, info)); ctrl.Born(obj.position); ctrl.ViewRange = spriteEntity.Range_View; m_CurrentCreateCount++; }
private void OnRoleDieCallBack(RoleCtrl ctrl) { //GameLevelCtrl.Instance.CurPassTime = (int)m_FightingTime; //UIViewMgr.Instance.OpenView(UIViewType.GameLevelVictory); m_KillRegionMonsterCount++; RoleInfoMonster info = (RoleInfoMonster)ctrl.CurRoleInfo; if (info != null) { GameLevelMonsterEntity monsterEntity = GameLevelMonsterDBModel.Instance.GetRegionMonsterInfo(m_GameLevelId, m_Grade, m_CurRegionCtrl.RegionId, info.SpriteEntity.Id); if (monsterEntity != null) { if (monsterEntity.Exp > 0) { UITipView.Instance.SetUI(0, monsterEntity.Exp.ToString()); GameLevelCtrl.Instance.CurGameLevelTotalExp += monsterEntity.Exp; } if (monsterEntity.Gold > 0) { UITipView.Instance.SetUI(1, monsterEntity.Gold.ToString()); GameLevelCtrl.Instance.CurGameLevelTotalGold += monsterEntity.Gold; } if (GameLevelCtrl.Instance.CurGameLevelKillMonsterDic.ContainsKey(monsterEntity.SpriteId)) { GameLevelCtrl.Instance.CurGameLevelKillMonsterDic[monsterEntity.SpriteId] += 1; } else { GameLevelCtrl.Instance.CurGameLevelKillMonsterDic[monsterEntity.SpriteId] = 1; } } } if (m_KillRegionMonsterCount >= m_CurrentRegionMonsterCount) { m_CurSelectRegionIndex++; if (LastRegion) { //胜利 m_IsFighting = false; GameLevelCtrl.Instance.CurPassTime = (int)m_FightingTime; TimeMgr.Instance.SetTimeScaleDuration(0.3f, 3); StartCoroutine("FightingWinIE"); return; } EnterRegion(m_CurSelectRegionIndex); } }
private void OnRoleDieCallBack(RoleCtrl ctrl) { GameLevelMonsterEntity entity = ((RoleInfoMonster)ctrl.CurrRoleInfo).GameLevelMonsterEntity; TipsUtil.ShowExpTips(entity.DropExp); TipsUtil.ShowCoinTips(entity.DropCoin); m_DropExp += entity.DropExp; m_DropCoin += entity.DropCoin; m_CurrRegionKillMonsterCount++; //掉落装备/材料 int equipNum = UnityEngine.Random.Range(1, 101); if (equipNum > 50) { int tempNum = UnityEngine.Random.Range(1, 101); int equipId = 0; if (tempNum < 35) { equipId = entity.DropEquip[0][0].ToInt(); } else if (tempNum < 60) { equipId = entity.DropEquip[1][0].ToInt(); } else if (tempNum < 80) { equipId = entity.DropEquip[2][0].ToInt(); } else if (tempNum < 95) { equipId = entity.DropEquip[3][0].ToInt(); } else { equipId = entity.DropEquip[4][0].ToInt(); } //掉落装备 //Debuger.Log("掉落装备Id = " + equipId); GameLevelSuccessRequestProto.GoodsItem item = new GameLevelSuccessRequestProto.GoodsItem(); item.GoodsType = 1; item.GoodsCount = 1; item.GoodsId = equipId; m_DropGoodsList.Add(item); } int matNum = UnityEngine.Random.Range(1, 101); if (matNum > 50) { int tempNum2 = UnityEngine.Random.Range(1, 101); int matId = 0; if (tempNum2 < 35) { matId = entity.DropMaterial[0][0].ToInt(); } else if (tempNum2 < 60) { matId = entity.DropMaterial[1][0].ToInt(); } else if (tempNum2 < 80) { matId = entity.DropMaterial[2][0].ToInt(); } else if (tempNum2 < 95) { matId = entity.DropMaterial[3][0].ToInt(); } else { matId = entity.DropMaterial[4][0].ToInt(); } //掉落材料 //Debuger.LogError("掉落材料Id = " + matId); bool isHaveMat = false; for (int i = 0; i < m_DropGoodsList.Count; i++) { if (m_DropGoodsList[i].GoodsId == matId) { isHaveMat = true; GameLevelSuccessRequestProto.GoodsItem item = new GameLevelSuccessRequestProto.GoodsItem(); item.GoodsType = m_DropGoodsList[i].GoodsType; item.GoodsId = m_DropGoodsList[i].GoodsId; item.GoodsCount = m_DropGoodsList[i].GoodsCount + 1; m_DropGoodsList[i] = item; break; } } if (!isHaveMat) { GameLevelSuccessRequestProto.GoodsItem item = new GameLevelSuccessRequestProto.GoodsItem(); item.GoodsType = 2; item.GoodsCount = 1; item.GoodsId = matId; m_DropGoodsList.Add(item); } } if (m_CurrRegionKillMonsterCount >= m_CurrRegionMonsterCount) { if (m_CurrRegionIndex < m_Region.Length - 1) { //进入下一区域 m_CurrRegionIndex++; EnterRegion(m_CurrRegionIndex); } else { m_IsFighting = false; GameLevelCtrl.Instance.Result = 1; GameLevelCtrl.Instance.UseTime = m_UseTime; GameLevelCtrl.Instance.DropExp = m_DropExp; GameLevelCtrl.Instance.DropCoin = m_DropCoin; //最后一击播放慢动画 TimeManager.Instance.ChangeTimeScale(0.3f, 5f, OpenFightResultWindow); //战斗胜利 Debug.Log("战斗胜利"); } } }