Exemple #1
0
    private void AutoReady(SelectModel sm)
    {
        if (myRoom == null)
        {
            return;
        }

        if (myRoom.inTeam(sm.userId) == 1)
        {
            foreach (SelectModel item in myRoom.teamOne)
            {
                if (item.userId == sm.userId)
                {
                    item.heroId = sm.heroId;
                    item.ready  = sm.ready;
                }
            }
        }
        else
        {
            foreach (SelectModel item in myRoom.teamTwo)
            {
                if (item.userId == sm.userId)
                {
                    item.heroId = sm.heroId;
                    item.ready  = sm.ready;
                }
            }
        }

        FindObjectOfType <SelectScreen>().refreshHeroList(myRoom);
    }
Exemple #2
0
    void refreshView(SelectRoomDTO dto)
    {
        int team = dto.inTeam(GameData.user.id);

        if (team == 1)
        {
            for (int i = 0; i < dto.teamOne.Length; i++)
            {
                left[i].setData(dto.teamOne[i]);
            }
            for (int i = 0; i < dto.teamTwo.Length; i++)
            {
                right[i].setData(dto.teamTwo[i]);
            }
        }
        else if (team == 2)
        {
            for (int i = 0; i < dto.teamOne.Length; i++)
            {
                right[i].setData(dto.teamOne[i]);
            }
            for (int i = 0; i < dto.teamTwo.Length; i++)
            {
                left[i].setData(dto.teamTwo[i]);
            }
        }
        refreshHeroList(dto);
    }
Exemple #3
0
    public void clickStart()
    {
        int team = room.inTeam(GameData.user.id);

        SelectModel[] sm;
        if (team == 1)
        {
            sm = room.teamOne;
        }
        else
        {
            sm = room.teamTwo;
        }
        List <int> last       = new List <int>();
        bool       mySelected = false;

        foreach (SelectModel item in sm)
        {
            if (item.heroId != -1)
            {
                if (item.userId == GameData.user.id)
                {
                    mySelected = true;
                    break;
                }
                last.Add(item.heroId);
            }
        }
        if (!mySelected)
        {
            List <int> temp = new List <int>();
            foreach (int item in GameData.user.heroList)
            {
                if (last.Contains(item))
                {
                    continue;
                }
                temp.Add(item);
            }
            //NetWorkScript.Instance.write(Protocol.TYPE_SELECT, 0, SelectProtocol.SELECT_CREQ, temp[Random.Range(0, temp.Count - 1)]);
            NetWorkScript.Instance.write(Protocol.TYPE_SELECT, 0, SelectProtocol.SELECT_CREQ, 1);
        }

        NetWorkScript.Instance.write(Protocol.TYPE_SELECT, 0, SelectProtocol.READY_CREQ, null);
    }
Exemple #4
0
    public void refreshHeroList(SelectRoomDTO dto)
    {
        room = dto;
        int        team     = dto.inTeam(GameData.user.id);
        List <int> selected = new List <int>();

        if (team == 1)
        {
            for (int i = 0; i < dto.teamOne.Length; i++)
            {
                if (dto.teamOne[i].heroId != -1)
                {
                    selected.Add(dto.teamOne[i].heroId);
                }
            }
        }
        else
        {
            for (int i = 0; i < dto.teamTwo.Length; i++)
            {
                if (dto.teamTwo[i].heroId != -1)
                {
                    selected.Add(dto.teamTwo[i].heroId);
                }
            }
        }
        foreach (int item in myGrid.Keys)
        {
            if (selected.Contains(item) || !startBtn.enabled)
            {
                myGrid[item].deactive();
            }
            else
            {
                myGrid[item].active();
            }
        }
    }