예제 #1
0
        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;
                }
            }
        }
예제 #2
0
 public void AssignUnitEntity(UnitEntity unitEntity)
 {
     if (unit != null)
     {
         unit.OnDeath -= () => game.npcList.Remove(this);
     }
     unit          = unitEntity;
     unit.OnDeath += () => game.npcList.Remove(this);
 }
예제 #3
0
        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;
        }
예제 #4
0
        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;
        }
예제 #5
0
        public void SetSelectedUnit(PlayerUnitEntityController ctrl)
        {
            UnitEntity unit = ctrl.Unit;

            RemoveCallbacks();
            selectedUnit = unit;

            SetUpUnitEntityVisual(ctrl);
            AddCallbacks();

            // Update graphics
            UpdateUnitPanel();
            UpdateActionButtons();
        }
예제 #6
0
        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;
        }
예제 #7
0
        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;
        }