当前位置: 首页>>代码示例>>C#>>正文


C# Game.getPlayers方法代码示例

本文整理汇总了C#中Game.getPlayers方法的典型用法代码示例。如果您正苦于以下问题:C# Game.getPlayers方法的具体用法?C# Game.getPlayers怎么用?C# Game.getPlayers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Game的用法示例。


在下文中一共展示了Game.getPlayers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var version = new SynchVersion(data);
            //Logging->writeLine("Client version: %s", version->version);

            var mapId = Config.gameConfig.map;
            Logger.LogCoreInfo("Current map: " + mapId);

            bool versionMatch = true;
            // Version might be an invalid value, currently it trusts the client
            if (version.version != Config.version)
            {
                versionMatch = false;
                Logger.LogCoreWarning("Client " + version.version + " does not match Server " + Config.version);
            }
            else
            {
                Logger.LogCoreInfo("Accepted client version (" + version.version + ")");
            }

            foreach (var player in game.getPlayers())
            {
                if (player.Item1 == peer->address.host)
                {
                    player.Item2.setVersionMatch(versionMatch);
                    break;
                }
            }
            int map;
            if (!int.TryParse(mapId, out map))
                map = 1;
            var answer = new SynchVersionAns(game.getPlayers(), Config.version, "CLASSIC", map);

            return PacketHandlerManager.getInstace().sendPacket(peer, answer, Channel.CHL_S2C);
        }
开发者ID:horato,项目名称:IntWarsSharp,代码行数:35,代码来源:HandleSynch.cs

示例2: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            game.IncrementReadyPlayers();
            if (game.getReadyPlayers() == game.getPlayers().Count)
            {
                var start = new StatePacket(PacketCmdS2C.PKT_S2C_StartGame);
                PacketHandlerManager.getInstace().broadcastPacket(start, Channel.CHL_S2C);

                foreach (var player in game.getPlayers())
                {
                    if (player.Item2.getPeer() == peer && !player.Item2.isVersionMatch())
                    {
                        var dm = new SpawnParticle.DebugMessage("Your client version does not match the server. Check the server log for more information.");
                        PacketHandlerManager.getInstace().sendPacket(peer, dm, Channel.CHL_S2C);
                    }
                }

                game.setStarted(true);
            }

            if (game.isStarted())
            {
                foreach (var p in game.getPlayers())
                {
                    var map = game.getMap();
                    map.addObject(p.Item2.getChampion());

                    // Send the initial game time sync packets, then let the map send another
                    float gameTime = map.getGameTime() / 1000.0f;

                    var timer = new GameTimer(gameTime); // 0xC1
                    PacketHandlerManager.getInstace().sendPacket(p.Item2.getPeer(), timer, Channel.CHL_S2C);

                    var timer2 = new GameTimerUpdate(gameTime); // 0xC2
                    PacketHandlerManager.getInstace().sendPacket(p.Item2.getPeer(), timer2, Channel.CHL_S2C);
                }
            }

            return true;
        }
开发者ID:horato,项目名称:IntWarsSharp,代码行数:40,代码来源:HandleStartGame.cs

示例3: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            //Builds team info
            var screenInfo = new LoadScreenInfo(game.getPlayers());
            bool pInfo = PacketHandlerManager.getInstace().sendPacket(peer, screenInfo, Channel.CHL_LOADING_SCREEN);

            //For all players send this info
            bool bOk = false;
            foreach (var player in game.getPlayers())
            {
                var loadName = new LoadScreenPlayerName(player);
                var loadChampion = new LoadScreenPlayerChampion(player);
                bool pName = PacketHandlerManager.getInstace().sendPacket(peer, loadName, Channel.CHL_LOADING_SCREEN);
                bool pHero = PacketHandlerManager.getInstace().sendPacket(peer, loadChampion, Channel.CHL_LOADING_SCREEN);

                bOk = (pName && pHero);

                if (!bOk)
                    break;
            }

            return (pInfo && bOk);
        }
开发者ID:horato,项目名称:IntWarsSharp,代码行数:23,代码来源:HandleMap.cs

示例4: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            // players[0].Item1 = peer->address.host; //temp
            //   players[0].Item2.setPeer(enetEvent.peer);

            var keyCheck = new KeyCheck(data);
            var userId = (long)BlowFishCS.BlowFishCS.Decrypt2(game.getBlowfish(), (ulong)keyCheck.checkId);

            if (userId != keyCheck.userId)
                return false;

            var playerNo = 0;

            foreach (var p in game.getPlayers())
            {
                var player = p.Item2;
                if (player.userId == userId)
                {
                    if (player.getPeer() != null)
                    {
                        Logger.LogCoreWarning("Ignoring new player " + userId + ", already connected!");
                        return false;
                    }

                    //TODO: add at least port or smth
                    p.Item1 = peer->address.host;
                    player.setPeer(peer);
                    var response = new KeyCheck(keyCheck.userId, playerNo);
                    bool bRet = PacketHandlerManager.getInstace().sendPacket(peer, response, Channel.CHL_HANDSHAKE);
                    handleGameNumber(player, peer, null);//Send 0x91 Packet?
                    return true;
                }
                ++playerNo;
            }
            return false;
        }
开发者ID:horato,项目名称:IntWarsSharp,代码行数:36,代码来源:HandleKeyCheck.cs

示例5: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var start = new StatePacket2(PacketCmdS2C.PKT_S2C_StartSpawn);
            bool p1 = PacketHandlerManager.getInstace().sendPacket(peer, start, Channel.CHL_S2C);
            Logger.LogCoreInfo("Spawning map");

            int playerId = 0;
            ClientInfo playerInfo = null;

            foreach (var p in game.getPlayers())
            {
                if (p.Item2.getPeer() == peer)
                    playerInfo = p.Item2;

                var spawn = new HeroSpawn(p.Item2, playerId++);
                PacketHandlerManager.getInstace().sendPacket(peer, spawn, Channel.CHL_S2C);

                var info = new PlayerInfo(p.Item2);
                PacketHandlerManager.getInstace().sendPacket(peer, info, Channel.CHL_S2C);

                p.Item2.getChampion().getStats().setSummonerSpellEnabled(0, true);
                p.Item2.getChampion().getStats().setSummonerSpellEnabled(1, true);

                // TODO: Recall slot
            }
            var objects = game.getMap().getObjects();

            foreach (var kv in objects)
            {
                var t = kv.Value as Turret;
                if (t != null)
                {
                    var turretSpawn = new TurretSpawn(t);
                    PacketHandlerManager.getInstace().sendPacket(peer, turretSpawn, Channel.CHL_S2C);

                    // To suppress game HP-related errors for enemy turrets out of vision
                    var sh = new SetHealth(t);
                    PacketHandlerManager.getInstace().sendPacket(peer, sh, Channel.CHL_S2C);
                    continue;
                }

                var lp = kv.Value as LevelProp;
                if (lp != null)
                {
                    var lpsPacket = new SpawnParticle.LevelPropSpawn(lp);
                    PacketHandlerManager.getInstace().sendPacket(peer, lpsPacket, Channel.CHL_S2C);
                }
            }

            // Level props are just models, we need button-object minions to allow the client to interact with it
            //if (playerInfo != null && playerInfo.getTeam() == TeamId.TEAM_BLUE)
            {
                // Shop (blue team)
                var ms1 = new MinionSpawn2(0xff10c6db);
                PacketHandlerManager.getInstace().sendPacket(peer, ms1, Channel.CHL_S2C);
                var sh1 = new SetHealth2(0xff10c6db);
                PacketHandlerManager.getInstace().sendPacket(peer, sh1, Channel.CHL_S2C);

                // Vision for hardcoded objects
                // Top inhib
                var ms2 = new MinionSpawn2(0xffd23c3e);
                PacketHandlerManager.getInstace().sendPacket(peer, ms2, Channel.CHL_S2C);
                var sh2 = new SetHealth2(0xffd23c3e);
                PacketHandlerManager.getInstace().sendPacket(peer, sh2, Channel.CHL_S2C);

                // Mid inhib
                var ms3 = new MinionSpawn2(0xff4a20f1);
                PacketHandlerManager.getInstace().sendPacket(peer, ms3, Channel.CHL_S2C);
                var sh3 = new SetHealth2(0xff4a20f1);
                PacketHandlerManager.getInstace().sendPacket(peer, sh3, Channel.CHL_S2C);

                // Bottom inhib
                var ms4 = new MinionSpawn2(0xff9303e1);
                PacketHandlerManager.getInstace().sendPacket(peer, ms4, Channel.CHL_S2C);
                var sh4 = new SetHealth2(0xff9303e1);
                PacketHandlerManager.getInstace().sendPacket(peer, sh4, Channel.CHL_S2C);

                // Nexus
                var ms5 = new MinionSpawn2(0xfff97db5);
                PacketHandlerManager.getInstace().sendPacket(peer, ms5, Channel.CHL_S2C);
                var sh5 = new SetHealth2(0xfff97db5);
                PacketHandlerManager.getInstace().sendPacket(peer, sh5, Channel.CHL_S2C);

            }
            //  else if (playerInfo != null && playerInfo.getTeam() == TeamId.TEAM_PURPLE)
            {
                // Shop (purple team)
                var ms1 = new MinionSpawn2(0xffa6170e);
                PacketHandlerManager.getInstace().sendPacket(peer, ms1, Channel.CHL_S2C);
                var sh1 = new SetHealth2(0xffa6170e);
                PacketHandlerManager.getInstace().sendPacket(peer, sh1, Channel.CHL_S2C);

                // Vision for hardcoded objects
                // Top inhib
                var ms2 = new MinionSpawn2(0xff6793d0);
                PacketHandlerManager.getInstace().sendPacket(peer, ms2, Channel.CHL_S2C);
                var sh2 = new SetHealth2(0xff6793d0);
                PacketHandlerManager.getInstace().sendPacket(peer, sh2, Channel.CHL_S2C);
               
                // Mid inhib
//.........这里部分代码省略.........
开发者ID:horato,项目名称:IntWarsSharp,代码行数:101,代码来源:HandleSpawn.cs


注:本文中的Game.getPlayers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。