Esempio n. 1
0
 public void Move(MoveType direction)
 {
     if (previousLocation != null && game.Location != null && game.Location.x == previousLocation.x && game.Location.y == previousLocation.y)
     {
         ConsoleDebug.Error("Snake time! =====================================");
         //if (direction==MoveType.up)
         //    direction=MoveType.right;
         //else if (direction == MoveType.right)
         //    direction = MoveType.down;
         //else if (direction == MoveType.down)
         //    direction = MoveType.left;
         //else
         //    direction = MoveType.up;
         direction = RandomMoveType();
     }
     previousLocation = new Common.Schema.Location() { x = game.Location.x, y = game.Location.y };
     Move m = new Move()
     {
         direction = direction,
         directionSpecified = true,
         gameId = game.GameId,
         playerGuid = game.Guid
     };
     Send(XmlMessageConverter.ToXml(m));
 }
Esempio n. 2
0
        private void Game_ProcessSpell(Obj_AI_Base hero, GameObjectProcessSpellCastEventArgs args)
        {
            ConsoleDebug.WriteLine(string.Format("'{0}' casted Spell: {1}", hero.Name, args.SData.Name));
            try
            {
                SpellData spellData;
                if (args.SData.ShouldEvade(hero, out spellData))
                {
                    if (!spellData.UsePackets)
                    {
                        var specialSpellArgs = new SpecialSpellEventArgs();
                        if (OnProcessSpecialSpell != null)
                        {
                            OnProcessSpecialSpell(hero, args, spellData, specialSpellArgs);
                        }

                        if (specialSpellArgs.NoProcess == false && spellData.NoProcess == false)
                        {
                            CreateSpellData(hero, hero.ServerPosition, args.End, spellData, null);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ConsoleDebug.WriteLine(e);
            }
        }
Esempio n. 3
0
        public static PositionInfo SetAllUndodgeable()
        {
            ConsoleDebug.WriteLineColor("Setting all Undodgeable", ConsoleColor.Red);
            List <int> dodgeableSpells   = new List <int>();
            List <int> undodgeableSpells = new List <int>();

            var posDangerLevel = 0;
            var posDangerCount = 0;

            foreach (KeyValuePair <int, Spell> entry in SpellDetector.Spells)
            {
                Spell spell = entry.Value;
                undodgeableSpells.Add(entry.Key);

                var spellDangerLevel = spell.Dangerlevel;

                posDangerLevel  = Math.Max(posDangerLevel, (int)spellDangerLevel);
                posDangerCount += (int)spellDangerLevel;
            }

            return(new PositionInfo(
                       MyHero.Position.To2D(),
                       posDangerLevel,
                       posDangerCount,
                       true,
                       0,
                       dodgeableSpells,
                       undodgeableSpells));
        }
Esempio n. 4
0
 public void HandleMessage(RegisteredGames message)
 {
     if (message.GameInfo == null || message.GameInfo.Length == 0 || !message.GameInfo.Where(g => g.gameName == Player.Options.GameName).Any())
     {
         Task.Run(() =>
         {
             Thread.Sleep((int)Player.Settings.RetryJoinGameInterval);
             string xmlMessage = XmlMessageConverter.ToXml(new GetGames());
             Player.Send(xmlMessage);
         });
     }
     else
     {
         ConsoleDebug.Good("Games available");
         if (Player.Options.GameName == null)
         {
             ConsoleDebug.Warning("Game name not specified");
             return;
         }
         if (message.GameInfo.Count(info => info.gameName == Player.Options.GameName) == 1)
         {
             string xmlMessage = XmlMessageConverter.ToXml(new JoinGame()
             {
                 gameName = Player.Options.GameName,
                 playerIdSpecified = false,
                 preferredRole = Player.Options?.PreferredRole == "player" ? PlayerType.member : PlayerType.leader,
                 preferredTeam = Player.Options?.PreferredTeam == "red" ? Common.Schema.TeamColour.red : Common.Schema.TeamColour.blue
             });
             Player.Send(xmlMessage);
         }
     }
 }
        private void OnDisconnect(object sender, ConnectEventArgs e)
        {
            RegisteredGames.RemoveGameMastersGames(e.Handler);


            // if it was a player, tell gm about it
            try
            {
                ulong playerId = Clients.First(pair => pair.Value == e.Handler).Key;
                ConsoleDebug.Message($"ID: {playerId}");



                IEnumerable <IGame> abandonedGames = RegisteredGames
                                                     .Where(game => game.Players.Any(player => player.Id == playerId));
                foreach (var game in abandonedGames)
                {
                    ConsoleDebug.Message($"Informing game master of game {game.Id} about disconnected player, id: {playerId}");
                    InformGameMasterAboutDisconnectedPlayer(game.GameMaster, playerId);

                    // remove player id occurrence
                    game.Players.Remove(game.Players.First(player => playerId == player.Id));
                }
            }
            catch (Exception exception)
            {
                // ignore: it was not a player
                Console.WriteLine(exception);
            }
        }
        public void PlaceNewPiece(Wrapper.TaskField field)
        {
            var pieceType = rng.NextDouble() < GameMasterClient.Settings.GameDefinition.ShamProbability
                ? PieceType.sham
                : PieceType.normal;

            lock (BoardLock)
            {
                var newPiece = new Wrapper.Piece((ulong)Pieces.Count, pieceType, DateTime.Now);
                newPiece.Id = pieceid++;
                if (field == null)
                {
                    ConsoleDebug.Warning("There are no empty places for a new Piece!");
                    return; //TODO BUSYWAITING HERE probably
                }
                //remove old piece
                if (field.PieceId != null)
                {
                    var oldPiece = Pieces.Where(p => p.Id == field.PieceId.Value).Single();
                    Pieces.Remove(oldPiece);
                }
                field.PieceId     = newPiece.Id;
                newPiece.Location = new Location()
                {
                    x = field.X, y = field.Y
                };
                Pieces.Add(newPiece);
                Board.UpdateDistanceToPiece(Pieces);
                ConsoleDebug.Good($"Placed new Piece at: ({field.X}, {field.Y})");
            }
            //BoardPrinter.Print(Board);
        }
        private void OnMessage(object sender, MessageRecieveEventArgs eventArgs)
        {
            var address = eventArgs.Handler.GetRemoteAddress();

            if (address != null)
            {
                Console.WriteLine("New message from {0}: {1}", address, eventArgs.Message);
            }

            try
            {
                if (eventArgs.Message.Length == 0) //ETB keep alive packet
                {
                    //send keep alive back
                    ConnectionEndpoint.SendFromServer(eventArgs.Handler, String.Empty);
                }
                else
                {
                    BehaviorChooser.HandleMessage((dynamic)XmlMessageConverter.ToObject(eventArgs.Message), this,
                                                  eventArgs.Handler);
                }
            }
            catch (Exception e)
            {
                ConsoleDebug.Error(e.Message);
            }

            //ConnectionEndpoint.SendFromServer(eventArgs.Handler, eventArgs.Message);
        }
Esempio n. 8
0
    void Start()
    {
        debug = GameObject.FindObjectOfType(typeof(ConsoleDebug)) as ConsoleDebug;

        if (Network.isClient) {
          StartCoroutine("BeginReport");
        }
    }
Esempio n. 9
0
 private void Orbwalking_BeforeAttack(AttackableUnit target, Orbwalker.PreAttackArgs args)
 {
     if (IsDodging)
     {
         args.Process = false; //Block orbwalking
         ConsoleDebug.WriteLineColor("Blocked Orbwalk Before Attack", ConsoleColor.Red);
     }
 }
Esempio n. 10
0
 public static void PrintChat(object data)
 {
     if (!ConfigValue.ShowDebugInfo.GetBool())
     {
         return;
     }
     Chat.Print(data);
     ConsoleDebug.WriteLine(data);
 }
Esempio n. 11
0
 public void HandleMessage(Common.Schema.Game message)
 {
     Player.game.Players = message.Players;
     Player.game.Board = message.Board;
     Player.game.Location = message.PlayerLocation;
     Player.game.Fields = new Common.SchemaWrapper.Field[message.Board.width, 2 * message.Board.goalsHeight + message.Board.tasksHeight];
     ConsoleDebug.Good("Game started");
     Player.ReadyForAction?.Invoke();
 }
Esempio n. 12
0
 public static void DrawTopLeft(object data)
 {
     ConsoleDebug.WriteLine(data);
     if (!ConfigValue.ShowDebugInfo.GetBool())
     {
         return;
     }
     textToWrite.Add(data.ToString());
     ConsoleDebug.WriteLine(data);
 }
Esempio n. 13
0
        private void OnMessageReceive(object sender, MessageRecieveEventArgs eventArgs)
        {
            var socket = eventArgs.Handler as Socket;

            if (eventArgs.Message.Length > 0) //the message is not the keepalive packet
            {
                ConsoleDebug.Message("New message from: " + socket.GetRemoteAddress() + "\n" + eventArgs.Message);
                messageHandler.HandleMessage((dynamic)XmlMessageConverter.ToObject(eventArgs.Message));
            }
        }
Esempio n. 14
0
        public static void Main(string[] args)
        {
            Debug.Active          = true;
            Debug.DevelopmentInfo = true;
            ConsoleDebug.Connect();
            Application.Init();
            MainWindow win = new MainWindow();

            win.Show();
            Application.Run();
        }
Esempio n. 15
0
        private void OnConnection(object sender, ConnectEventArgs eventArgs)
        {
            var address = eventArgs.Handler.GetRemoteAddress();

            ConsoleDebug.Ordinary("Successful connection with address " + address.ToString());
            var socket = eventArgs.Handler as Socket;

            RegisterNewGame(socket);

            //start sending keepalive bytes
            startKeepAlive(socket);
        }
Esempio n. 16
0
 public static void CastSpell(EvadeSpellData spellData)
 {
     EvadeSpell.LastSpellEvadeCommand = new EvadeCommand
     {
         Order          = EvadeOrderCommand.CastSpell,
         EvadeSpellData = spellData,
         Timestamp      = EvadeUtils.TickCount,
         IsProcessed    = false
     };
     ConsoleDebug.WriteLine("CastSpell");
     MyHero.Spellbook.CastSpell(spellData.SpellKey, false);
 }
Esempio n. 17
0
 void Start()
 {
     networkView.viewID = Network.AllocateViewID();
     debug = GameObject.FindObjectOfType(typeof(ConsoleDebug)) as ConsoleDebug;
     if (Network.isClient) {
       StartCoroutine("BeginReport");
       debug.DebugLine(networkView.viewID.ToString());
     } else {
       StartCoroutine("BeginTest");
       debug.DebugLine(networkView.viewID.ToString());
     }
 }
        public void HandleMessage(PlayerDisconnected message, Socket handler)
        {
            ConsoleDebug.Error($"Player disconnected! Player id: {message.playerId}");
            var player = Players.First(p => p.Id == message.playerId);

            TeamBlue.Players.Remove(player);
            TeamRed.Players.Remove(player);
            if (TeamRed.Players.Count + TeamBlue.Players.Count == 0)
            {
                GameInProgress = false;
            }
        }
Esempio n. 19
0
 private void Game_OnGameLoad_Disabled(EventArgs args)
 {
     ConsoleDebug.WriteLineColor("Failed loading Evade...", ConsoleColor.Red);
     ConsoleDebug.WriteLine("   Disabled due to needed core update (as of 5.24), please be patient!");
     Chat.Print("<font color='#ff0000'>Failed loading Evade...</font>");
     Chat.Print("   Disabled due to needed core update (as of 5.24), please be patient!");
     Menu = MainMenu.AddMenu("Evade (Disabled)", "Evade", "Evade (Disabled)");
     Menu.AddGroupLabel("Disabled due to needed core update!");
     Menu.AddLabel("As the latest update has caused issues with getting buffs and sending movement commands\n" +
                   " Evade can not be fixed.\n");
     Menu.AddSeparator();
     Menu.AddLabel("Please be patient for an update and in the mean time use EvadePlus");
 }
Esempio n. 20
0
 public static void Attack(EvadeSpellData spellData, Obj_AI_Base target)
 {
     EvadeSpell.LastSpellEvadeCommand = new EvadeCommand
     {
         Order          = EvadeOrderCommand.Attack,
         Target         = target,
         EvadeSpellData = spellData,
         Timestamp      = EvadeUtils.TickCount,
         IsProcessed    = false
     };
     ConsoleDebug.WriteLine("Attack: " + target.Name);
     Player.IssueOrder(GameObjectOrder.AttackUnit, target, false);
 }
Esempio n. 21
0
        private void CreateConfigFile()
        {
            if (!Directory.Exists(ConfigDataFolder))
            {
                Directory.CreateDirectory(ConfigDataFolder);
            }
            if (!File.Exists(ConfigDataFile))
            {
                File.Create(ConfigDataFile).Close();
            }

            ConsoleDebug.WriteLine("Creating Config...");
        }
Esempio n. 22
0
 public static void CastSpell(EvadeSpellData spellData, Vector2 movePos)
 {
     EvadeSpell.LastSpellEvadeCommand = new EvadeCommand
     {
         Order          = EvadeOrderCommand.CastSpell,
         TargetPosition = movePos,
         EvadeSpellData = spellData,
         Timestamp      = EvadeUtils.TickCount,
         IsProcessed    = false
     };
     ConsoleDebug.WriteLine("CastSpell: " + movePos);
     MyHero.Spellbook.CastSpell(spellData.SpellKey, movePos.To3D(), false);
 }
Esempio n. 23
0
 public static void CastSpell(EvadeSpellData spellData, Obj_AI_Base target)
 {
     EvadeSpell.LastSpellEvadeCommand = new EvadeCommand
     {
         Order          = EvadeOrderCommand.CastSpell,
         Target         = target,
         EvadeSpellData = spellData,
         Timestamp      = EvadeUtils.TickCount,
         IsProcessed    = false
     };
     ConsoleDebug.WriteLine("CastSpell: " + target.Name);
     MyHero.Spellbook.CastSpell(spellData.SpellKey, target, false);
 }
Esempio n. 24
0
        private void OnConnection(object sender, ConnectEventArgs eventArgs)
        {
            var address = eventArgs.Handler.GetRemoteAddress();
            ConsoleDebug.Ordinary("Successful connection with address " + address.ToString());
            var socket = eventArgs.Handler as Socket;
            serverSocket = socket;
            string xmlMessage = XmlMessageConverter.ToXml(new GetGames());

            connection.SendFromClient(socket, xmlMessage);

            //start sending keep alive bytes
            startKeepAlive(socket);
        }
Esempio n. 25
0
 public void RemoveConfig()
 {
     if (!Directory.Exists(ConfigDataFolder))
     {
         return;
     }
     if (!File.Exists(ConfigDataFile))
     {
         return;
     }
     ConsoleDebug.WriteLine("Removing Config File.");
     File.Delete(ConfigDataFile);
     Directory.Delete(ConfigDataFolder);
 }
Esempio n. 26
0
        public void Play()
        {
            ConsoleDebug.Strategy(currentState.Name);
            Player.Game.PrintBoard();

            currentState = currentState.NextState();
            if (currentState.Action == null)
            {
                Play();
            }
            else
            {
                currentState.Action();
            }
        }
Esempio n. 27
0
            public void HandleMessage(ConfirmJoiningGame message)
            {

                if (message == null)
                    return;

                ConsoleDebug.Good(message.gameId.ToString());

                Player.game.Id = message.playerId;
                Player.game.GameId = message.gameId;
                Player.game.Guid = message.privateGuid;
                Player.game.Team = message.PlayerDefinition.team;
                Player.game.Type = message.PlayerDefinition.type;

                return;
            }
Esempio n. 28
0
        // Unity controlled.
        // Update: Each update, check if the game is running,
        //         if the key is pressed, and then toggles the lock state of the helmet
        //         as needed
        public void Update()
        {
            if (GameManager.GameState == GameState.Running)
            {
                // If the button is being pressed but was not pressed previously
                if (KeyManager.GetButtonDown(KeyManager.GetKey("Lock Helmet")))
                {
                    if (_lastButtonState == false)
                    {
                        // Find the local player
                        var player = Human.AllHumans.FirstOrDefault(human => human.IsLocalPlayer);

                        if (player == null)
                        {
                            Debug.LogError("HelmetLockMod: Could not find local player");
                        }
                        else
                        {
                            // If the helmet slot has a helmet
                            if (player.HelmetSlot.Occupant)
                            {
                                var helmet = player.HelmetSlot.Occupant;

                                // Check the helmet can be locked
                                if (helmet.HasLockState)
                                {
                                    // Print a string to the console telling the player what is being done
                                    var consoleString = String.Format("{0}ing {1}...",
                                                                      helmet.IsLocked ? ActionStrings.Unlock : ActionStrings.Lock,
                                                                      helmet.DisplayName);

                                    ConsoleDebug.AddText(String.Format("<color=yellow>{0}</color>", consoleString));

                                    // Get the index of the "Lock Item" action for the helmet
                                    // Then tell the player to send a command to the helmet to toggle its lock
                                    var helmetLockIndex = helmet.InteractLock.InteractableId;
                                    player.CallCmdInteractWith(helmetLockIndex, helmet.netId, player.netId, player.HelmetSlot.SlotId, false);
                                }
                            }
                        }
                    }
                }

                // Update the buttons last state
                _lastButtonState = KeyManager.GetButton(KeyManager.GetKey("Lock Helmet"));
            }
        }
Esempio n. 29
0
        static void ValidationEventHandler(object sender, ValidationEventArgs e)
        {
            ConsoleDebug.Error("\n ERROR IN VALIDATION\n ");

            switch (e.Severity)
            {
            case XmlSeverityType.Error:
                Console.WriteLine("Error: {0}", e.Message);
                throw new  XmlException();
                break;

            case XmlSeverityType.Warning:
                Console.WriteLine("Warning {0}", e.Message);
                throw new XmlException();
                break;
            }
        }
Esempio n. 30
0
        private void OnMessageReceive(object sender, MessageRecieveEventArgs eventArgs)
        {
            var socket = eventArgs.Handler as Socket;

            if (eventArgs.Message.Length > 0) //the message is not the keepalive packet
            {
                ConsoleDebug.Message("New message from:" + socket.GetRemoteAddress() + "\n" + eventArgs.Message);
                messageHandler.PrintBoard();
                try
                {
                    messageHandler.HandleMessage((dynamic)XmlMessageConverter.ToObject(eventArgs.Message), socket);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
        }
Esempio n. 31
0
        private void Game_OnCreateObj(GameObject sender, EventArgs args)
        {
            var missile = sender as MissileClient;

            if (missile != null && missile.SpellCaster.IsMe)
            {
                if (_lastSpellCastArgs.Process == true
                    )
                {
                    //Draw.RenderObjects.Add(new Draw.RenderPosition(lastSpellCastServerPos, 1000, System.Drawing.Color.Red, 10));
                    RenderObjects.Add(new RenderCircle(missile.StartPosition.To2D(), 1000, Color.Red, 10));

                    var   distance = _lastSpellCastServerPos.Distance(missile.StartPosition.To2D());
                    float moveTime = 1000 * distance / MyHero.MoveSpeed;
                    ConsoleDebug.WriteLine("Extra Delay: " + moveTime);
                }
            }
        }
        public async void HandleMessage(TestPiece message, Socket handler)
        {
            if (!ValidateMessage(message))
            {
                return;
            }
            string resp = "";
            await Task.Delay((int)GameMasterClient.Settings.ActionCosts.TestDelay);

            Wrapper.Player currentPlayer = Players.SingleOrDefault(p => p.Guid == message.playerGuid);
            if (currentPlayer == null)
            {
                return;
            }
            GameMasterClient.Logger.Log(message, currentPlayer);
            lock (BoardLock)
            {
                Wrapper.Piece piece =
                    Pieces.SingleOrDefault(
                        pc =>
                        pc.PlayerId == currentPlayer.Id);
                if (piece == null) // not carrying anything
                {
                    ConsoleDebug.Warning("Not carrying a piece!");
                    piece = Pieces.FirstOrDefault(pc => pc.Location.Equals(currentPlayer.Location));
                }
                if (piece == null)
                {
                    ConsoleDebug.Warning("Not on a piece!");
                    //send empty piece collection
                    resp = new DataMessageBuilder(currentPlayer.Id, endGame)
                           .SetPieces(new Piece[0])
                           .GetXml();
                }
                else
                {
                    ConsoleDebug.Warning("On a piece!");
                    resp = new DataMessageBuilder(currentPlayer.Id, endGame)
                           .AddPiece(piece.SchemaPiece)
                           .GetXml();
                }
            }
            GameMasterClient.Connection.SendFromClient(handler, resp);
        }
Esempio n. 33
0
		public void SendSignedEmail()
		{
			var message = new MailMessage();


			
			message.To.Add(new MailAddress("*****@*****.**", "Port25"));
			


			message.From = new MailAddress(ConfigurationManager.AppSettings["from"]);

			message.Subject = @"test©";
			// message contains white space 
//            message.Body = @"abc©
// ©   ©
// ©
//
//
//";

//            message.IsBodyHtml = false;


//            message.Body = @"
//line 1
//
//line 2
//
//line 3";


			message.AlternateViews.Add(AlternateView.CreateAlternateViewFromString("text", Encoding.ASCII, "text/plain"));
			message.AlternateViews.Add(AlternateView.CreateAlternateViewFromString("html", Encoding.ASCII, "text/html"));



			var privateKey = PrivateKeySigner.Create(ConfigurationManager.AppSettings["privatekey"], SigningAlgorithm.RSASha1);

			var dkim = new DkimSigner(
				privateKey,
				ConfigurationManager.AppSettings["domain"],
				ConfigurationManager.AppSettings["selector"],
				new string[] { "From", "To", "Subject" }
				);



			var debugger = new ConsoleDebug();

			dkim.Debug = debugger;
			dkim.Encoding = Encoding.ASCII;
			dkim.BodyCanonicalization = DkimCanonicalizationAlgorithm.Relaxed;



	

			

			var signedMessage = dkim.SignMessage(message);

			
			var text = signedMessage.GetText();
			debugger.WriteLine();
			debugger.WriteContent("dkim", text);



		//    var domainkey = new DomainKeySigner(
		//privateKey,
		//ConfigurationManager.AppSettings["domain"],
		//ConfigurationManager.AppSettings["selector"],
		//new string[] { "From", "To", "Subject" }
		//);

			//signedMessage = domainkey.SignMessage(signedMessage);
			
			//text = signedMessage.GetText();
			//debugger.WriteContent("domainkey", text);

			new SmtpClient().Send(signedMessage);

		}