Exemplo n.º 1
0
    //初始化释放器
    private void initDeployer()
    {
        //存储选择方法和影响效果
        selector = DeployConfigFactory.CreateAttackSelector(skillData);

        impactArray = DeployConfigFactory.CreateImpactEffect(skillData);
    }
Exemplo n.º 2
0
 // 创建算法对象
 private void InitDeployer()
 {
     // 选区
     selector = DeployerConfigFactory.CreateAttackSelector(skillData);
     // 影响
     impactEffects = DeployerConfigFactory.CreateImpactEffects(skillData);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 工厂方法设计模式:创建目标选择对象的方法 符合 定义
        /// </summary>
        /// <param name="skill"></param>
        /// <returns></returns>
        public static IAttackSelector CreateAttackSelector(SkillData skill)
        {
            IAttackSelector attackSelector = null;

            #region switch
            //switch (skill.damageMode)
            //{
            //    case DamageMode.Circle:
            //        attackSelector = new CircleAttackSelector();
            //        break;
            //    case DamageMode.Sector:
            //        attackSelector = new SectorAttackSelector();
            //        break;
            //}
            #endregion

            #region 反射 创建实例 》》灵活性 复用性好
            //1得到Type类数据类型的对象!
            //string allName = "ARPGDemo.Skill.CircleAttackSelector";
            //string allName = "ARPGDemo.Skill."+"Circle"+"AttackSelector";
            string allName = "ARPGDemo.Skill." + skill.damageMode + "AttackSelector";
            Type   typeObj = Type.GetType(allName);
            //2	动态【使用反射技术】创建对象
            object obj = Activator.CreateInstance(typeObj);
            attackSelector = (IAttackSelector)obj;
            #endregion

            return(attackSelector);
        }
Exemplo n.º 4
0
        //创建目标选择对象
        public static IAttackSelector CreateAttackSelector(SkillData skill)
        {
            IAttackSelector attackSelector = null;

            #region  switch 实现方式:条件不同对象不同 修改量大
            //switch (skill.damageMode)
            //{
            //    case DamageMode.Circle:
            //        attackSelector = new CircleAttackSelector();
            //        break;
            //    case DamageMode.Sector:
            //        attackSelector = new SectorAttackSelector();
            //        break;
            //}
            #endregion
            #region  反射 实现方式:条件不同对象不同 不用修改
            //1
            //string path = "ARPGDemo.Skill.CircleAttackSelector";
            //string path = "ARPGDemo.Skill."+"Circle"+"AttackSelector";
            string path    = "ARPGDemo.Skill." + skill.damageMode + "AttackSelector";
            Type   typeObj = Type.GetType(path);
            //2
            object obj = Activator.CreateInstance(typeObj);
            attackSelector = (IAttackSelector)obj;
            #endregion
            return(attackSelector);
        }
Exemplo n.º 5
0
        //创建算法对象
        private void InitDeployer()
        {
            //反射创建对象
            attackSelector = SkillDeployerConfigFactory.CreateAttackSelector(currentSkillData);

            //影响对象
            impactArray = SkillDeployerConfigFactory.CreateImpactEffects(currentSkillData);
        }
Exemplo n.º 6
0
        //初始化释放器
        private void InitDeployer()
        {
            //创建算法对象 skillData.VectorType
            selector = DeployerConfigFactory.CreateAttackSelector(m_skillData);

            //创建影响效果
            impactEffects = DeployerConfigFactory.CreateImpactEffects(m_skillData);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 初始化释放器
        /// </summary>
        private void InitDeployer()
        {
            //创建算法对象
            //skillData.selectorType;

            //选取(单个)
            attackSelector = DeployerConfigFactory.CreateAttackSelector(skillData);
            //影响(数组类型)
            impactArray = DeployerConfigFactory.CreateImpactEffects(skillData);
        }
Exemplo n.º 8
0
 //初始化释放器:创建释放器依赖的算法对象
 private void InitDeployer()
 {
     //……
     //currentSkillData.selectorType.ToString()  -->  Sector
     //命名空间.类名
     //ARPGDemo.Skill. + 枚举 + AttackSelector
     selector = DeployerConfigFactory.CreateAttackSelector(currentSkillData);
     //currentSkillData.impactType
     //命名空间.类名
     //ARPGDemo.Skill. + 影响名称 + Impact
     impactList = DeployerConfigFactory.CreateAttackImpact(currentSkillData);
 }
Exemplo n.º 9
0
        //初始化释放器
        private void InitDeployer()
        {
            //创建算法对象
            //命名规则:SkillSystem.Common.+枚举名AttackSelector
            //skillData.selectorType 反射实现
            //1.选区
            selector = DeployerConfigFactory.CreatAttackSelector(skillData);

            //2.影响
            //命名规则:SkillSystem.Common.+skillData.impactType[i]+Impact
            impactArray = DeployerConfigFactory.CreatImpactEffects(skillData);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 工厂方法设计模式:创建目标选择对象的方法 符合 定义
        /// </summary>
        /// <param name="skill"></param>
        /// <returns></returns>
        public static IAttackSelector CreateAttackSelector(SkillData skill)
        {
            IAttackSelector attackSelector = null;

            switch (skill.damageMode)
            {
            case DamageMode.Circle:
                attackSelector = new CircleAttackSelector();
                break;

            case DamageMode.Sector:
                attackSelector = new SectorAttackSelector();
                break;
            }
            return(attackSelector);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 工厂方法设计模式:创建目标选择对象方法
        /// </summary>
        /// <param name="skillData"></param>
        /// <returns></returns>
        public static IAttackSelector CreateAttackSelector(SkillData skillData)
        {
            IAttackSelector attackSelector = null;

            //switch (skillData.damageMode)
            //{
            //    case DamageMode.Circle:
            //        attackSelector = new CircleAttackSelector();
            //        break;
            //    case DamageMode.Sector:
            //        attackSelector = new SectorAttackSelector();
            //        break;
            //}
            string allName = "ARPGDemo.Skill." + skillData.damageMode + "AttackSelector";
            Type   typeObj = Type.GetType(allName);
            object obj     = Activator.CreateInstance(typeObj);

            attackSelector = (IAttackSelector)obj;

            return(attackSelector);
        }
Exemplo n.º 12
0
    //初始化Deployer字段
    //方法的功能特点:根据条件的不同,返回不同的对象,
    //                对象有共同的父类>设计模式:工厂设计模式
    //简单工厂设计模式:饭馆 饭
    //一个
    static public IAttackSelector CreateAttackSelector(SkillData skill)
    {
        IAttackSelector attackSelector = null;
        //switch (skill.damageMode)
        //{
        //    case DamageMode.Circle:
        //        attackSelector = new CircleAttackSelector();
        //        break;
        //    case DamageMode.Sector:
        //        attackSelector = new SectorAttackSelector();
        //        break;
        //        //....
        //}
        //使用反射做 复用 维护性
        //string path = "ARPGDemo.Skill."+"Circle"+"AttackSelector";
        //string path = "ARPGDemo.Skill." + DamageMode.Circle + "AttackSelector";
        string path = "ARPGDemo.Skill." + skill.damageMode +
                      "AttackSelector";
        Type   typeObj = Type.GetType(path);
        object obj     = Activator.CreateInstance(typeObj);

        attackSelector = (IAttackSelector)obj;
        return(attackSelector);
    }
Exemplo n.º 13
0
 public AttacksGenerator(ICollectionSelector collectionSelector, IAdjustmentsSelector adjustmentsSelector, IAttackSelector attackSelector)
 {
     this.collectionSelector  = collectionSelector;
     this.adjustmentsSelector = adjustmentsSelector;
     this.attackSelector      = attackSelector;
 }
Exemplo n.º 14
0
 /// <summary>
 /// 选区算法对象 伤害影响效果对象创建
 /// </summary>
 private void ConfigDeployer()
 {
     selector   = DeployerConfigFactory.CreateAttackSelector(currentSkillData);
     impactList = DeployerConfigFactory.CreateImpact(currentSkillData);
 }
Exemplo n.º 15
0
    private IImpactEffect[] impactArray; //影响

    private void InitDeployer()
    {
        selector = DeployerConfigFactory.CreateAttackSelector(skillData);

        impactArray = DeployerConfigFactory.CreateImpactEffects(skillData);
    }
Exemplo n.º 16
0
 public void Setup()
 {
     attackSelector = GetNewInstanceOf <IAttackSelector>();
 }