コード例 #1
0
 private void InstantiateCursorSlot(SlotColor color)
 {
     cursorSlot = Instantiate(CursorSlot, this.transform).GetComponent <Slot>();
     cursorSlot.transform.SetAsFirstSibling();
     cursorSlot.name = "CursorSlot";
     cursorSlot.SetSlotColor(color);
 }
コード例 #2
0
ファイル: Slot.cs プロジェクト: EdwinHeuver/4-op-een-rij
    public void SetSlotColor(SlotColor playerColor)
    {
        switch (playerColor)
        {
        case SlotColor.Empty:
            SlotBackground.color = EmptySlotColor;
            SlotBackground.gameObject.SetActive(false);
            slotColor = SlotColor.Empty;
            break;

        case SlotColor.Red:
            SlotBackground.color = RedSlotColor;
            SlotBackground.gameObject.SetActive(true);
            slotColor = SlotColor.Red;
            break;

        case SlotColor.Green:
            SlotBackground.color = GreenSlotColor;
            SlotBackground.gameObject.SetActive(true);
            slotColor = SlotColor.Green;
            break;

        default:
            break;
        }
    }
コード例 #3
0
        /// <summary>
        /// Sets the team of the player
        /// </summary>
        /// <param name="player">Player to change team for</param>
        /// <param name="color">Team to change to</param>
        public void SetTeam(string player, SlotColor color)
        {
            if (string.IsNullOrEmpty(player))
            {
                throw new ArgumentNullException(nameof(player));
            }

            SendCommand(MPCommand.Team, player, color.ToString().ToLower(CultureInfo.CurrentCulture));
        }
コード例 #4
0
    public void ChangeSlotColor(Slot slotToUpdate, SlotColor color)
    {
        if (!CanSlotColorBeChanged(slotToUpdate))
        {
            return;
        }

        slotToUpdate.SetSlotColor(color);
    }
コード例 #5
0
    int CountSlotsAllStages(SlotColor color, SlotShape shape)
    {
        int count = 0;

        for (int i = 0; i <= mPreviousSlots.Count - 2; i++)
        {
            count += mPreviousSlots[i].Count(s => s.color == color && s.shape == shape);
        }
        return(count);
    }
コード例 #6
0
 public static void UpdatePlayersTurn()
 {
     if (currentPlayersTurn == SlotColor.Red)
     {
         currentPlayersTurn = SlotColor.Green;
     }
     else
     {
         currentPlayersTurn = SlotColor.Red;
     }
 }
コード例 #7
0
ファイル: Slot.cs プロジェクト: Blade12629/Skybot
        public void Swap(Slot other)
        {
            bool          isReady    = other.IsReady;
            Uri           profileUrl = other.ProfileUrl;
            string        nick       = other.Nickname;
            SlotColor     color      = other.Color;
            string        role       = other.Role;
            List <string> mods       = other.Mods.ToList();

            Move(other);

            IsReady    = isReady;
            ProfileUrl = profileUrl;
            Nickname   = nick;
            Color      = color;
            Role       = role;
            Mods       = mods.ToList();
        }
コード例 #8
0
            public override bool Invoke(ChatMessage message)
            {
                if (!message.From.Equals("banchobot", StringComparison.CurrentCultureIgnoreCase) ||
                    !message.Message.Contains("joined in slot", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(false);
                }

                int    index = message.Message.IndexOf(" joined in slot", StringComparison.CurrentCultureIgnoreCase);
                string user  = message.Message.Substring(0, index);

                string msg = message.Message.Remove(0, index + "joined in slot".Length + 2);

                index = msg.IndexOf(' ', StringComparison.CurrentCultureIgnoreCase);

                int slot;

                if (index == -1)
                {
                    slot = int.Parse(msg.Remove(msg.Length - 1), CultureInfo.CurrentCulture);
                    _lc.DataHandler.OnUserJoinLobby(user, slot, SlotColor.None);
                    return(true);
                }

                slot = int.Parse(msg.Substring(0, index), CultureInfo.CurrentCulture);

                index = msg.LastIndexOf(' ');
                msg   = msg.Remove(0, index + 1).TrimEnd('.');

                if (char.IsLower(msg[0]))
                {
                    msg = char.ToUpper(msg[0]) + msg.Remove(0, 1);
                }

                SlotColor color = Enum.Parse <SlotColor>(msg);

                _lc.DataHandler.OnUserJoinLobby(user, slot, color);

                return(true);
            }
コード例 #9
0
ファイル: Slot.cs プロジェクト: EdwinHeuver/4-op-een-rij
 public void Initialize(Vector2Int slotCoordinate)
 {
     this.slotCoordinate = slotCoordinate;
     this.slotColor      = SlotColor.Empty;
 }
コード例 #10
0
            public override bool Invoke(ChatMessage message)
            {
                if (!message.From.Equals("banchobot", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(false);
                }

                string line = message.Message;

                if (line.StartsWith(_SLOT, StringComparison.CurrentCultureIgnoreCase))
                {
                    line = line.Remove(0, _SLOT.Length).TrimStart(' ');

                    int slotId       = 0;
                    int slotIdLength = 1;

                    if (char.IsNumber(line[1]))
                    {
                        slotIdLength = 2;
                    }

                    slotId = int.Parse(line.Substring(0, slotIdLength), CultureInfo.CurrentCulture);
                    line   = line.Remove(0, slotIdLength).TrimStart(' ');

                    bool isReady = false;
                    if (line.StartsWith(_READY, StringComparison.CurrentCultureIgnoreCase))
                    {
                        isReady = true;
                        line    = line.Remove(0, _READY.Length).TrimStart(' ');
                    }
                    else
                    {
                        line = line.Remove(0, _NOT_READY.Length).TrimStart(' ');
                    }

                    int    index      = line.IndexOf(' ', StringComparison.CurrentCultureIgnoreCase);
                    string profileUrl = line.Substring(0, index);
                    line = line.Remove(0, index + 1);

                    index = line.IndexOf(' ', StringComparison.CurrentCultureIgnoreCase);
                    string nickname = line.Substring(0, index).Replace(' ', '_');
                    line = line.Remove(0, index).TrimStart(' ');

                    index = line.IndexOf('[', StringComparison.CurrentCultureIgnoreCase);

                    SlotColor     color = SlotColor.None;
                    string        role  = null;
                    List <string> mods  = new List <string>();
                    if (index > -1)
                    {
                        line = line.Remove(0, index + 1);
                        if (line.StartsWith(_TEAM_BLUE, StringComparison.CurrentCultureIgnoreCase))
                        {
                            color = SlotColor.Blue;
                            line  = line.Remove(0, _TEAM_BLUE.Length);
                        }
                        else if (line.StartsWith(_TEAM_RED, StringComparison.CurrentCultureIgnoreCase))
                        {
                            color = SlotColor.Red;
                            line  = line.Remove(0, _TEAM_RED.Length);
                        }

                        if (line.StartsWith(_SPLITTER, StringComparison.CurrentCultureIgnoreCase))
                        {
                            line = line.Remove(0, _SPLITTER.Length);
                        }

                        if (line.StartsWith(_HOST_ROLE, StringComparison.CurrentCultureIgnoreCase))
                        {
                            role = _HOST_ROLE;
                            line = line.Remove(0, _HOST_ROLE.Length);
                        }

                        if (line.StartsWith(_SPLITTER, StringComparison.CurrentCultureIgnoreCase))
                        {
                            line = line.Remove(0, _SPLITTER.Length);
                        }

                        string[] split;
                        if (line.Contains(',', StringComparison.CurrentCultureIgnoreCase))
                        {
                            split = line.TrimEnd(']').Split(',');
                        }
                        else
                        {
                            split = new string[1] {
                                line.TrimEnd(']')
                            }
                        };

                        mods.AddRange(split);
                    }

                    Slot slot = (Slot)_lc.DataHandler.GetSlot(slotId);
                    slot.Reset();

                    slot.IsReady    = isReady;
                    slot.ProfileUrl = new Uri(profileUrl);
                    slot.Nickname   = nickname;
                    slot.Role       = role;
                    slot.Color      = color;

                    if (mods.Count > 0)
                    {
                        slot.Mods.AddRange(mods);
                    }

                    _lc.DataHandler.OnSlotUpdate(slot);

                    return(true);
                }

                for (int i = 0; i < 2; i++)
                {
                    var pair = _settingParsers.FirstOrDefault(p => line.StartsWith(p.Key, StringComparison.CurrentCultureIgnoreCase));

                    if (pair.Key == null || pair.Value == null)
                    {
                        if (i == 1)
                        {
                            return(true);
                        }

                        return(false);
                    }

                    string value = TryParseSetting(ref line, pair.Key);
                    line = line.TrimStart(' ');

                    if (value == null)
                    {
                        if (i == 1)
                        {
                            return(true);
                        }

                        return(false);
                    }

                    pair.Value(value);
                }

                return(true);
            }
コード例 #11
0
 public Slot(SlotShape shape, SlotColor color, float position)
 {
     this.shape    = shape;
     this.color    = color;
     this.position = position;
 }