Beispiel #1
0
        private Matrix4 getModelMatrix(IScale scale, IRotate rotate, ITranslate translate, IHasImage image,
                                       IJumpOffsetComponent jump, PointF areaScaling, PointF resolutionTransform, bool useCustomImageSize)
        {
            if (scale == null)
            {
                return(Matrix4.Identity);
            }
            float?customWidth = _customImageSize == null || !useCustomImageSize ?
                                _nullFloat : (_customImageSize.Value.Width * scale.ScaleX);
            float?customHeight = _customImageSize == null || !useCustomImageSize ?
                                 _nullFloat : (_customImageSize.Value.Height * scale.ScaleY);
            float  width        = (customWidth ?? scale.Width) * areaScaling.X * resolutionTransform.X;
            float  height       = (customHeight ?? scale.Height) * areaScaling.Y * resolutionTransform.Y;
            PointF pivotOffsets = GetPivotOffsets(image == null ? PointF.Empty : image.Pivot,
                                                  width, height);
            Matrix4 pivotMat = Matrix4.CreateTranslation(new Vector3(-pivotOffsets.X, -pivotOffsets.Y, 0f));
            Matrix4 scaleMat = Matrix4.CreateScale(new Vector3(scale.ScaleX * areaScaling.X,
                                                               scale.ScaleY * areaScaling.Y, 1f));
            float   radians     = rotate == null ? 0f : MathUtils.DegreesToRadians(rotate.Angle);
            Matrix4 rotationMat = Matrix4.CreateRotationZ(radians);
            float   x           = translate == null ? 0f : translate.X * resolutionTransform.X;
            float   y           = translate == null ? 0f : translate.Y * resolutionTransform.Y;

            if (jump != null)
            {
                x += jump.JumpOffset.X * resolutionTransform.X;
                y += jump.JumpOffset.Y * resolutionTransform.Y;
            }
            Matrix4 translateMat = Matrix4.CreateTranslation(new Vector3(x, y, 0f));

            return(scaleMat * pivotMat * rotationMat * translateMat);
        }
Beispiel #2
0
        /// <summary>
        /// Moves the specified rotate command.
        /// </summary>
        /// <param name="_rotateCommand">The rotate command.</param>
        /// <returns>IPosition.</returns>
        public IPosition Move(IRotate _rotateCommand)
        {
            _command = (ICommand)_rotateCommand;

            RotateRobot();

            _currentPosition = _newPosition;

            DetectCollisions();
            return(_currentPosition);
        }
        /// <summary>
        /// This method sets up the character.
        /// </summary>
        private void InitCharacter()
        {
            _movement = GetComponent <IMove>();
            _rotate   = GetComponent <IRotate>();
            health    = GetComponent <IHealth>();
            health.StartSetup(_maxHealth);
            _rigidBody = GetComponent <Rigidbody>();
            _weapons   = new IWeapon[_weaponModels.Length];

            for (_index = 0; _index < _weaponModels.Length; _index++)
            {
                _weapons[_index] = _weaponModels[_index].GetComponent <IWeapon>();
                _fireWeapon     += _weapons[_index].Fire;
            }
        }
Beispiel #4
0
		public AGSSprite (Resolver resolver, IMaskLoader maskLoader)
		{
            _maskLoader = maskLoader;
            _resolver = resolver;

            //todo: abstract it to the constructor
            _translate = new AGSTranslate();
            _hasImage = new AGSHasImage();
            _hasImage.Anchor = new PointF();                        
            _rotate = new AGSRotate();

            ScaleX = 1;
            ScaleY = 1;
            _hasImage.OnImageChanged.Subscribe((sender, args) => ScaleBy(ScaleX, ScaleY));
        }
Beispiel #5
0
        public AGSSprite(Resolver resolver, IMaskLoader maskLoader)
        {
            _maskLoader    = maskLoader;
            _resolver      = resolver;
            OnScaleChanged = new AGSEvent <AGSEventArgs>();

            //todo: abstract it to the constructor
            _translate       = new AGSTranslate();
            _hasImage        = new AGSHasImage();
            _hasImage.Anchor = new PointF();
            _rotate          = new AGSRotate();

            ScaleX = 1;
            ScaleY = 1;
            _hasImage.OnImageChanged.Subscribe((sender, args) => ScaleBy(ScaleX, ScaleY));
        }
Beispiel #6
0
        public AGSSprite(Resolver resolver, IMaskLoader maskLoader)
        {
            _id         = Interlocked.Increment(ref _lastId);
            _maskLoader = maskLoader;
            _resolver   = resolver;

            //todo: abstract it to the constructor
            _translate      = new AGSTranslate();
            _hasImage       = new AGSHasImage();
            _hasImage.Pivot = new PointF();
            _scale          = new AGSScale(_hasImage);
            _rotate         = new AGSRotate();

            _scale.PropertyChanged     += onPropertyChanged;
            _hasImage.PropertyChanged  += onPropertyChanged;
            _translate.PropertyChanged += onPropertyChanged;
        }
        private Matrix4 createMatrix(ITranslate translate, IRotate rotate)
        {
            if (translate == null && rotate == null)
            {
                return(Matrix4.Identity);
            }

            var     radians = rotate == null ? 0f : MathUtils.DegreesToRadians(rotate.Angle);
            Matrix4 rotation;

            Matrix4.CreateRotationZ(radians, out rotation);
            Matrix4 translation = Matrix4.CreateTranslation(new Vector3(translate == null ? 0f : translate.X,
                                                                        translate == null ? 0f : translate.Y, 0f));
            Matrix4 transformation = rotation * translation;

            return(transformation);
        }
        public IEnumerable <IPosition> Run(string queueOfCommands)
        {
            foreach (char command in queueOfCommands)
            {
                ICommand commandToRun = new CommandFactory().Get(command);

                if (commandToRun is IRotate)
                {
                    IRotate rotateCommand = (IRotate)commandToRun;
                    yield return(_robotController.Move(rotateCommand));
                }
                else
                {
                    yield return(_robotController.Move(commandToRun));
                }
            }
        }
Beispiel #9
0
        /// <summary>
        ///Metoda implemetująca obrót figury
        /// </summary>
        public void Rotate()
        {
            int i, j;

            bool[,] oldGrid = new bool[4, 4];
            for (i = 0; i < 4; i++)
            {
                for (j = 0; j < 4; j++)
                {
                    oldGrid[i, j] = figure.grid[i, j];
                }
            }

            // Rzutowanie w dół interfejsu IRotate
            IRotate rotatable = (IRotate)figure;

            rotatable.Rotate();
            for (i = 0; i < 4; i++)
            {
                for (j = 0; j < 4; j++)
                {
                    if (figure.grid[i, j] && !CheckSize(figure.x + i, figure.y + j))
                    {
                        return;
                    }
                    if (figure.grid[i, j] && !oldGrid[i, j] && grid[figure.x + i, figure.y + j].InUse)
                    {
                        return;
                    }
                }
            }
            for (i = 0; i < 4; i++)
            {
                for (j = 0; j < 4; j++)
                {
                    if (oldGrid[i, j])
                    {
                        grid[figure.x + i, figure.y + j].Remove(graphic, BackColor);
                    }
                }
            }

            DrawFigure(figure.x, figure.y, figure);
        }
Beispiel #10
0
        public AGSSprite(Resolver resolver, IMaskLoader maskLoader)
        {
            _id = Interlocked.Increment(ref _lastId);
            _pixelPerfectArea = new Lazy <IArea>(generatePixelPerfectArea);
            _maskLoader       = maskLoader;
            _resolver         = resolver;

            //todo: abstract it to the constructor
            _translate      = new AGSTranslate();
            _hasImage       = new AGSHasImage();
            _hasImage.Pivot = new PointF();
            _scale          = new AGSScale();
            AGSScale.BindSizeToImage(_hasImage, _scale);
            _rotate = new AGSRotate();

            _scale.PropertyChanged     += onPropertyChanged;
            _hasImage.PropertyChanged  += onPropertyChanged;
            _translate.PropertyChanged += onPropertyChanged;
        }
Beispiel #11
0
    private void FireRotateEvent(float angle, RotationDirections dir)
    {
        Vector2 midPoint = GetMidPoint(gesture_finger1.position, gesture_finger2.position);

        GameObject hitObj = GetHit(midPoint);

        RotateEventArgs args = new RotateEventArgs(gesture_finger1, gesture_finger2, angle, dir, hitObj);

        if (OnRotate != null)
        {
            OnRotate(this, args);
        }

        if (hitObj != null)
        {
            IRotate rot = hitObj.GetComponent <IRotate>();
            if (rot != null)
            {
                rot.onRotate(args);
            }
        }
    }
        private Matrix4 getModelMatrix(IScale scale, IRotate rotate, ITranslate translate, IHasImage image,
                                       PointF areaScaling, PointF resolutionTransform, bool useCustomImageSize)
        {
            if (scale == null)
            {
                return(Matrix4.Identity);
            }
            float?customWidth = _customImageSize == null || !useCustomImageSize ?
                                _nullFloat : _customImageSize.Value.Width;
            float?customHeight = _customImageSize == null || !useCustomImageSize ?
                                 _nullFloat : _customImageSize.Value.Height;
            float   width         = (customWidth ?? scale.Width) * resolutionTransform.X;
            float   height        = (customHeight ?? scale.Height) * resolutionTransform.Y;
            PointF  anchorOffsets = getAnchorOffsets(image.Anchor, width, height);
            Matrix4 anchor        = Matrix4.CreateTranslation(new Vector3(-anchorOffsets.X, -anchorOffsets.Y, 0f));
            Matrix4 scaleMat      = Matrix4.CreateScale(new Vector3(scale.ScaleX * areaScaling.X,
                                                                    scale.ScaleY * areaScaling.Y, 1f));
            Matrix4 rotation  = Matrix4.CreateRotationZ(rotate.Angle);
            float   x         = translate.X * resolutionTransform.X;
            float   y         = translate.Y * resolutionTransform.Y;
            Matrix4 transform = Matrix4.CreateTranslation(new Vector3(x, y, 0f));

            return(anchor * scaleMat * rotation * transform);
        }
Beispiel #13
0
 public AGSRotateComponent(IRotate rotate)
 {
     _rotate = rotate;
 }
Beispiel #14
0
 void Awake()
 {
     myTarget = GetComponent <ITarget>();
     myRotate = GetComponent <IRotate>();
     myEffect = GetComponent <IEffect>();
 }
 void Awake()
 {
     _rotateController = GetComponent <IRotate>();
     _camera           = Camera.main;
     _transform        = transform;
 }
Beispiel #16
0
 private void Awake()
 {
     _moveController   = GetComponent <IMove>();
     _rotateController = GetComponent <IRotate>();
     _transform        = transform;
 }
 public AGSRotateComponent(IRotate rotate)
 {
     _rotate = rotate;
 }
Beispiel #18
0
 /// <summary>
 /// Tweens the angle to rotate.
 /// <example>
 /// <code language="lang-csharp">
 /// var tween = obj.TweenAngle(45f, 2f, Ease.Linear);
 /// await tween.Task;
 /// </code>
 /// </example>
 /// <seealso cref="Tween"/>
 /// <seealso cref="IRotate.Angle"/>
 /// </summary>
 /// <returns>The tween.</returns>
 /// <param name="sprite">Sprite.</param>
 /// <param name="toAngle">To angle.</param>
 /// <param name="timeInSeconds">Time in seconds.</param>
 /// <param name="easing">Easing function.</param>
 public static Tween TweenAngle(this IRotate sprite, float toAngle, float timeInSeconds, Func <float, float> easing = null)
 {
     return(Tween.Run(sprite.Angle, toAngle, a => sprite.Angle = a, timeInSeconds, easing));
 }
Beispiel #19
0
 public App(IConfigurationRoot config, IReadMeta readMeta, IRotate rotate)
 {
     _config   = config;
     _readMeta = readMeta;
     _rotate   = rotate;
 }
Beispiel #20
0
 public static T Rotate <T>(this IRotate <T> objectToRotate, ILinear axisOfRotation, Angle angleOfRotation)
 {
     return(objectToRotate.Rotate(new Rotation(angleOfRotation, axisOfRotation)));
 }
Beispiel #21
0
 protected virtual void Awake()
 {
     _moveController   = GetComponent <IMove>();
     _rotateController = GetComponent <IRotate>();
 }
Beispiel #22
0
        void Start()
        {
            inputActions.Player.Aim.performed += OnRotationInput;

            rotateable = GetComponent <IRotate>();
        }
Beispiel #23
0
        private IRotate _rotate; // For rotating the turret

        protected override void Awake()
        {
            base.Awake();
            _rotate = GetComponent <IRotate>();
        }
Beispiel #24
0
 void Awake()
 {
     movement = GetComponent <IMoveVelocity>();
     rotation = GetComponent <IRotate>();
 }
Beispiel #25
0
 public void Start()
 {
     this._translation = GetComponent <ITranslation>();
     this._rotate      = GetComponent <IRotate>();
     this._animate     = GetComponent <IAnimate>();
 }