Example #1
0
        public override void Act(KeyboardState ks, MouseState ms)
        {
            Vector3 mousePoint = GetMouseIntersectionPoint(ms, Plane.Z);

            TurnTowardsXY(mousePoint);

            if (ks[Key.A] && Position.X > -17)
            {
                MoveOffset(-_movementSpeed * KWEngine.DeltaTimeFactor, 0, 0);
            }
            if (ks[Key.D] && Position.X < 17)
            {
                MoveOffset(+_movementSpeed * KWEngine.DeltaTimeFactor, 0, 0);
            }
            if (ks[Key.W] && Position.Y < 10)
            {
                MoveOffset(0, +_movementSpeed * KWEngine.DeltaTimeFactor, 0);
            }
            if (ks[Key.S] && Position.Y > -10)
            {
                MoveOffset(0, -_movementSpeed * KWEngine.DeltaTimeFactor, 0);
            }

            if (ms.LeftButton == ButtonState.Pressed || ks[Key.Space])
            {
                long timestampNow = GetCurrentTimeInMilliseconds();

                if (timestampNow - _timestampLastShot > _cooldown)
                {
                    Vector3 lav = GetLookAtVector();

                    Shot s = new Shot(this);
                    s.SetModel("KWCube");
                    s.Name = "PlayerShot";
                    s.SetRotation(this.Rotation);
                    s.SetPosition(this.Position + lav);
                    s.SetScale(0.075f, 0.075f, 0.5f);
                    s.SetColorEmissive(0, 1, 1, 1);
                    s.IsCollisionObject = true;
                    s.SetGlow(0, 1, 0, 1);
                    CurrentWorld.AddGameObject(s);

                    _timestampLastShot = timestampNow;
                }
            }

            Intersection i = GetIntersection(0, 0, 0, typeof(Enemy));

            if (i != null)
            {
                CurrentWorld.RemoveGameObject(this);
                Explosion ex = new Explosion(Position, 512, 5, ExplosionType.SkullRingZ);
                CurrentWorld.AddGameObject(ex);
            }
        }
Example #2
0
        public override void Act(KeyboardState ks, MouseState ms)
        {
            if (!IsInsideScreenSpace)
            {
                CurrentWorld.RemoveGameObject(this);
                return;
            }

            Move(_movementSpeed * KWEngine.DeltaTimeFactor);

            Intersection intersection;

            if (_parent is Player)
            {
                intersection = GetIntersection(0, 0, 0, typeof(Enemy));
            }
            else
            {
                intersection = GetIntersection(0, 0, 0, typeof(Player));
            }

            if (intersection != null && !intersection.Object.Equals(_parent))
            {
                if (_parent is Player)
                {
                    if (intersection.Object is Enemy)
                    {
                        CurrentWorld.RemoveGameObject(this);
                        CurrentWorld.RemoveGameObject(intersection.Object);
                        Explosion ex = new Explosion(Position, 16);
                        ex.SetColor(1, 1, 1);
                        ex.SetGlow(1, 1, 0.5f, 0.25f);
                        CurrentWorld.AddGameObject(ex);
                    }
                }
                else if (_parent is Enemy)
                {
                    if (intersection.Object is Player)
                    {
                        CurrentWorld.RemoveGameObject(intersection.Object);
                        Explosion ex1 = new Explosion(intersection.Object.Position, 128);
                        ex1.SetColor(0, 1, 0);
                        ex1.SetGlow(0, 1, 0.5f, 1);
                        CurrentWorld.AddGameObject(ex1);

                        CurrentWorld.RemoveGameObject(this);
                        Explosion ex = new Explosion(Position, 16);
                        ex.SetColor(1, 1, 1);
                        ex.SetGlow(1, 1, 0.5f, 0.25f);
                        CurrentWorld.AddGameObject(ex);
                    }
                }
            }
        }
Example #3
0
        public override void Act(KeyboardState ks, MouseState ms, float deltaTimeFactor)
        {
            if (_health <= 0)
            {
                Explosion ex = new Explosion(Position, 16);
                ex.SetColor(1, 1, 1);
                ex.SetGlow(1, 0, 1f, 0.5f);
                CurrentWorld.AddGameObject(ex);

                CurrentWorld.RemoveGameObject(this);
            }
        }
Example #4
0
        public override void Act(KeyboardState ks, MouseState ms)
        {
            long now = GetCurrentTimeInMilliseconds();

            float z = (float)Math.Sin(_spawnTime + now / 75.0);

            //float y = -0.001f * (now * now * now) + 0.1f * (now * now);
            MoveOffset(z * KWEngine.DeltaTimeFactor * _movementSpeed, -_movementSpeed * KWEngine.DeltaTimeFactor, 0);

            if (now - _timestampLastShot > 200)
            {
                Vector3 lav = GetLookAtVector();

                Shot s = new Shot(this);
                s.SetModel("KWCube");
                s.SetRotation(this.Rotation);
                s.AddRotationZ(10, true);
                s.SetPosition(this.Position + 0.5f * lav);
                s.SetScale(0.075f, 0.075f, 0.5f);
                s.IsCollisionObject = true;
                s.SetGlow(1, 0.5f, 0, 1);
                CurrentWorld.AddGameObject(s);

                Shot s2 = new Shot(this);
                s2.SetModel("KWCube");
                s2.SetRotation(this.Rotation);
                s2.AddRotationZ(-10, true);
                s2.SetPosition(this.Position + 0.5f * lav);
                s2.SetScale(0.075f, 0.075f, 0.5f);
                s2.IsCollisionObject = true;
                s2.SetGlow(1, 0.5f, 0, 1);
                CurrentWorld.AddGameObject(s2);


                _timestampLastShot = now + HelperRandom.GetRandomNumber(0, 500);
            }

            if (!IsInsideScreenSpace)
            {
                CurrentWorld.RemoveGameObject(this);
            }

            base.Act(ks, ms);
        }
Example #5
0
        public override void Act(KeyboardState ks, MouseState ms)
        {
            float currentSpeed = _speed * KWEngine.DeltaTimeFactor;

            _distance += currentSpeed;
            Move(currentSpeed);

            Intersection i = GetIntersection();

            if (i != null && !(i.Object is Player))
            {
                Explosion ex = new Explosion(_lastPos != Vector3.Zero ? _lastPos : Position, 8, 0.25f, 0.5f, 2f, ExplosionType.Cube, new Vector4(0, 0.25f, 1f, 1));
                CurrentWorld.AddGameObject(ex);
                CurrentWorld.RemoveGameObject(this);
            }
            else if (_distance > 50)
            {
                CurrentWorld.RemoveGameObject(this);
            }
            _lastPos = Position;
        }