コード例 #1
0
ファイル: NewEffect.cs プロジェクト: vinhpsviguys/sample
        public void parseAtomics(NewCharacterStatus me, NewCharacterStatus you)
        {
            for (int i = 0; i < atomicEffects.Count; i++)
            {
                ArrayList atomics = parseAtomic((AtomicEffect)atomicEffects[i], me, you);
                if (atomics != null)  // parse ra
                {
                    AtomicEffect removeA = (AtomicEffect)atomicEffects[i];
                    atomicEffects.RemoveAt(i);
                    i--;
                    // remove Atomics
                    // remove condition
                    NewCharacterStatus target = removeA.enemy ? you : me;
                    target.atomics[removeA.index].Remove(removeA);
                    if (removeA.condition != "")
                    {
                        target.enableAtomics[removeA.condition].Remove(removeA);
                    }
                    // add Atomics
                    // Add condition
                    foreach (AtomicEffect atomic in atomics)
                    {
                        target = atomic.enemy ? you : me;
                        ArrayList list = target.atomics.ContainsKey(atomic.index) ? target.atomics[atomic.index] : new ArrayList();
                        list.Add(atomic);
                        target.atomics.Add(atomic.index, list);
                        if (atomic.condition != "")
                        {
                            list = target.enableAtomics.ContainsKey(atomic.condition) ? target.enableAtomics[atomic.condition] : new ArrayList();
                            list.Add(atomic);
                            target.enableAtomics.Add(atomic.condition, list);
                        }
                    }

                    atomicEffects.AddRange(atomics);
                    //foreach (AtomicEffect atomic in atomics) {
                    //    Console.WriteLine("parse  to Atomic Skill "+atomic.index+" "+atomic.delta+" "+atomic.condition);
                    //}
                }
            }

            //foreach (string key in me.enableAtomics.Keys) {
            //    Console.WriteLine("me "+key);
            //}

            //foreach (string key in you.enableAtomics.Keys)
            //{
            //    Console.WriteLine("you "+key);
            //}
        }
コード例 #2
0
ファイル: NewEffect.cs プロジェクト: vinhpsviguys/sample
        private ArrayList parseAtomic(AtomicEffect atomic, NewCharacterStatus me, NewCharacterStatus you)
        {
            switch (atomic.index)
            {
            case "allaps":
                MyDictionary <string, NewSkill> skills = me.character.newSkillDic;
                ArrayList list = new ArrayList();
                foreach (string skill in skills.Keys)
                {
                    string index = atomic.index;
                    string delta = atomic.delta;
                    index = index.Replace("allaps", skill + "_aps");
                    delta = delta.Replace("allaps", skill + "_aps");
                    Debug.Log(atomic.index + " " + atomic.index + " " + atomic.delta + " " + index + " " + delta);
                    AtomicEffect newAtomic = new AtomicEffect((NewEffect)atomic.parent, delta, index, atomic.enemy, atomic.condition, atomic.duration);
                    list.Add(newAtomic);
                }
                return(list);

            default:
                return(null);
            }
        }
コード例 #3
0
        public ArrayList affect(NewCharacterStatus attStatus, NewCharacterStatus defStatus)
        {
            bool   me       = false;
            bool   you      = false;
            string name     = data["name"].Value;
            string nick     = data["nick"].Value;
            int    level    = Convert.ToInt32(data["level"].Value);
            int    duration = data["duration"] == null? -1 :  Convert.ToInt32(data["duration"].Value);

            string    condition = data["condition"] == null ? "" : data["condition"].Value;
            NewEffect effect    = new NewEffect(attStatus.playerID, name, nick, level, 2 * duration, condition); // vi tinh theo turn

            if (condition != "")
            {
                ArrayList enableSkills = attStatus.enableSkills.ContainsKey(condition) ? attStatus.enableSkills[condition] : new ArrayList();
                enableSkills.Add(effect);
                attStatus.enableSkills.Add(condition, enableSkills);
            }

            JSONArray lines = (JSONArray)data["lines"];

            foreach (JSONObject line in lines)
            {
                string delta = line["delta"].Value;
                string index = line["index"].Value;
                string con   = line["condition"] == null ? "" : line["condition"].Value;
                bool   enemy = line["enemy"] == null ? false : Convert.ToBoolean(line["enemy"].Value);
                duration = line["duration"] == null ? -1 : Convert.ToInt32(line["duration"].Value);
                AtomicEffect       atomic       = new AtomicEffect(effect, delta, index, enemy, con, duration);
                NewCharacterStatus targetStatus = null;
                if (enemy)
                {
                    targetStatus = defStatus;
                    // them effect vao danh sach effect
                    // them danh sach atmoic
                    // them danh sach fomula
                    you = true;
                }
                else
                {
                    targetStatus = attStatus;
                    me           = true;
                }

                //targetStatus.replaceEffect(name, effect);

                ArrayList atomics = targetStatus.atomics.ContainsKey(index) ? targetStatus.atomics[index] : new ArrayList();
                atomics.Add(atomic);
                targetStatus.atomics.Add(index, atomics);

                effect.atomicEffects.Add(atomic);
                // tinh lai cong thuc
                //ArrayList formulas = defStatus.formulas.ContainsKey(index) ? defStatus.formulas[index] : new ArrayList();
                //string formulas = !targetStatus.deltaFormulas.ContainsKey(index) ? "" : targetStatus.deltaFormulas[index] + " + ";
                //formulas += delta;
                //targetStatus.deltaFormulas.Add(index, formulas);

                if (con != "")
                {
                    // them vao danh sach dieu kien
                    ArrayList enableAtomics = targetStatus.enableAtomics.ContainsKey(con) ? targetStatus.enableAtomics[con] : new ArrayList();
                    enableAtomics.Add(atomic);
                    targetStatus.enableAtomics.Add(con, enableAtomics);
                }
            }
            int playerID = 0;

            if (me && you)
            {
                playerID = attStatus.playerID + defStatus.playerID;
            }
            else if (me)
            {
                playerID = attStatus.playerID;
            }
            else if (you)
            {
                playerID = defStatus.playerID;
            }


            //NewEffect clone = effect.clone();
            effect.playerID = playerID;

            if (me)
            {
                attStatus.replaceEffect(name, effect);
            }
            if (you)
            {
                defStatus.replaceEffect(name, effect);
            }
            // parse Special Atomics
            effect.parseAtomics(attStatus, defStatus);


            ArrayList result = new ArrayList();

            result.Add(effect);

            return(result);
        }
コード例 #4
0
ファイル: NewEffect.cs プロジェクト: vinhpsviguys/sample
        public NewEffect parseString(string base64string) // Convert ra NewEffect chua ket noi voi cac Status
        {
            NewEffect effect = null;

            byte[] bytes = Convert.FromBase64String(base64string);
            bytes = Utilities.SubArray <byte>(bytes, 1, bytes.Length - 1);            // loai bo byte file do dai day byte


            int byte_shift = 0;
            int sub        = 0;

            byte[] part = Utilities.SubArray <byte>(bytes, byte_shift, sizeof(ushort));
            ushort type = BitConverter.ToUInt16(part, 0);

            byte_shift += sizeof(ushort);

            part        = Utilities.SubArray <byte>(bytes, byte_shift, sizeof(byte));
            byte_shift += sizeof(byte);
            int originID = part[0];

            string name = "";
            string nick = "";

            part        = Utilities.SubArray <byte>(bytes, byte_shift, sizeof(byte));
            byte_shift += sizeof(byte);
            int playerID = part[0];

            if (type < 1000)             // SKill
            {
                NewSkill skill = Adapter.skills["Skill" + type];
                nick = "Skill" + type;
                name = skill.data["name"].Value;
                // doc tiep
                part        = Utilities.SubArray <byte>(bytes, byte_shift, sizeof(byte));
                byte_shift += sizeof(byte);
                int level = (sbyte)part[0];
                // duration
                part        = Utilities.SubArray <byte>(bytes, byte_shift, sizeof(byte));
                byte_shift += sizeof(byte);
                int duration = (sbyte)part[0];
                // doc tiep cac atomic

                string condition = skill.data["condition"] == null ? "" : skill.data["condition"].Value;
                effect = new NewEffect(originID, name, nick, level, duration, condition);

                JSONNode data = skill.data;

                JSONArray lines = (JSONArray)data["lines"];

                foreach (JSONObject line in lines)
                {
                    part        = Utilities.SubArray <byte>(bytes, byte_shift, sizeof(byte));
                    byte_shift += sizeof(byte);
                    duration    = (sbyte)part[0];

                    string       delta  = line["delta"].Value;
                    string       index  = line["index"].Value;
                    string       con    = line["condition"] == null ? "" : line["condition"].Value;
                    bool         enemy  = line["enemy"] == null ? false : Convert.ToBoolean(line["enemy"].Value);
                    AtomicEffect atomic = new AtomicEffect(effect, delta, index, enemy, con, duration);
                    effect.atomicEffects.Add(atomic);
                }

                effect.playerID = playerID;
            }
            else if (type < 2000)             // AS
            {
                sub = type - 1000;
                AbnormalStatus ab = Adapter.abs["AS" + type];
                nick = "AS" + type;
                name = ab.data["name"].Value;

                part        = Utilities.SubArray <byte>(bytes, byte_shift, sizeof(byte));
                byte_shift += sizeof(byte);
                int duration = (sbyte)part[0];
                effect = new NewEffect(originID, name, nick, -1, duration);
                JSONNode data = ab.data;

                JSONArray lines = data["line"] != null ? (JSONArray)data["lines"] : null;
                if (lines != null)
                {
                    foreach (JSONObject line in lines)
                    {
                        part        = Utilities.SubArray <byte>(bytes, byte_shift, sizeof(byte));
                        byte_shift += sizeof(byte);
                        duration    = (sbyte)part[0];
                        string       delta  = line["delta"].Value;
                        string       index  = line["index"].Value;
                        string       con    = line["condition"] == null ? "" : line["condition"].Value;
                        bool         enemy  = true;
                        AtomicEffect atomic = new AtomicEffect(effect, delta, index, enemy, con, duration);
                        effect.atomicEffects.Add(atomic);
                    }
                }
                switch (name)
                {
                case Burn:
                    part = Utilities.SubArray <byte>(bytes, byte_shift, bytes.Length - byte_shift);
                    effect.indexes.Add("burn_damage", BitConverter.ToInt32(part, 0));
                    break;

                case Poisoning:
                    part = Utilities.SubArray <byte>(bytes, byte_shift, bytes.Length - byte_shift);
                    effect.indexes.Add("poison_damage", BitConverter.ToInt32(part, 0));
                    break;
                }

                effect.playerID = playerID;
            }
            else
            {
                sub = type - 2000;
                switch (sub)
                {
                case 1:
                    effect = new NewEffect(originID, "HealthChanges");
                    break;

                case 2:
                    effect = new NewEffect(originID, "Blocking");

                    break;

                case 3:
                    effect = new NewEffect(originID, "Dodge");

                    break;

                case 4:
                    effect = new NewEffect(originID, "Critical");

                    break;

                case 5:
                    effect = new NewEffect(originID, "ReturnDamage");
                    break;

                case 6:
                    effect = new NewEffect(originID, "Multicast");
                    break;

                case 7:
                    effect = new NewEffect(originID, "RemoveAllAbnormal");
                    break;

                case 8:
                    effect = new NewEffect(originID, "DoubleMagic");
                    break;

                case 9:
                    effect = new NewEffect(originID, "HealthRecovery");
                    break;

                case 10:
                    effect = new NewEffect(originID, "HealthRecovery_Glamour");
                    break;

                default:
                    if (sub < 4000)
                    {    // HealthAdd_Skill
                        effect = new NewEffect(originID, "HealthAdd_Skill" + (sub - 3000));
                    }
                    else if (sub < 5000)
                    {    // HealthAdd_Glamour_Skill
                        effect = new NewEffect(originID, "HealthAdd_Glamour_Skill" + (sub - 4000));
                    }
                    else if (sub < 6000)
                    {
                        effect = new NewEffect(originID, "HealthSub_Skill" + (sub - 5000));
                    }
                    break;
                }
                effect.playerID = playerID;
            }


            return(effect);
        }