Ejemplo n.º 1
0
	// 顯示資訊
	public void ShowInfo(ISoldier Soldier)
	{
		//Debug.Log("顯示Soldier資訊");
		m_Soldier = Soldier;
		if( m_Soldier == null || m_Soldier.IsKilled())
		{
			Hide ();
			return ;
		}
		Show ();

		// 顯示Soldier資訊
		// Icon
		IAssetFactory Factory = PBDFactory.GetAssetFactory();
		m_Icon.sprite = Factory.LoadSprite( m_Soldier.GetIconSpriteName());
		// 名稱
		m_NameTxt.text =  m_Soldier.GetName();
		// 等級 
		m_LvTxt.text =string.Format("等級:{0}", m_Soldier.GetSoldierValue().GetSoldierLv());
		// Atk
		m_AtkTxt.text = string.Format( "攻擊力:{0}",m_Soldier.GetWeapon().GetAtkValue());
		// Atk距離
		m_AtkRangeTxt.text = string.Format( "攻擊距離:{0}",m_Soldier.GetWeapon().GetAtkRange());
		// Speed
		m_SpeedTxt.text = string.Format("移動速度:{0}", m_Soldier.GetSoldierValue().GetMoveSpeed());;

		// 更新HP資訊
		RefreshHPInfo();
	}
    // 显示信息
    public void ShowInfo(ISoldier Soldier)
    {
        //Debug.Log("显示Soldier信息");
        m_Soldier = Soldier;
        if (m_Soldier == null || m_Soldier.IsKilled())
        {
            Hide();
            return;
        }
        Show();

        // 显示Soldier信息
        // Icon
        IAssetFactory Factory = PBDFactory.GetAssetFactory();

        m_Icon.sprite = Factory.LoadSprite(m_Soldier.GetIconSpriteName());
        // 名称
        m_NameTxt.text = m_Soldier.GetName();
        // 等级
        m_LvTxt.text = string.Format("等级:{0}", m_Soldier.GetSoldierValue().GetSoldierLv());
        // Atk
        m_AtkTxt.text = string.Format("攻击力:{0}", m_Soldier.GetWeapon().GetAtkValue());
        // Atk距离
        m_AtkRangeTxt.text = string.Format("攻击距离:{0}", m_Soldier.GetWeapon().GetAtkRange());
        // Speed
        m_SpeedTxt.text = string.Format("移动速度:{0}", m_Soldier.GetSoldierValue().GetMoveSpeed());;

        // 更新HP信息
        RefreshHPInfo();
    }
    // 顯示資訊
    public void ShowInfo(ISoldier Soldier)
    {
        //Debug.Log("顯示Soldier資訊");
        m_Soldier = Soldier;
        if (m_Soldier == null || m_Soldier.IsKilled())
        {
            Hide();
            return;
        }
        Show();

        // 顯示Soldier資訊
        // Icon
        IAssetFactory Factory = PBDFactory.GetAssetFactory();

        m_Icon.sprite = Factory.LoadSprite(m_Soldier.GetIconSpriteName());
        // 名稱
        m_NameTxt.text = m_Soldier.GetName();
        // 等級
        m_LvTxt.text = string.Format("等級:{0}", m_Soldier.GetSoldierValue().GetSoldierLv());
        // Atk
        m_AtkTxt.text = string.Format("攻擊力:{0}", m_Soldier.GetWeapon().GetAtkValue());
        // Atk距離
        m_AtkRangeTxt.text = string.Format("攻擊距離:{0}", m_Soldier.GetWeapon().GetAtkRange());
        // Speed
        m_SpeedTxt.text = string.Format("移動速度:{0}", m_Soldier.GetSoldierValue().GetMoveSpeed());;

        // 更新HP資訊
        RefreshHPInfo();
    }
    // 更新HP信息
    private void RefreshHPInfo()
    {
        int NowHP = m_Soldier.GetSoldierValue().GetNowHP();
        int MaxHP = m_Soldier.GetSoldierValue().GetMaxHP();

        m_HPTxt.text = string.Format("HP({0}/{1})", NowHP, MaxHP);
        // HP圆示
        m_HPSlider.maxValue = MaxHP;
        m_HPSlider.minValue = 0;
        m_HPSlider.value    = NowHP;
    }
Ejemplo n.º 5
0
    //  執行
    public override void Execute()
    {
        // 建立Soldier
        ICharacterFactory Factory = PBDFactory.GetCharacterFactory();
        ISoldier          Soldier = Factory.CreateSoldier(m_emSoldier, m_emWeapon, m_Lv, m_Position);

        // 依機率產生前輟能力
        int Rate   = UnityEngine.Random.Range(0, 100);
        int AttrID = 0;

        if (Rate > 90)
        {
            AttrID = 13;
        }
        else if (Rate > 80)
        {
            AttrID = 12;
        }
        else if (Rate > 60)
        {
            AttrID = 11;
        }
        else
        {
            return;
        }

        // 加上字首能力
        //Debug.Log("加上前輟能力:"+AttrID);
        IAttrFactory AttrFactory = PBDFactory.GetAttrFactory();
        SoldierAttr  PreAttr     = AttrFactory.GetEliteSoldierAttr(ENUM_AttrDecorator.Prefix, AttrID, Soldier.GetSoldierValue());

        Soldier.SetCharacterAttr(PreAttr);
    }
    // Soldier能力
    void UnitTest_SoldierValue()
    {
        ICharacterFactory Factory = PBDFactory.GetCharacterFactory();

        // 建立Soldier
        ISoldier theSoldier = Factory.CreateSoldier(ENUM_Soldier.Rookie, ENUM_Weapon.Gun, 1, new Vector3(0, 0, 0));

        // 加上前輟能力
        IAttrFactory ValueFactory = PBDFactory.GetAttrFactory();
        SoldierAttr  PreAttr      = ValueFactory.GetEliteSoldierAttr(ENUM_AttrDecorator.Prefix, 11, theSoldier.GetSoldierValue());

        theSoldier.SetCharacterAttr(PreAttr);

        // 加上後輟能力
        SoldierAttr SufValue = ValueFactory.GetEliteSoldierAttr(ENUM_AttrDecorator.Suffix, 21, theSoldier.GetSoldierValue());

        theSoldier.SetCharacterAttr(SufValue);

        // 建立Enemy
        IEnemy theEnemy = Factory.CreateEnemy(ENUM_Enemy.Elf, ENUM_Weapon.Rocket, new Vector3(0, 0, 0), new Vector3(100, 0, 0));

        // 建立俘兵
        ISoldier theCaptive = new SoldierCaptive(theEnemy);

        // 加上前輟能力
        PreAttr = ValueFactory.GetEliteSoldierAttr(ENUM_AttrDecorator.Prefix, 11, theCaptive.GetSoldierValue());
        theCaptive.SetCharacterAttr(PreAttr);

        // 加上後輟能力
        SufValue = ValueFactory.GetEliteSoldierAttr(ENUM_AttrDecorator.Suffix, 21, theCaptive.GetSoldierValue());
        theCaptive.SetCharacterAttr(SufValue);

        // Soldier打Enemy
        //theSoldier.Attack( theEnemy );

        // Enemy打Soldier
        //theEnemy.Attack( theSoldier );
    }