Ejemplo n.º 1
0
        public override void Tick()
        {
            base.Tick();
            if (FramesAlive == 120 && !ignited)
            {
                Ignite();
            }
            if (FramesAlive == 240)
            {
                Dispose();
                DarkRiftWriter writer = DarkRiftWriter.Create();
                writer.Write(Id);
                Game.SendMessageToAll(Message.Create((ushort)Tags.KillObject, writer));
                Light = Arealight.CreateA(new CircleCollider(Transform, 3f), Game, 2);
            }

            Vector2 oldPos = Transform.Position;

            Velocity.y -= Gravity * Clock.DeltaTime;

            if (Velocity.y < 0 && !ignited)
            {
                //   Ignite();
            }

            Transform.Translate(new Vector2(0, Velocity.y * Clock.DeltaTime));
            Collider other = Game.CollideWithMapReturnCollider(Collider);

            if (other != null)
            {
                Transform.Translate(new Vector2(0, -Velocity.y * Clock.DeltaTime));
                OnHit(other);
            }

            Transform.Translate(new Vector2(Velocity.x * Clock.DeltaTime, 0));
            other = Game.CollideWithMapReturnCollider(Collider);
            if (other != null)
            {
                Transform.Translate(new Vector2(-Velocity.x * Clock.DeltaTime, 0));
                OnHit(other);
            }

            if (!ignited)
            {
                DarkRiftWriter writer = DarkRiftWriter.Create();
                writer.Write(Id);
                writer.Write(Transform.Position.x);
                writer.Write(Transform.Position.y);
                Owner.Owner.Client.SendMessage(Message.Create((ushort)Tags.MoveObject, writer), SendMode.Reliable);
            }
            else
            {
                DarkRiftWriter writer = DarkRiftWriter.Create();
                writer.Write(Id);
                writer.Write(Transform.Position.x);
                writer.Write(Transform.Position.y);
                Game.SendMessageToAll(Message.Create((ushort)Tags.MoveObject, writer));
            }
        }
Ejemplo n.º 2
0
        public void OnHit()
        {
            Game.GameTick -= Tick;
            DarkRiftWriter writer = DarkRiftWriter.Create();

            writer.Write(Id);
            Owner.Owner.Client.SendMessage(Message.Create((ushort)Tags.KillObject, writer), SendMode.Reliable);
            Arealight.CreateA(new CircleCollider(Transform, 1f), Game, 4);
        }