コード例 #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));
            }
        }
コード例 #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);
        }
コード例 #3
0
        public static Arealight CreateA(Collider collider, Game game, ushort type)
        {
            Arealight l = new Arealight();

            l.Collider = collider;
            game.Lights.Add(l);
            l.Game           = game;
            l.Game.GameTick += l.Tick;

            l.Id = game.NextObjectId++;
            DarkRiftWriter writer = DarkRiftWriter.Create();

            writer.Write(type);
            writer.Write(l.Id);
            writer.Write(collider.Transform.Position.x);
            writer.Write(collider.Transform.Position.y);

            game.SendMessageToAll(Message.Create((ushort)Tags.SpawnObject, writer));


            return(l);
        }