コード例 #1
0
        private static void Events_OnClose(object sender, EventArgs e)
        {
            ZaioMenu.ResetHeroSettings();
            _controlledUnits.Clear();
            if (_currentHero == null)
            {
                return;
            }
            GameDispatcher.OnIngameUpdate -= OnIngameUpdate;

            _currentHero.OnClose();
            _currentHero.Deactivate();
            _currentHero = null;
        }
コード例 #2
0
        private static void Events_OnLoad(object sender, EventArgs e)
        {
            ZaioMenu.OnLoad();

            var hero = ObjectManager.LocalHero;

            if (hero != null)
            {
                var types = Assembly.GetExecutingAssembly().GetTypes().Where(x => x.Namespace == "Zaio.Heroes");
                foreach (var type in types)
                {
                    var property = type.GetCustomAttribute <HeroAttribute>();
                    if (property != null)
                    {
                        Log.Debug($"OnLoad ID: {property.Id}");
                        if (hero.HeroId == property.Id)
                        {
                            Log.Debug($"Found hero.. activating!");
                            _currentHero = (ComboHero)Activator.CreateInstance(type);
                            break;
                        }
                    }
                }

                if (_currentHero == null)
                {
                    _currentHero = new GenericHero();
                    Game.PrintMessage(
                        $"Zaio: <font color='#FF1133'>The abilities of {Game.Localize(hero.Name)} are not supported!</font> But items and orbwalking will still work.");
                }

                _currentHero.OnLoad();
                _currentHero.Activate();

                if (ZaioMenu.ActiveControlMode != ActiveControlMode.None)
                {
                    Game.PrintMessage(
                        $"Zaio: Unit control mode <font color='#FF1133'>{ZaioMenu.ActiveControlMode}</font> is enabled!");
                }

                GameDispatcher.OnIngameUpdate += OnIngameUpdate;
            }
        }