|
@@ -36,18 +36,18 @@ namespace FL.Nodes.GameMain
|
|
|
private bool _isBossChallenge;
|
|
|
|
|
|
private PlayerEntity _player;
|
|
|
- /// <summary>
|
|
|
- /// 怪物坐标相对出生点的偏移值
|
|
|
- /// 怪物最多13个,分两排排列,索引如下
|
|
|
- /// 二排 9 5 1 2 6 10
|
|
|
- /// 一排 11 7 3 0 4 8 12
|
|
|
- /// 0的左边偏移值为负数
|
|
|
- /// </summary>
|
|
|
- private Vector3 _monsterOffset = new Vector3(0.8f, 1.5f, 0);
|
|
|
- /// <summary>
|
|
|
- /// 空闲的怪物位置索引
|
|
|
- /// </summary>
|
|
|
- private List<int> _unusedIndexs;
|
|
|
+ ///// <summary>
|
|
|
+ ///// 怪物坐标相对出生点的偏移值
|
|
|
+ ///// 怪物最多13个,分两排排列,索引如下
|
|
|
+ ///// 二排 9 5 1 2 6 10
|
|
|
+ ///// 一排 11 7 3 0 4 8 12
|
|
|
+ ///// 0的左边偏移值为负数
|
|
|
+ ///// </summary>
|
|
|
+ //private Vector3 _monsterOffset = new Vector3(0.8f, 1.5f, 0);
|
|
|
+ ///// <summary>
|
|
|
+ ///// 空闲的怪物位置索引
|
|
|
+ ///// </summary>
|
|
|
+ //private List<int> _unusedIndexs;
|
|
|
/// <summary>
|
|
|
/// 怪物的实例对象
|
|
|
/// </summary>
|
|
@@ -64,8 +64,10 @@ namespace FL.Nodes.GameMain
|
|
|
EventSingle.Instance.AddListener(EventDefine.GameMainMapEndMask, OnMapEndMask);
|
|
|
EventSingle.Instance.AddListener(EventDefine.PartnerDown, OnPartnerDown);
|
|
|
EventSingle.Instance.AddListener(EventDefine.PartnerUp, OnPartnerUp);
|
|
|
+ EventSingle.Instance.AddListener(EventDefine.PartnerPlanChange, OnPartnersChanged);
|
|
|
+ EventSingle.Instance.AddListener(EventDefine.PartnerWearAll, OnPartnersChanged);
|
|
|
EventSingle.Instance.AddListener(EventDefine.GameMainMapChallengeBoss, OnChallengeBoss);
|
|
|
- InitMonsters();
|
|
|
+ //InitMonsters();
|
|
|
StartMap(PlayerData.Instance.chapterId);
|
|
|
}
|
|
|
|
|
@@ -75,6 +77,8 @@ namespace FL.Nodes.GameMain
|
|
|
EventSingle.Instance.RemoveListener(EventDefine.GameMainMapEndMask, OnMapEndMask);
|
|
|
EventSingle.Instance.RemoveListener(EventDefine.PartnerDown, OnPartnerDown);
|
|
|
EventSingle.Instance.RemoveListener(EventDefine.PartnerUp, OnPartnerUp);
|
|
|
+ EventSingle.Instance.RemoveListener(EventDefine.PartnerPlanChange, OnPartnersChanged);
|
|
|
+ EventSingle.Instance.RemoveListener(EventDefine.PartnerWearAll, OnPartnersChanged);
|
|
|
EventSingle.Instance.RemoveListener(EventDefine.GameMainMapChallengeBoss, OnChallengeBoss);
|
|
|
|
|
|
_player = null;
|
|
@@ -86,23 +90,23 @@ namespace FL.Nodes.GameMain
|
|
|
_isBossFailed = false;
|
|
|
_isBossChallenge = false;
|
|
|
_monsterMap?.Clear();
|
|
|
- _unusedIndexs?.Clear();
|
|
|
+ //_unusedIndexs?.Clear();
|
|
|
|
|
|
Context.Map.Close(_currentMap);
|
|
|
_currentMap = null;
|
|
|
}
|
|
|
|
|
|
- private void InitMonsters()
|
|
|
- {
|
|
|
- if (_unusedIndexs == null)
|
|
|
- _unusedIndexs = new List<int>();
|
|
|
- else
|
|
|
- _unusedIndexs.Clear();
|
|
|
- for (var i = 0; i < 13; i++)
|
|
|
- {
|
|
|
- _unusedIndexs.Add(i);
|
|
|
- }
|
|
|
- }
|
|
|
+ //private void InitMonsters()
|
|
|
+ //{
|
|
|
+ // if (_unusedIndexs == null)
|
|
|
+ // _unusedIndexs = new List<int>();
|
|
|
+ // else
|
|
|
+ // _unusedIndexs.Clear();
|
|
|
+ // for (var i = 0; i < 13; i++)
|
|
|
+ // {
|
|
|
+ // _unusedIndexs.Add(i);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
private void StartMap(int chapterId)
|
|
|
{
|
|
|
_chapterId = chapterId;
|
|
@@ -316,58 +320,58 @@ namespace FL.Nodes.GameMain
|
|
|
position.x += (index % cols) * offset;
|
|
|
return position;
|
|
|
}
|
|
|
- /// <summary>
|
|
|
- /// 获取怪物的出生坐标和索引
|
|
|
- /// </summary>
|
|
|
- /// <param name="position"></param>
|
|
|
- /// <param name="positionIdx"></param>
|
|
|
- /// <returns></returns>
|
|
|
- private Vector3 GetMonsterBirth(Vector3 position, out int positionIdx)
|
|
|
- {
|
|
|
- if (_unusedIndexs.Count > 0)
|
|
|
- {
|
|
|
- positionIdx = _unusedIndexs[0];
|
|
|
- _unusedIndexs.RemoveAt(0);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- positionIdx = 0;
|
|
|
- }
|
|
|
- if (positionIdx == 0)
|
|
|
- {
|
|
|
- return position;
|
|
|
- }
|
|
|
- var offset = Vector3.zero;
|
|
|
- var xMultiple = (positionIdx + 1) / 2;
|
|
|
- offset.x = _monsterOffset.x * xMultiple;
|
|
|
- if (positionIdx % 2 != 0)
|
|
|
- { // 索引为奇数的在左边
|
|
|
- offset.x = -offset.x;
|
|
|
- }
|
|
|
- if (xMultiple % 2 != 0)
|
|
|
- { // 倍数为奇数的在上面
|
|
|
- offset.y = _monsterOffset.y;
|
|
|
- }
|
|
|
- var target = position + offset;
|
|
|
- // 随机偏移xy(-0.2, 0.2)
|
|
|
- target.x += Random.Range(-0.25f, 0.25f);
|
|
|
- target.y += Random.Range(-0.25f, 0.25f);
|
|
|
- return target;
|
|
|
- }
|
|
|
- private void PushMonstPositionIdx(int positionIdx)
|
|
|
- {
|
|
|
- if (_unusedIndexs.Contains(positionIdx))
|
|
|
- return; // 避免重复记录
|
|
|
- for (var i = 0; i < _unusedIndexs.Count; i++)
|
|
|
- {
|
|
|
- if (positionIdx < _unusedIndexs[i] && (i == 0 || positionIdx > _unusedIndexs[i - 1]))
|
|
|
- { // 小于当前索引的值 且 大于(i - 1 )的值
|
|
|
- _unusedIndexs.Insert(i, positionIdx);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- _unusedIndexs.Add(positionIdx);
|
|
|
- }
|
|
|
+ ///// <summary>
|
|
|
+ ///// 获取怪物的出生坐标和索引
|
|
|
+ ///// </summary>
|
|
|
+ ///// <param name="position"></param>
|
|
|
+ ///// <param name="positionIdx"></param>
|
|
|
+ ///// <returns></returns>
|
|
|
+ //private Vector3 GetMonsterBirth(Vector3 position, out int positionIdx)
|
|
|
+ //{
|
|
|
+ // if (_unusedIndexs.Count > 0)
|
|
|
+ // {
|
|
|
+ // positionIdx = _unusedIndexs[0];
|
|
|
+ // _unusedIndexs.RemoveAt(0);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // positionIdx = 0;
|
|
|
+ // }
|
|
|
+ // if (positionIdx == 0)
|
|
|
+ // {
|
|
|
+ // return position;
|
|
|
+ // }
|
|
|
+ // var offset = Vector3.zero;
|
|
|
+ // var xMultiple = (positionIdx + 1) / 2;
|
|
|
+ // offset.x = _monsterOffset.x * xMultiple;
|
|
|
+ // if (positionIdx % 2 != 0)
|
|
|
+ // { // 索引为奇数的在左边
|
|
|
+ // offset.x = -offset.x;
|
|
|
+ // }
|
|
|
+ // if (xMultiple % 2 != 0)
|
|
|
+ // { // 倍数为奇数的在上面
|
|
|
+ // offset.y = _monsterOffset.y;
|
|
|
+ // }
|
|
|
+ // var target = position + offset;
|
|
|
+ // // 随机偏移xy(-0.2, 0.2)
|
|
|
+ // target.x += Random.Range(-0.25f, 0.25f);
|
|
|
+ // target.y += Random.Range(-0.25f, 0.25f);
|
|
|
+ // return target;
|
|
|
+ //}
|
|
|
+ //private void PushMonstPositionIdx(int positionIdx)
|
|
|
+ //{
|
|
|
+ // if (_unusedIndexs.Contains(positionIdx))
|
|
|
+ // return; // 避免重复记录
|
|
|
+ // for (var i = 0; i < _unusedIndexs.Count; i++)
|
|
|
+ // {
|
|
|
+ // if (positionIdx < _unusedIndexs[i] && (i == 0 || positionIdx > _unusedIndexs[i - 1]))
|
|
|
+ // { // 小于当前索引的值 且 大于(i - 1 )的值
|
|
|
+ // _unusedIndexs.Insert(i, positionIdx);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // _unusedIndexs.Add(positionIdx);
|
|
|
+ //}
|
|
|
private MonsterEntity[] GenMonsters()
|
|
|
{
|
|
|
var chapter = ChapterTableRepo.Get(_chapterId);
|
|
@@ -421,6 +425,7 @@ namespace FL.Nodes.GameMain
|
|
|
entity.BirthPosition = position;
|
|
|
entity.BirthDelay = row * chapter.Interval + (isBossPart ? 1000 : 0); // boss额外加1000毫秒延迟
|
|
|
entity.BirthCurve = curve;
|
|
|
+ entity.IsBoss = monsterTab.Type == 2;
|
|
|
monsters[i] = entity;
|
|
|
}
|
|
|
return monsters;
|
|
@@ -487,6 +492,28 @@ namespace FL.Nodes.GameMain
|
|
|
dto.partners = partners;
|
|
|
EventSingle.Instance.Notify(EventDefine.GameMainMapLoadEntities, dto);
|
|
|
}
|
|
|
+ private void OnPartnersChanged(int eventId, object args)
|
|
|
+ {
|
|
|
+ //TODO 临时代码
|
|
|
+ if (_partnerMap == null) return;
|
|
|
+ var partnerIds = _partnerMap.Keys.ToList();
|
|
|
+ _partnerMap.Clear();
|
|
|
+ foreach (var partnerId in partnerIds)
|
|
|
+ {
|
|
|
+ EventSingle.Instance.Notify(EventDefine.GameMainMapRemoveEntity, partnerId);
|
|
|
+ }
|
|
|
+ var chapter = ChapterTableRepo.Get(_chapterId);
|
|
|
+ var map = MapTableRepo.Get(chapter.Map);
|
|
|
+ var dto = new LoadEntitiesDto();
|
|
|
+ dto.chapterId = _chapterId;
|
|
|
+ //战斗位置
|
|
|
+ dto.battlePosition = GetBattlePosition(map, chapter.Part);// map.BattlePositions[chapter.Part - 1].ToVector3();
|
|
|
+ var partners = GenPartners(dto.battlePosition);
|
|
|
+ AddPartners(partners);
|
|
|
+ dto.partners = partners;
|
|
|
+ EventSingle.Instance.Notify(EventDefine.GameMainMapLoadEntities, dto);
|
|
|
+
|
|
|
+ }
|
|
|
private void OnChallengeBoss(int eventId, object args)
|
|
|
{
|
|
|
CombatFailed(true);
|