예제 #1
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();
        }
    }
예제 #2
0
    public void Init(FSClient client)
    {
        var map       = client.GetManager <RandomMapCreator>();
        var playerPos = Fixed2.zero;

        if (map)
        {
            playerPos = map.GetRandomPos();
        }
        else
        {
            playerPos = new Fixed2(client.random.Range(0, 20), client.random.Range(0, 20));
        }

        int count = GameUser.user.fightRoom.playerInfos.Count;

        for (int i = 0; i < count; i++)
        {
            var player = new PlayerData();
            player.Init(client, i);

            if (map != null)
            {
                player.transform.Position = playerPos + Fixed2.left * i.ToFixed();
            }
            else
            {
                player.transform.Position = new IDG.Fixed2(0, i);
            }

            client.objectManager.Instantiate(player);
        }

        for (int i = 0; i < m_nItemCount; i++)
        {
            ItemData item;
            if (i % 2 == 0)
            {
                var Titem = new SkillItem();
                item = Titem;
                Titem.Init(client);
                if (client.random.Range(0, 100) < 50)
                {
                    Titem.skillId = SkillId.拳击右直;
                }
                else
                {
                    Titem.skillId = SkillId.拳击左直;
                }
            }
            else
            {
                var Titem = new WeaponItem();
                item = Titem;
                Titem.Init(client);
                Titem.weaponId = WeaponId.F57;
            }

            if (map)
            {
                item.transform.Position = map.GetRandomPos();
            }
            else
            {
                item.transform.Position = new Fixed2(client.random.Range(0, 20), client.random.Range(0, 20));
            }
            client.objectManager.Instantiate(item);
        }

        for (int i = 0; i < enemy; i++)
        {
            var item = new ZombieData();
            item.Init(client);
            if (map)
            {
                item.transform.Position = map.GetRandomPos();
            }
            else
            {
                item.transform.Position = new Fixed2(client.random.Range(0, 20), client.random.Range(0, 20));
            }
            client.objectManager.Instantiate(item);
        }
    }