public void SpawnUnitEntity(string id, string name, Vector3Int position) { UnitEntityData unitData = GlobalUnitEntityDictionary.GetUnitEntityData("Unit Entities", id); // This might be too tightly coupled to Unity? UnitEntityCombatData combatData = UnitEntityCombatData.LoadFromSO(unitData); UnitEntity unitEntity = new UnitEntity(name, position, unitData.maxHealth, unitData.sight, unitData.isPlayerControlled, unitData.movementSpeed, World, combatData); OnUnitSpawn?.Invoke(unitEntity, id); }
public static void LoadCombatData(string path) { foreach (UnitEntityData data in Resources.LoadAll <UnitEntityData>(path + '/')) { UnitEntityCombatData combatData = UnitEntityCombatData.LoadFromSO(data); unitData.Add(data.name, combatData); } }
protected virtual void CreateUnitEntity(bool isPlayerControlled) { Vector3Int gridPos = world.WorldToCell(transform.position); transform.position = world.CellToWorld(gridPos); UnitEntityData unitData = GlobalUnitEntityDictionary.GetUnitEntityData("Unit Entities", unitID); UnitEntityCombatData combatData = UnitEntityCombatData.LoadFromSO(unitData); unitEntity = new UnitEntity(this.name, gridPos, unitData.maxHealth, unitData.sight, isPlayerControlled, unitData.movementSpeed, world, combatData); unitEntity.OnDeath += OnDeath; Sprite sprite = Resources.Load <Sprite>("Unit Entity Sprites/" + unitID); GetComponent <SpriteRenderer>().sprite = sprite; }
public UnitEntity(string name, Vector3Int initialPosition, int maxHealth, int sight, bool isPlayerControlled, int movementSpeed, IWorld world, UnitEntityCombatData combatData) { //ID = id; Name = name; Position = initialPosition; Level = 0; Experience = 0; MaxHealth = maxHealth; Health = maxHealth; IsAlive = true; this.sight = sight; this.world = world; IsPlayerControlled = isPlayerControlled; movement = new UnitEntityMovement(this, world, movementSpeed); combat = new UnitEntityCombat(this, world, movement, combatData); inventory = new Inventory(100); //TODO: placeholder UnitEntity inventory weight // TODO: placeholder UnitEntity initialization inventory.AddItem(new Items.UtilityItems.UtilityItem("health_potion", "Health Potion", 1, 1, 1, "Potion", 1, 0, new Abilities.AbilityEffect[] { new Abilities.HealAbilityEffect(10) }, new Abilities.HexAbilityAOE(0), true, false)); UpdateVision(); world.UnitManager.AddUnit(this); }