Esempio n. 1
0
    void OnWeaponToggleClick(GunConfig config)
    {
        if (mCurAvatar == null)
        {
            return;
        }

        Transform weaponPoint = CommonFunction.FindObject(mCurAvatar.transform, "Weapon");

        if (weaponPoint == null)
        {
            return;
        }

        foreach (Transform childs in weaponPoint)
        {
            Destroy(childs.gameObject);
        }

        GameObject prefab = Resources.Load(GameDefine.GunPrefabPrefix + config.GunPrefab) as GameObject;
        GameObject gun    = Object.Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;

        gun.transform.parent = weaponPoint;
        if (config.GunId == 1000)
        {
            gun.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
        }
        else
        {
            gun.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
        }
        gun.transform.localPosition = Vector3.zero;
        gun.transform.localRotation = Quaternion.identity;
    }
Esempio n. 2
0
 public void setConfig(GunConfig config)
 {
     data.bulletPrefab     = config.bulletPrefab;
     data.bulletPosX       = config.bulletPosX;
     data.bulletPosY       = config.bulletPosY;
     data.bulletShootForce = config.bulletShootForce;
 }
Esempio n. 3
0
 public static void Decode()
 {
     BulletConfig.DecodeTable(Resources.Load("config/Bullet") + "");
     GunConfig.DecodeTable(Resources.Load("config/Gun") + "");
     ItemConfig.DecodeTable(Resources.Load("config/Item") + "");
     PlayerConfig.DecodeTable(Resources.Load("config/Player") + "");
     BulletConfig.DecodeTableItem();
     GunConfig.DecodeTableItem();
     ItemConfig.DecodeTableItem();
     PlayerConfig.DecodeTableItem();
 }
Esempio n. 4
0
    public static void DecodeTable(string str)
    {
        str = StringUtils.Replace(str, '\r', '\n');
        str = StringUtils.Replace(str, "\n\n", '\n');
        List <List <string> > list = CSV.Parse(str);

        for (int i = 2, len = list.Count; i < len; i++)
        {
            GunConfig item = new GunConfig();
            item.Decode(list[i]);
            Configs.Add(item);
        }
    }
Esempio n. 5
0
 public void DecodeConfigItem()
 {
     for (int i = 0; i < list.Count; i++)
     {
         if (i == 1)
         {
             BornItem = ItemConfig.GetConfig(Id);
         }
         if (i == 2)
         {
             BornGun = GunConfig.GetConfig(Id);
         }
     }
     list = null;
 }
Esempio n. 6
0
    private void Awake()
    {
        Instance = this;
        //模拟第一种角色
        RoleConfig role = new RoleConfig();

        role.id        = 1;
        role.prefabURL = "prefab/player";
        roles.Add(role.id, role);

        //模拟第一种子弹
        BulletConfig bullet = new BulletConfig();

        bullet.id            = 1;
        bullet.prefabURL     = "bullet/FireBullet";
        bullet.hitPrefabURL  = "bullet/HitAnimation";
        bullet.startV        = 5f;
        bullet.rotationRange = 10;
        bullets.Add(bullet.id, bullet);

        //模拟第二种子弹
        bullet               = new BulletConfig();
        bullet.id            = 2;
        bullet.prefabURL     = "bullet/FireBullet";
        bullet.hitPrefabURL  = "bullet/HitAnimation";
        bullet.startV        = 1f;
        bullet.rotationRange = 20;
        bullets.Add(bullet.id, bullet);

        //模拟第一种枪
        GunConfig gun = new GunConfig();

        gun.id          = 1;
        gun.prefabURL   = "gun/Gun";
        gun.bulletId    = 1;
        gun.cd          = 100;
        gun.bulletCount = 1;
        guns.Add(gun.id, gun);

        //模拟第二种枪
        gun             = new GunConfig();
        gun.id          = 2;
        gun.prefabURL   = "gun/Gun";
        gun.bulletId    = 2;
        gun.cd          = 50;
        gun.bulletCount = 1;
        guns.Add(gun.id, gun);
    }
Esempio n. 7
0
        public void Init(GridLayoutGroup grid, ToggleGroup group, GunConfig config)
        {
            GameObject prefab = (GameObject)Resources.Load(GameDefine.WeaponTypeTemplatePath);
            GameObject weapon = (GameObject)Object.Instantiate(prefab, Vector3.zero, Quaternion.identity);

            weapon.transform.SetParent(grid.transform);
            weapon.transform.localPosition = Vector3.zero;
            weapon.transform.localRotation = Quaternion.identity;
            weapon.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);

            weapon.GetComponent <Toggle>().group = group;
            weapon.transform.Find("icon").GetComponent <Image>().sprite =
                (Sprite)Resources.Load(GameDefine.GunIconPathPrefix + config.Icon, typeof(Sprite));

            UIEventListener.Get(weapon).onClick += OnClick;

            mConfig = config;
            mGo     = weapon;
        }
Esempio n. 8
0
    void SelectWeapon()
    {
        GunConfigMgr gunmgr = ResourceManager.Instance.ConfigManager.Gun;

        if (gunmgr == null)
        {
            return;
        }

        for (int i = 0; i < mWeaponList.Count; i++)
        {
            Destroy(mWeaponList[i].mGo);
        }
        mWeaponList.Clear();

        for (int i = 0; i < gunmgr.Count; i++)
        {
            GunConfig config = (GunConfig)gunmgr.Value(i);
            if (config == null)
            {
                continue;
            }

            if (mCurAvatarType == config.UserType)
            {
                WeaponItem item = new WeaponItem();
                item.Init(mWeaponGrid, mWeaponTogGroup, config);
                item.mWeaponClickEvent += OnWeaponToggleClick;
                mWeaponList.Add(item);
            }
        }

        if (mWeaponList.Count > 0)
        {
            mWeaponList[0].Selected();
        }
    }
Esempio n. 9
0
 public Gun(GunConfig config)
 {
     m_config = config;
 }
Esempio n. 10
0
            public void UpdateGuns()
            {
                if (player == null)
                {
                    return;
                }
                int     mainGunValue    = -1;
                Item    mainGun         = null;
                int     holsterGunValue = -1;
                Item    holsterGun      = null;
                Vector3 offset          = Vector3.zero;

                //Gets offset based on items worn
                foreach (Item item in player.inventory.containerWear.itemList)
                {
                    if (armourOffsetValues.ContainsKey(item.info.shortname))
                    {
                        offset = armourOffsetValues[item.info.shortname];
                        break;
                    }
                    if (shirtOffsetValues.ContainsKey(item.info.shortname))
                    {
                        offset = shirtOffsetValues[item.info.shortname];
                    }
                }

                //Checks hotbar for weapons
                foreach (Item item in player.inventory.containerBelt.itemList)
                {
                    if (/*item.info.shortname != this.mainGun*/ item.info.shortname != activeItem?.info.shortname)
                    {
                        if (gunSettings_main.ContainsKey(item.info.shortname))
                        {
                            if (mainGunValue < gunSettings_main[item.info.shortname].priority)
                            {
                                mainGunValue = gunSettings_main[item.info.shortname].priority;
                                mainGun      = item;
                            }
                        }
                    }
                    if (/*item.info.shortname != this.holsterGun*/ item.info.shortname != activeItem?.info.shortname)
                    {
                        if (gunSettings_holster.ContainsKey(item.info.shortname))
                        {
                            if (holsterGunValue < gunSettings_holster[item.info.shortname].priority)
                            {
                                holsterGunValue = gunSettings_holster[item.info.shortname].priority;
                                holsterGun      = item;
                            }
                        }
                    }
                }

                //Make sure same function as above, Checks inventory
                if (WeaponsOnBack.displayMode == 1)
                {
                    foreach (Item item in player.inventory.containerMain.itemList)
                    {
                        if (/*item.info.shortname != this.mainGun*/ item.info.shortname != activeItem?.info.shortname)
                        {
                            if (gunSettings_main.ContainsKey(item.info.shortname))
                            {
                                if (mainGunValue < gunSettings_main[item.info.shortname].priority)
                                {
                                    mainGunValue = gunSettings_main[item.info.shortname].priority;
                                    mainGun      = item;
                                }
                            }
                        }
                        if (/*item.info.shortname != this.holsterGun*/ item.info.shortname != activeItem?.info.shortname)
                        {
                            if (gunSettings_holster.ContainsKey(item.info.shortname))
                            {
                                if (holsterGunValue < gunSettings_holster[item.info.shortname].priority)
                                {
                                    holsterGunValue = gunSettings_holster[item.info.shortname].priority;
                                    holsterGun      = item;
                                }
                            }
                        }
                    }
                }

                //Spawns guns on back of player
                if (mainGun != null)
                {
                    if (mainGun.info.shortname != this.mainGun)
                    {
                        GunConfig settings = gunSettings_main[mainGun.info.shortname];
                        this.mainGun = mainGun.info.shortname;
                        DestroyWeapon(mainWeapon);
                        mainWeapon = SpawnEntity(settings.prefabName, settings.localPosition_slot1 + offset, settings.localRotation_slot1, player, mainGun.skin);
                    }
                }
                else
                {
                    DestroyWeapon(mainWeapon);
                    this.mainGun = "";
                }

                if (holsterGun != null)
                {
                    if (holsterGun.info.shortname != this.holsterGun)
                    {
                        GunConfig settings = gunSettings_holster[holsterGun.info.shortname];
                        this.holsterGun = holsterGun.info.shortname;
                        if (sideWeapon != null)
                        {
                            DestroyWeapon(sideWeapon);
                        }
                        sideWeapon = SpawnEntity(settings.prefabName, settings.localPosition_slot1, settings.localRotation_slot1, player, holsterGun.skin);
                    }
                }
                else
                {
                    DestroyWeapon(sideWeapon);
                    this.holsterGun = "";
                }
            }
Esempio n. 11
0
 private void Awake()
 {
     gScript = this.GetComponent <GunConfig>();
     getConfigVariables();
 }