예제 #1
0
 private UnitDescriptionForSerialization(UnitDescription unit)
 {
     name        = unit.GetUnitName();
     unitRace    = unit.GetRace().race.ToString();
     unitClass   = unit.GetClass().clas.ToString();
     abilityName = unit.GetAbilityName();
     id          = unit.GetId();
     experience  = unit.GetExperience();
     level       = unit.GetLevel();
     gems        = unit.GetGems();
 }
예제 #2
0
    public void OnDrag(PointerEventData eventData)
    {
        if (eventData.button != PointerEventData.InputButton.Left)
        {
            return;
        }

        if (_status != SlotState.Used || GameManager.instance.gamestate != GameManager.GameState.Placement)
        {
            return;
        }

        List <Cell> authorizedCells = Board.CurrentBoard.GetAuthorizedAllyCells();

        List <Cell> avalaibleCells = new List <Cell>();

        foreach (Cell cell in authorizedCells)
        {
            if (!cell.GetIsOccupied() && cell.GetIsObstacle() == false)
            {
                avalaibleCells.Add(cell);
            }
        }

        if (avalaibleCells.Count == 0)
        {
            return;
        }

        Unit newUnit = Instantiate(unitPrefab).GetComponent <Unit>();

        newUnit.SetName(unitDescription.GetUnitName());
        newUnit.SetSprite(unitDescription.GetSprite());
        newUnit.raceStats = unitDescription.GetRace();
        newUnit.classStat = unitDescription.GetClass();
        newUnit.SetAbilityName(unitDescription.GetAbilityName());
        newUnit.SetGems(unitDescription.GetGems());
        newUnit.Level = unitDescription.GetLevel();
        newUnit.AttachBoard();
        newUnit.transform.SetPositionAndRotation(attachedCamera.ScreenToWorldPoint(Input.mousePosition), Quaternion.identity);

        Cell destinatinCell = avalaibleCells[0];

        newUnit.initialPos = destinatinCell.TileMapPosition;

        newUnit.tag          = Unit.allyTag;
        newUnit.isRandomUnit = false;
        newUnit.id           = unitDescription.GetId();

        newUnit.PrepareForDragNDrop();
        ClearSlot();
    }
예제 #3
0
    public void AddUnitInInventory(UnitDescription unit, bool addToGUINow = false)
    {
        UnitDescription equivalentUnit = GetEquivalentUnit(unit);

        if (equivalentUnit == null)
        {
            if (unitsInInventory.Count >= maxElements)
            {
                Player.instance.Wallet.Earn(ShopSystem.GetUnitSellPrice(unit));
                return;
            }

            unitsInInventory.Add(unit.GetId(), unit);

            if (addToGUINow)
            {
                inventoryUI.PutInEmptySlot(unit);
            }

            return;
        }

        equivalentUnit.EarnExperience(3);
    }
예제 #4
0
 public void RemoveFromInventory(UnitDescription unit)
 {
     unitsInInventory.Remove(unit.GetId());
     inventoryUI.UpdateGUI();
 }