void SetUnit(BaseSoldierData unitData)
    {
        _unitData = unitData;
        if (_unitData == null)
            return;

        GameObject cardResource = UIResourcesManager.Instance.GetResource<GameObject>(
            string.Format("{0}/{1}", GameConstants.Paths.UI_WINDOWS_PREFAB_RESOURCES, "Unit_card"));
        if (cardResource == null)
            return;

        GameObject cardUnitData = GameObject.Instantiate(cardResource) as GameObject;
        UIUnitCard unitCard = cardUnitData.GetComponent<UIUnitCard>();
        unitCard.UnitKey = _unitData.Key;
        cardUnitData.transform.SetParent(transform, false);

        RectTransform rectCard = cardUnitData.GetComponent<RectTransform>();
        Rect rectBackground = gameObject.GetComponent<RectTransform>().rect;
        rectCard.anchoredPosition = new Vector2(rectBackground.width / 2, rectBackground.height / 2);
        rectCard.localScale *= _imgUnit.rectTransform.rect.width / rectCard.rect.width;

        _txtDamage.text = "Damage: " + _unitData.BaseDamage.ToString();
        _txtHP.text = "Health Points: " + _unitData.BaseHealthPoints.ToString();
        _txtInfo.text = "About Unit: " + _unitData.AboutInfo;
    }
 public void Show(BaseSoldierData slotData)
 {
     _slotData = slotData;
     SetCurrentHero();
     SetAllAvailableUnits();
     Show();
 }
    void SetSelectedUnit(BaseSoldierData currentSoldierData)
    {
        if (_currentSoldierData != null)
        {
            UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(_currentSoldierData.IconName));
        }

        _currentSoldierData = currentSoldierData;
        if (_currentSoldierData != null)
        {
            _lblCurrentSoldierLeadershipCost.text = _currentSoldierData.LeadershipCost.ToString();
            _lblCurrentSoldierLevel.text          = Global.Instance.Player.City.GetSoldierUpgradesInfo(_currentSoldierData.Key).Level.ToString();
            _lblCurrentSoldierDescription.text    = _currentSoldierData.PrefabName;

            _imgCurrrentSoldier.enabled = true;
            _imgCurrrentSoldier.sprite  = UIResourcesManager.Instance.GetResource <Sprite>(GameConstants.Paths.GetUnitIconResourcePath(_currentSoldierData.IconName));
        }
        else
        {
            _lblCurrentSoldierLeadershipCost.text = _lblCurrentSoldierLevel.text = _lblCurrentSoldierDescription.text = string.Empty;

            _imgCurrrentSoldier.enabled = false;
            _imgCurrrentSoldier.sprite  = null;
        }
        UpdateLeadership();
    }
    void ShowPageUnits(int pageIndex)
    {
        _pageIndex = pageIndex;
        int startSoldierIndex = _pageIndex * AvailableUnitsRO.Length;

        if (startSoldierIndex > _soldiersData.Length - 1)
        {
            startSoldierIndex = (int)((_soldiersData.Length - 1) / AvailableUnitsRO.Length) * AvailableUnitsRO.Length;
        }
        int soldierCount = _soldiersData.Length > startSoldierIndex + AvailableUnitsRO.Length
            ? AvailableUnitsRO.Length : _soldiersData.Length - startSoldierIndex;

        for (int i = 0; i < AvailableUnitsRO.Length; i++)
        {
            AvailableUnitsRO[i].ClearData();
            if (i < soldierCount)
            {
                BaseSoldierData soldierData = _soldiersData[i + startSoldierIndex];
                AvailableUnitsRO[i].LoadSoldierData(soldierData, soldierData.Equals(_slotData));
            }
            else
            {
                AvailableUnitsRO[i].LoadSoldierData(null, false);
            }
        }
        ShowNavigationButtonEnabled(_btnLeft, _pageIndex > 0);
        ShowNavigationButtonEnabled(_btnRight, _soldiersData.Length > startSoldierIndex + AvailableUnitsRO.Length);
    }
Beispiel #5
0
    void SetUnit(BaseSoldierData unitData)
    {
        _unitData = unitData;
        if (_unitData == null)
        {
            return;
        }

        GameObject cardResource = UIResourcesManager.Instance.GetResource <GameObject>(
            string.Format("{0}/{1}", GameConstants.Paths.UI_WINDOWS_PREFAB_RESOURCES, "Unit_card"));

        if (cardResource == null)
        {
            return;
        }

        GameObject cardUnitData = GameObject.Instantiate(cardResource) as GameObject;
        UIUnitCard unitCard     = cardUnitData.GetComponent <UIUnitCard>();

        unitCard.UnitKey = _unitData.Key;
        cardUnitData.transform.SetParent(transform, false);

        RectTransform rectCard       = cardUnitData.GetComponent <RectTransform>();
        Rect          rectBackground = gameObject.GetComponent <RectTransform>().rect;

        rectCard.anchoredPosition = new Vector2(rectBackground.width / 2, rectBackground.height / 2);
        rectCard.localScale      *= _imgUnit.rectTransform.rect.width / rectCard.rect.width;

        _txtDamage.text = "Damage: " + _unitData.BaseDamage.ToString();
        _txtHP.text     = "Health Points: " + _unitData.BaseHealthPoints.ToString();
        _txtInfo.text   = "About Unit: " + _unitData.AboutInfo;
    }
    void SetFilterUnits(int filterIndex)
    {
        if (filterIndex > _btnLeadershipFilters.Length - 1)
        {
            return;
        }
        Button filterButton = _btnLeadershipFilters[filterIndex];
        string filterText   = filterButton.transform.childCount > 0 ? filterButton.transform.GetChild(0).GetComponent <Text>().text : string.Empty;

        EUnitKey[]             units       = Global.Instance.Player.City.AvailableUnits.ToArray();
        List <BaseSoldierData> filtersData = new List <BaseSoldierData>();

        for (int i = 0; i < units.Length; i++)
        {
            int             leadership;
            BaseSoldierData filterData = UnitsConfig.Instance.GetSoldierData(units[i]);
            if (filterIndex < _btnLeadershipFilters.Length - 1)
            {
                if (int.TryParse(filterText, out leadership) && filterData.LeadershipCost == leadership)
                {
                    filtersData.Add(filterData);
                }
            }
            else if (filterIndex > 0)
            {
                if (int.TryParse(filterText.Replace("+", string.Empty), out leadership) && filterData.LeadershipCost > leadership)
                {
                    filtersData.Add(filterData);
                }
            }
        }
        SetAvailableUnits(filtersData.ToArray());
    }
 public void Show(BaseSoldierData slotData)
 {
     _slotData = slotData;
     SetCurrentHero();
     SetAllAvailableUnits();
     Show();
 }
Beispiel #8
0
    public void SaveHiredSoldiers()
    {
        List <BaseSoldier> soldiers = new List <BaseSoldier>();

        for (int i = 0; i < UnitSlotsRO.Length; i++)
        {
            if (UnitSlotsRO[i] != null)
            {
                BaseSoldierData soldierData = UnitSlotsRO[i].UnitData;
                if (soldierData != null)
                {
                    BaseSoldier soldier = new BaseSoldier(soldierData,
                                                          Global.Instance.Player.City.GetSoldierUpgradesInfo(soldierData.Key).Level);
                    soldier.TemplatePlace = UnitSlotsRO[i].Place;
                    soldiers.Add(soldier);
                }
            }
        }
        Global.Instance.CurrentMission.SelectedSoldiers = new ArrayRO <BaseSoldier>(soldiers.ToArray());

        UnitSlot[] slotTemplate = new UnitSlot[soldiers.Count];
        for (int i = 0; i < slotTemplate.Count(); i++)
        {
            slotTemplate[i] = new UnitSlot(soldiers[i].TemplatePlace, soldiers[i].Data.Key);
        }
        Global.Instance.Player.Heroes.Current.Data.SlotTemplate = new ArrayRO <UnitSlot>(slotTemplate);
    }
Beispiel #9
0
 private void OnWindowHide(UIWindow window)
 {
     _unitData = null;
     if (ConfirmIsHided != null)
     {
         ConfirmIsHided(this, new EventArgs());
     }
 }
	private void SelectUnit() {
		_currentSoldierData = UnitsConfig.Instance.GetSoldierData(_availableUnits[_currentUnitIndex]);

		_txtUnitName.text = _availableUnits[_currentUnitIndex].ToString();
		_txtUnitHealth.text = _currentSoldierData.BaseHealthPoints.ToString();
		_txtUnitDamage.text = _currentSoldierData.BaseDamage.ToString();
		_txtUnitLeadershipCost.text = _currentSoldierData.LeadershipCost.ToString();
	}
    private void SelectUnit()
    {
        _currentSoldierData = UnitsConfig.Instance.GetSoldierData(_availableUnits[_currentUnitIndex]);

        _txtUnitName.text           = _availableUnits[_currentUnitIndex].ToString();
        _txtUnitHealth.text         = _currentSoldierData.BaseHealthPoints.ToString();
        _txtUnitDamage.text         = _currentSoldierData.BaseDamage.ToString();
        _txtUnitLeadershipCost.text = _currentSoldierData.LeadershipCost.ToString();
    }
    public void ClearData()
    {
        Button button = Button;
        for (int i = button.transform.childCount; i > 0; i--)
            GameObject.Destroy(button.transform.GetChild(i - 1).gameObject);

        _unitData = null;
        _isLoad = false;
    }
 void SetAllAvailableUnits()
 {
     EUnitKey[]        units        = Global.Instance.Player.City.AvailableUnits.ToArray();
     BaseSoldierData[] soldiersData = new BaseSoldierData[units.Length];
     for (int i = 0; i < units.Length; i++)
     {
         soldiersData[i] = UnitsConfig.Instance.GetSoldierData(units[i]);
     }
     SetAvailableUnits(soldiersData);
 }
    public void OnDestroy()
    {
        if (_soldierData != null)
        {
            UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(_soldierData.IconName));
        }
        _soldierData = null;

        UIResourcesManager.Instance.FreeResource(string.Format("{0}/{1}", GameConstants.Paths.UI_WINDOWS_PREFAB_RESOURCES, "rank_mini"));
    }
	public void Clear() {
		_lblLeadershipCost.text = "0";
		_lblLevel.text = "1";

		if (_imgUnitIcon.sprite != null) {
			_imgUnitIcon.sprite = null;
			UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(_unitData.IconName));
		}

		_unitData = null;
	}
	public void Setup(EUnitKey unitKey) {
		_unitData = UnitsConfig.Instance.GetSoldierData(unitKey);

		_lblLeadershipCost.text = _unitData.LeadershipCost.ToString();
		//TODO: set leved

		Sprite enemyIconResource = UIResourcesManager.Instance.GetResource<Sprite>(GameConstants.Paths.GetUnitIconResourcePath(_unitData.IconName));
		if (enemyIconResource != null) {
			_imgUnitIcon.sprite = enemyIconResource;
		}
	}
Beispiel #17
0
    public void ClearData()
    {
        Button button = Button;

        for (int i = button.transform.childCount; i > 0; i--)
        {
            GameObject.Destroy(button.transform.GetChild(i - 1).gameObject);
        }

        _unitData = null;
        _isLoad   = false;
    }
Beispiel #18
0
    public void Clear()
    {
        _lblLeadershipCost.text = "0";
        _lblLevel.text          = "1";

        if (_imgUnitIcon.sprite != null)
        {
            _imgUnitIcon.sprite = null;
            UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(_unitData.IconName));
        }

        _unitData = null;
    }
Beispiel #19
0
    public void Setup(EUnitKey unitKey)
    {
        _unitData = UnitsConfig.Instance.GetSoldierData(unitKey);

        _lblLeadershipCost.text = _unitData.LeadershipCost.ToString();
        //TODO: set leved

        Sprite enemyIconResource = UIResourcesManager.Instance.GetResource <Sprite>(GameConstants.Paths.GetUnitIconResourcePath(_unitData.IconName));

        if (enemyIconResource != null)
        {
            _imgUnitIcon.sprite = enemyIconResource;
        }
    }
    void OnBtnHeroClick()
    {
        EUnitKey[]             units       = Global.Instance.Player.City.AvailableUnits.ToArray();
        List <BaseSoldierData> filtersData = new List <BaseSoldierData>();

        for (int i = 0; i < units.Length; i++)
        {
            BaseSoldierData filterData = UnitsConfig.Instance.GetSoldierData(units[i]);
            Debug.Log("Type " + filterData.Type + ", " + Global.Instance.Player.Heroes.Current.Data.Key);
            if (filterData.Type == Global.Instance.Player.Heroes.Current.Data.Key)
            {
                filtersData.Add(filterData);
            }
        }
        SetAvailableUnits(filtersData.ToArray());
    }
Beispiel #21
0
    public void Update()
    {
        if (_unitData == null)
        {
            _slotPosition = transform.position;
            return;
        }
        if (Input.touchCount > 0)
        {
            Touch touch = Input.GetTouch(0);
            if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary)
            {
                Vector2 position = touch.position;
                if (_touchSlot == null)
                {
                    List <UIUnitSlot> slots = GetSlots(position);
                    if (slots.Contains(this))
                    {
                        _touchSlot = this;
                    }
                }
                if (_touchSlot == this)
                {
                    _targetSlot = GetTargetSlot(position);
                    Vector3 targetPosition = new Vector3(position.x, position.y, transform.position.z);
                    transform.position = targetPosition;
                }
            }
        }
        else
        {
            if (_targetSlot != null)
            {
                BaseSoldierData targetData = _targetSlot.UnitData;
                _targetSlot.SetUnitData(_unitData);
                _targetSlot.SelectSlot(true);

                SetUnitData(targetData);
                _targetSlot = null;
            }
            transform.position = _slotPosition;
            _touchSlot         = null;
        }
    }
    void SetSelectedUnit(BaseSoldierData currentSoldierData)
    {
        if (_currentSoldierData != null)
        {
            UIResourcesManager.Instance.FreeResource(
                string.Format("{0}/{1}", GameConstants.Paths.UI_WINDOWS_PREFAB_RESOURCES, "Unit_card"));
        }
        Rect rectImage = _mbtnCurrrentSoldier.GetComponent <RectTransform>().rect;

        if (rectImage.width == 0 || rectImage.height == 0)
        {
            return;
        }

        _currentSoldierData = currentSoldierData;
        if (_currentSoldierData != null)
        {
            GameObject cardResource = UIResourcesManager.Instance.GetResource <GameObject>(
                string.Format("{0}/{1}", GameConstants.Paths.UI_WINDOWS_PREFAB_RESOURCES, "Unit_card"));
            if (cardResource == null)
            {
                return;
            }

            GameObject cardUnitData = GameObject.Instantiate(cardResource) as GameObject;
            UIUnitCard unitCard     = cardUnitData.GetComponent <UIUnitCard>();
            unitCard.UnitKey = _currentSoldierData.Key;
            cardUnitData.transform.SetParent(_mbtnCurrrentSoldier.transform, false);

            RectTransform rectCard = cardUnitData.GetComponent <RectTransform>();
            rectCard.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, rectImage.width);
            rectCard.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, rectImage.height);
            rectCard.anchoredPosition = new Vector2(rectImage.width / 2, rectImage.height / 2);
            _mbtnCurrrentSoldier.AddChildImages(cardUnitData);
        }
        else
        {
            for (int i = _mbtnCurrrentSoldier.transform.childCount; i > 0; i--)
            {
                GameObject.Destroy(_mbtnCurrrentSoldier.transform.GetChild(i - 1).gameObject);
            }
        }
        UpdateLeadership();
    }
Beispiel #23
0
    public void SetUnitData(BaseSoldierData unitData)
    {
        if (_unitData != null)
            UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(_unitData.IconName));

        _unitData = unitData;
        if (_unitData != null)
        {
            _button.image.enabled = true;
            _button.image.sprite = UIResourcesManager.Instance.GetResource<Sprite>(GameConstants.Paths.GetUnitIconResourcePath(_unitData.IconName));

        }
        else
        {
            _button.image.enabled = false;
            _button.image.sprite = null;
            _isSelected = false;
        }
    }
Beispiel #24
0
    public void SetUnitData(BaseSoldierData unitData)
    {
        if (_unitData != null)
        {
            UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(_unitData.IconName));
        }

        _unitData = unitData;
        if (_unitData != null)
        {
            _button.image.enabled = true;
            _button.image.sprite  = UIResourcesManager.Instance.GetResource <Sprite>(GameConstants.Paths.GetUnitIconResourcePath(_unitData.IconName));
        }
        else
        {
            _button.image.enabled = false;
            _button.image.sprite  = null;
            _isSelected           = false;
        }
    }
Beispiel #25
0
    public void SetUnitData(BaseSoldierData unitData)
    {
        if (_unitData != null)
        {
            UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(_unitData.IconName));
        }

        _unitData            = unitData;
        _imgSlot.enabled     = _unitData == null;
        _imgMaskUnit.enabled = _imgUnit.enabled = !_imgSlot.enabled;
        if (_unitData != null)
        {
            _imgUnit.sprite = UIResourcesManager.Instance.GetResource <Sprite>(GameConstants.Paths.GetUnitIconResourcePath(_unitData.IconName));
        }
        else
        {
            _isSelected = false;
        }
        SelectImage();
    }
Beispiel #26
0
    public void SetHeroTemplate()
    {
        UIUnitSlot   firstUISlot = null;
        BaseHeroData heroData    = Global.Instance.Player.Heroes.Current.Data;

        for (int i = 0; i < heroData.SlotTemplate.Length; i++)
        {
            UnitSlot slot = heroData.SlotTemplate[i];
            if (slot != null)
            {
                UIUnitSlot uiSlot = GetUIUnitSlot(slot.Place);
                if (uiSlot != null)
                {
                    BaseSoldierData soldierData = UnitsConfig.Instance.GetSoldierData(slot.Unit);
                    uiSlot.SetUnitData(soldierData);
                    if (firstUISlot == null)
                    {
                        uiSlot.SelectSlot(true);
                        firstUISlot = uiSlot;
                    }
                }
            }
        }
    }
    public void Update()
    {
        if (_unitKey == EUnitKey.Idle || _soldierData != null)
        {
            return;
        }

        _soldierData = UnitsConfig.Instance.GetSoldierData(_unitKey);
        if (_soldierData == null)
        {
            return;
        }

        _imgUnit.sprite = UIResourcesManager.Instance.GetResource <Sprite>(GameConstants.Paths.GetUnitIconResourcePath(_soldierData.IconName));
        if (_imgUnit.sprite == null)
        {
            return;
        }

        _txtLeadership.text = _soldierData.LeadershipCost.ToString();
        // _txtLevel.text = "lvl " + Global.Instance.Player.City.GetSoldierUpgradesInfo(_soldierData.Key).Level.ToString();
        _txtDescription.text = _soldierData.AboutInfo;

        Sprite starImage = UIResourcesManager.Instance.GetResource <Sprite>(
            string.Format("{0}/{1}", GameConstants.Paths.UI_WINDOWS_PREFAB_RESOURCES, "rank_mini"));

        if (starImage != null)
        {
            for (int i = 0; i < _rank && i <= 5; i++)
            {
                GameObject star = new GameObject("Star_" + (i + 1).ToString());
                star.AddComponent <Image>().sprite = GameObject.Instantiate(starImage) as Sprite;
                star.transform.SetParent(_panRank.transform, false);
            }
        }
    }
    private void OnWindowHide(UIWindow window)
    {
        if (_btnHeroFilter.transform.childCount != 0)
        {
            Image heroImage = _btnHeroFilter.transform.GetChild(0).GetComponent <Image>();
            if (heroImage.sprite != null)
            {
                heroImage.sprite = null;
                UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(Global.Instance.Player.Heroes.Current.Data.IconName));
            }
        }
        for (int i = 0; i < AvailableUnitsRO.Length; i++)
        {
            AvailableUnitsRO[i].ClearData();
        }

        _slotData     = null;
        _soldiersData = null;
        _pageIndex    = 0;
        if (UnitSelectIsHided != null)
        {
            UnitSelectIsHided(this, new EventArgs());
        }
    }
    void SetSelectedUnit(BaseSoldierData currentSoldierData)
    {
        if (_currentSoldierData != null)
            UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(_currentSoldierData.IconName));

        _currentSoldierData = currentSoldierData;
        if (_currentSoldierData != null)
        {
            _lblCurrentSoldierLeadershipCost.text = _currentSoldierData.LeadershipCost.ToString();
            _lblCurrentSoldierLevel.text = Global.Instance.Player.City.GetSoldierUpgradesInfo(_currentSoldierData.Key).Level.ToString();
            _lblCurrentSoldierDescription.text = _currentSoldierData.PrefabName;

            _imgCurrrentSoldier.enabled = true;
            _imgCurrrentSoldier.sprite = UIResourcesManager.Instance.GetResource<Sprite>(GameConstants.Paths.GetUnitIconResourcePath(_currentSoldierData.IconName));
        }
        else
        {
            _lblCurrentSoldierLeadershipCost.text = _lblCurrentSoldierLevel.text = _lblCurrentSoldierDescription.text = string.Empty;

            _imgCurrrentSoldier.enabled = false;
            _imgCurrrentSoldier.sprite = null;
        }
        UpdateLeadership();
    }
    void SetSelectedUnit(BaseSoldierData currentSoldierData)
    {
        if (_currentSoldierData != null)
        {
            UIResourcesManager.Instance.FreeResource(
                string.Format("{0}/{1}", GameConstants.Paths.UI_WINDOWS_PREFAB_RESOURCES, "Unit_card"));
        }
        Rect rectImage = _mbtnCurrrentSoldier.GetComponent<RectTransform>().rect;
        if (rectImage.width == 0 || rectImage.height == 0)
            return;

        _currentSoldierData = currentSoldierData;
        if (_currentSoldierData != null)
        {
            GameObject cardResource = UIResourcesManager.Instance.GetResource<GameObject>(
                string.Format("{0}/{1}", GameConstants.Paths.UI_WINDOWS_PREFAB_RESOURCES, "Unit_card"));
            if (cardResource == null)
                return;

            GameObject cardUnitData = GameObject.Instantiate(cardResource) as GameObject;
            UIUnitCard unitCard = cardUnitData.GetComponent<UIUnitCard>();
            unitCard.UnitKey = _currentSoldierData.Key;
            cardUnitData.transform.SetParent(_mbtnCurrrentSoldier.transform, false);

            RectTransform rectCard = cardUnitData.GetComponent<RectTransform>();
            rectCard.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, rectImage.width);
            rectCard.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, rectImage.height);
            rectCard.anchoredPosition = new Vector2(rectImage.width / 2, rectImage.height / 2);
            _mbtnCurrrentSoldier.AddChildImages(cardUnitData);
        }
        else
        {
            for (int i = _mbtnCurrrentSoldier.transform.childCount; i > 0; i--)
                GameObject.Destroy(_mbtnCurrrentSoldier.transform.GetChild(i - 1).gameObject);
        }
        UpdateLeadership();
    }
	public BaseSoldier(BaseSoldierData data, int level) : base(data) {
		_data = data;
		Level = level;
	}
    public void SetUnitData(BaseSoldierData unitData)
    {
        if (_unitData != null)
            UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(_unitData.IconName));

        _unitData = unitData;
        _imgSlot.enabled = _unitData == null;
        _imgMaskUnit.enabled = _imgUnit.enabled = !_imgSlot.enabled;
        if (_unitData != null)
        {
            _imgUnit.sprite = UIResourcesManager.Instance.GetResource<Sprite>(GameConstants.Paths.GetUnitIconResourcePath(_unitData.IconName));
        }
        else
            _isSelected = false;
        SelectImage();
    }
Beispiel #33
0
 public BaseSoldier(BaseSoldierData data, int level) : base(data)
 {
     _data = data;
     Level = level;
 }
Beispiel #34
0
 public void Show(BaseSoldierData unitData)
 {
     SetUnit(unitData);
     Show();
 }
    private void OnWindowHide(UIWindow window)
    {
        if (_btnHeroFilter.transform.childCount != 0)
        {
            Image heroImage = _btnHeroFilter.transform.GetChild(0).GetComponent<Image>();
            if (heroImage.sprite != null)
            {
                heroImage.sprite = null;
                UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(Global.Instance.Player.Heroes.Current.Data.IconName));
            }
        }
        for (int i = 0; i < AvailableUnitsRO.Length; i++)
            AvailableUnitsRO[i].ClearData();

        _slotData = null;
        _soldiersData = null;
        _pageIndex = 0;
        if (UnitSelectIsHided != null)
            UnitSelectIsHided(this, new EventArgs());
    }
Beispiel #36
0
 public void LoadSoldierData(BaseSoldierData unitData, bool isSelected)
 {
     _unitData = unitData;
 }
 public void Show(BaseSoldierData unitData)
 {
     SetUnit(unitData);
     Show();
 }
 void SetAllAvailableUnits()
 {
     EUnitKey[] units = Global.Instance.Player.City.AvailableUnits.ToArray();
     BaseSoldierData[] soldiersData = new BaseSoldierData[units.Length];
     for (int i = 0; i < units.Length; i++)
         soldiersData[i] = UnitsConfig.Instance.GetSoldierData(units[i]);
     SetAvailableUnits(soldiersData);
 }
	private void OnWindowHide(UIWindow window)
    {
        _unitData = null;
        if (ConfirmIsHided != null)
            ConfirmIsHided(this, new EventArgs());
    }
 public void LoadSoldierData(BaseSoldierData unitData, bool isSelected)
 {
     _unitData = unitData;
 }
 void SetAvailableUnits(BaseSoldierData[] soldiersData)
 {
     _soldiersData = soldiersData;
     int pageIndex = 0;
     if (_slotData != null)
     {
         for (int i = 0; i < soldiersData.Length; i++)
         {
             if (soldiersData[i].Equals(_slotData))
             {
                 pageIndex = AvailableUnitsRO.Length > 0 ? (int)(i / AvailableUnitsRO.Length) : 0;
                 break;
             }
         }
     }
     ShowPageUnits(pageIndex);
 }