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


C# Game.getPeerInfo方法代码示例

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


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

示例1: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var sell = new SellItem(data);
            var client = game.getPeerInfo(peer);

            var i = game.getPeerInfo(peer).getChampion().getInventory().getItemSlot(sell.slotId);
            if (i == null)
                return false;

            float sellPrice = i.getTemplate().getTotalPrice() * i.getTemplate().getSellBackModifier();
            client.getChampion().getStats().setGold(client.getChampion().getStats().getGold() + sellPrice);

            if (i.getTemplate().getMaxStack() > 1)
            {
                i.decrementStacks();
                PacketNotifier.notifyRemoveItem(client.getChampion(), sell.slotId, i.getStacks());

                if (i.getStacks() == 0)
                    client.getChampion().getInventory().removeItem(sell.slotId);
            }
            else
            {
                PacketNotifier.notifyRemoveItem(client.getChampion(), sell.slotId, 0);
                client.getChampion().getInventory().removeItem(sell.slotId);
            }

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

示例2: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var request = new SwapItems(data);

            if (request.slotFrom > 6 || request.slotTo > 6)
                return false;

            game.getPeerInfo(peer).getChampion().getInventory().swapItems(request.slotFrom, request.slotTo);
            PacketNotifier.notifyItemsSwapped(game.getPeerInfo(peer).getChampion(), request.slotFrom, request.slotTo);

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

示例3: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var skillUpPacket = new SkillUpPacket(data);
            //!TODO Check if can up skill? :)

            var s = game.getPeerInfo(peer).getChampion().levelUpSpell(skillUpPacket.skill);

            if (s == null)
                return false;

            var skillUpResponse = new SkillUpPacket(game.getPeerInfo(peer).getChampion().getNetId(), skillUpPacket.skill, (byte)s.getLevel(), (byte)s.getOwner().getSkillPoints());
            PacketHandlerManager.getInstace().sendPacket(peer, skillUpResponse, Channel.CHL_GAMEPLAY);
            game.getPeerInfo(peer).getChampion().getStats().setSpellEnabled(skillUpPacket.skill, true);

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

示例4: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var click = new Click(data);
            Logger.LogCoreInfo("Object " + game.getPeerInfo(peer).getChampion().getNetId() + " clicked on " + click.targetNetId);

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

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

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

示例7: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var loadInfo = new PingLoadInfo(data);
            var peerInfo = game.getPeerInfo(peer);
            if (peerInfo == null)
                return false;
            var response = new PingLoadInfo(loadInfo, peerInfo.userId);

            //Logging->writeLine("loaded: %f, ping: %f, %f", loadInfo->loaded, loadInfo->ping, loadInfo->f3);
            return PacketHandlerManager.getInstace().broadcastPacket(response, Channel.CHL_LOW_PRIORITY, PacketFlags.None);
        }
开发者ID:horato,项目名称:IntWarsSharp,代码行数:11,代码来源:HandleLoadPing.cs

示例8: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var heartbeat = new HeartBeat(data);

            float diff = heartbeat.ackTime - heartbeat.receiveTime;
            if (heartbeat.receiveTime > heartbeat.ackTime)
            {
                Logger.LogCoreWarning("Player " + game.getPeerInfo(peer).userId + " sent an invalid heartbeat - Timestamp error (diff: " + diff);
            }
            else
            {
              //  Logger.LogCoreInfo("Player %d sent heartbeat (diff: %.f)", peerInfo(peer)->userId, diff);
            }

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

示例9: HandlePacket

 public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
 {
     var ping = new AttentionPing(data);
     var response = new AttentionPingAns(game.getPeerInfo(peer), ping);
     return PacketHandlerManager.getInstace().broadcastPacketTeam(game.getPeerInfo(peer).getTeam(), response, Channel.CHL_S2C);
 }
开发者ID:horato,项目名称:IntWarsSharp,代码行数:6,代码来源:HandleAttentionPing.cs

示例10: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var request = new BuyItemReq(data);

            var itemTemplate = ItemManager.getInstance().getItemTemplateById(request.id);
            if (itemTemplate == null)
                return false;

            var recipeParts = game.getPeerInfo(peer).getChampion().getInventory().getAvailableRecipeParts(itemTemplate);
            var price = itemTemplate.getTotalPrice();
            ItemInstance i;

            if (recipeParts.Count == 0)
            {
                if (game.getPeerInfo(peer).getChampion().getStats().getGold() < price)
                {
                    return true;
                }

                i = game.getPeerInfo(peer).getChampion().getInventory().addItem(itemTemplate);

                if (i == null)
                { // Slots full
                    return false;
                }
            }
            else
            {
                foreach (var instance in recipeParts)
                    price -= instance.getTemplate().getTotalPrice();

                if (game.getPeerInfo(peer).getChampion().getStats().getGold() < price)
                    return false;


                foreach (var instance in recipeParts)
                {
                    game.getPeerInfo(peer).getChampion().getStats().unapplyStatMods(instance.getTemplate().getStatMods());
                    PacketNotifier.notifyRemoveItem(game.getPeerInfo(peer).getChampion(), instance.getSlot(), 0);
                    game.getPeerInfo(peer).getChampion().getInventory().removeItem(instance.getSlot());
                }

                i = game.getPeerInfo(peer).getChampion().getInventory().addItem(itemTemplate);
            }

            game.getPeerInfo(peer).getChampion().getStats().setGold(game.getPeerInfo(peer).getChampion().getStats().getGold() - price);
            game.getPeerInfo(peer).getChampion().getStats().applyStatMods(itemTemplate.getStatMods());
            PacketNotifier.notifyItemBought(game.getPeerInfo(peer).getChampion(), i);

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

示例11: HandlePacket

        public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
        {
            var message = new ChatMessage(data);
            var split = message.msg.Split(' ');
            if (split.Length > 1)
            {
                int x, y = 0;
                if (int.TryParse(split[0], out x))
                {
                    if (int.TryParse(split[1], out y))
                    {
                        var response = new AttentionPingAns(game.getPeerInfo(peer), new AttentionPing { x = x, y = y, targetNetId = 0, type = 0 });
                        PacketHandlerManager.getInstace().broadcastPacketTeam(game.getPeerInfo(peer).getTeam(), response, Channel.CHL_S2C);
                    }
                }
            }

            #region Commands
            //Lets do commands

            if (message.msg.StartsWith("."))
            {
                var cmd = new string[] { ".set", ".gold", ".speed", ".health", ".xp", ".ap", ".ad", ".mana", ".model", ".help", ".spawn", ".size", ".junglespawn", ".skillpoints", ".level", ".tp", ".coords", ".ch" };
                var debugMsg = new StringBuilder();
                split = message.msg.ToLower().Split(' ');
                switch (split[0])
                {
                    case ".set":
                        if (split.Length < 4)
                            return true;
                        int blockNo, fieldNo = 0;
                        float value = 0;
                        if (int.TryParse(split[1], out blockNo))
                            if (int.TryParse(split[2], out fieldNo))
                                if (float.TryParse(split[3], out value))
                                {
                                    // blockNo = 1 << (blockNo - 1);
                                    //var mask = 1 << (fieldNo - 1);
                                    game.getPeerInfo(peer).getChampion().getStats().setStat((MasterMask)blockNo, (FieldMask)fieldNo, value);
                                }
                        return true;
                    case ".gold":
                        float gold;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out gold))
                            game.getPeerInfo(peer).getChampion().getStats().setGold(gold);
                        return true;
                    case ".speed":
                        float speed;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out speed))
                            game.getPeerInfo(peer).getChampion().getStats().setMovementSpeed(speed);
                        return true;
                    case ".health":
                        float hp;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out hp))
                        {
                            game.getPeerInfo(peer).getChampion().getStats().setCurrentHealth(hp);
                            game.getPeerInfo(peer).getChampion().getStats().setMaxHealth(hp);

                            PacketNotifier.notifySetHealth(game.getPeerInfo(peer).getChampion());
                        }
                        return true;
                    case ".xp":
                        float xp;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out xp))
                            game.getPeerInfo(peer).getChampion().getStats().setExp(xp);
                        return true;
                    case ".ap":
                        float ap;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out ap))
                            game.getPeerInfo(peer).getChampion().getStats().setBonusApFlat(ap);
                        return true;
                    case ".ad":
                        float ad;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out ad))
                            game.getPeerInfo(peer).getChampion().getStats().setBonusAdFlat(ad);
                        return true;
                    case ".mana":
                        float mp;
                        if (split.Length < 2)
                            return true;
                        if (float.TryParse(split[1], out mp))
                        {
                            game.getPeerInfo(peer).getChampion().getStats().setCurrentMana(mp);
                            game.getPeerInfo(peer).getChampion().getStats().setMaxMana(mp);
                        }
                        return true;
                    case ".model":
                        if (split.Length >= 2)
//.........这里部分代码省略.........
开发者ID:horato,项目名称:IntWarsSharp,代码行数:101,代码来源:HandleChatBoxMessage.cs

示例12: HandlePacket

 public unsafe bool HandlePacket(ENetPeer* peer, byte[] data, Game game)
 {
     var world = new WorldSendGameNumber(1, game.getPeerInfo(peer).getName());
     return PacketHandlerManager.getInstace().sendPacket(peer, world, Channel.CHL_S2C);
 }
开发者ID:horato,项目名称:IntWarsSharp,代码行数:5,代码来源:HandleGameNumber.cs


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