示例#1
0
 public void ExchangeNewWeapon(WeaponBasic weapon)
 {
     //如果是肉搏
     if (weapon.acc < 0)
     {
         //找到武器欄內的肉搏
     }
     //如果不是肉搏
     //獲得新武器
 }
示例#2
0
        public void ChangeWeapon(string weaponName)
        {
            //關閉上個武器模組
            if (NowWeapon != null)
            {
                if (NowWeapon.weapon != null)
                {
                    NowWeapon.weapon.SetActive(false);
                }
            }
            //找到新武器
            NowWeapon = WeaponSlot.Find(x => x.name == weaponName);
            NowWeapon.weapon.SetActive(true);

            if (NowWeapon.acc > 0)//肉搏武器的準度為負數
            {
                NowWeapon.bullet = Resources.Load("Prefabs/" + NowWeapon.type) as GameObject;
            }
            //canshoot = true;
        }
示例#3
0
        //開始時就載入全列表,被呼叫時返回一個新的武器給該單位
        //近接和遠程分開
        public Dictionary <string, WeaponBasic> Loadweapon(string close_or_range, string weapontype)
        {
            Dictionary <string, WeaponBasic> weapondictionary = new Dictionary <string, WeaponBasic>();
            XmlDocument doc = new XmlDocument();

            doc.Load("data\\weapon\\weapon.xml");
            XmlNodeList weapontypeNode = doc.SelectNodes("weapon/" + close_or_range + "/" + weapontype);
            XmlNodeList nodeList       = weapontypeNode[0].ChildNodes;

            foreach (XmlNode node in nodeList)
            {
                string name = node.Attributes["name"].Value;
                string type = node.Attributes["type"].Value;

                int damage            = Convert.ToInt32(node.Attributes["damage"].Value);
                int magsize           = Convert.ToInt32(node.Attributes["magsize"].Value);
                int bulletusedpershot = Convert.ToInt32(node.Attributes["bulletusedpershot"].Value);
                int maxammo           = Convert.ToInt32(node.Attributes["maxammo"].Value);
                int nowammo           = Convert.ToInt32(node.Attributes["nowammo"].Value);

                float charge  = (float)Convert.ToDouble(node.Attributes["charge"].Value);
                float acc     = (float)Convert.ToDouble(node.Attributes["acc"].Value);
                float stun    = (float)Convert.ToDouble(node.Attributes["stun"].Value);
                float rof     = (float)Convert.ToDouble(node.Attributes["rof"].Value);
                float dropoff = (float)Convert.ToDouble(node.Attributes["dropoff"].Value);
                float speed   = (float)Convert.ToDouble(node.Attributes["speed"].Value);
                float recoil  = (float)Convert.ToDouble(node.Attributes["recoil"].Value);
                float blast   = (float)Convert.ToDouble(node.Attributes["blast"].Value);

                GameObject weaponGameObject = Resources.Load("Prefabs/" + name) as GameObject;

                WeaponBasic weapon = new WeaponBasic()
                {
                    name   = name, type = type, Damage = damage, MagSize = magsize, BulletUsedPerShot = bulletusedpershot
                    , acc  = acc, dropoff = dropoff, speed = speed, recoil = recoil, rof = rof, maxammo = maxammo, nowammo = nowammo
                    , stun = stun, charge = charge, blast = blast, weapon = weaponGameObject
                };
                weapondictionary.Add(name, weapon);
            }
            return(weapondictionary);
        }
示例#4
0
 public void AddWeapon(WeaponBasic weapon)
 {
     weapon.BulletInMag = weapon.MagSize;
     this.WeaponSlot.Add(weapon);
 }