增加容错处理,修改技能继承方法
This commit is contained in:
parent
3920366820
commit
ed6a8928e8
@ -7,6 +7,7 @@
|
||||
|
||||
|
||||
using JetBrains.Annotations;
|
||||
using Logic.CrashSight;
|
||||
using RuntimeData;
|
||||
using TH1_Anim.UnitAtomAnim;
|
||||
using TH1_DataAssetsScript;
|
||||
@ -63,6 +64,13 @@ namespace TH1_Anim.Fragments
|
||||
//Step #1执行第一步,弹动,并且更新cityInfo的人口条部分和金钱部分
|
||||
if (progressTime >= _step1_time && !_step1_bounce)
|
||||
{
|
||||
if (GridRenderer == null || CityInfoRenderer == null)
|
||||
{
|
||||
LogSystem.LogError($"Wrong With FragmentCityExpUp lv={Level},exp={LevelExp}");
|
||||
_step1_bounce = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_step1_bounce = true;
|
||||
GridRenderer.SetBounceAnim();
|
||||
CityInfoRenderer.UpdateLevelShow(Level,LevelExp);
|
||||
|
||||
@ -1367,8 +1367,8 @@ namespace RuntimeData
|
||||
}
|
||||
|
||||
// 检查下超时
|
||||
if (Main.MapData.Net.Mode == NetMode.Multi && Net.CurPlayerId != 0 && Time.time - Net.PlayerStartTime >= 300)
|
||||
Main.PlayerLogic.EndPlayerTurn(Main.MapData, Net.CurPlayerId);
|
||||
// if (Main.MapData.Net.Mode == NetMode.Multi && Net.CurPlayerId != 0 && Time.time - Net.PlayerStartTime >= 300)
|
||||
// Main.PlayerLogic.EndPlayerTurn(Main.MapData, Net.CurPlayerId);
|
||||
if (Net.CurPlayerId != 0) return;
|
||||
|
||||
// 获取下一位
|
||||
|
||||
@ -23,7 +23,7 @@ namespace Logic.Skill
|
||||
IsTrigger = false;
|
||||
}
|
||||
|
||||
public override bool ReservedOnTransform()
|
||||
public override bool ReservedOnTransform(UnitData self, UnitFullType fullType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ namespace Logic.Skill
|
||||
origin.Renderer(mapData)?.InstantUpdateUnit(false);
|
||||
}
|
||||
|
||||
public override bool ReservedOnTransform()
|
||||
public override bool ReservedOnTransform(UnitData self, UnitFullType fullType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
using System;
|
||||
using MemoryPack;
|
||||
using RuntimeData;
|
||||
|
||||
|
||||
namespace Logic.Skill
|
||||
@ -25,7 +26,7 @@ namespace Logic.Skill
|
||||
return SkillType.NOPOPULATION;
|
||||
}
|
||||
|
||||
public override bool ReservedOnTransform()
|
||||
public override bool ReservedOnTransform(UnitData self, UnitFullType fullType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ namespace Logic.Skill
|
||||
return _level * 1f;
|
||||
}
|
||||
|
||||
public override bool ReservedOnTransform()
|
||||
public override bool ReservedOnTransform(UnitData self, UnitFullType fullType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6,10 +6,7 @@
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using MemoryPack;
|
||||
using RuntimeData;
|
||||
using TH1_Logic.Core;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ namespace Logic.Skill
|
||||
{
|
||||
public SkillType GetSkillType();
|
||||
|
||||
public bool ReservedOnTransform();
|
||||
public bool ReservedOnTransform(UnitData self, UnitFullType fullType);
|
||||
public void NewSkillOnTransform(List<SkillBase> oldSkills);
|
||||
public void OnGet();
|
||||
public void OnLose(UnitData self,MapData map);
|
||||
@ -206,7 +206,7 @@ namespace Logic.Skill
|
||||
}
|
||||
|
||||
public abstract SkillType GetSkillType();
|
||||
public virtual bool ReservedOnTransform()
|
||||
public virtual bool ReservedOnTransform(UnitData self, UnitFullType fullType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1011,7 +1011,8 @@ namespace Logic
|
||||
{
|
||||
unitData.GetSkill(skilltype, out var skill);
|
||||
if (skill == null) continue;
|
||||
if (skill.ReservedOnTransform()) continue;
|
||||
var fullType = new UnitFullType(targetType, giantType, unitLevel);
|
||||
if (skill.ReservedOnTransform(unitData, fullType)) continue;
|
||||
oldSkills.Add(skill);
|
||||
unitData.RemoveSkill(skilltype, mapData);
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Logic;
|
||||
using Logic.CrashSight;
|
||||
using Logic.Multilingual;
|
||||
using RuntimeData;
|
||||
using TH1_Logic.Core;
|
||||
@ -206,7 +207,17 @@ namespace TH1_Renderer
|
||||
|
||||
private void RenderUpdateCityPops(int level,int levelExp) //更新经验条+人口条的显示,一线打工的渲染函数
|
||||
{
|
||||
|
||||
if (_mapData?.PlayerMap?.SelfPlayerData?.Sight == null)
|
||||
{
|
||||
LogSystem.LogError($"RenderUpdateCityPops _mapData?.PlayerMap?.SelfPlayerData?.Sight == null");
|
||||
return;
|
||||
}
|
||||
if (_cityData == null)
|
||||
{
|
||||
LogSystem.LogError($"RenderUpdateCityPops _cityData == null");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_mapData.PlayerMap.SelfPlayerData.Sight.CheckIsInSight(_cityData.Grid(Main.MapData)?.Id ?? 0))
|
||||
return;
|
||||
|
||||
@ -230,26 +241,44 @@ namespace TH1_Renderer
|
||||
{
|
||||
lineNo = i / 10;
|
||||
rankNo = i % 10;
|
||||
GameObject houseFather = _ROCityInfo.transform.Find("CityInfoCanvas").transform.Find("CityLevelBar")
|
||||
.transform.Find($"CityLevelBarLine ({lineNo})").transform.Find($"HouseFather ({rankNo})").gameObject;
|
||||
var houseFather = _ROCityInfo?.transform
|
||||
.Find($"CityInfoCanvas/CityLevelBar/CityLevelBarLine ({lineNo})/HouseFather ({rankNo}")?.gameObject;
|
||||
if (!houseFather)
|
||||
{
|
||||
LogSystem.LogError($"RenderUpdateCityPops not find CityInfoCanvas/CityLevelBar/CityLevelBarLine ({lineNo})/HouseFather ({rankNo}");
|
||||
continue;
|
||||
}
|
||||
|
||||
houseFather.SetActive(true);
|
||||
var houseCom = houseFather.transform.Find("House")?.GetComponent<SpriteRenderer>();
|
||||
var populationCom = houseFather.transform.Find("Population")?.GetComponent<SpriteRenderer>();
|
||||
if (!houseCom || !populationCom) continue;
|
||||
//处理绿色house城市经验的情况
|
||||
if (levelExp > i)
|
||||
houseFather.transform.Find("House").GetComponent<SpriteRenderer>().sprite
|
||||
= Resources.Load<Sprite>("ArtResources/TH1Miscs/TH1Misc_House_green");
|
||||
{
|
||||
houseCom.sprite = Resources.Load<Sprite>("ArtResources/TH1Miscs/TH1Misc_House_green");
|
||||
}
|
||||
//处理负citylevel的情况
|
||||
else if (levelExp < -i)
|
||||
houseFather.transform.Find("House").GetComponent<SpriteRenderer>().sprite
|
||||
= Resources.Load<Sprite>("ArtResources/TH1Miscs/TH1Misc_House_red");
|
||||
{
|
||||
houseCom.sprite = Resources.Load<Sprite>("ArtResources/TH1Miscs/TH1Misc_House_red");
|
||||
}
|
||||
//其他情况是白色house
|
||||
else
|
||||
houseFather.transform.Find("House").GetComponent<SpriteRenderer>().sprite
|
||||
= Resources.Load<Sprite>("ArtResources/TH1Miscs/TH1Misc_House_white");
|
||||
{
|
||||
houseCom.sprite = Resources.Load<Sprite>("ArtResources/TH1Miscs/TH1Misc_House_white");
|
||||
}
|
||||
//处理人口显示
|
||||
houseFather.transform.Find("Population").gameObject.SetActive(population > i);
|
||||
populationCom.gameObject.SetActive(population > i);
|
||||
}
|
||||
//根据level确定缩放尺寸
|
||||
_ROCityInfo.transform.Find("CityInfoCanvas").transform.Find("CityLevelBar").localScale = new Vector3(scale,scale,scale);
|
||||
var cityLevelBatTrs = _ROCityInfo?.transform.Find($"CityInfoCanvas/CityLevelBar");
|
||||
if (!cityLevelBatTrs)
|
||||
{
|
||||
LogSystem.LogError($"RenderUpdateCityPops not find CityInfoCanvas/CityLevelBar");
|
||||
return;
|
||||
}
|
||||
cityLevelBatTrs.localScale = new Vector3(scale,scale,scale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -672,6 +672,7 @@ namespace TH1Renderer
|
||||
|
||||
public void SetBounceAnim(bool NeedRandomWait=false, bool isLevelupBounce = false)
|
||||
{
|
||||
if (!_ROGrid) return;
|
||||
if (needBounce) return;
|
||||
levelupBounce = isLevelupBounce;
|
||||
if(!NeedRandomWait)
|
||||
|
||||
@ -163,6 +163,7 @@ namespace TH1_Renderer
|
||||
|
||||
public void RenderUpdateUnitInfo()
|
||||
{
|
||||
if (!_unitMono?.HealthText || !_unitMono?.UnitInfoBGImg || !_unitMono?.UnionIcon) return;
|
||||
_unitMono.HealthText.text = _unitData.Health.ToString();
|
||||
//处理血量的颜色。如果血量<一半且<5,那么赋予红色,否则白色
|
||||
if(_unitData.Health < 5 && _unitData.Health < _unitData.GetMaxHealth() / 2)
|
||||
@ -171,7 +172,8 @@ namespace TH1_Renderer
|
||||
_unitMono.HealthText.color = Color.white;
|
||||
//根据敌我情况更新infoBG的颜色
|
||||
//_unitInfoBGImg.sprite = (Main.MapData.SameUnion(_playerData.Id , Main.MapData.PlayerMap.SelfPlayerId)) ? ResourceCache.Instance.SpriteCache.UnitInfoSelf :
|
||||
if(!Main.MapData.GetPlayerDataByUnitId(_unitData.Id,out var playerData))return;
|
||||
if (Main.MapData == null) return;
|
||||
if (!Main.MapData.GetPlayerDataByUnitId(_unitData.Id, out var playerData)) return;
|
||||
if (playerData.Id == Main.MapData.PlayerMap.SelfPlayerId)
|
||||
_unitMono.UnitInfoBGImg.material = ResourceCache.Instance.MatCache.GradientBG_Blue;
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user