Exemplo n.º 1
0
 public static WeaponFactory GetInstance()
 {
     if (instance == null)
     {
         instance = new WeaponFactory();
     }
     return(instance);
 }
Exemplo n.º 2
0
        public void InitWeapons()
        {
            if (!weaponsInited)
            {
                Debug.Log("Init Weapons");
                weaponList.Clear();

                for (int i = 0; i < rectToWeaponMap.Length; i++)
                {
                    rectToWeaponMap[i] = -1;
                }

                //! 武器列表
                List <WeaponConfig> wConfList = gConfig.GetWeapons();

                foreach (WeaponConfig wConf in wConfList)
                {
                    string weaponName = wConf.name;
                    Weapon weapon     = WeaponFactory.GetInstance().CreateWeapon(wConf.wType);
                    if (wConf.name == GunName.MP5)
                    {
                        weapon.IsSelectedForBattle = true;
                        rectToWeaponMap[0]         = GetWeaponIndex(weapon);
                    }

                    if (wConf.name == GunName.SAW)
                    {
                        weapon.IsSelectedForBattle = true;
                        rectToWeaponMap[1]         = 8;
                    }

                    weapon.Exist = wConf.startEquip;

                    weapon.Name  = weaponName;
                    weapon.WConf = wConf;
                    weapon.LoadConfig();
                    weaponList.Add(weapon);
                }

                weaponsInited = true;
            }
        }
Exemplo n.º 3
0
        public void LoadData(BinaryReader br)
        {
            Debug.Log("Load");

            if (!inited)
            {
                Init();
            }

            weaponsInited = true;

            cash = br.ReadInt32();

            score = br.ReadInt32();

            LevelNum = br.ReadInt32();

            weaponList = new List <Weapon>();

            int count = br.ReadInt32();


            for (int i = 0; i < count; i++)
            {
                int    weaponType = br.ReadInt32();
                Weapon weapon     = WeaponFactory.GetInstance().CreateWeapon((WeaponType)weaponType);

                weapon.Name  = br.ReadString();
                weapon.WConf = gConfig.GetWeaponConfig(weapon.Name);
                weapon.LoadConfig();



                weapon.BulletCount         = br.ReadInt32();
                weapon.Damage              = (float)br.ReadDouble();
                weapon.AttackFrequency     = (float)br.ReadDouble();
                weapon.Accuracy            = (float)br.ReadDouble();
                weapon.DamageLevel         = br.ReadInt32();
                weapon.FrequencyLevel      = br.ReadInt32();
                weapon.AccuracyLevel       = br.ReadInt32();
                weapon.IsSelectedForBattle = br.ReadBoolean();
                weapon.Exist = (WeaponExistState)br.ReadInt32();



                weaponList.Add(weapon);
            }


            for (int i = 0; i < rectToWeaponMap.Length; i++)
            {
                rectToWeaponMap[i] = br.ReadInt32();
            }

            for (int i = 0; i < avatarData.Length; i++)
            {
                avatarData[i] = (AvatarState)br.ReadInt32();
            }
            Avatar        = (AvatarType)br.ReadInt32();
            ArmorLevel    = br.ReadInt32();
            FirstTimeGame = br.ReadBoolean();
            Achievement.Load(br);
        }