Beispiel #1
0
        /// <summary>
        /// Initialize easy mode player and sets oponents to players
        /// </summary>
        public void GetEasyPlayer()
        {
            _logger.Debug("Attempt to get full path and load library CustomGamePlagin.dll");
            var fullpath = AppDomain.CurrentDomain.BaseDirectory;

            var dllPath = string.Empty;

            if (fullpath.Contains(@"WindowsFormsApplication3\bin\Debug\"))
            {
                dllPath = fullpath.Replace(@"WindowsFormsApplication3\bin\Debug\", @"Plugins\CustomGamePlugin.dll");
            }
            else if (fullpath.Contains(@"SeaBattleMVVM\bin\Debug\"))
            {
                dllPath = fullpath.Replace(@"SeaBattleMVVM\bin\Debug\", @"Plugins\CustomGamePlugin.dll");
            }
            var pluginAssembly = Assembly.LoadFrom(dllPath);

            _logger.Debug("Attempt to get full path and load library CustomGamePlagin.dll successfully completed.Full path: " + fullpath);
            _logger.Debug("Attempt to create Right Player instance and set oponents for players");
            foreach (var plugin in pluginAssembly.GetTypes())
            {
                if (plugin.BaseType != null && (plugin.BaseType.ToString() != "GameCore.Player"))
                {
                    continue;
                }

                RightPlayer = (Player)Activator.CreateInstance(plugin, new object[] { RightField });
            }

            LeftPlayer.Oponent  = RightPlayer;
            RightPlayer.Oponent = LeftPlayer;
            _logger.Debug("Attempt to create Right Player instance and set oponents for players successfully completed" + RightPlayer.GetHashCode());
        }
Beispiel #2
0
 /// <summary>
 /// Initialize normal mode player and sets oponents to players
 /// </summary>
 public void GetNormalPlayer()
 {
     _logger.Debug("Attempt to create Right Player instance and set oponents for players");
     RightPlayer         = new MyBotPlayer(RightField);
     LeftPlayer.Oponent  = RightPlayer;
     RightPlayer.Oponent = LeftPlayer;
     _logger.Debug("Attempt to create Right Player instance and set oponents for players successfully completed" + RightPlayer.GetHashCode());
 }