Ejemplo n.º 1
0
        public virtual void AddStackData(string newModel, uint skinId, bool modelOnly, bool overrideSpells,
                                         bool replaceCharacterPackage, bool notif = true)
        {
            CharacterStacks.Clear();

            AIUnitRecord record = AIUnitRecord.GetAIUnitRecord(newModel);

            if (record != null)
            {
                CharacterStacks.Clear();
                uint id             = 1;
                var  characterStack = new CharacterStack(record, id, modelOnly, overrideSpells, replaceCharacterPackage, skinId);
                CharacterStacks.Add(id, characterStack);

                if (notif)
                {
                    Game.Send(new ChangeCharacterDataMessage(NetId, characterStack.GetProtocolObject()));
                }
            }
            else
            {
                logger.Write("Unable to assign skin, (" + newModel + ") is not a valid AIUnit model name.",
                             MessageState.WARNING);
            }
        }
Ejemplo n.º 2
0
        protected void SpawnMonster(string name, Vector2 position, int delay)
        {
            uint         netId   = Game.NetIdProvider.PopNextNetId();
            AIUnitRecord record  = AIUnitRecord.GetAIUnitRecord(name);
            AIMonster    monster = new AIMonster(netId, record, delay);

            monster.SpawnPosition = position;
            monster.Position      = position;
            monster.DefineGame(Game);
            Game.AddUnitToTeam(monster, TeamId.NEUTRAL);
            Game.Map.AddUnit(monster);
        }
Ejemplo n.º 3
0
        public void SpawnCamp(string monsterName, Game game, Vector2 position)
        {
            AIMonster monster = new AIMonster(game.NetIdProvider.PopNextNetId(), AIUnitRecord.GetAIUnitRecord(monsterName), 0);

            monster.Position      = position;
            monster.SpawnPosition = position;
            monster.DefineGame(game);
            game.AddUnitToTeam(monster, TeamId.NEUTRAL);
            game.Map.AddUnit(monster);
            monster.Initialize();
            monster.Create();
        }
Ejemplo n.º 4
0
        public static void HandleKeyCheckMessage(KeyCheckMessage message, LoLClient client)
        {
            long userId = LoLServer.BlowFish.Decrypt((ulong)message.checkId);

            logger.Write("User (" + userId + ") connected!");

            if (userId != message.userId)
            {
                return;
            }
            client.UserId = userId;

            PlayerData datas = ConfigurationProvider.Instance.GetPlayerData(userId);

            if (datas == null)
            {
                logger.Write("No player data for userId:" + userId, MessageState.WARNING);
                return;
            }

            Game targetGame = GameProvider.TestGame;

            if (targetGame.Contains(userId))
            {
                logger.Write(userId + "try to connect a second time!", MessageState.WARNING);
                return;
            }
            client.DefinePlayer(new AIHero(client, datas, AIUnitRecord.GetAIUnitRecord(datas.ChampionName)));

            client.Hero.DefineGame(targetGame);

            client.Hero.Game.AddUnitToTeam(client.Hero, client.Hero.Data.Team);

            client.Hero.PlayerNo = client.Hero.Game.PopNextPlayerNo();

            // on montre aux joueurs de la partie que je suis la !
            client.Hero.Game.Send(new KeyCheckMessage(PartialKey, client.Hero.PlayerNo, userId, 0, 0, 0), Channel.CHL_HANDSHAKE);

            // on montre a moi les autre joueurs de la partie
            foreach (var player in client.Hero.Game.Players)
            {
                client.Send(new KeyCheckMessage(PartialKey, player.PlayerNo, player.Client.UserId.Value, 0, 0, 0), Channel.CHL_HANDSHAKE);
            }

            // useless??
            client.Send(new WorldGameNumberMessage(client.Hero.Game.Id, client.Hero.Game.Name), Channel.CHL_S2C);

            // blowfish >= 8
            client.Encrypt = true;
        }
Ejemplo n.º 5
0
        protected void SpawnAITurret(string turretName, string aiUnitRecordName, string customAIUnitRecord = null)
        {
            AIUnitRecord aIUnitRecord = AIUnitRecord.GetAIUnitRecord(customAIUnitRecord != null ? customAIUnitRecord : aiUnitRecordName);

            MapObjectRecord objectRecord = Game.Map.Record.GetObject(turretName);

            if (objectRecord == null)
            {
                logger.Write(string.Format(SPAWN_EX_STRING, turretName, "the GameObjectRecord do not exist."), MessageState.WARNING);
                return;
            }
            if (aIUnitRecord == null)
            {
                logger.Write(string.Format(SPAWN_EX_STRING, turretName, "the AIUnitRecord do not exist."), MessageState.WARNING);
                return;
            }

            string fullName = turretName + BuildingProvider.TOWER_SUFFIX;

            var teamId = BuildingProvider.Instance.GetTeamId(turretName);

            if (teamId != TeamId.UNKNOWN)
            {
                uint     netId  = (uint)(BuildingProvider.BUILDING_NETID_X | CRC32.Compute(Encoding.ASCII.GetBytes(fullName)));
                AITurret turret = new AITurret(netId, aIUnitRecord, objectRecord, BuildingRecord.GetBuildingRecord(Game.Map.Id, turretName), BuildingProvider.TOWER_SUFFIX);
                turret.DefineGame(Game);
                Game.AddUnitToTeam(turret, teamId);
                Game.Map.AddUnit(turret);

                if (customAIUnitRecord != null)
                {
                    turret.AddStackData(customAIUnitRecord, 0, false, true, true, false);
                }
            }
            else
            {
                logger.Write(string.Format(SPAWN_EX_STRING, turretName, "Unable to find a team."), MessageState.WARNING);
            }
        }