Ejemplo n.º 1
0
    // 建立武器
    public override IWeapon CreateWeapon(ENUM_Weapon emWeapon)
    {
        IWeapon pWeapon   = null;
        string  AssetName = "";
        int     AttrID    = 0;

        //根据武器类型建立
        switch (emWeapon)
        {
        case ENUM_Weapon.Knife:
            pWeapon   = new WeaponKnife();
            AssetName = "5";
            AttrID    = 1;
            break;

        default:
            Debug.LogWarning("创建[" + emWeapon + "]失败!!!");
            return(null);
        }

        // 加载武器资源
        IAssetFactory AssetFactory    = GameFactory.GetAssetFactory();
        Sprite        WeaponGameObjet = AssetFactory.LoadWeapon(AssetName);

        pWeapon.SetIWeapon(WeaponGameObjet);

        // 设置武器的威力
        IAttrFactory theAttrFactory = GameFactory.GetAttrFactory();
        WeaponAttr   theWeaponAttr  = theAttrFactory.GetWeaponAttr(AttrID);

        pWeapon.SetWeaponAttr(theWeaponAttr);

        return(pWeapon);
    }
Ejemplo n.º 2
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);
    }
Ejemplo n.º 3
0
 // 數值工廠
 public static IAttrFactory GetAttrFactory()
 {
     if (m_AttrFactory == null)
     {
         m_AttrFactory = new AttrFactory();
     }
     return(m_AttrFactory);
 }
Ejemplo n.º 4
0
 public static IAttrFactory GetAttrFactory()
 {
     if (AttrFactory == null)
     {
         return(AttrFactory = new AttrFactory());
     }
     return(AttrFactory);
 }
Ejemplo n.º 5
0
        public override void SetCharacterAttr()
        {
            IAttrFactory AttrFactory  = RTSFactory.GetAttrFactory();
            EnemyAttr    theEnemyAttr = AttrFactory.GetEnemyAttr(
                m_BuildParam.NewCharacter.GetAttrID());

            theEnemyAttr.SetAttrStrategy(new EnemyAttrStrategy());
            m_BuildParam.NewCharacter.SetCharacterAttr(theEnemyAttr);
        }
Ejemplo n.º 6
0
    public override void SetCharacterAttr()
    {
        IAttrFactory theAttrFactory = GameFactory.GetAttrFactory();
        int          AttrID         = m_BuildParam.NewCharacter.GetAttrID();
        EnemyAttr    theEnemyAttr   = theAttrFactory.GetEnemyAttr(AttrID);

        theEnemyAttr.SetAttStrategy(new EnemyAttrStrategy());



        m_BuildParam.NewCharacter.SetCharacterAttr(theEnemyAttr);
    }
Ejemplo n.º 7
0
    public override void SetBuildingAttr()
    {
        IAttrFactory Factroy = PBDGFactory.GetAttrFactory();
        int          attrID  = m_buildParam.AttrID;


        SoldierAttr soldierAttr = Factroy.GetSoldierAttr(attrID);



        m_buildParam.NewBuding.SetAttr(soldierAttr);
    }
    // 设定角色能力
    public override void SetCharacterAttr()
    {
        // 取得Enemy的数值
        IAttrFactory theAttrFactory = PBDFactory.GetAttrFactory();
        int          AttrID         = m_BuildParam.NewCharacter.GetAttrID();
        EnemyAttr    theEnemyAttr   = theAttrFactory.GetEnemyAttr(AttrID);

        // 设定数值的计算策略
        theEnemyAttr.SetAttStrategy(new EnemyAttrStrategy());

        // 设定给角色
        m_BuildParam.NewCharacter.SetCharacterAttr(theEnemyAttr);
    }
    public override void SetCharacterAttr()
    {
        // 取得Enemy的數值
        IAttrFactory theAttrFactory = PBDFactory.GetAttrFactory();
        int          AttrID         = m_BuildParam.NewCharacter.GetAttrID();
        SoldierAttr  theSoldierAttr = theAttrFactory.GetSoldierAttr(AttrID);

        // 設定數值的計算策略
        theSoldierAttr.SetAttStrategy(new SoldierAttrStrategy());

        // 設定給角色
        m_BuildParam.NewCharacter.SetCharacterAttr(theSoldierAttr);
    }
Ejemplo n.º 10
0
    // 设定角色能力
    public override void SetCharacterAttr()
    {
        // 取得Soldier的数值
        IAttrFactory theAttrFactory = PBDFactory.GetAttrFactory();
        int          AttrID         = m_BuildParam.NewCharacter.GetAttrID();
        SoldierAttr  theSoldierAttr = theAttrFactory.GetSoldierAttr(AttrID);

        // 设定
        theSoldierAttr.SetAttStrategy(new SoldierAttrStrategy());

        // 设定等级
        theSoldierAttr.SetSoldierLv(m_BuildParam.Lv);

        // 设定给角色
        m_BuildParam.NewCharacter.SetCharacterAttr(theSoldierAttr);
    }
Ejemplo n.º 11
0
        // 设置角色能力
        public override void SetCharacterAttr()
        {
            // 获取Soldier的属性
            IAttrFactory theAttrFactory = RTSFactory.GetAttrFactory();
            SoldierAttr  theSoldierAttr = theAttrFactory.GetSoldierAttr(
                m_BuildParam.NewCharacter.GetAttrID());

            // 设置
            theSoldierAttr.SetAttrStrategy(new SoldierAttrStrategy());

            // 设置等级
            theSoldierAttr.SetSoldierLv(m_BuildParam.Lv);

            // 设置给角色
            m_BuildParam.NewCharacter.SetCharacterAttr(theSoldierAttr);
        }
Ejemplo n.º 12
0
    // 建立武器
    public override IWeapon CreateWeapon(ENUM_Weapon emWeapon)
    {
        IWeapon pWeapon   = null;
        string  AssetName = "";         // Unity模型名称
        int     AttrID    = 0;          // 武器的能力值

        // 依武器
        switch (emWeapon)
        {
        case ENUM_Weapon.Gun:
            pWeapon   = new WeaponGun();
            AssetName = "WeaponGun";
            AttrID    = 1;
            break;

        case ENUM_Weapon.Rifle:
            pWeapon   = new WeaponRifle();
            AssetName = "WeaponRifle";
            AttrID    = 2;
            break;

        case ENUM_Weapon.Rocket:
            pWeapon   = new WeaponRocket();
            AssetName = "WeaponRocket";
            AttrID    = 3;
            break;

        default:
            Debug.LogWarning("CreateWeapon:无法建立[" + emWeapon + "]");
            return(null);
        }

        // 产生Asset
        IAssetFactory AssetFactory    = PBDFactory.GetAssetFactory();
        GameObject    WeaponGameObjet = AssetFactory.LoadWeapon(AssetName);

        pWeapon.SetGameObject(WeaponGameObjet);

        // 取得武器的威力
        IAttrFactory theAttrFactory = PBDFactory.GetAttrFactory();
        WeaponAttr   theWeaponAttr  = theAttrFactory.GetWeaponAttr(AttrID);

        // 设定武器的威力
        pWeapon.SetWeaponAttr(theWeaponAttr);

        return(pWeapon);
    }
Ejemplo n.º 13
0
    /// <summary>
    /// 设置角色属性
    /// </summary>
    public override void SetCharacterAttr()
    {
        IAttrFactory theAttrFactory = GameFactory.GetAttrFactory();
        int          AttrID         = m_BuildParam.NewCharacter.GetAttrID();
        SoldierAttr  theSoldierAttr = theAttrFactory.GetSoldierAttr(AttrID);



        //m_BuildParam.NewCharacter.SetCharacterAttr(theSoldierAttr);

        theSoldierAttr.SetAttStrategy(new SoldierAttrStrategy());


        theSoldierAttr.SetSoldierLv(m_BuildParam.Lv);

        m_BuildParam.NewCharacter.SetCharacterAttr(theSoldierAttr);
    }
Ejemplo n.º 14
0
    // 增加勋章
    public virtual void AddMedal()
    {
        if (m_MedalCount >= MAX_MEDAL)
        {
            return;
        }

        // 增加勋章
        m_MedalCount++;
        // 取得对应的勋章加乘值
        int AttrID = m_MedalCount + MEDAL_VALUE_ID;

        IAttrFactory theAttrFactory = PBDFactory.GetAttrFactory();

        // 加上字尾能力
        SoldierAttr SufAttr = theAttrFactory.GetEliteSoldierAttr(ENUM_AttrDecorator.Suffix, AttrID, m_Attribute as SoldierAttr);

        SetCharacterAttr(SufAttr);
    }
    // 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 );
    }
Ejemplo n.º 16
0
	// 數值工廠
	public static IAttrFactory GetAttrFactory()
	{
		if( m_AttrFactory == null)		
			m_AttrFactory = new AttrFactory();
		return m_AttrFactory;
	}