public override void Update(float delta)
        {
            GameObject.MoveBy(Vector3.UnitY);

            if (ObjectCollision.Intersects(GameObject.Collision, _player.Collision))
            {
                GameObject.Scene.Game.ChangeScene(new WonScene());
            }

            GameObject.MoveBy(-Vector3.UnitY);
        }
        public override void Update(float delta = 1)
        {
            var direction = _target.Position - GameObject.Position;

            direction.Normalize();
            GameObject.MoveBy(direction * delta * _flySpeed);
            if (ObjectCollision.Intersects(_target.Collision, GameObject.Collision))
            {
                var targetHealthComponent = _target.GetComponent <HealthComponent>();
                targetHealthComponent.DealDamage(_damage);
                GameObject.Scene.RemoveGameObject(GameObject);
            }
        }
Esempio n. 3
0
        public override void Update(float delta)
        {
            var positionToMove = new Vector3(0, _speedY, 0);

            GameObject.MoveBy(positionToMove);

            if (ObjectCollision.Intersects(GameObject.Collision, _player.Collision))
            {
                _player.MoveBy(positionToMove);
            }

            if (GameObject.Position.Y >= _maxY || GameObject.Position.Y <= _minY)
            {
                _speedY *= -1;
            }
        }
        public override void Update(float delta)
        {
            GameObject.MoveBy(_direction * delta * _speed);
            ObjectCollision collision = GameObject.Collision;

            foreach (Game3DObject gameObject in GameObject.Scene.GameObjects)
            {
                if (gameObject == GameObject)
                {
                    continue;
                }

                if (gameObject.Collision != null)
                {
                    if (ObjectCollision.Intersects(gameObject.Collision, collision))
                    {
                        gameObject.GetComponent <HealthComponent>()?.DealDamage(_damage);
                        GameObject.Scene.RemoveGameObject(GameObject);
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Проверка столкновения коллайдера с другими объектами с тегам
        /// </summary>
        /// <param name="gameObject">Пересекаемый объект или NULL</param>
        /// <param name="tag">Тэг объкта, с которым проверяется пересечение</param>
        /// <returns>Результат пересечения</returns>
        public bool CheckIntersects(out Game3DObject gameObject, string tag = "")
        {
            foreach (var collision in _collisions)
            {
                if (tag == "" || collision.GameObject.Tag != tag)
                {
                    continue;
                }

                if (collision != GameObject.Collision)
                {
                    var result = ObjectCollision.Intersects(GameObject.Collision, collision);
                    if (result)
                    {
                        gameObject = collision.GameObject;
                        return(result);
                    }
                }
            }

            gameObject = null;
            return(false);
        }
Esempio n. 6
0
        /// <summary>
        /// Обновление поведения
        /// </summary>
        /// <param name="delta">Время между кадрами</param>
        public override void Update(float delta)
        {
            if (_physicsComponent == null)
            {
                return;
            }

            if (_physicsComponent.IsGrounded)
            {
                if (!ObjectCollision.Intersects(GameObject.Collision, _ground.Collision))
                {
                    _ground = null;
                }
            }
            else
            {
                if (_colliderComponent.CheckIntersects(out Game3DObject ground, "ground"))
                {
                    _ground = ground;
                }
            }

            _physicsComponent.UpdateGrounded(_ground);
        }