Exemplo n.º 1
0
        private IAIPlugin InitializeAIPlugin(string path)
        {
            Assembly pluginDLL = Assembly.LoadFrom(path);

            if (pluginDLL != null)
            {
                Type[] types = pluginDLL.GetExportedTypes();

                for (int i = 0; i < types.Length; i++)
                {
                    Type type = types[i];
                    if (type.GetInterface("BombermanBasics.Interfaces.IAIPlugin") != null && type != null)
                    {
                        IAIPlugin plugin = pluginDLL.CreateInstance(type.FullName) as IAIPlugin;
                        if (plugin != null)
                        {
                            plugin.Initialize(this);
                            return(plugin);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                return(null);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
 public Team(string name,
             System.Windows.Media.Color teamColor,
             IAIPlugin aiPlugin) : base(name)
 {
     TeamColor      = teamColor;
     TeamColorBrush = new SolidColorBrush(TeamColor);
     AIPlugin       = aiPlugin;
 }
Exemplo n.º 3
0
        private bool LoadTeamsAndPlugins()
        {
            m_teams = new List <Team>();
            foreach (var team in m_configHandler.Teams)
            {
                IAIPlugin aiPlugin = InitializeAIPlugin(team.DLLPath);

                if (aiPlugin != null)
                {
                    Team teamToAdd = new Team(team.Name,
                                              Team.s_colors[m_teams.Count],
                                              aiPlugin);
                    m_teams.Add(teamToAdd);
                    aiPlugin.Initialize(teamToAdd);
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }