예제 #1
0
 public GameObject PickUp(Transform controllPoint)
 {
     FlagOnMove = true;
     transform.SetParent(controllPoint);
     transform.localPosition = Vector3.zero;
     CurPoint.RemovePick();
     GameManager.ChangeGameState(GameState.PickThing);
     PlayerInput.Pickable = this;
     return(gameObject);
 }
예제 #2
0
    public GameObject PutDown(Vector3 centerPos)
    {
        if (!flagActive)
        {
            return(null);
        }

        FlagOnMove = false;
        ShowFlag(true);
        transform.SetParent(null);
        transform.position = centerPos;
        CurPoint.SetPickable(this);
        GameManager.ChangeGameState(GameState.PlayGame);
        return(gameObject);
    }
예제 #3
0
        /// <summary>
        /// Translates a 2D object, represented as an array of points that form it`s outline.
        /// </summary>
        /// <param name="obj"> The object to transform represented as an array of points that form it`s outline. </param>
        /// <param name="HorisontalTrans"> The horizontal translation distance. </param>
        /// <param name="VerticalTrans">  The vertical translation distance.</param>
        /// <returns> A PointF[] with outline points of the transformed copy of the object. </returns>
        public static PointF[] Translate(PointF[] obj, double HorisontalTrans, double VerticalTrans)
        {
            PointF[] TranslatedtedObj = new PointF[obj.Length];
            TMatrix  CurPoint;

            for (int i = 0; i < TranslatedtedObj.Length; i++)
            {
                CurPoint = FormCoordsMatrix(obj[i].X, obj[i].Y);
                CurPoint = GetTranslationMatrix(HorisontalTrans, VerticalTrans).Multiply(CurPoint);
                TranslatedtedObj[i].X = CurPoint.GetValue(0, 0);
                TranslatedtedObj[i].Y = CurPoint.GetValue(1, 0);
            }

            return(TranslatedtedObj);
        }
예제 #4
0
        public static PointF3D[] Translate3D(PointF3D[] obj, double x, double y, double z)
        {
            PointF3D[] TranslatedtedObj = new PointF3D[obj.Length];
            obj.CopyTo(TranslatedtedObj, 0);
            Matrix CurPoint;

            for (int i = 0; i < TranslatedtedObj.Length; i++)
            {
                CurPoint = Form3DCoordsMatrix(obj[i].X, obj[i].Y, obj[i].Z);
                CurPoint = Get3DTranslationMatrix(x, y, z).Multiply(CurPoint);
                TranslatedtedObj[i].X = (float)CurPoint.GetElementValue(0, 0);
                TranslatedtedObj[i].Y = (float)CurPoint.GetElementValue(1, 0);
                TranslatedtedObj[i].Z = (float)CurPoint.GetElementValue(2, 0);
            }

            return(TranslatedtedObj);
        }
예제 #5
0
        /* Rotates the object.
         * Input:
         * PointF[] obj - the object`s outline, represented as an array of points;
         * double angle - the rotation angle in degrees;
         * PointF RotationCentre - a point the rotation will be performed around.
         * Output: a PointF array that contains the rotated object`s outline.
         */
        public static PointF[] Rotate(PointF[] obj, double angle, PointF RotationCentre)
        {
            PointF[] RotatedObj = new PointF[obj.Length];
            obj.CopyTo(RotatedObj, 0);

            RotatedObj = Translate(RotatedObj, -RotationCentre.X, -RotationCentre.Y);

            TMatrix CurPoint;

            for (int i = 0; i < RotatedObj.Length; i++)
            {
                CurPoint        = FormCoordsMatrix(RotatedObj[i].X, RotatedObj[i].Y);
                CurPoint        = GetRotationMatrix(angle).Multiply(CurPoint);
                RotatedObj[i].X = CurPoint.GetValue(0, 0);
                RotatedObj[i].Y = CurPoint.GetValue(1, 0);
            }

            RotatedObj = Translate(RotatedObj, RotationCentre.X, RotationCentre.Y);
            return(RotatedObj);
        }
예제 #6
0
        public static PointF3D[] RotateZ3D(PointF3D[] obj, double angle, PointF3D RotationCentre)
        {
            PointF3D[] RotatedObj = new PointF3D[obj.Length];
            obj.CopyTo(RotatedObj, 0);

            RotatedObj = Translate3D(RotatedObj, -RotationCentre.X, -RotationCentre.Y, -RotationCentre.Z);

            Matrix CurPoint;

            for (int i = 0; i < RotatedObj.Length; i++)
            {
                CurPoint        = Form3DCoordsMatrix(RotatedObj[i].X, RotatedObj[i].Y, RotatedObj[i].Z);
                CurPoint        = GetZRotation3DMatrix(angle).Multiply(CurPoint);
                RotatedObj[i].X = (float)CurPoint.GetElementValue(0, 0);
                RotatedObj[i].Y = (float)CurPoint.GetElementValue(1, 0);
                RotatedObj[i].Z = (float)CurPoint.GetElementValue(2, 0);
            }

            RotatedObj = Translate3D(RotatedObj, RotationCentre.X, RotationCentre.Y, RotationCentre.Z);
            return(RotatedObj);
        }
예제 #7
0
        /// <summary>
        /// Scales a 2D object relative to a point.
        /// The object is represented as an array of points that form it`s outline.
        /// </summary>
        /// <param name="obj"> The object to transform, represented as an array of points that form it`s outline. </param>
        /// <param name="HorisontalScaling"> Value of horizontal scaling. </param>
        /// <param name="VerticalScaling"> Value of vertical scaling. </param>
        /// <param name="ScalingCentre"> The point that scaling is relative to. </param>
        /// <returns> A PointF[] with outline points of the transformed copy of the object. </returns>
        public static PointF[] Scale(PointF[] obj, double HorisontalScaling, double VerticalScaling, PointF ScalingCentre)
        {
            PointF[] ScaledtedObj = new PointF[obj.Length];
            obj.CopyTo(ScaledtedObj, 0);

            ScaledtedObj = Translate(ScaledtedObj, -ScalingCentre.X, -ScalingCentre.Y);

            TMatrix CurPoint;

            for (int i = 0; i < ScaledtedObj.Length; i++)
            {
                CurPoint          = FormCoordsMatrix(ScaledtedObj[i].X, ScaledtedObj[i].Y);
                CurPoint          = GetScalingMatrix(HorisontalScaling, VerticalScaling).Multiply(CurPoint);
                ScaledtedObj[i].X = CurPoint.GetValue(0, 0);
                ScaledtedObj[i].Y = CurPoint.GetValue(1, 0);
            }

            ScaledtedObj = Translate(ScaledtedObj, ScalingCentre.X, ScalingCentre.Y);

            return(ScaledtedObj);
        }
예제 #8
0
        public static PointF3D[] Scale3D(PointF3D[] obj, double xScal, double yScal, double zScal, PointF3D ScalingCentre)
        {
            PointF3D[] ScaledtedObj = new PointF3D[obj.Length];
            obj.CopyTo(ScaledtedObj, 0);

            ScaledtedObj = Translate3D(ScaledtedObj, -ScalingCentre.X, -ScalingCentre.Y, -ScalingCentre.Z);

            Matrix CurPoint;

            for (int i = 0; i < ScaledtedObj.Length; i++)
            {
                CurPoint          = Form3DCoordsMatrix(ScaledtedObj[i].X, ScaledtedObj[i].Y, ScaledtedObj[i].Z);
                CurPoint          = Get3DScalingMatrix(xScal, yScal, zScal).Multiply(CurPoint);
                ScaledtedObj[i].X = (float)CurPoint.GetElementValue(0, 0);
                ScaledtedObj[i].Y = (float)CurPoint.GetElementValue(1, 0);
                ScaledtedObj[i].Z = (float)CurPoint.GetElementValue(2, 0);
            }

            ScaledtedObj = Translate3D(ScaledtedObj, ScalingCentre.X, ScalingCentre.Y, ScalingCentre.Z);

            return(ScaledtedObj);
        }
예제 #9
0
        /// <summary>
        /// Reflects a 2D object relative to a point.
        /// The object is represented as an array of points that form it`s outline.
        /// </summary>
        /// <param name="obj"> The object to transform, represented as an array of points that form it`s outline. </param>
        /// <param name="ReflectXAxis"> A flag, that tells whether the object should be reflected around the X axis. </param>
        /// <param name="ReflectYAxis"> A flag, that tells whether the object should be reflected around the Y axis. </param>
        /// <param name="ReflectionCentre"> A point that the object should be reflected relative to. </param>
        /// <returns> A PointF[] with outline points of the transformed copy of the object. </returns>
        public static PointF[] Reflect(PointF[] obj, bool ReflectXAxis, bool ReflectYAxis, PointF ReflectionCentre)
        {
            PointF[] ReflectedObj = new PointF[obj.Length];
            obj.CopyTo(ReflectedObj, 0);

            ReflectedObj = Translate(ReflectedObj, -ReflectionCentre.X, -ReflectionCentre.Y);

            int xReflection = (ReflectXAxis) ? -1 : 1;
            int YReflection = (ReflectYAxis) ? -1 : 1;

            TMatrix CurPoint;

            for (int i = 0; i < ReflectedObj.Length; i++)
            {
                CurPoint          = FormCoordsMatrix(ReflectedObj[i].X, ReflectedObj[i].Y);
                CurPoint          = GetScalingMatrix(xReflection, YReflection).Multiply(CurPoint);
                ReflectedObj[i].X = CurPoint.GetValue(0, 0);
                ReflectedObj[i].Y = CurPoint.GetValue(1, 0);
            }

            ReflectedObj = Translate(ReflectedObj, ReflectionCentre.X, ReflectionCentre.Y);

            return(ReflectedObj);
        }