//  執行
    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);
    }
    // 更新
    public override void Update()
    {
        if (m_StageData.Count == 0)
        {
            return;
        }

        // 是否可以产生
        m_CoolDown -= Time.deltaTime;
        if (m_CoolDown > 0)
        {
            return;
        }
        m_CoolDown = m_MaxCoolDown;

        // 取得上场的角色
        StageData theNewEnemy = GetEnemy();

        if (theNewEnemy == null)
        {
            return;
        }

        // 一次产生一个单位
        ICharacterFactory Factory = PBDFactory.GetCharacterFactory();

        Factory.CreateEnemy(theNewEnemy.emEnemy, theNewEnemy.emWeapon, m_SpawnPosition, m_AttackPosition);
    }
예제 #3
0
    public override void Execute()
    {
        // 先产生Enemy
        ICharacterFactory Factory  = PBDFactory.GetCharacterFactory();
        IEnemy            theEnemy = Factory.CreateEnemy(m_emEnemy, ENUM_Weapon.Gun, m_Position, Vector3.zero);

        // 再建立俘兵(轉接器)
        SoldierCaptive NewSoldier = new SoldierCaptive(theEnemy);

        // 移除Enemy
        m_PBDGame.RemoveEnemy(theEnemy);

        // 加入Soldier
        m_PBDGame.AddSoldier(NewSoldier);
    }
    // Update is called once per frame
    void UnitTest_CharacterCreate()
    {
        ICharacterFactory Factory = PBDFactory.GetCharacterFactory();

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

        // 建立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);

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

        // Enemy打Soldier
        //theEnemy.Attack( theSoldier );
    }
    // 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 );
    }