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


C# Game.getMap方法代码示例

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


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

示例1: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var peerInfo = game.getPeerInfo(peer);
            if (peerInfo == null || peerInfo.getChampion().isDashing() || peerInfo.getChampion().isDead())
                return true;

            var request = new MovementReq(data);
            var vMoves = new List<Vector2>();//readWaypoints(request.moveData, request.coordCount, game.getMap());
            vMoves.Add(new Vector2(peerInfo.getChampion().getX(), peerInfo.getChampion().getY()));
            vMoves.Add(new Vector2(request.x, request.y)); // TODO
            switch (request.type)
            {
                case MoveType.STOP:
                    {
                        //TODO anticheat, currently it trusts client 100%

                        peerInfo.getChampion().setPosition(request.x, request.y);
                        float x = ((request.x) - game.getMap().getWidth()) / 2;
                        float y = ((request.y) - game.getMap().getHeight()) / 2;

                        for (var i = 0; i < vMoves.Count; i++)
                        {
                            var v = vMoves[i];
                            v.X = (short)request.x;
                            v.Y = (short)request.y;
                        }

                        Logger.LogCoreInfo("Stopped at x: " + request.x + ", y: " + request.y);
                        break;
                    }
                case MoveType.EMOTE:
                    //Logging->writeLine("Emotion");
                    return true;
                case MoveType.ATTACKMOVE:
                    peerInfo.getChampion().setMoveOrder(MoveOrder.MOVE_ORDER_ATTACKMOVE);
                    break;
                case MoveType.MOVE:
                    peerInfo.getChampion().setMoveOrder(MoveOrder.MOVE_ORDER_MOVE);
                    break;
            }

            // Sometimes the client will send a wrong position as the first one, override it with server data
            vMoves[0] = new Vector2(peerInfo.getChampion().getX(), peerInfo.getChampion().getY());

            peerInfo.getChampion().setWaypoints(vMoves);

            var u = game.getMap().getObjectById(request.targetNetId) as Unit;
            if (u == null)
            {
                peerInfo.getChampion().setTargetUnit(null);
                return true;
            }

            peerInfo.getChampion().setTargetUnit(u);

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

示例2: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var spell = new CastSpell(data);
            //Todo spellslot 0-3 qwer, 4-5 d f, 6-11 items

            // There are some bits triggering this
            if ((spell.spellSlotType & 0x0F) > 0)
            {
                Logger.LogCoreInfo("Summoner Spell Cast");
                Logger.LogCoreInfo("Type: " + spell.spellSlotType.ToString("x") + ", Slot " + spell.spellSlot + ", coord " + spell.x + " ; " + spell.y + ", coord2 " + spell.x2 + ", " + spell.y2 + ", target NetId " + spell.targetNetId.ToString("x"));
                return true;
            }

            var futureProjNetId = Game.GetNewNetID();
            var spellNetId = Game.GetNewNetID();
            var targetObj = game.getMap().getObjectById(spell.targetNetId);
            var targetUnit = targetObj as Unit;

            var s = game.getPeerInfo(peer).getChampion().castSpell(spell.spellSlot, spell.x, spell.y, targetUnit, futureProjNetId, spellNetId);

            if (s == null)
                return false;

            var response = new CastSpellAns(s, spell.x, spell.y, futureProjNetId, spellNetId);
            PacketHandlerManager.getInstace().broadcastPacket(response, Channel.CHL_S2C);
            return true;
        }
开发者ID:horato,项目名称:IntWarsSharp,代码行数:27,代码来源:HandleCastSpell.cs

示例3: 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

示例4: 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

示例5: HandlePacket


//.........这里部分代码省略.........
                        debugMsg.Append("List of available commands: ");
                        foreach (var cc in cmd)
                            debugMsg.Append(cc + " ");

                        var dm = new SpawnParticle.DebugMessage(debugMsg.ToString());
                        PacketHandlerManager.getInstace().sendPacket(peer, dm, Channel.CHL_S2C);
                        return true;
                    case ".spawn":
                        Logger.LogCoreInfo("Not implemented command .spawn");
                        return true;
                    case ".size":
                        float size;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out size))
                            game.getPeerInfo(peer).getChampion().getStats().setSize(size);
                        return true;
                    case ".junglespawn":
                        cmd = new string[] { "c baron", "c wolves", "c red", "c blue", "c dragon", "c wraiths", "c golems" };
                        return true;
                    case ".skillpoints":
                        game.getPeerInfo(peer).getChampion().setSkillPoints(17);
                        var skillUpResponse = new SkillUpPacket(game.getPeerInfo(peer).getChampion().getNetId(), 0, 0, 17);
                        PacketHandlerManager.getInstace().sendPacket(peer, skillUpResponse, Channel.CHL_GAMEPLAY);
                        return true;
                    case ".level":
                        float lvl;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out lvl))
                        {
                            if (lvl < 1 || lvl > 18)
                                return true;
                            game.getPeerInfo(peer).getChampion().getStats().setExp(game.getMap().getExperienceToLevelUp()[(int)lvl - 1]);
                            //game.peerInfo(peer).getChampion().getStats().setLevel(lvl);
                        }
                        return true;
                    case ".tp":
                        float x, y;
                        if (split.Length < 3)
                            return true;
                        if (float.TryParse(split[1], out x))
                            if (float.TryParse(split[2], out y))
                                PacketNotifier.notifyTeleport(game.getPeerInfo(peer).getChampion(), x, y);
                        return true;
                    case ".coords":
                        Logger.LogCoreInfo("At " + game.getPeerInfo(peer).getChampion().getX() + ";" + game.getPeerInfo(peer).getChampion().getY());
                        debugMsg.Append("At Coords - X: ");
                        debugMsg.Append(game.getPeerInfo(peer).getChampion().getX());
                        debugMsg.Append(" Y: ");
                        debugMsg.Append(game.getPeerInfo(peer).getChampion().getY());
                        debugMsg.Append(" Z: ");
                        debugMsg.Append(game.getPeerInfo(peer).getChampion().getZ());
                        PacketNotifier.notifyDebugMessage(debugMsg.ToString());
                        return true;
                    case ".ch":
                        if (split.Length < 2)
                            return true;
                        new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                        {
                            var c = new Champion(split[1], game.getMap(), game.getPeerInfo(peer).getChampion().getNetId(), (int)game.getPeerInfo(peer).userId);
                            c.setPosition(game.getPeerInfo(peer).getChampion().getX(), game.getPeerInfo(peer).getChampion().getY());
                            c.setModel(split[1]); // trigger the "modelUpdate" proc
                            game.getMap().removeObject(game.getPeerInfo(peer).getChampion());
                            game.getMap().addObject(c);
                            game.getPeerInfo(peer).setChampion(c);
开发者ID:horato,项目名称:IntWarsSharp,代码行数:67,代码来源:HandleChatBoxMessage.cs


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