Exemplo n.º 1
0
        public static BeaconArrow ShootArrow(Vector2 position, Vector2 direction, Game game, Character owner)
        {
            BeaconArrow arrow = new BeaconArrow();

            arrow.Owner     = owner;
            arrow.Transform = new STransform(position, 0);
            arrow.Collider  = new CircleCollider(arrow.Transform, 0.3f);

            Vector2 force = direction;

            force.Normalize();
            force               *= ShootStrenght;
            arrow.Velocity       = force;
            arrow.Game           = game;
            arrow.Game.GameTick += arrow.Tick;

            arrow.Id = game.NextObjectId++;

            DarkRiftWriter writer = DarkRiftWriter.Create();

            writer.Write((ushort)0);
            writer.Write(arrow.Id);
            writer.Write(arrow.Transform.Position.x);
            writer.Write(arrow.Transform.Position.y);

            owner.Owner.Client.SendMessage(Message.Create((ushort)Tags.SpawnObject, writer), SendMode.Reliable);

            return(arrow);
        }
Exemplo n.º 2
0
        void ShootBeacon(object sender, Message message)
        {
            DarkRiftReader reader = message.GetReader();
            IClient        client = (IClient)sender;
            Player         p      = Players[client.ID];

            if (p.Game != null)
            {
                if (p.Character.LastCastBeacon + 120 > p.Game.Frame)
                {
                    return;
                }
                p.Character.LastCastBeacon = p.Game.Frame;
                Vector2     dir = new Vector2(reader.ReadSingle(), reader.ReadSingle());
                BeaconArrow a   = BeaconArrow.ShootArrow(p.Character.Transform.Position, dir, p.Game, p.Character);
            }
        }