Example #1
0
        /// <summary>
        /// 法术的导入
        /// </summary>
        /// <param name="target"></param>
        /// <param name="workbook"></param>
        private void Ability(TargetType target, dynamic workbook)
        {
            if (Directory.Exists(XmlFolderPicker.SelectedPathOrFileName + "\\Ability\\"))
            {
                Directory.Delete(XmlFolderPicker.SelectedPathOrFileName + "\\Ability\\", true);
            }
            Directory.CreateDirectory(XmlFolderPicker.SelectedPathOrFileName + "\\Ability\\");
            //法术的导入
            dynamic worksheet = workbook.Sheets(2);
            int rowCount = 4;
            while (!String.IsNullOrEmpty(worksheet.Cells(rowCount, 2).Text))
            {
                Card.AbilityCard Ability = new Card.AbilityCard();
                Ability.SN = worksheet.Cells(rowCount, 2).Text;
                Ability.Name = worksheet.Cells(rowCount, 3).Text;
                Ability.Description = worksheet.Cells(rowCount, 4).Text;
                Ability.Class = CardUtility.GetEnum<Card.CardUtility.ClassEnum>(worksheet.Cells(rowCount, 5).Text, Card.CardUtility.ClassEnum.中立);
                Ability.StandardCostPoint = CardUtility.GetInt(worksheet.Cells(rowCount, 7).Text);
                Ability.ActualCostPoint = Ability.StandardCostPoint;

                Ability.Rare = CardUtility.GetEnum<Card.CardBasicInfo.稀有程度>(worksheet.Cells(rowCount, 12).Text, CardBasicInfo.稀有程度.白色);
                Ability.IsCardReady = !String.IsNullOrEmpty(worksheet.Cells(rowCount, 13).Text);

                Card.Effect.EffectDefine effect = new Card.Effect.EffectDefine();
                effect.Description = String.IsNullOrEmpty(worksheet.Cells(rowCount, 14).Text) ? String.Empty : worksheet.Cells(rowCount, 14).Text;
                effect.AbilityEffectType = CardUtility.GetEnum<Card.Effect.CardEffect.AbilityEffectEnum>(worksheet.Cells(rowCount, 15).Text, Card.Effect.CardEffect.AbilityEffectEnum.未定义);
                effect.EffictTargetSelectMode = CardUtility.GetEnum<Card.CardUtility.TargetSelectModeEnum>(worksheet.Cells(rowCount, 16).Text, CardUtility.TargetSelectModeEnum.不用选择);
                effect.EffectTargetSelectDirect = CardUtility.GetEnum<Card.CardUtility.TargetSelectDirectEnum>(worksheet.Cells(rowCount, 17).Text, CardUtility.TargetSelectDirectEnum.双方);
                effect.EffectTargetSelectRole = CardUtility.GetEnum<Card.CardUtility.TargetSelectRoleEnum>(worksheet.Cells(rowCount, 18).Text, CardUtility.TargetSelectRoleEnum.随从);
                effect.StandardEffectPoint = CardUtility.GetInt(worksheet.Cells(rowCount, 19).Text);
                effect.EffectCount = CardUtility.GetInt(worksheet.Cells(rowCount, 20).Text);
                if (effect.EffectCount == 0) effect.EffectCount = 1;
                effect.AddtionInfo = worksheet.Cells(rowCount, 21).Text;
                Ability.CardAbility.FirstAbilityDefine = effect;
                Ability.CardAbility.JoinType = CardUtility.GetEnum<Card.CardUtility.EffectJoinType>(worksheet.Cells(rowCount, 22).Text, Card.CardUtility.EffectJoinType.None);
                Boolean HasSecond = false;
                for (int i = 23; i < 31; i++)
                {
                    if (!String.IsNullOrEmpty(worksheet.Cells(rowCount, i).Text))
                    {
                        HasSecond = true;
                        break;
                    }
                }
                if (HasSecond)
                {
                    Card.Effect.EffectDefine effect2 = new Card.Effect.EffectDefine();
                    effect2.Description = String.IsNullOrEmpty(worksheet.Cells(rowCount, 23).Text) ? String.Empty : worksheet.Cells(rowCount, 23).Text;
                    effect2.AbilityEffectType = CardUtility.GetEnum<Card.Effect.CardEffect.AbilityEffectEnum>(worksheet.Cells(rowCount, 24).Text, Card.Effect.CardEffect.AbilityEffectEnum.未定义);
                    effect2.EffictTargetSelectMode = CardUtility.GetEnum<Card.CardUtility.TargetSelectModeEnum>(worksheet.Cells(rowCount, 25).Text, CardUtility.TargetSelectModeEnum.不用选择);
                    effect2.EffectTargetSelectDirect = CardUtility.GetEnum<Card.CardUtility.TargetSelectDirectEnum>(worksheet.Cells(rowCount, 26).Text, CardUtility.TargetSelectDirectEnum.双方);
                    effect2.EffectTargetSelectRole = CardUtility.GetEnum<Card.CardUtility.TargetSelectRoleEnum>(worksheet.Cells(rowCount, 27).Text, CardUtility.TargetSelectRoleEnum.随从);
                    effect2.StandardEffectPoint = CardUtility.GetInt(worksheet.Cells(rowCount, 28).Text);
                    effect2.EffectCount = CardUtility.GetInt(worksheet.Cells(rowCount, 29).Text);
                    effect2.AddtionInfo = worksheet.Cells(rowCount, 30).Text;
                    Ability.CardAbility.SecondAbilityDefine = effect2;
                }
                switch (target)
                {
                    case TargetType.MongoDB:
                        //innerCollection.Insert<Card.AbilityCard>(Ability);
                        break;
                    case TargetType.Xml:
                        XmlSerializer xml = new XmlSerializer(typeof(Card.AbilityCard));
                        String XmlFilename = XmlFolderPicker.SelectedPathOrFileName + "\\Ability\\" + Ability.SN + ".xml";
                        xml.Serialize(new StreamWriter(XmlFilename), Ability);
                        break;
                    default:
                        break;
                }
                rowCount++;
            }
        }
Example #2
0
        /// <summary>
        /// 使用法术
        /// </summary>
        /// <param name="card"></param>
        /// <param name="ConvertPosDirect">对象方向转换</param>
        public List <String> UseAbility(Card.AbilityCard card, Boolean ConvertPosDirect)
        {
            List <String> Result = new List <string>();

            //法术伤害
            if (MySelf.RoleInfo.BattleField.AbilityEffect != 0)
            {
                //法术强度本意是增加法术卡的总伤。以奥术飞弹为例,法术强度+1会令奥术飞弹多1发伤害,而非单发伤害+1。法术强度不影响治疗效果。
                switch (card.CardAbility.FirstAbilityDefine.AbilityEffectType)
                {
                case EffectDefine.AbilityEffectEnum.攻击:
                    if (card.CardAbility.FirstAbilityDefine.StandardEffectCount == 1)
                    {
                        card.CardAbility.FirstAbilityDefine.ActualEffectPoint = card.CardAbility.FirstAbilityDefine.StandardEffectPoint + MySelf.RoleInfo.BattleField.AbilityEffect;
                    }
                    else
                    {
                        card.CardAbility.FirstAbilityDefine.ActualEffectCount = card.CardAbility.FirstAbilityDefine.StandardEffectCount + MySelf.RoleInfo.BattleField.AbilityEffect;
                    }
                    break;

                case EffectDefine.AbilityEffectEnum.回复:
                    card.CardAbility.FirstAbilityDefine.ActualEffectPoint = card.CardAbility.FirstAbilityDefine.StandardEffectPoint + MySelf.RoleInfo.BattleField.AbilityEffect;
                    break;
                }
                if (card.CardAbility.SecondAbilityDefine.AbilityEffectType != EffectDefine.AbilityEffectEnum.未定义)
                {
                    switch (card.CardAbility.SecondAbilityDefine.AbilityEffectType)
                    {
                    case EffectDefine.AbilityEffectEnum.攻击:
                        if (card.CardAbility.SecondAbilityDefine.StandardEffectCount == 1)
                        {
                            card.CardAbility.SecondAbilityDefine.ActualEffectPoint = card.CardAbility.SecondAbilityDefine.StandardEffectPoint + MySelf.RoleInfo.BattleField.AbilityEffect;
                        }
                        else
                        {
                            card.CardAbility.SecondAbilityDefine.ActualEffectCount = card.CardAbility.SecondAbilityDefine.StandardEffectCount + MySelf.RoleInfo.BattleField.AbilityEffect;
                        }
                        break;

                    case EffectDefine.AbilityEffectEnum.回复:
                        card.CardAbility.SecondAbilityDefine.ActualEffectPoint = card.CardAbility.SecondAbilityDefine.StandardEffectPoint + MySelf.RoleInfo.BattleField.AbilityEffect;
                        break;
                    }
                }
            }
            Card.CardUtility.PickEffect PickEffectResult = CardUtility.PickEffect.第一效果;
            if (card.CardAbility.IsNeedSelect())
            {
                PickEffectResult = PickEffect(card.CardAbility.FirstAbilityDefine.Description, card.CardAbility.SecondAbilityDefine.Description);
                if (PickEffectResult == CardUtility.PickEffect.取消)
                {
                    return(new List <string>());
                }
            }
            var SingleEffectList = card.CardAbility.GetSingleEffectList(PickEffectResult == CardUtility.PickEffect.第一效果);

            for (int i = 0; i < SingleEffectList.Count; i++)
            {
                Card.CardUtility.TargetPosition Pos = new CardUtility.TargetPosition();
                var singleEff = SingleEffectList[i];
                singleEff.StandardEffectCount = 1;
                if (singleEff.IsNeedSelectTarget())
                {
                    Pos = GetSelectTarget(singleEff.EffectTargetSelectDirect, singleEff.EffectTargetSelectRole, false);
                    //取消处理
                    if (Pos.Postion == -1)
                    {
                        return(new List <string>());
                    }
                }
                else
                {
                    if (ConvertPosDirect)
                    {
                        switch (singleEff.EffectTargetSelectDirect)
                        {
                        case CardUtility.TargetSelectDirectEnum.本方:
                            singleEff.EffectTargetSelectDirect = CardUtility.TargetSelectDirectEnum.对方;
                            break;

                        case CardUtility.TargetSelectDirectEnum.对方:
                            singleEff.EffectTargetSelectDirect = CardUtility.TargetSelectDirectEnum.本方;
                            break;

                        case CardUtility.TargetSelectDirectEnum.双方:
                            break;

                        default:
                            break;
                        }
                    }
                }
                Result.AddRange(EffectDefine.RunSingleEffect(singleEff, this, Pos, Seed));
                Seed++;
                //每次原子操作后进行一次清算
                //将亡语效果也发送给对方
                Result.AddRange(Settle());
            }
            return(Result);
        }
Example #3
0
        /// <summary>
        /// 使用法术
        /// </summary>
        /// <param name="card"></param>
        /// <param name="ConvertPosDirect">对象方向转换</param>
        public List <String> UseAbility(Card.AbilityCard card, Boolean ConvertPosDirect)
        {
            List <String> Result = new List <string>();

            //法术伤害
            if (MyInfo.BattleField.AbilityEffect != 0)
            {
                card.JustfyEffectPoint(MyInfo.BattleField.AbilityEffect);
            }
            Card.CardUtility.PickEffect PickEffectResult = CardUtility.PickEffect.第一效果;
            if (card.CardAbility.IsNeedSelect())
            {
                PickEffectResult = PickEffect(card.CardAbility.FirstAbilityDefine.Description, card.CardAbility.SecondAbilityDefine.Description);
                if (PickEffectResult == CardUtility.PickEffect.取消)
                {
                    return(new List <string>());
                }
            }
            var SingleEffectList = card.CardAbility.GetSingleEffectList(PickEffectResult == CardUtility.PickEffect.第一效果);

            //Pos放在循环外部,这样的话,达到继承的效果
            Card.CardUtility.TargetPosition TargetPosInfo = new CardUtility.TargetPosition();
            for (int i = 0; i < SingleEffectList.Count; i++)
            {
                var singleEffect = SingleEffectList[i];
                singleEffect.StandardEffectCount = 1;
                if (singleEffect.IsNeedSelectTarget())
                {
                    TargetPosInfo = GetSelectTarget(singleEffect.SelectOpt, false);
                    //取消处理
                    if (TargetPosInfo.Postion == -1)
                    {
                        return(new List <string>());
                    }
                }
                else
                {
                    if (ConvertPosDirect)
                    {
                        switch (singleEffect.SelectOpt.EffectTargetSelectDirect)
                        {
                        case CardUtility.TargetSelectDirectEnum.本方:
                            singleEffect.SelectOpt.EffectTargetSelectDirect = CardUtility.TargetSelectDirectEnum.对方;
                            break;

                        case CardUtility.TargetSelectDirectEnum.对方:
                            singleEffect.SelectOpt.EffectTargetSelectDirect = CardUtility.TargetSelectDirectEnum.本方;
                            break;

                        case CardUtility.TargetSelectDirectEnum.双方:
                            break;

                        default:
                            break;
                        }
                    }
                }
                Result.AddRange(Effecthandler.RunSingleEffect(singleEffect, this, TargetPosInfo, Seed));
                Seed++;
                //每次原子操作后进行一次清算
                //将亡语效果也发送给对方
                Result.AddRange(Settle());
            }
            return(Result);
        }
Example #4
0
        /// <summary>
        /// 法术的导入
        /// </summary>
        /// <param name="target"></param>
        /// <param name="workbook"></param>
        private void Ability(TargetType target, dynamic workbook)
        {
            if (Directory.Exists(XmlFolderPicker.SelectedPathOrFileName + "\\Ability\\"))
            {
                Directory.Delete(XmlFolderPicker.SelectedPathOrFileName + "\\Ability\\", true);
            }
            Directory.CreateDirectory(XmlFolderPicker.SelectedPathOrFileName + "\\Ability\\");
            //法术的导入
            dynamic worksheet = workbook.Sheets(2);
            int     rowCount  = 4;

            while (!String.IsNullOrEmpty(worksheet.Cells(rowCount, 2).Text))
            {
                Card.AbilityCard Ability = new Card.AbilityCard();
                Ability.SN                = worksheet.Cells(rowCount, 2).Text;
                Ability.Name              = worksheet.Cells(rowCount, 3).Text;
                Ability.Description       = worksheet.Cells(rowCount, 4).Text;
                Ability.Class             = CardUtility.GetEnum <Card.CardUtility.ClassEnum>(worksheet.Cells(rowCount, 5).Text, Card.CardUtility.ClassEnum.中立);
                Ability.StandardCostPoint = CardUtility.GetInt(worksheet.Cells(rowCount, 7).Text);

                Ability.Rare        = CardUtility.GetEnum <Card.CardBasicInfo.稀有程度>(worksheet.Cells(rowCount, 12).Text, CardBasicInfo.稀有程度.白色);
                Ability.IsCardReady = !String.IsNullOrEmpty(worksheet.Cells(rowCount, 13).Text);

                Card.Effect.EffectDefine effect = new Card.Effect.EffectDefine();
                effect.Description       = String.IsNullOrEmpty(worksheet.Cells(rowCount, 14).Text) ? String.Empty : worksheet.Cells(rowCount, 14).Text;
                effect.AbilityEffectType = CardUtility.GetEnum <Card.Effect.CardEffect.AbilityEffectEnum>(worksheet.Cells(rowCount, 15).Text, Card.Effect.CardEffect.AbilityEffectEnum.未定义);
                effect.SelectOpt.EffictTargetSelectMode   = CardUtility.GetEnum <Card.CardUtility.TargetSelectModeEnum>(worksheet.Cells(rowCount, 16).Text, CardUtility.TargetSelectModeEnum.用选择);
                effect.SelectOpt.EffectTargetSelectDirect = CardUtility.GetEnum <Card.CardUtility.TargetSelectDirectEnum>(worksheet.Cells(rowCount, 17).Text, CardUtility.TargetSelectDirectEnum.双方);
                effect.SelectOpt.EffectTargetSelectRole   = CardUtility.GetEnum <Card.CardUtility.TargetSelectRoleEnum>(worksheet.Cells(rowCount, 18).Text, CardUtility.TargetSelectRoleEnum.随从);

                String 种族限制 = worksheet.Cells(rowCount, 19).Text;
                if (!String.IsNullOrEmpty(种族限制))
                {
                    if (种族限制.StartsWith("非"))
                    {
                        effect.SelectOpt.EffectTargetSelect种族条件   = CardUtility.GetEnum <Card.CardUtility.种族Enum>(种族限制.Substring(1), CardUtility.种族Enum.无);
                        effect.SelectOpt.EffectTargetSelect种族条件取反 = true;
                    }
                    else
                    {
                        effect.SelectOpt.EffectTargetSelect种族条件 = CardUtility.GetEnum <Card.CardUtility.种族Enum>(种族限制, CardUtility.种族Enum.无);
                    }
                }
                else
                {
                    effect.SelectOpt.EffectTargetSelect种族条件 = CardUtility.种族Enum.无;
                }

                effect.StandardEffectPoint = CardUtility.GetInt(worksheet.Cells(rowCount, 20).Text);
                effect.StandardEffectCount = CardUtility.GetInt(worksheet.Cells(rowCount, 21).Text);
                if (effect.StandardEffectCount == 0)
                {
                    effect.StandardEffectCount = 1;
                }
                effect.AddtionInfo = worksheet.Cells(rowCount, 22).Text;
                Ability.CardAbility.FirstAbilityDefine = effect;
                Ability.CardAbility.JoinType           = CardUtility.GetEnum <Card.CardUtility.EffectJoinType>(worksheet.Cells(rowCount, 23).Text, Card.CardUtility.EffectJoinType.None);
                Boolean HasSecond = false;
                for (int i = 24; i < 32; i++)
                {
                    if (!String.IsNullOrEmpty(worksheet.Cells(rowCount, i).Text))
                    {
                        HasSecond = true;
                        break;
                    }
                }
                if (HasSecond)
                {
                    Card.Effect.EffectDefine effect2 = new Card.Effect.EffectDefine();
                    effect2.Description       = String.IsNullOrEmpty(worksheet.Cells(rowCount, 24).Text) ? String.Empty : worksheet.Cells(rowCount, 24).Text;
                    effect2.AbilityEffectType = CardUtility.GetEnum <Card.Effect.CardEffect.AbilityEffectEnum>(worksheet.Cells(rowCount, 25).Text, Card.Effect.CardEffect.AbilityEffectEnum.未定义);
                    effect2.SelectOpt.EffictTargetSelectMode   = CardUtility.GetEnum <Card.CardUtility.TargetSelectModeEnum>(worksheet.Cells(rowCount, 26).Text, CardUtility.TargetSelectModeEnum.用选择);
                    effect2.SelectOpt.EffectTargetSelectDirect = CardUtility.GetEnum <Card.CardUtility.TargetSelectDirectEnum>(worksheet.Cells(rowCount, 27).Text, CardUtility.TargetSelectDirectEnum.双方);
                    effect2.SelectOpt.EffectTargetSelectRole   = CardUtility.GetEnum <Card.CardUtility.TargetSelectRoleEnum>(worksheet.Cells(rowCount, 28).Text, CardUtility.TargetSelectRoleEnum.随从);

                    种族限制 = worksheet.Cells(rowCount, 29).Text;
                    if (!String.IsNullOrEmpty(种族限制))
                    {
                        if (种族限制.StartsWith("非"))
                        {
                            effect.SelectOpt.EffectTargetSelect种族条件   = CardUtility.GetEnum <Card.CardUtility.种族Enum>(种族限制.Substring(1), CardUtility.种族Enum.无);
                            effect.SelectOpt.EffectTargetSelect种族条件取反 = true;
                        }
                        else
                        {
                            effect.SelectOpt.EffectTargetSelect种族条件 = CardUtility.GetEnum <Card.CardUtility.种族Enum>(种族限制, CardUtility.种族Enum.无);
                        }
                    }
                    else
                    {
                        effect.SelectOpt.EffectTargetSelect种族条件 = CardUtility.种族Enum.无;
                    }

                    effect2.StandardEffectPoint             = CardUtility.GetInt(worksheet.Cells(rowCount, 30).Text);
                    effect2.StandardEffectCount             = CardUtility.GetInt(worksheet.Cells(rowCount, 31).Text);
                    effect2.AddtionInfo                     = worksheet.Cells(rowCount, 32).Text;
                    Ability.CardAbility.SecondAbilityDefine = effect2;
                }
                Ability.Overload = CardUtility.GetInt(worksheet.Cells(rowCount, 33).Text);
                switch (target)
                {
                case TargetType.MongoDB:
                    //innerCollection.Insert<Card.AbilityCard>(Ability);
                    break;

                case TargetType.Xml:
                    XmlSerializer xml         = new XmlSerializer(typeof(Card.AbilityCard));
                    String        XmlFilename = XmlFolderPicker.SelectedPathOrFileName + "\\Ability\\" + Ability.SN + ".xml";
                    xml.Serialize(new StreamWriter(XmlFilename), Ability);
                    break;

                default:
                    break;
                }
                rowCount++;
            }
        }