コード例 #1
0
ファイル: PlayerClass.cs プロジェクト: cytricks/PSMSS
        public void Move( float X, float Y ,Vector2 RightStick)
        {
            position.Y-=Y*ySpeed;
            position.X+=X*xSpeed;

            if(position.Y < 0)
                position.Y=0;

            if(position.X < 0)
                position.X=0;

            if(position.Y > bounds.Y)
                position.Y=bounds.Y;

            if(position.X > bounds.X)
                position.X=bounds.X;

            temp = new Vector2(RightStick.X, RightStick.Y);

            Vector2 CompareVector = new Vector2(0,-1);

            if(!directionVector.IsUnit(1)){
                directionVector = directionVector.Divide(directionVector.Length());
            }

            if(!RightStick.IsUnit(1)){
                RightStick = RightStick.Divide(RightStick.Length());
            }

            directionVector = directionVector.Add(RightStick);
            directionVector = directionVector.Divide(2);

            //			if(RightStick.X < .1 && RightStick.X > -.1)
            //				RightStick.X = 0;
            //
            //			if(RightStick.Y < .1 && RightStick.Y > -.1)
            //				RightStick.Y = 0;

            if(RightStick.X != 0 || RightStick.Y != 0) {
                RotationAngle = CompareVector.Angle(directionVector);//CompareVector.Angle(RightStick);
            }
            else {
                //RotationAngle = 0;
            }

            //			if(RotationAngle < 0 && currentAngle-RotationAngle >0 )
            //				currentAngle -= .1f;
            //			else if(RotationAngle < 0)
            //				currentAngle += .1f;
            //
            //			if(RotationAngle > 0 && currentAngle-RotationAngle <0 )
            //				currentAngle += .1f;
            //			else if(RotationAngle > 0)
            //				currentAngle -= .1f;
        }