コード例 #1
0
        private void UpdateLockedEntity()
        {
            if (IsPlayerLocked)
            {
                try
                {
                    var player = Galaxy.GetPlayer(LockedPlayerId);
                    if (player != null && player.Unit != null)
                    {
                        ViewModel.LPilotedUnit = player.Unit;
                        return;
                    }
                }
                catch (Exception ex)
                {
                    l.Error(ex.ToString());
                }

                Task.Factory.StartNew(() =>
                {
                    Thread.Sleep(3000);
                    LockOnAnyPlayer(); // TEMP
                });
            }
        }
コード例 #2
0
 private bool LockOnAnyPlayer()
 {
     for (sbyte i = 0; i < 16; i++)
     {
         try
         {
             Player player = Galaxy.GetPlayer(i);
             if (player.Team == MyTeam && player.Status == PlayerStatus.Alive)
             {
                 TryPlayerLock(i);
                 return(true);
             }
         }
         catch (Exception ex)
         {
             l.Warn("LockOnAnyPlayer(): " + ex.ToString());
             continue;
         }
     }
     l.Warn("LockOnAnyPlayer(): failed to lock on");
     return(false);
 }
コード例 #3
0
        private void Handle(mesg_spacket msg)
        {
            lMessage.Debug(msg.ToString());

            if (!msg.Flags.HasFlag(MessageFlags.MVALID))
            {
                l.Warn("UNEXPECTED: Got message without MVALID bit set");
                return;
            }

            Message message = new Message()
            {
                Text = msg.Message,
            };

            if (msg.Flags.HasFlag(MessageFlags.MGOD))
            {
                Player player = Galaxy.GetPlayer(msg.from);
                message.Source = "GOD";
            }
            else
            {
                if (msg.from == 255)
                {
                    message.Source = "GOD";
                }
                else
                {
                    Player player = Galaxy.GetPlayer(msg.from);
                    message.Source = player.SlotName;
                }
            }


            if (msg.Flags.HasFlag(MessageFlags.MINDIV))
            {
                Player player = Galaxy.GetPlayer(msg.recipient);
                if (player != null)
                {
                    message.Recipient = player.SlotNameAndName;
                }
            }
            else if (msg.Flags.HasFlag(MessageFlags.MTEAM))
            {
                NetrekTeam team = (NetrekTeam)msg.recipient;
                if (Enum.IsDefined(typeof(NetrekTeam), team))
                {
                    message.Recipient = team.ToShortName();
                }
                else
                {
                    l.Warn("!Enum.IsDefined(team)");
                }

                //Player player = Galaxy.(msg.recipient);
                //if (player != null)
                //{
                //    message.Recipient = player.SlotNameAndName;
                //}
            }
            else if (msg.Flags.HasFlag(MessageFlags.MALL))
            {
                message.Recipient = "ALL";
            }

            Bridge.MessengerServer.Send(message);
        }