示例#1
0
        void OnFishBobblerInWaterPacketReceived(Packet.FishBobblerInWater fw, NetPeer peer)
        {
            var fwCopy = fw.Copy();

            try
            {
                ValidatePacket(fwCopy);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(String.Format("Failed to validate packet in OnFishBobblerInWaterPacketReceived from {0}: {1}", peer.EndPoint, ex.ToString()));
                return;
            }
            var p = _connectedPlayers[fwCopy.userName];

            DelayedEvent fishBitingEvent = new DelayedEvent(() =>  // This delayed event is cancelled if AbortFishing is called.
            {
                p.FishBiting();
                SendToAllPlayers(this.Write(new Packet.FishBiting {
                    userName = p._userName
                }));
            });

            p.BobblerInWater(fishBitingEvent, ZonesSchema.ZoneHelper.GetZone(fwCopy.zone));
            Random rnd         = new Random();
            int    waitSeconds = rnd.Next(3, 15);

            AddDelayedEvent(fishBitingEvent, waitSeconds * GameTime.SECOND);
        }
示例#2
0
 void AddDelayedEvent(DelayedEvent e, long executionDelay)
 {
     e.ExecuteAt = GameTime.Instance().TickStartTime() + executionDelay;
     _delayedEvents.Add(e);
 }
示例#3
0
 public void BobblerInWater(DelayedEvent e, ZonesSchema.Zone zone)
 {
     _stateMachine.Fire(Trigger.BobblerInWater);
     fishingState.fishBitingEventRef = e;
     fishingState.zone = zone;
 }