public async Task DoMove(MoveDirection direction) { if (bot.Energy > MainGame.Settings.EnergyLostByMove) { bot.Energy -= MainGame.Settings.EnergyLostByMove; } else { bot.Energy = 0; } int x = 0; int y = 0; switch (direction) {// TODO: check if it is ok for east/west. Ok for north/south // pour l'instant, on se déplace haut/bas/gauche/droite, pas de diagonale case MoveDirection.North: y = 1; break; case MoveDirection.South: y = -1; break; case MoveDirection.East: x = -1; break; case MoveDirection.West: x = 1; break; /*case MoveDirection.NorthWest: y = 1; x = 1; break; * case MoveDirection.NorthEast: y = 1; x = -1; break; * case MoveDirection.SouthWest: y = -1; x = 1; break; * case MoveDirection.SouthEast: y = -1; x = -1; break; */ } switch (MainGame.TheMap[bot.X + x, bot.Y + y]) { case CaseState.Empty: MainGame.ViewerMovePlayer(bot.X, bot.Y, (byte)(bot.X + x), (byte)(bot.Y + y)); MainGame.TheMap[bot.X, bot.Y] = CaseState.Empty; bot.X = (byte)(bot.X + x); bot.Y = (byte)(bot.Y + y); MainGame.TheMap[bot.X, bot.Y] = CaseState.Ennemy; SendPositionToCockpit(); break; case CaseState.Energy: MainGame.ViewerClearCase((byte)(bot.X + x), (byte)(bot.Y + y)); MainGame.ViewerMovePlayer(bot.X, bot.Y, (byte)(bot.X + x), (byte)(bot.Y + y)); MainGame.TheMap[bot.X, bot.Y] = CaseState.Empty; bot.X = (byte)(bot.X + x); bot.Y = (byte)(bot.Y + y); MainGame.TheMap[bot.X, bot.Y] = CaseState.Ennemy; UInt16 temp = (UInt16)(MainGame.RND.Next(1 + MainGame.Settings.EnergyPodMax - MainGame.Settings.EnergyPodFrom) + MainGame.Settings.EnergyPodFrom); bot.Energy += temp; Console.WriteLine($"Bot {bot.Name} win energy: {temp}"); bot.Score += MainGame.Settings.PointByEnergyFound; SendPositionToCockpit(); break; case CaseState.Ennemy: // on tamponne un bot adverse if (bot.ShieldLevel >= MainGame.Settings.EnergyLostContactEnemy) { bot.ShieldLevel -= MainGame.Settings.EnergyLostContactEnemy; MainGame.ViewerPlayerShield(bot.X, bot.Y, bot.ShieldLevel); } else { UInt16 tmp = bot.ShieldLevel; bot.ShieldLevel = 0; tmp = (UInt16)(2 * (MainGame.Settings.EnergyLostContactEnemy - tmp)); if (bot.Energy >= tmp) { bot.Energy -= tmp; } else { bot.Energy = 0; } } // perte du champ occultant if (bot.CloakLevel > 0) { bot.CloakLevel = 0; MainGame.ViewerPlayerCloak(bot.X, bot.Y, bot.CloakLevel); } bot.Score += MainGame.Settings.PointByEnnemyTouch; Console.WriteLine($"Bot {bot.Name} tamponne un bot ennemi !"); TouchEnemy((UInt16)(bot.X + x), (UInt16)(bot.Y + y)); break; case CaseState.Wall: if (bot.ShieldLevel > 0) { bot.ShieldLevel--; MainGame.ViewerPlayerShield(bot.X, bot.Y, bot.ShieldLevel); } else { if (bot.Energy > MainGame.Settings.EnergyLostContactWall) { bot.Energy -= MainGame.Settings.EnergyLostContactWall; } else { bot.Energy = 0; } } // perte du champ occultant if (bot.CloakLevel > 0) { bot.CloakLevel = 0; MainGame.ViewerPlayerCloak(bot.X, bot.Y, bot.CloakLevel); } break; } await SendChangeInfo(); //MainGame.RefreshViewer(); if (bot.Energy == 0) { await SendDead(); } } // DoMove