Пример #1
0
        public override void Tick()
        {
            Vector2 oldPos = Transform.Position;

            Velocity.y -= Gravity * Clock.DeltaTime;

            Transform.Translate(new Vector2(0, Velocity.y * Clock.DeltaTime));
            if (Game.CollideWithMap(Collider))
            {
                Transform.Translate(new Vector2(0, -Velocity.y * Clock.DeltaTime));
                OnHit();
            }

            Transform.Translate(new Vector2(Velocity.x * Clock.DeltaTime, 0));
            if (Game.CollideWithMap(Collider))
            {
                Transform.Translate(new Vector2(-Velocity.x * Clock.DeltaTime, 0));
                OnHit();
            }

            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);
        }
Пример #2
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));
            }
        }
Пример #3
0
        public override void Tick()
        {
            if (Game.Frame > Frame + 600)
            {
                Game.GameTick -= Tick;
                Dispose();
            }

            Vector2 oldPos = Transform.Position;

            Velocity.y -= Gravity * Clock.DeltaTime;

            Transform.Translate(new Vector2(Velocity.x * Clock.DeltaTime, Velocity.y * Clock.DeltaTime));

            //if hit player disapear and do dmg
            Character hit          = Game.HitEnemyCharacter(Collider, Owner);
            bool      hitMapObject = Game.CollideWithMap(Collider);

            if (hit != null)
            {
                //do dmg
                hit.TakeDmg(40, Owner);
                Dispose();
            }

            if (hitMapObject)
            {
                Dispose();
            }

            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));
        }
Пример #4
0
        public void Tick()
        {
            if (Hp < 100 && Game.Frame % 40 == 0)
            {
                Hp += 1;
            }
            if (Hp < 70 && Game.Frame % 300 == 0)
            {
                Blood.FireBlood(Transform.Position, Game, this);
            }
            else if (Hp < 45 && Game.Frame % 120 == 0)
            {
                Blood.FireBlood(Transform.Position, Game, this);
            }

            Vector2 oldPos = Transform.Position;

            if (Grounded && Jumped)
            {
                Velocity.y += jumpStrenght;
            }
            Grounded    = false;
            Jumped      = false;
            Velocity.y -= gravity * Clock.DeltaTime;

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

            if (CollidedMapObjectVert != null)
            {
                float ResetDistance = 0;
                if (CollidedMapObjectVert.GetType() == typeof(BoxCollider))
                {
                    ResetDistance = ((BoxCollider)CollidedMapObjectVert).Size.y / 2 + ((BoxCollider)Collider).Size.y / 2 + 0.001f;
                }
                else if (CollidedMapObjectVert.GetType() == typeof(BoxCollider))
                {
                    ResetDistance = ((CircleCollider)CollidedMapObjectVert).Radius + ((BoxCollider)Collider).Size.y / 2 + 0.001f;
                }
                if (Velocity.y <= 0)
                {
                    Transform.Translate(new Vector2(0, CollidedMapObjectVert.Transform.Position.y - Transform.Position.y + ResetDistance));
                    Grounded = true;
                }
                else
                {
                    Transform.Translate(new Vector2(0, CollidedMapObjectVert.Transform.Position.y - Transform.Position.y - ResetDistance));
                }

                //Transform.Translate(new Vector2(0, -Velocity.y*Clock.DeltaTime));
                //if (Velocity.y <= 0)
                //{
                //    Grounded = true;
                //}
                Velocity.y = 0;
            }

            float walkVelocity = 0;

            if (WalkL)
            {
                walkVelocity -= movementSpeed * Clock.DeltaTime;
            }
            if (WalkR)
            {
                walkVelocity += movementSpeed * Clock.DeltaTime;
            }

            Transform.Translate(new Vector2(Velocity.x * Clock.DeltaTime + walkVelocity, 0));
            Collider CollidedMapObjectHor = Game.CollideWithMapReturnCollider(Collider);

            if (CollidedMapObjectHor != null)
            {
                float ResetDistance = 0;
                if (CollidedMapObjectHor.GetType() == typeof(BoxCollider))
                {
                    ResetDistance = ((BoxCollider)CollidedMapObjectHor).Size.x / 2 + ((BoxCollider)Collider).Size.x / 2 + 0.001f;
                }
                else if (CollidedMapObjectHor.GetType() == typeof(CircleCollider))
                {
                    ResetDistance = ((CircleCollider)CollidedMapObjectHor).Radius + ((BoxCollider)Collider).Size.x / 2 + 0.001f;
                }
                if (walkVelocity < 0)
                {
                    Transform.Translate(new Vector2(CollidedMapObjectHor.Transform.Position.x - Transform.Position.x + ResetDistance, 0));
                }
                else
                {
                    Transform.Translate(new Vector2(CollidedMapObjectHor.Transform.Position.x - Transform.Position.x - ResetDistance, 0));
                }
                //Transform.Translate(new Vector2(-Velocity.x * Clock.DeltaTime - walkVelocity, 0));
                Velocity.x = 0;
            }



            if (/*oldPos != Transform.Position*/ true)
            {
                if (Game.IsEnlighted(Collider))
                {
                    Game.UpdateMessage.AddCharacterPosUpdate(Owner.PlayerId, Transform.Position);
                    WasEnlighted = true;
                }
                else
                {
                    DarkRiftWriter writer = DarkRiftWriter.Create();
                    if (WasEnlighted)
                    {
                        WasEnlighted = false;
                        writer.Write(Owner.PlayerId);
                        Game.SendMessageToAll(Message.Create((ushort)Tags.MakeInvisisble, writer));;
                    }
                    writer = DarkRiftWriter.Create();
                    writer.Write(Transform.Position.x);
                    writer.Write(Transform.Position.y);
                    Owner.Client.SendMessage(Message.Create((ushort)Tags.WalkInvisible, writer), SendMode.Reliable);
                }
            }
        }