示例#1
0
 public override void step()
 {
     if (chase())
     {
         NailTrapAreaEffect areaEffect = new NailTrapAreaEffect(ownerTower.board.player, targetPosition, slowAmount, dmgPerSecond);
         Messages.OutgoingMessages.Game.GAddNailTrapAreaEffect.sendMessage(ownerTower.board.player.game.players, areaEffect);
         targetBoard.player.game.addAreaEffect(areaEffect);
         destroyable = true;
     }
 }
        public override void processMessage(NetWorker.Utilities.RawMessage message)
        {
            int  instanceId = message.getInt("iid");
            int  typeId     = message.getInt("tid");
            User ownerUser  = Engine.Game.getUserById(message.getInt("uid"));

            float[] position     = message.getFloatArray("pos");
            float   dmgPerSecond = message.getFloat("dps");
            float   slowAmount   = message.getFloat("sa");

            if (ownerUser != null)
            {
                NailTrapAreaEffect areaEffect = new NailTrapAreaEffect(instanceId, ownerUser.player, new Vector3(position[0], position[1], position[2]), slowAmount, dmgPerSecond);
                Engine.Game.AddAreaEffect(areaEffect);
                Runner.Graphics.createAreaEffect(areaEffect);
            }
        }
        public static void sendMessage(ICollection <Player> receiverPlayers, NailTrapAreaEffect areaEffect)
        {
            if (receiverPlayers != null && receiverPlayers.Count != 0)
            {
                RawMessage msg = new RawMessage();
                msg.putInt("id", TypeIdGenerator.getMessageId(typeof(GAddNailTrapAreaEffect)));

                msg.putInt("iid", areaEffect.instanceId);
                msg.putInt("tid", TypeIdGenerator.getAreaEffectId(areaEffect.GetType()));
                msg.putInt("uid", areaEffect.ownerPlayer.user.id);

                msg.putFloat("dps", areaEffect.dmgPerSecond);
                msg.putFloat("sa", areaEffect.slowAmount);

                Vector3 position = areaEffect.getWorldPosition();
                msg.putFloatArray("pos", new float[] { position.x, position.y, position.z });

                foreach (var receiverPlayer in receiverPlayers)
                {
                    receiverPlayer.user.session.client.SendMessage(msg);
                }
            }
        }