|
@ -7,19 +7,19 @@ namespace GWConquest |
|
|
Sprite Icon {get;} |
|
|
Sprite Icon {get;} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public class Unit : Bolt.EntityEventListener<IUnitState>, IIconObject |
|
|
|
|
|
|
|
|
public class Unit : GWBoltEntityListener<IUnitState>, IIconObject |
|
|
{ |
|
|
{ |
|
|
public UnitClass Class |
|
|
public UnitClass Class |
|
|
{ |
|
|
{ |
|
|
get => UnitClass.FromName(state.UnitClass); |
|
|
|
|
|
|
|
|
get => UnitClass.FromName(State.UnitClass); |
|
|
set { |
|
|
set { |
|
|
if(value == null) |
|
|
if(value == null) |
|
|
{ |
|
|
{ |
|
|
state.UnitClass = null; |
|
|
|
|
|
|
|
|
State.UnitClass = null; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
state.UnitClass = value.ShortName; |
|
|
|
|
|
|
|
|
State.UnitClass = value.ShortName; |
|
|
|
|
|
|
|
|
Inventory.StorageCapacity = value.InventorySlots; |
|
|
Inventory.StorageCapacity = value.InventorySlots; |
|
|
Equipment.StorageCapacity = value.EquipmentSlots; |
|
|
Equipment.StorageCapacity = value.EquipmentSlots; |
|
@ -34,18 +34,18 @@ namespace GWConquest |
|
|
|
|
|
|
|
|
public Formation Formation |
|
|
public Formation Formation |
|
|
{ |
|
|
{ |
|
|
get => state.Formation?.GetComponent<Formation>(); |
|
|
|
|
|
set => state.Formation = value.entity; |
|
|
|
|
|
|
|
|
get => State.Formation?.GetComponent<Formation>(); |
|
|
|
|
|
set => State.Formation = value.entity; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public int Hitpoints { |
|
|
public int Hitpoints { |
|
|
get => state.Hitpoints; |
|
|
|
|
|
set => state.Hitpoints = value; |
|
|
|
|
|
|
|
|
get => State.Hitpoints; |
|
|
|
|
|
set => State.Hitpoints = value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public int Shields { |
|
|
public int Shields { |
|
|
get => state.Shields; |
|
|
|
|
|
set => state.Shields = value; |
|
|
|
|
|
|
|
|
get => State.Shields; |
|
|
|
|
|
set => State.Shields = value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public float Armour { |
|
|
public float Armour { |
|
@ -66,8 +66,8 @@ namespace GWConquest |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public float Morale { |
|
|
public float Morale { |
|
|
get => state.Morale; |
|
|
|
|
|
set => state.Morale = value; |
|
|
|
|
|
|
|
|
get => State.Morale; |
|
|
|
|
|
set => State.Morale = value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public Player Player { |
|
|
public Player Player { |
|
@ -75,9 +75,9 @@ namespace GWConquest |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public BattleUnitState BattleState { |
|
|
public BattleUnitState BattleState { |
|
|
get => (BattleUnitState) state.BattleState; |
|
|
|
|
|
|
|
|
get => (BattleUnitState) State.BattleState; |
|
|
set { |
|
|
set { |
|
|
state.BattleState = (int) value; |
|
|
|
|
|
|
|
|
State.BattleState = (int) value; |
|
|
if(BoltNetwork.IsServer) |
|
|
if(BoltNetwork.IsServer) |
|
|
{ |
|
|
{ |
|
|
if(CurrentBattle != null) |
|
|
if(CurrentBattle != null) |
|
@ -89,16 +89,16 @@ namespace GWConquest |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public RevealState RevealState { |
|
|
public RevealState RevealState { |
|
|
get => (RevealState) state.RevealState; |
|
|
|
|
|
set => state.RevealState = (int) value; |
|
|
|
|
|
|
|
|
get => (RevealState) State.RevealState; |
|
|
|
|
|
set => State.RevealState = (int) value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public float ActionCooldown { |
|
|
public float ActionCooldown { |
|
|
get => state.ActionCooldown; |
|
|
|
|
|
|
|
|
get => State.ActionCooldown; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public float ActionCooldownPercent { |
|
|
public float ActionCooldownPercent { |
|
|
get => state.ActionCooldown / state.ActionCooldownMax; |
|
|
|
|
|
|
|
|
get => State.ActionCooldown / State.ActionCooldownMax; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public BattleFlank FlankTarget { |
|
|
public BattleFlank FlankTarget { |
|
@ -108,7 +108,7 @@ namespace GWConquest |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
int ind = state.FlankTarget; |
|
|
|
|
|
|
|
|
int ind = State.FlankTarget; |
|
|
if(ind >= 0 && CurrentBattle.FlankCount < ind) |
|
|
if(ind >= 0 && CurrentBattle.FlankCount < ind) |
|
|
{ |
|
|
{ |
|
|
return CurrentBattle.GetFlank(ind); |
|
|
return CurrentBattle.GetFlank(ind); |
|
@ -116,13 +116,13 @@ namespace GWConquest |
|
|
else return null; |
|
|
else return null; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
set => state.FlankTarget = value == null ? -1 : value.FlankId; |
|
|
|
|
|
|
|
|
set => State.FlankTarget = value == null ? -1 : value.FlankId; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void SetActionCooldown(float value) |
|
|
public void SetActionCooldown(float value) |
|
|
{ |
|
|
{ |
|
|
state.ActionCooldown = value; |
|
|
|
|
|
state.ActionCooldownMax = value; |
|
|
|
|
|
|
|
|
State.ActionCooldown = value; |
|
|
|
|
|
State.ActionCooldownMax = value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[System.NonSerialized] |
|
|
[System.NonSerialized] |
|
@ -153,10 +153,10 @@ namespace GWConquest |
|
|
|
|
|
|
|
|
public override void Attached() |
|
|
public override void Attached() |
|
|
{ |
|
|
{ |
|
|
Inventory = new Inventory(state, "Inventory"); |
|
|
|
|
|
Equipment = new Inventory(state, "Equipment"); |
|
|
|
|
|
|
|
|
Inventory = new Inventory(State, "Inventory"); |
|
|
|
|
|
Equipment = new Inventory(State, "Equipment"); |
|
|
|
|
|
|
|
|
state.AddCallback("Formation", () => |
|
|
|
|
|
|
|
|
State.AddCallback("Formation", () => |
|
|
{ |
|
|
{ |
|
|
if(Formation != null) |
|
|
if(Formation != null) |
|
|
{ |
|
|
{ |
|
@ -185,9 +185,9 @@ namespace GWConquest |
|
|
Unit unit = unitEntity.GetComponent<Unit>(); |
|
|
Unit unit = unitEntity.GetComponent<Unit>(); |
|
|
unit.Class = uc; |
|
|
unit.Class = uc; |
|
|
unit.gameObject.name = uc.ShortName + "_" + unitEntity.NetworkId.PackedValue.ToString(); |
|
|
unit.gameObject.name = uc.ShortName + "_" + unitEntity.NetworkId.PackedValue.ToString(); |
|
|
unit.state.Hitpoints = uc.Hitpoints; |
|
|
|
|
|
unit.state.Shields = uc.Shields; |
|
|
|
|
|
unit.state.Morale = uc.Morale; |
|
|
|
|
|
|
|
|
unit.State.Hitpoints = uc.Hitpoints; |
|
|
|
|
|
unit.State.Shields = uc.Shields; |
|
|
|
|
|
unit.State.Morale = uc.Morale; |
|
|
unit.Formation = playerFormation; |
|
|
unit.Formation = playerFormation; |
|
|
playerFormation.UnitEntities.Add(unitEntity); |
|
|
playerFormation.UnitEntities.Add(unitEntity); |
|
|
|
|
|
|
|
@ -222,7 +222,7 @@ namespace GWConquest |
|
|
|
|
|
|
|
|
var evnt = UnitDamageAnimEvent.Create(entity); |
|
|
var evnt = UnitDamageAnimEvent.Create(entity); |
|
|
evnt.Attacker = attacker.entity; |
|
|
evnt.Attacker = attacker.entity; |
|
|
evnt.IsDead = state.Hitpoints <= 0; |
|
|
|
|
|
|
|
|
evnt.IsDead = State.Hitpoints <= 0; |
|
|
evnt.IsDemoralized = IsDemoralized; |
|
|
evnt.IsDemoralized = IsDemoralized; |
|
|
evnt.GlancingHit = isGlancingHit; |
|
|
evnt.GlancingHit = isGlancingHit; |
|
|
evnt.WeaponType = (int) weaponType; |
|
|
evnt.WeaponType = (int) weaponType; |
|
@ -298,7 +298,7 @@ namespace GWConquest |
|
|
|
|
|
|
|
|
if (ActionCooldown <= 0) |
|
|
if (ActionCooldown <= 0) |
|
|
{ |
|
|
{ |
|
|
state.ActionCooldown = 0; |
|
|
|
|
|
|
|
|
State.ActionCooldown = 0; |
|
|
if (BattleState == BattleUnitState.MovingToFlank) |
|
|
if (BattleState == BattleUnitState.MovingToFlank) |
|
|
{ |
|
|
{ |
|
|
BattleState = BattleUnitState.OnFlank; |
|
|
BattleState = BattleUnitState.OnFlank; |
|
@ -321,7 +321,7 @@ namespace GWConquest |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
state.ActionCooldown -= BoltNetwork.FrameDeltaTime; |
|
|
|
|
|
|
|
|
State.ActionCooldown -= BoltNetwork.FrameDeltaTime; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|