コード例 #1
0
    public void SetUnit(Province province, Unit unit)
    {
        _unit        = unit;
        _maxQuantity = unit.GetQuantity();

        UnitType unitType = _unit.GetUnitType();

        if (unitType != null)
        {
            _unitImage.sprite = SpriteCollectionManager.GetSpriteByName(unitType.GetName());
            List <Unit> garrison = province.GetUnits();
            for (int i = 0; i < garrison.Count; i++)
            {
                if (garrison[i].GetUnitType() == unitType)
                {
                    _maxQuantity += garrison[i].GetQuantity();
                    break;
                }
            }
        }
        else
        {
            _unitImage.sprite = SpriteCollectionManager.GetSpriteByName("empty");
        }
        UpdateView();
    }
コード例 #2
0
    /// <summary>
    /// Updates the image of the army and the number of units in it
    /// Usually called after the underlying model is updated
    /// </summary>
    private void Update()
    {
        UnitType armyRepresentative = GameUtils.GetRepresentative(_model.GetUnits());

        _armyImage.material.mainTexture = SpriteCollectionManager.GetTextureByName(armyRepresentative.GetName());
        _quantityField.text             = _model.GetUnitsCount().ToString();
    }
コード例 #3
0
ファイル: ArmyView.cs プロジェクト: valambrian/holy_wars
    public void UpdateView()
    {
        if (_armyImage == null)
        {
            Debug.Log("Army view image renderer destroyed in " + _province.GetName());
            return;
        }

        UnitType representative = GameUtils.GetRepresentative(_province.GetUnits());

        if (representative != null)
        {
            _armyImage.material.mainTexture = SpriteCollectionManager.GetTextureByName(representative.GetName());
        }
        else
        {
            _armyImage.material.mainTexture = SpriteCollectionManager.GetTextureByName("empty");
        }
        _quantity = CountUnits();
        if (_quantity > 0)
        {
            _quantityField.text = _quantity.ToString();
        }
        else
        {
            _quantityField.text = "";
        }
    }
コード例 #4
0
 public void SetModel(UnitType unitType, int quantity, bool isOrderStanding)
 {
     _unitType             = unitType;
     _quantity             = quantity;
     _remainingManpower    = 0;
     _isOrderStanding      = isOrderStanding;
     _unitTypeImage.sprite = SpriteCollectionManager.GetSpriteByName(_unitType.GetName());
     _checkMark.gameObject.SetActive(isOrderStanding);
     UpdateView();
 }
コード例 #5
0
 public void SetModel(WoundCheckEvent eventData, UnitType unitType)
 {
     _model                  = eventData;
     _unitImage.sprite       = SpriteCollectionManager.GetSpriteByName(unitType.GetName());
     _target.text            = "Need to Roll:";
     _roll.text              = "Rolling 1d" + unitType.GetHitPoints() + ":";
     _result.text            = "";
     _unitQuantityField.text = "";
     _unitHealthField.text   = "";
 }
コード例 #6
0
ファイル: UnitStackView.cs プロジェクト: valambrian/holy_wars
 public void SetModel(UnitStack unitStack)
 {
     _model = unitStack;
     _model.WoundCheckMade                += OnWoundCheckMade;
     _unitImage.material.mainTexture       = SpriteCollectionManager.GetTextureByName(_model.GetUnitType().GetName());
     _mouseListener.MouseClickDetected    += OnStackSelected;
     _mouseOverListener.MouseOverDetected += OnStackInspected;
     _mouseOverListener.MouseExitDetected += OnStackInspectionEnd;
     _explosion.gameObject.SetActive(false);
     _healing.gameObject.SetActive(false);
     UpdateView();
 }
コード例 #7
0
 public void SetModel(AttackResolutionEvent eventData)
 {
     _model = eventData;
     _defenderImage.material.mainTexture = SpriteCollectionManager.GetTextureByName(_model.GetTarget().GetUnitType().GetName());
     _attackerImage.material.mainTexture = SpriteCollectionManager.GetTextureByName(_model.GetAttack().GetUnitType().GetName());
     _attackerRoll.text          = "";
     _defenderRoll.text          = "";
     _hitOrMissMessage.text      = "";
     _damageRoll.text            = "";
     _defenderArmor.text         = "";
     _finalDamage.text           = "";
     _defenderQuantityField.text = "";
     _defenderHealthField.text   = "";
     StartCoroutine("UpdateView");
 }
コード例 #8
0
    // Use this for initialization
    void Start()
    {
        SpriteCollectionManager.CreateInstance();

        SpriteCollection spriteCollection = SpriteCollectionManager.Instance.GetCollection("Icons");

        Debug.Log(spriteCollection.GetSprite("Bracer"));
        Debug.Log(spriteCollection.GetSprite("Runestone_Blue"));
        Debug.Log(spriteCollection.GetSprite("Scroll"));
        Debug.Log(spriteCollection.GetSprite("Sword"));

        spriteCollection = SpriteCollectionManager.Instance.GetCollection("TransparentIcons");
        Debug.Log(spriteCollection.GetSprite("T_Bracer"));
        Debug.Log(spriteCollection.GetSprite("T_Runestone_Blue"));
        Debug.Log(spriteCollection.GetSprite("T_Scroll"));
        Debug.Log(spriteCollection.GetSprite("T_Sword"));
    }
コード例 #9
0
 public void SetModel(AttackResolutionEvent eventData)
 {
     _model = eventData;
     _attackerNameField.text     = _model.GetAttack().GetUnitType().GetName();
     _defenderNameField.text     = _model.GetTarget().GetUnitType().GetName();
     _defenderImage.sprite       = SpriteCollectionManager.GetSpriteByName(_defenderNameField.text);
     _attackerImage.sprite       = SpriteCollectionManager.GetSpriteByName(_attackerNameField.text);
     _attack.text                = "";
     _attackerRoll.text          = "";
     _totalAttack.text           = "";
     _defense.text               = "";
     _defenderRoll.text          = "";
     _totalDefense.text          = "";
     _hitOrMissMessage.text      = "VS";
     _hitOrMissMessage.color     = Color.black;
     _damageRoll.text            = "";
     _defenderArmor.text         = "";
     _finalDamage.text           = "";
     _defenderQuantityField.text = "";
     _defenderHealthField.text   = "";
     StartCoroutine("UpdateView");
 }