コード例 #1
0
        private void Indicator_RightClick(object sender, EventArgs e)
        {
            var indicator = (PlayerLocationIndicator)sender;

            if (!EnableContextMenu)
            {
                PlayerInfo pInfo = players.Find(p => p.Name == ProgramConstants.PLAYERNAME);

                if (pInfo.StartingLocation == (int)indicator.Tag + 1)
                {
                    LocalStartingLocationSelected?.Invoke(this, new LocalStartingLocationEventArgs(0));
                }

                return;
            }

            foreach (PlayerInfo pInfo in players.Union(aiPlayers))
            {
                if (pInfo.StartingLocation == (int)indicator.Tag + 1)
                {
                    pInfo.StartingLocation = 0;
                }
            }

            StartingLocationApplied?.Invoke(this, EventArgs.Empty);
        }
コード例 #2
0
        private void ContextMenu_OptionSelected(object sender, ContextMenuOptionEventArgs e)
        {
            if (sndDropdownSound != null)
            {
                AudioMaster.PlaySound(sndDropdownSound);
            }

            if (Map.EnforceMaxPlayers)
            {
                foreach (PlayerInfo pInfo in players.Concat(aiPlayers))
                {
                    if (pInfo.StartingLocation == (int)contextMenu.Tag + 1)
                    {
                        pInfo.StartingLocation = 0;
                    }
                }
            }

            PlayerInfo player;

            if (e.Index >= players.Count)
            {
                int aiIndex = e.Index - players.Count;
                if (aiIndex >= aiPlayers.Count)
                {
                    return;
                }

                player = aiPlayers[aiIndex];
            }
            else
            {
                player = players[e.Index];
            }

            player.StartingLocation = (int)contextMenu.Tag + 1;

            StartingLocationApplied?.Invoke(this, EventArgs.Empty);
        }
コード例 #3
0
        private void ContextMenu_OptionSelected(int index)
        {
            SoundPlayer.Play(sndDropdownSound);

            if (Map.EnforceMaxPlayers)
            {
                foreach (PlayerInfo pInfo in players.Concat(aiPlayers))
                {
                    if (pInfo.StartingLocation == (int)contextMenu.Tag + 1)
                    {
                        pInfo.StartingLocation = 0;
                    }
                }
            }

            PlayerInfo player;

            if (index >= players.Count)
            {
                int aiIndex = index - players.Count;
                if (aiIndex >= aiPlayers.Count)
                {
                    return;
                }

                player = aiPlayers[aiIndex];
            }
            else
            {
                player = players[index];
            }

            player.StartingLocation = (int)contextMenu.Tag + 1;

            StartingLocationApplied?.Invoke(this, EventArgs.Empty);
        }