コード例 #1
0
    //装備のロード
    public void LoadEquipment(string type)
    {
        if (!PlayerPrefs.HasKey(type))
        {
            return;
        }

        if (type == "Weapon")
        {
            string             equipment_text     = PlayerPrefs.GetString(type);
            PlayerSwordControl playerSwordControl = ps.sword_collider.GetComponent <PlayerSwordControl>();
            playerSwordControl.sword_power = weapon_dic[equipment_text];

            //装備品に「極」などの文字が含まれていても識別できるような仕組み
            WeaponGetter weaponGetter = new WeaponGetter();
            var          ket_list     = weapon_dic.Keys.ToList();
            for (int i = 0; i < ket_list.Count; i++)
            {
                if (equipment_text.Contains(ket_list[i]))
                {
                    //ただの剣系統
                    if (i <= 8)
                    {
                        meshFilters.mesh       = sword_mesh[0];
                        MeshRenderers.material = sword_material[0];
                    }
                }
            }


            sword_power = weapon_dic[equipment_text];
            CanvasUpdate();
        }

        if (type == "Shield")
        {
            string equipment_text = PlayerPrefs.GetString(type);
            _def  = shirld_dic[equipment_text];

            //装備品に「極」などの文字が含まれていても識別できるような仕組み
            WeaponGetter weaponGetter = new WeaponGetter();
            var          key_list     = shirld_dic.Keys.ToList();
            for (int i = 0; i < key_list.Count; i++)
            {
                if (equipment_text.Contains(key_list[i]))
                {
                    //ただの剣系統
                    if (i <= 8)
                    {
                        meshFilters.mesh       = sword_mesh[0];
                        MeshRenderers.material = sword_material[0];
                    }
                }
            }


            _def = shirld_dic[equipment_text];
            CanvasUpdate();
        }
    }
コード例 #2
0
        public void ParseWeaponXml_PopulateAllXmlRelatedFields()
        {
            XmlDocument document = new XmlDocument();

            document.Load(@"DataAccess\TestData\ValidWeaponXml.xml");
            WeaponGetter weaponGetter = new WeaponGetter();
            MethodInfo   methodInfo   = typeof(WeaponGetter).GetMethod("ParseWeaponPropertiesXml", BindingFlags.NonPublic | BindingFlags.Instance);

            object[] parameters = { document };

            // Method under test
            Properties weaponProperties = new Properties();

            weaponProperties = (Properties)methodInfo.Invoke(weaponGetter, parameters);

            Assert.Equal("bullet_gen_s_plasma_01_mk1_macro", weaponProperties.Bullet.Class);
            Assert.Equal(10000, weaponProperties.Heat.Overheat);
            Assert.Equal(1.13, weaponProperties.Heat.CoolDelay);
            Assert.Equal(2000, weaponProperties.Heat.CoolRate);
            Assert.Equal(2000, weaponProperties.Heat.Reenable);
            Assert.Equal(47.4, weaponProperties.RotationSpeed.Max);
            Assert.Equal(23.7, weaponProperties.RotationAcceleration.Max);
            Assert.Equal(500, weaponProperties.Hull.Max);
            Assert.Equal(0, weaponProperties.Hull.Hittable);
        }
コード例 #3
0
        public void GenerateWeaponName_WeaponHasVersion02()
        {
            WeaponModel weapon = new WeaponModel {
                Faction = FactionType.BUC, Grade = WeaponSystemGrade.mk1, Name = "Some Weapon Name", Size = WeaponSystemSize.s, Type = WeaponSystemType.laser, Version = 2
            };
            WeaponGetter weaponGetter = new WeaponGetter();
            MethodInfo   methodInfo   = typeof(WeaponGetter).GetMethod("GenerateWeaponName", BindingFlags.NonPublic | BindingFlags.Instance);

            object[] parameters = { weapon };

            // Method under test
            string weaponName = (string)methodInfo.Invoke(weaponGetter, parameters);

            Assert.Equal("S BUC Laser Weapon Mk1 02", weaponName);
        }
コード例 #4
0
        public void ParseWeaponSubstring_FactionFound()
        {
            const string weaponSubstring = "arg";
            WeaponModel  weapon          = new WeaponModel();
            WeaponGetter weaponGetter    = new WeaponGetter();
            MethodInfo   methodInfo      = typeof(WeaponGetter).GetMethod("ParseWeaponSubstring", BindingFlags.NonPublic | BindingFlags.Instance);

            object[] parameters = { weapon, weaponSubstring };

            // Method under test
            weapon = (WeaponModel)methodInfo.Invoke(weaponGetter, parameters);

            Assert.Equal(FactionType.ARG, weapon.Faction);
            Assert.Null(weapon.Size);
            Assert.Null(weapon.Type);
            Assert.Null(weapon.Grade);
            Assert.Null(weapon.Version);
        }
コード例 #5
0
        public void ParseWeaponSubstring_VersionFound_AllOthersPreviouslyPopulated()
        {
            const string weaponSubstring = "01";
            WeaponGetter weaponGetter    = new WeaponGetter();
            WeaponModel  weapon          = new WeaponModel {
                Faction = FactionType.BUC, Grade = WeaponSystemGrade.mk3, Name = "Some Weapon Name", Size = WeaponSystemSize.xl, Type = WeaponSystemType.laser
            };
            MethodInfo methodInfo = typeof(WeaponGetter).GetMethod("ParseWeaponSubstring", BindingFlags.NonPublic | BindingFlags.Instance);

            object[] parameters = { weapon, weaponSubstring };

            // Method under test
            weapon = (WeaponModel)methodInfo.Invoke(weaponGetter, parameters);

            Assert.Equal(FactionType.BUC, weapon.Faction);
            Assert.Equal(WeaponSystemSize.xl, weapon.Size);
            Assert.Equal(WeaponSystemType.laser, weapon.Type);
            Assert.Equal(WeaponSystemGrade.mk3, weapon.Grade);
            Assert.Equal(1, weapon.Version);
        }
コード例 #6
0
        public void ParseWeaponSubstring_AllParsingFails()
        {
            const string weaponSubstring = "invalid string to parse";
            WeaponModel  weapon          = new WeaponModel();
            WeaponGetter weaponGetter    = new WeaponGetter();
            MethodInfo   methodInfo      = typeof(WeaponGetter).GetMethod("ParseWeaponSubstring", BindingFlags.NonPublic | BindingFlags.Instance);

            object[] parameters = { weapon, weaponSubstring };


            // Method under test
            void Action() => weapon = (WeaponModel)methodInfo.Invoke(weaponGetter, parameters);

            Exception exception = Assert.Throws <TargetInvocationException>(Action);

            Assert.Equal($"Failed to parse weapon substring \"{weaponSubstring}\"", exception.InnerException.Message);

            Assert.Null(weapon.Faction);
            Assert.Null(weapon.Size);
            Assert.Null(weapon.Type);
            Assert.Null(weapon.Grade);
            Assert.Null(weapon.Version);
        }