Exemple #1
0
        void Update()
        {
            if (!make)
            {
                return;
            }
            make = false;

            string xml = xml_vertion;//<?xml version="1.0" encoding="UTF-8"?>

            xml += "\n" + "<root>" + "\n";

            foreach (RuntimeWeapen i in canidates)
            {
                Weapen w = i.instance;

                xml += "<weapen>" + "\n";
                xml += "<oh_idle>" + w.oh_idle + "</oh_idle>" + "\n";
                xml += "<th_idle>" + w.th_idle + "</th_idle>" + "\n";
                xml += ActionListToString(w.actions, "actions");
                xml += ActionListToString(w.two_handenActions, "two_handenActions");
                xml += "<parryMultiplier>" + w.parryMultiplier + "</parryMultiplier>" + "\n";
                xml += "<backstabMultiplier>" + w.backstabMultiplier + "</backstabMultiplier>" + "\n";
                xml += "<leftHandMirror>" + w.leftHandMirror + "</leftHandMirror>" + "\n";

//                xml += "<mp_x>" + w.model_pos.x + "</mp_x>" + "\n";
//                xml += "<mp_y>" + w.model_pos.y + "</mp_y>" + "\n";
//                xml += "<mp_z>" + w.model_pos.z + "</mp_z>" + "\n";
//
//                xml += "<me_x>" + w.model_eulers.x + "</me_x>" + "\n";
//                xml += "<me_y>" + w.model_eulers.y + "</me_y>" + "\n";
//                xml += "<me_z>" + w.model_eulers.z + "</me_z>" + "\n";

                xml += "<ms_x>" + w.model_scale.x + "</ms_x>" + "\n";
                xml += "<ms_y>" + w.model_scale.y + "</ms_y>" + "\n";
                xml += "<ms_z>" + w.model_scale.z + "</ms_z>" + "\n";

                xml += "</weapen>" + "\n";
            }

            xml += "</root>";

            string path = StaticStrings.SaveLocation() + StaticStrings.itemFolder;

            if (string.IsNullOrEmpty(targetName))
            {
                targetName = "items_database.xml";
            }

            path += targetName;
            File.WriteAllText(path, xml);
        }
Exemple #2
0
        void Update()
        {
            if (!saveWeapen)
            {
                return;
            }
            saveWeapen = false;
            if (weapenModel == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(weapenId))
            {
                return;
            }
            WeapenScriptableObject obj = Resources.Load("AW.WeapenScriptableObject") as WeapenScriptableObject;

            if (obj == null)
            {
                return;
            }
            for (int i = 0; i < obj.weapen_all.Count; i++)
            {
                if (obj.weapen_all[i].itemName == weapenId)
                {
                    Weapen w = obj.weapen_all[i];
                    if (lefthand)
                    {
                        w.l_model_pos    = weapenModel.transform.localPosition;
                        w.l_model_eulers = weapenModel.transform.localEulerAngles;
                    }
                    else
                    {
                        w.r_model_pos    = weapenModel.transform.localPosition;
                        w.r_model_eulers = weapenModel.transform.localEulerAngles;
                    }
                    w.model_scale = weapenModel.transform.localScale;
                    return;
                }
            }

            Debug.Log("weapenId not find in WeapenScriptableObject");
        }
        public void LoadWeapenData(ResourcesManager rm)
        {
            string filePath = StaticStrings.SaveLocation() + StaticStrings.itemFolder;

            filePath += weapenFileName;

            XmlDocument doc = new XmlDocument();

            doc.Load(filePath);

            foreach (XmlNode w in doc.DocumentElement.SelectNodes("//weapen"))
            {
                Weapen _w = new Weapen();
                _w.actions           = new List <Action>();
                _w.two_handenActions = new List <Action>();

                XmlNode weapenId = w.SelectSingleNode("weapenId");
                XmlNode oh_idle  = w.SelectSingleNode("oh_idle");
                _w.oh_idle = oh_idle.InnerText;
                XmlNode th_idle = w.SelectSingleNode("th_idle");
                _w.th_idle = th_idle.InnerText;

                XmlNode parryMultiplier = w.SelectSingleNode("parryMultiplier");
                float.TryParse(parryMultiplier.InnerText, out _w.parryMultiplier);
                XmlNode backstabMultiplier = w.SelectSingleNode("backstabMultiplier");
                float.TryParse(backstabMultiplier.InnerText, out _w.backstabMultiplier);

                XmlNode leftHandMirror = w.SelectSingleNode("leftHandMirror");
                _w.leftHandMirror = (leftHandMirror.InnerText == "True");

//                _w.model_pos = XmlToVector3(w,"mp");
//                _w.model_eulers = XmlToVector3(w, "me");
//                _w.model_scale = XmlToVector3(w, "ms");

                XmlToActions(doc, "actions", ref _w);
                XmlToActions(doc, "two_handenActions", ref _w);

                resourcesManager.weapenList.Add(_w);
            }
        }
Exemple #4
0
            //因为我这里有两种士兵,所以在这里可以增加另外一个参数,士兵类型,原模式里面没有,
            public Soldier GetSoldier(string name, Weapen weapen, SoldierType soldierType)
            {
                foreach (Soldier soldier in soldiers)
                {
                    if (string.Compare(soldier.Name, name, true) == 0)
                    {
                        mySoldier = soldier;
                        return(mySoldier);
                    }
                }
                //我们这里就任务名称是唯一的
                if (soldierType == SoldierType.Normal)
                {
                    mySoldier = new NormalSoldier(name);
                }
                else
                {
                    mySoldier = new WaterSoldier(name);
                }
                mySoldier.WeapenInstance = weapen;

                soldiers.Add(mySoldier);
                return(mySoldier);
            }
        private void XmlToActions(XmlDocument doc, string nodeName, ref Weapen _w)
        {
            foreach (XmlNode a in doc.DocumentElement.SelectNodes("//" + nodeName))
            {
//                XmlNode weapenId = w.SelectSingleNode("weapenId");
//                _w.weapenId = weapenId.InnerText;
//
//                XmlNode parryMultiplier = w.SelectSingleNode("parryMultiplier");
//                float.TryParse(parryMultiplier.InnerText, out _w.parryMultiplier);


                Action _a = new Action();

                XmlNode actionInput = a.SelectSingleNode("ActionInput");
                _a.input = (ActionInput)Enum.Parse(typeof(ActionInput), actionInput.InnerText);

                XmlNode actionType = a.SelectSingleNode("ActionType");
                _a.type = (ActionType)Enum.Parse(typeof(ActionType), actionType.InnerText);

                XmlNode targetAnim = a.SelectSingleNode("targetAnim");
                _a.targetAnim = targetAnim.InnerText;

                XmlNode damageAnim = a.SelectSingleNode("damageAnim");
                _a.damageAnim = damageAnim.InnerText;

                XmlNode animSpeed = a.SelectSingleNode("animSpeed");
                float.TryParse(animSpeed.InnerText, out _a.animSpeed);

                XmlNode mirror = a.SelectSingleNode("mirror");
                _a.mirror = (mirror.InnerText == "True");

                XmlNode canBenParried = a.SelectSingleNode("canBenParried");
                _a.canBenParried = (canBenParried.InnerText == "True");

                XmlNode changeSpeed = a.SelectSingleNode("changeSpeed");
                _a.changeSpeed = (changeSpeed.InnerText == "True");

                XmlNode canParry = a.SelectSingleNode("canParry");
                _a.canParry = (canParry.InnerText == "True");

                XmlNode canBackstab = a.SelectSingleNode("canBackstab");
                _a.canBackstab = (canBackstab.InnerText == "True");

                XmlNode overrideDamageAnim = a.SelectSingleNode("overrideDamageAnim");
                _a.overrideDamageAnim = (overrideDamageAnim.InnerText == "True");

                _a.weapenStats = new WeapenStats();
                XmlNode physical = a.SelectSingleNode("physical");
                int.TryParse(physical.InnerText, out _a.weapenStats.physical);
                XmlNode strike = a.SelectSingleNode("strike");
                int.TryParse(strike.InnerText, out _a.weapenStats.strike);
                XmlNode slash = a.SelectSingleNode("slash");
                int.TryParse(slash.InnerText, out _a.weapenStats.slash);
                XmlNode thrust = a.SelectSingleNode("thrust");
                int.TryParse(thrust.InnerText, out _a.weapenStats.thrust);
                XmlNode magic = a.SelectSingleNode("magic");
                int.TryParse(magic.InnerText, out _a.weapenStats.magic);
                XmlNode fire = a.SelectSingleNode("fire");
                int.TryParse(fire.InnerText, out _a.weapenStats.fire);
                XmlNode lighting = a.SelectSingleNode("lighting");
                int.TryParse(lighting.InnerText, out _a.weapenStats.lighting);
                XmlNode dark = a.SelectSingleNode("dark");
                int.TryParse(dark.InnerText, out _a.weapenStats.dark);

                if (nodeName == "actions")
                {
                    _w.actions.Add(_a);
                }
                else
                {
                    _w.two_handenActions.Add(_a);
                }
            }
        }