public UnitPanelGraphics(GameObject panel, Button moveButton, Button attackButton, Button abilityButton, Button itemsButton) { selectedUnit = null; this.panel = panel; this.moveButton = moveButton; this.attackButton = attackButton; this.abilityButton = abilityButton; this.itemsButton = itemsButton; foreach (Text t in panel.GetComponentsInChildren <Text>()) { if (t.name == "Name Plate") { namePlate = t; } else if (t.name == "Status Text") { statusText = t; } } foreach (Image img in panel.GetComponentsInChildren <Image>()) { if (img.name == "Image") { image = img; } } }
public void AssignUnitEntity(UnitEntity unitEntity) { if (unit != null) { unit.OnDeath -= () => game.npcList.Remove(this); } unit = unitEntity; unit.OnDeath += () => game.npcList.Remove(this); }
public UnitEntityGraphics(GameObject obj, UnitEntity unit, UnitEntityConfig config, World world) { this.Obj = obj; ShowingSelectionIndicator = false; this.Unit = unit; this.Config = config; this.World = world; this.MovementGraphics = new UnitEntityMovementGraphics(this); this.CombatGraphics = new UnitEntityCombatGraphics(this); unit.OnDamaged += OnDamaged; }
public void Initialize(string id, Vector3Int position, GUIMaster gui, World world, UnitEntity unitEntity) { unitID = id; Sprite sprite = Resources.Load <Sprite>("Unit Entity Sprites/" + id); GetComponent <SpriteRenderer>().sprite = sprite; transform.position = world.CellToWorld(position); this.gui = gui; this.world = world; this.unitEntity = unitEntity; unitEntity.OnDeath += OnDeath; }
public void SetSelectedUnit(PlayerUnitEntityController ctrl) { UnitEntity unit = ctrl.Unit; RemoveCallbacks(); selectedUnit = unit; SetUpUnitEntityVisual(ctrl); AddCallbacks(); // Update graphics UpdateUnitPanel(); UpdateActionButtons(); }
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 void SetSelectedUnit(BaseUnitEntityController ctrl) { UnitEntity unit = ctrl.Unit; // Maybe move to different class? SpriteRenderer renderer = ctrl.GetComponent <SpriteRenderer>(); unitSprite = renderer.sprite; unitColor = renderer.color; if (selectedUnit != null) { selectedUnit.OnStatusChanged -= UpdateStatus; } selectedUnit = unit; UpdateStatus(); unit.OnStatusChanged += UpdateStatus; }