Пример #1
0
    public void EquipItem(Item itemToReplace, int itemAreaPlayerId)
    {
        if (SelectedItem != null)
        {
            if (SelectedItem.Owner.Id == itemAreaPlayerId)
            {
                if (!SelectedItem.Owner.Hero.EquippedItems.Select(x => x.Id).Contains(SelectedItem.Id) || (itemToReplace != null && itemToReplace.Id == SelectedItem.Id))
                {
                    if (itemToReplace != null)
                    {
                        itemToReplace.DestroyItem();
                    }

                    if (SelectedCard != null)
                    {
                        SelectedCard.Play();
                    }
                    else
                    {
                        SelectedItem.Equip();
                    }

                    SelectedItem = null;
                    GameManager.instance.uiManager.RefreshUI();
                    RefreshEffectManager();
                }
            }
        }
    }
Пример #2
0
 public void CastSpell(Cell targetCell)
 {
     if (SelectedCard != null)
     {
         //Need to account for caster (Selected Unit)
         SelectedCard.Play();
         GameManager.instance.uiManager.RefreshUI();
         RefreshEffectManager();
     }
 }
Пример #3
0
 internal void NodeClicked(Node node)
 {
     Debug.Log($"Node Clicked: {node}");
     if (SelectedUnit && SelectedUnit.TaskInProgress == null)
     {
         SelectedUnit.TaskInProgress = StartCoroutine(UnitNodeActionCoroutine(node));
     }
     else if (SelectedCard && SelectedCard.CanBePlayed() && SelectedCard.CanBePlayedOn(node))
     {
         SelectedCard.Play(node);
         CardBase.Selected_Card = null;
     }
 }
Пример #4
0
    public GameObject CreateUnitCounter(Unit unit, Cell cell, bool isNew = true)
    {
        if (cell.occupantCounter == null)
        {
            var createdCounter = Instantiate(unitCounterPrefab, cell.backgroundImage.transform);

            var unitCounterScript = createdCounter.GetComponent <UnitCounter>();
            unitCounterScript.InitUnitCounter(unit, cell);
            unit.UnitCounter = unitCounterScript;
            if (!unit.Owner.DeployedUnits.Contains(unitCounterScript))
            {
                unit.Owner.DeployedUnits.Add(unitCounterScript);
            }
            cell.occupantCounter = createdCounter.GetComponent <UnitCounter>();

            if (isNew)
            {
                if (SelectedCard != null)
                {
                    SelectedCard.Play();
                }
                else
                {
                    unit.Deploy();
                }
                GameManager.instance.uiManager.RefreshUI();
            }

            if (unit.Owner.RedeployUnits.Contains(unit))
            {
                unit.Owner.RedeployUnits.Remove(unit);
                GameManager.instance.uiManager.RefreshUI();
            }

            cell.CheckTileStatusOnEntry(unit);

            DeployUnits.Remove(unit);

            GameManager.instance.CheckWarden();

            unitCounterScript.RefreshUnitCounter();

            return(createdCounter);
        }
        else
        {
            return(null);
        }
    }