Example #1
0
        public void cannot_move_rover_outside_of_plateau(int x, int y, CameraDirection cameraDirection)
        {
            var mars = new Plateau(new Size(1, 1));
            var rover = new Rover(new Coordinate(x, y), cameraDirection);
            mars.PlaceRover(rover);

            Assert.Throws<RoverCannotMoveException>(() => rover.SendInstruction(RoverInstruction.M));
        }
Example #2
0
        public void changes_direction(RoverInstruction instruction, CameraDirection initialDirection, CameraDirection expectedDirection)
        {
            var rover = new Rover(new Coordinate(0, 0), initialDirection);

            rover.SendInstruction(instruction);

            Assert.AreEqual(expectedDirection, rover.CameraDirection);
        }
    void Start()
    {
        Instance = this;
        VisualEffectController = GetComponent<VisualEffectController>();
        player = GameObject.FindGameObjectWithTag("Player");
        CameraDirection = startCameraDirection;

        doOnce = true;
    }
Example #4
0
        protected void OnHandSwipeHandler(Gesture gesture, float moveTime)
        {
            if (m_inZooming || !m_canSlide || this.m_isKickBack)
            {
                return;
            }

            if (rotateTweener != null)
            {
                rotateTweener.Kill();
            }

            Vector2 swipeDelta = gesture.swipeVector;

            swipeDelta.x = Mathf.Sign(swipeDelta.x) * Mathf.Min(Mathf.Abs(swipeDelta.x), X_AXIS_ROTATE_THRESHOLD);
            swipeDelta.y = Mathf.Sign(swipeDelta.y) * Mathf.Min(Mathf.Abs(swipeDelta.y), Y_AXIS_ROTATE_THRESHOLD);

            Vector3 rotateValue = Vector3.right * swipeDelta.y - Vector3.up * swipeDelta.x;

            CameraDirection cameraDirection_0 = CameraDirection.None;
            CameraDirection cameraDirection_1 = CameraDirection.None;
            Vector3         cacheRotate       = rotateValue;

            //Debug.Log("rotateValue" + rotateValue);
            IsCameraOverStep(ref cameraDirection_0, ref cameraDirection_1, ref rotateValue);

            if (cameraDirection_0 != CameraDirection.None && cameraDirection_1 != CameraDirection.None)
            {
                //Debug.Log("rotateValue" + rotateValue + "  targetDummy_0 : " + targetDummy_0 + "targetDummy_1 :  " + targetDummy_1 + " d_0 : " + cameraDirection_0 + "   d_1 : " + cameraDirection_1);
                if (!m_needKickBack)
                {
                    m_srcRotate = GameSceneCamera.transform.localEulerAngles;
                    EngineCoreEvents.InputEvent.OnTouchup -= OnTouchup;
                    EngineCoreEvents.InputEvent.OnTouchup += OnTouchup;
                }
                this.m_needKickBack = true;

                rotateValue = Vector3.Normalize(cacheRotate) * KICK_BACKFACTOR;
            }
            m_currentDir = rotateValue * 0.1f * CameraManager.Instance.DragDelta;                                                      // + m_moveRotate;
            rotateTweener.Kill();
            Vector3 targetRotate = GameSceneCamera.transform.localEulerAngles + rotateValue * 0.1f * CameraManager.Instance.DragDelta; // + m_moveRotate;

            m_cacheRotate = targetRotate;

            rotateTweener = GameSceneCamera.transform.DOLocalRotate(targetRotate, moveTime).SetEase(Ease.OutSine).OnUpdate(OnRotateTweenerTweening);//.OnComplete(() =>


            EngineCoreEvents.InputEvent.OnTouchScene.SafeInvoke();
            //Vector3 targetRotate = GameSceneCamera.transform.localEulerAngles + rotateValue * 0.1f * CameraManager.Instance.DragDelta;

            //rotateTweener = GameSceneCamera.transform.DOLocalRotate(targetRotate, moveTime).OnUpdate(OnRotateTweenerTweening);
        }
Example #5
0
 public override void OnEnter(GameObject cameraRig, int number, CameraDirection cameraDirection = null)
 {
     if (!m_active)
     {
         if (null == m_camerarigobject)
         {
             base.OnEnter(cameraRig, number, cameraDirection);
             m_directionHoverPattern.OnEnter(cameraRig, cameraDirection);
             m_camerarigobject = cameraRig;
         }
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        if (Player == null)
        {
            Player = FindObjectOfType <PlayerController>();
        }

        // Starting camera position
        targetPos          = new Vector3(Player.transform.position.x, Player.transform.position.y + camMinOffsetY, -camDepth);
        transform.position = targetPos;
        CamDirection       = CameraDirection.NORMAL;
    }
        public void StopFly(CameraDirection direction)
        {
            CameraDirection oldDirection = _flyDirection;

            _flyDirection &= ~direction;

            if (oldDirection != CameraDirection.None &&
                _flyDirection == CameraDirection.None)
            {
                CompositionTarget.Rendering -= OnCompositionTargetRendering;
            }
        }
Example #8
0
        public SteeringStep WithCamDirection(CameraDirection direction, bool value)
        {
            if (value)
            {
                CamDirection |= direction;
            }
            else
            {
                CamDirection &= ~direction;
            }

            return(this);
        }
Example #9
0
        public void StartFly(CameraDirection direction)
        {
            CameraDirection oldDirection = _flyDirection;

            _flyDirection |= direction;

            if (oldDirection == CameraDirection.None &&
                _flyDirection != CameraDirection.None)
            {
                this.lastTick                = 0;
                this.flyIncrement            = 0;
                CompositionTarget.Rendering += OnCompositionTargetRendering;
            }
        }
Example #10
0
        public void Move(CameraType type, CameraDirection direction)
        {
            string d;

            switch (direction)
            {
            case CameraDirection.ZoomIn: d = "zoom+"; break;

            case CameraDirection.ZoomOut: d = "zoom-"; break;

            default: d = direction.ToString().ToLower(); break;
            }
            Codec.Send(string.Format("camera {0} move {1}", type.ToString().ToLower(), d));
        }
Example #11
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            //Client client = new Client();
            //new Thread(new ThreadStart(StartThread)).Start();

            /*
             * CommandWriter CommandWriter = new SpaceSimLibrary.Networking.CommandWriter();
             * CommandWriter.WriteCommand(Commands.UpdateEntity);
             * CommandWriter.WriteData(4251);
             * CommandWriter.WriteMatrix(Matrix.Identity);
             * Server.Broadcast(CommandWriter.GetBytes());
             * CommandWriter.Reset();
             */

            /*
             * Client client = new Client();
             * CommandWriter cw = new CommandWriter(Commands.RegisterEntity);
             * cw.WriteData(1);
             * cw.WriteData((byte)3);
             * cw.WriteMatrix(Matrix.Identity);
             * Server.Broadcast(cw.GetBytes());
             * new Thread(new ThreadStart(StartThread)).Start();
             */

            int             clientPort      = 12345;
            CameraDirection cameraDirection = CameraDirection.Forward;

            if (args.Length > 0)
            {
                if (args[0] == "-c2")
                {
                    cameraDirection = CameraDirection.Backward;
                }
                else if (args[0] == "-c3")
                {
                    cameraDirection = CameraDirection.Left;
                    clientPort      = 12346;
                }
                else if (args[0] == "-c4")
                {
                    cameraDirection = CameraDirection.Right;
                }
            }

            using (SpaceSimGame game = new SpaceSimGame(cameraDirection, clientPort))
            {
                game.Run();
            }
        }
 private Vector3 CalculateMovement(CameraDirection cameraDirection, float hoz, float vert)
 {
     switch (cameraDirection)
     {
         case CameraDirection.North:
             return new Vector3(hoz + vert, 0, vert - hoz);
         case CameraDirection.East:
             return new Vector3(hoz - vert, 0, vert + hoz);
         case CameraDirection.South:
             return new Vector3(-hoz - vert, 0, hoz - vert);
         case CameraDirection.West:
             return new Vector3(vert - hoz, 0, -vert - hoz);
         default:
             throw new System.Exception("Bad Camera Direction");
     }
 }
Example #13
0
    /// <summary>
    /// 유저가 호버보드에 탑승했는지 여부를 판단한다.
    /// 유저가 탑승할 수 있는 위치가 정해져 있는데 그 부분에 맞게 탑승했을 경우
    /// 이펙트가 발생하면서 유저가 탑승했는지 여부를 상위 개체에 알려준다.
    /// </summary>
    /// <param name="other"></param>
    private void OnTriggerEnter(Collider other)
    {
        if (GameData.Instance.UserType == UserType.Host)
        {
            return;
        }

        if (other.tag == "Direction")
        {
            if (m_active)
            {
                return;
            }

            if (m_direction.Active)
            {
                return;
            }

            if (0 == GameData.Instance.Player.Team)
            {
                if (null != m_kgPlayer && !m_kgPlayer.NickName.Equals(GameData.Instance.Player.NickName))
                {
                    return;
                }
            }
            else
            {
                if (null != m_kgPlayer && !m_kgPlayer.StoreName.Equals(GameData.Instance.Player.StoreName))
                {
                    return;
                }
            }

            m_cameradirection = other.GetComponent <CameraDirection>();

            if (null == m_cameradirection)
            {
                return;
            }

            m_camerarig = m_cameradirection.m_camerarig;
            OnEnter(true);

            m_direction.OnEnter(m_camerarig, m_number, m_cameradirection);
        }
    }
Example #14
0
        public override void Initialize()
        {
            NearPlane = 1.0f;
            FarPlane  = 1000.0f;
            UpVector  = Vector3.Up;
            CameraDirection.Normalize();

            UpdateView();

            Projection = Matrix.CreatePerspectiveFieldOfView(
                MathHelper.PiOver4,
                GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.AspectRatio,
                NearPlane,
                FarPlane);

            base.Initialize();
        }
Example #15
0
    private void OnTriggerEnter(Collider other)
    {
        if (UserType.Host == GameData.Instance.UserType)
        {
            return;
        }

        if (GameData.Instance.Player.IsDead)
        {
            return;
        }

        CameraDirection cameraDirection = other.GetComponent <CameraDirection>();

        if (null == cameraDirection)
        {
            return;
        }

        switch (m_itemType)
        {
        case ItemType.GunParts:
            if (!GameData.Instance.Player.IsPartsOn)
            {
                GameData.Instance.Player.IsPartsOn = true;
                Active(other.transform);
                SendItemRestore();
            }
            break;

        case ItemType.Buff:
            bool isBuffOn = GameData.Instance.Player.IsBuffOn;
            if (isBuffOn == false)
            {
                Active(other.transform);
                SendItemRestore();
            }
            break;

        case ItemType.Coin:
        case ItemType.Heal:
            Active(other.transform);
            SendItemRestore();
            break;
        }
    }
Example #16
0
    public void SetCameraState(CameraState state, CameraDirection direction)
    {
        switch (state)
        {
        case CameraState.ROTATE:
            CameraRotate(direction);
            break;

        case CameraState.UPANDDOWN:
            CameraUD(direction);
            break;

        case CameraState.ZOOM:
            CameraZoom(direction);
            break;
        }
    }
Example #17
0
        /// <summary>
        /// Check if the camera can move in a direction in a number of pixels.
        /// </summary>
        /// <param name="dir">Direction</param>
        /// <param name="amount">Number of pixels</param>
        /// <returns>False if there are bounded objects blocking move, otherwise true.</returns>
        bool CanMove(CameraDirection dir, int amount)
        {
            // checks the bounded
            Vector2 newOffset = offset;

            foreach (ICameraMonitorable monitorable in boundeds)
            {
                MonitorInfo mi = monitorable.GetMonitorInfo();
                switch (dir)
                {
                case CameraDirection.Up:
                    newOffset.Y -= amount;
                    if (newOffset.Y <= mi.AbsolutePosition.Y)
                    {
                        return(false);
                    }
                    break;

                case CameraDirection.Down:
                    if (newOffset.Y + Game.Window.ClientBounds.Height >= mi.PixelDimensions.Y)
                    {
                        return(false);
                    }
                    newOffset.Y += amount;
                    break;

                case CameraDirection.Left:
                    if (newOffset.X <= mi.AbsolutePosition.X)
                    {
                        return(false);
                    }
                    newOffset.X -= amount;
                    break;

                case CameraDirection.Right:
                    if (newOffset.X + Game.Window.ClientBounds.Width >= mi.PixelDimensions.X)
                    {
                        return(false);
                    }
                    newOffset.X += amount;
                    break;
                }
            }
            return(true);
        }
Example #18
0
        public Vector3D GetDirection(CameraDirection direction)
        {
            // calculate directions
            Vector3D forward = Camera.LookDirection;

            forward.Normalize();

            Vector3D up = Camera.UpDirection;

            up.Normalize();

            Vector3D right = Vector3D.CrossProduct(forward, up);

            // calculate normalized offset
            Vector3D offset = new Vector3D();

            if ((direction & CameraDirection.Forward) == CameraDirection.Forward)
            {
                offset += forward;
            }
            if ((direction & CameraDirection.Backward) == CameraDirection.Backward)
            {
                offset -= forward;
            }

            if ((direction & CameraDirection.Left) == CameraDirection.Left)
            {
                offset -= right;
            }
            if ((direction & CameraDirection.Right) == CameraDirection.Right)
            {
                offset += right;
            }

            if ((direction & CameraDirection.Up) == CameraDirection.Up)
            {
                offset += up;
            }
            if ((direction & CameraDirection.Down) == CameraDirection.Down)
            {
                offset -= up;
            }

            return(offset);
        }
 private void MoveDetectionSqaures(CameraDirection dir)
 {
     for (int i = 0; i < 5; i++)
     {
         if (dir == CameraDirection.FORWARD)
         {
             DetectionList[i].FaceForward();
         }
         else if (dir == CameraDirection.LEFT)
         {
             DetectionList[i].FaceLeft();
         }
         else//dir == CameraDirection.RIGHT
         {
             DetectionList[i].FaceRight();
         }
     }
 }
        public static CameraDirection Turn(this CameraDirection direction, CameraTurn turn)
        {
            if (direction == CameraDirection.Up && turn == CameraTurn.Left)
            {
                return(CameraDirection.Left);
            }

            if (direction == CameraDirection.Up && turn == CameraTurn.Right)
            {
                return(CameraDirection.Right);
            }

            if (direction == CameraDirection.Right && turn == CameraTurn.Left)
            {
                return(CameraDirection.Up);
            }

            if (direction == CameraDirection.Right && turn == CameraTurn.Right)
            {
                return(CameraDirection.Down);
            }

            if (direction == CameraDirection.Down && turn == CameraTurn.Left)
            {
                return(CameraDirection.Right);
            }

            if (direction == CameraDirection.Down && turn == CameraTurn.Right)
            {
                return(CameraDirection.Left);
            }

            if (direction == CameraDirection.Left && turn == CameraTurn.Left)
            {
                return(CameraDirection.Down);
            }

            if (direction == CameraDirection.Left && turn == CameraTurn.Right)
            {
                return(CameraDirection.Up);
            }

            throw new System.Exception($"Unable to turn {turn} from {direction}");
        }
Example #21
0
        public void IsCameraOverStep(ref CameraDirection direction_0, ref CameraDirection direction_1, ref Vector3 rotateValue)
        {
            direction_0 = CameraDirection.None;
            direction_1 = CameraDirection.None;
            float tempY = IsBoundsOutY(rotateValue.y);

            if (tempY > -0.001 && tempY < 0.001 && rotateValue.y != 0)
            {
                direction_0 = rotateValue.y > 0 ? CameraDirection.Right : CameraDirection.Left;
            }
            float tempX = IsBoundsOutX(rotateValue.x);

            if (tempX > -0.001 && tempX < 0.001 && rotateValue.x != 0)
            {
                direction_1 = rotateValue.x > 0 ? CameraDirection.Down : CameraDirection.Up;
            }
            rotateValue.y = tempY;
            rotateValue.x = tempX;
        }
Example #22
0
 public void ChangeDirection(CameraDirection direction, Vector3 portalPosition)
 {
     if (direction == CameraDirection.UP)
     {
         this.offset = firstOffset;
     }
     else if (direction == CameraDirection.DOWN)
     {
         this.offset = new Vector3(firstOffset.x, -firstOffset.y, firstOffset.z);
     }
     else if (direction == CameraDirection.RIGHT)
     {
         this.offset = new Vector3(firstOffset.y * 1.2f, 0.0f, firstOffset.z);
     }
     else if (direction == CameraDirection.LEFT)
     {
         this.offset = new Vector3(-firstOffset.y * 1.2f, 0.0f, firstOffset.z);
     }
 }
Example #23
0
        public void IsCameraOverStep(ref CameraDirection direction_0, ref CameraDirection direction_1, ref Vector3 rotateValue)
        {
            //x > 0  up  y<0 right
            direction_0   = CameraDirection.None;
            direction_1   = CameraDirection.None;
            targetDummy_0 = GetRotateX(rotateValue.x);
            targetDummy_1 = GetRotateY(rotateValue.y);
            if (CameraUtility.IsBoundsInCameraView(targetDummy_1))
            {
                direction_0   = rotateValue.y > 0 ? CameraDirection.Right : CameraDirection.Left;
                rotateValue.y = 0;
            }

            if (CameraUtility.IsBoundsInCameraView(targetDummy_0))
            {
                direction_1   = rotateValue.x > 0 ? CameraDirection.Down : CameraDirection.Up;
                rotateValue.x = 0;
            }
        }
Example #24
0
        public virtual void Update(InputComponent input)
        {
            if (!_camera.Enabled) // Scene change disabled camera temporarily.
            {
                _camera.Enabled = true;
            }

            CameraDirectionChanged = false;
            if (_currentDirectionDegrees == _newDirectionDegrees)
            {
                if (input.RotateCameraLeft)
                {
                    _newDirection        = CameraDirection.Previous();
                    _newDirectionDegrees = _currentDirectionDegrees + 45;
                }
                else if (input.RotateCameraRight)
                {
                    _newDirection        = CameraDirection.Next();
                    _newDirectionDegrees = _currentDirectionDegrees - 45;
                }
            }
            if (_currentDirectionDegrees != _newDirectionDegrees)
            {
                var deltaTime         = Game.UpdateTime.Elapsed.TotalSeconds;
                var desiredQuaternion = Quaternion.RotationY(_newDirectionDegrees * (float)(Math.PI / 180));
                var amount            = (float)Math.Clamp(_currentLerpAmount + (1.5 * deltaTime), 0, 1);
                _cameraTarget.Rotation = Quaternion.Lerp(_currentQuaternion, desiredQuaternion, amount);
                _currentLerpAmount     = amount;
                if (amount >= 0.6f && CameraDirection != _newDirection)
                {
                    CameraDirection        = _newDirection;
                    CameraDirectionChanged = true;
                }
                if (amount == 1.0f)
                {
                    _currentLerpAmount       = 0;
                    _currentDirectionDegrees = _newDirectionDegrees;
                    _currentQuaternion       = _cameraTarget.Rotation;
                    PreviousCameraDirection  = CameraDirection;
                }
            }
        }
Example #25
0
 private void KeyDetection()
 {
     isCameraChange = false;
     if (Input.GetKey(KeyCode.A))
     {
         cameraState     = CameraState.ROTATE;
         cameraDirection = CameraDirection.FORWARD;
         isCameraChange  = true;
     }
     else if (Input.GetKey(KeyCode.D))
     {
         cameraState     = CameraState.ROTATE;
         cameraDirection = CameraDirection.OPPOSITE;
         isCameraChange  = true;
     }
     else if (Input.GetKey(KeyCode.W))
     {
         cameraState     = CameraState.UPANDDOWN;
         cameraDirection = CameraDirection.FORWARD;
         isCameraChange  = true;
     }
     else if (Input.GetKey(KeyCode.S))
     {
         cameraState     = CameraState.UPANDDOWN;
         cameraDirection = CameraDirection.OPPOSITE;
         isCameraChange  = true;
     }
     else if (Input.GetKey(KeyCode.J))
     {
         cameraState     = CameraState.ZOOM;
         cameraDirection = CameraDirection.FORWARD;
         isCameraChange  = true;
     }
     else if (Input.GetKey(KeyCode.K))
     {
         cameraState     = CameraState.ZOOM;
         cameraDirection = CameraDirection.OPPOSITE;
         isCameraChange  = true;
     }
 }
        public void SetCamera(Camera cam, CameraDirection dir)
        {
            AxisAlignedBox boundingBox = disp.BoundingBox;

            // find the size along the largest axis
            float   size = Math.Max(Math.Max(boundingBox.Size.x, boundingBox.Size.y), boundingBox.Size.z);
            Vector3 dirVec;

            switch (dir)
            {
            default:
            case CameraDirection.Above:
                // for some reason axiom messes up the camera matrix when you point
                // the camera directly down, so this vector is ever so slightly off
                // from negative Y.
                dirVec = new Vector3(0.0001f, -1f, 0f);
                dirVec.Normalize();
                break;

            case CameraDirection.North:
                dirVec = Vector3.UnitZ;
                break;

            case CameraDirection.South:
                dirVec = Vector3.NegativeUnitZ;
                break;

            case CameraDirection.West:
                dirVec = Vector3.UnitX;
                break;

            case CameraDirection.East:
                dirVec = Vector3.NegativeUnitX;
                break;
            }

            cam.Position = boundingBox.Center + (size * 2 * (-dirVec));

            cam.Direction = dirVec;
        }
Example #27
0
        private void CameraMove(CameraDirection direction)
        {
            Vector3 rotation = pivot.rotation.eulerAngles;
            int     targetZoom;

            switch (direction)
            {
            case CameraDirection.Up:
                rotation.x = Mathf.Clamp(rotation.x + verticalIncrement, verticalLimits.x, verticalLimits.y);
                break;

            case CameraDirection.Down:
                rotation.x = Mathf.Clamp(rotation.x - verticalIncrement, verticalLimits.x, verticalLimits.y);
                break;

            case CameraDirection.Left:
                rotation.y += horizontalIncrement;
                break;

            case CameraDirection.Right:
                rotation.y -= horizontalIncrement;
                break;

            case CameraDirection.ZoomIn:
                targetZoom = (int)Mathf.Clamp(gameCamera.orthographicSize + 1, zoomLimits.x, zoomLimits.y);
                StartCoroutine(ZoomSmooth(targetZoom));
                break;

            case CameraDirection.ZoomOut:
                targetZoom = (int)Mathf.Clamp(gameCamera.orthographicSize - 1, zoomLimits.x, zoomLimits.y);
                StartCoroutine(ZoomSmooth(targetZoom));
                break;
            }

            if (!pivoting)
            {
                StartCoroutine(PivotCamera(Quaternion.Euler(rotation)));
            }
        }
    void Update()
    {
        if (GameInformation.Instance.GameState != GameState.Playing) return;
        if (player.GetComponent<PlayerInformation>().CharacterState != CharacterState.Alive) return;

        if (doOnce)
        {
            doOnce = false;
            StartCoroutine(CameraDistanceController());
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            CameraDirection = SwitchCameraDirection(CameraDirection, true);
            StartCoroutine(RotateCamera());
            return;
        }
        else if (Input.GetKeyDown(KeyCode.Q))
        {
            CameraDirection = SwitchCameraDirection(CameraDirection, false);
            StartCoroutine(RotateCamera());
            return;
        }

        if (player.gameObject != null)
        {
            transform.position = CalculateTargetPosition();
            transform.LookAt(player.transform);
        }

        if (Input.mouseScrollDelta != Vector2.zero)
            TargetCameraDistance -= Convert.ToInt32(Input.mouseScrollDelta.y);

        TargetCameraDistance = Mathf.Clamp(TargetCameraDistance, MinCameraDistance, MaxCameraDistance);

        DebugController.Instance.LogLine(string.Format("CAM DIRECTION: {0}", CameraDirection.ToString()));
        DebugController.Instance.LogLine(string.Format("CAM TARGET DISTANCE: {0}", TargetCameraDistance));
    }
    private void MoveCameraInDirection(CameraDirection direciton)
    {
        Vector3 newPosition;

        switch (direciton)
        {
        case CameraDirection.Left: {
            newPosition = Vector3.Lerp(_cameraTransform.position, new Vector3(-1.0f * _speed, _cameraTransform.transform.position.y, _cameraTransform.position.z), Time.deltaTime);
            break;
        }

        case CameraDirection.Right: {
            newPosition = Vector3.Lerp(_cameraTransform.position, new Vector3(_speed, _cameraTransform.transform.position.y, _cameraTransform.position.z), Time.deltaTime);
            break;
        }

        default: {
            newPosition = _cameraTransform.position;
            break;
        }
        }
        _cameraTransform.position = newPosition;
    }
        public static Point RePositionCamera(this CameraDirection direction, Point position)
        {
            if (direction == CameraDirection.Up)
            {
                return(new Point(position.X, position.Y + 1));
            }

            if (direction == CameraDirection.Right)
            {
                return(new Point(position.X + 1, position.Y));
            }

            if (direction == CameraDirection.Down)
            {
                return(new Point(position.X, position.Y - 1));
            }

            if (direction == CameraDirection.Left)
            {
                return(new Point(position.X - 1, position.Y));
            }

            throw new System.Exception($"Unable to reposition {direction} from {position}");
        }
Example #31
0
        public void MoveCameraInDirection(CameraDirection direction)
        {
            switch (direction)
            {
            case CameraDirection.Down:
                targetCamPosition.Y -= cameraPanRate;
                break;

            case CameraDirection.Right:
                targetCamPosition.X -= cameraPanRate;
                break;

            case CameraDirection.Up:
                targetCamPosition.Y += cameraPanRate;
                break;

            case CameraDirection.Left:
                targetCamPosition.X += cameraPanRate;
                break;

            default:
                throw new ArgumentOutOfRangeException("direction", direction, null);
            }
        }
 public DirectionAndMarker(CameraDirection dir, Waypoint obj)
 {
     this.dir = dir;
     this.obj = obj;
 }
Example #33
0
        public void CameraMove(float speed)
        {
            cameracnt++;
            if (cameracnt >= a)
            {
                if (player2.IsStop())//もしプレイヤーが止まってたら
                {
                    if (cameraPos.X < player2.GetPosition().X)
                    {
                        cameraDirection = CameraDirection.RIGHT;
                    }
                    if (cameraPos.X > player2.GetPosition().X)
                    {
                        cameraDirection = CameraDirection.LEFT;
                    }
                    if (cameraPos.Y < player2.GetPosition().Y)
                    {
                        cameraDirection = CameraDirection.UP;
                    }
                    if (cameraPos.Y > player2.GetPosition().Y)
                    {
                        cameraDirection = CameraDirection.DOWN;
                    }

                    cameraPos = player2.GetPosition();
                }
                else if (player.IsStop())//もしプレイヤーが止まってたら
                {
                    if (cameraPos.X < player.GetPosition().X)
                    {
                        cameraDirection = CameraDirection.RIGHT;
                    }
                    if (cameraPos.X > player.GetPosition().X)
                    {
                        cameraDirection = CameraDirection.LEFT;
                    }
                    if (cameraPos.Y < player.GetPosition().Y)
                    {
                        cameraDirection = CameraDirection.UP;
                    }
                    if (cameraPos.Y > player.GetPosition().Y)
                    {
                        cameraDirection = CameraDirection.DOWN;
                    }
                    cameraPos = player.GetPosition();
                }
                cameracnt = 0;
            }

            if (bpm == 150)
            {
                if (StageState.worldsStage == 1)
                {
                    switch (cameraDirection)
                    {
                    case CameraDirection.IDLE:
                        camera.Move(0, 0);
                        a = 20;
                        break;

                    case CameraDirection.RIGHT:
                        camera.Move(3.8f, 0);
                        a = 60;
                        break;

                    case CameraDirection.LEFT:
                        camera.Move(-3, 0);
                        a = 60;
                        break;

                    case CameraDirection.UP:
                        camera.Move(0, 2);
                        a = 3;
                        break;

                    case CameraDirection.DOWN:
                        camera.Move(0, -2);
                        a = 3;
                        break;
                    }
                }
                else
                {
                    switch (cameraDirection)
                    {
                    case CameraDirection.IDLE:
                        camera.Move(0, 0);
                        a = 60;
                        break;

                    case CameraDirection.RIGHT:
                        camera.Move(4, 0);
                        a = 60;
                        break;

                    case CameraDirection.LEFT:
                        camera.Move(-3, 0);
                        break;

                    case CameraDirection.UP:
                        camera.Move(0, 3f);
                        a = 30;
                        break;

                    case CameraDirection.DOWN:
                        camera.Move(0, -3f);
                        a = 40;
                        break;
                    }
                }
            }
            if (bpm == 120)
            {
                //ステージ3-5のカメラワーク
                if (StageState.worldsStage == 3 && StageState.stageStage == 5)
                {
                    switch (cameraDirection)
                    {
                    case CameraDirection.IDLE:
                        camera.Move(0, 0);
                        a = 20;
                        break;

                    case CameraDirection.RIGHT:
                        camera.Move(3, 0);
                        a = 20;
                        break;

                    case CameraDirection.LEFT:
                        camera.Move(-3, 0);
                        a = 20;
                        break;

                    case CameraDirection.UP:
                        camera.Move(0, 3.5f);
                        a = 10;
                        break;

                    case CameraDirection.DOWN:
                        camera.Move(0, -3.5f);
                        a = 10;
                        break;
                    }
                }
                else
                {
                    switch (cameraDirection)
                    {
                    case CameraDirection.IDLE:
                        camera.Move(0, 0);
                        a = 20;
                        break;

                    case CameraDirection.RIGHT:
                        camera.Move(3, 0);
                        a = 20;
                        break;

                    case CameraDirection.LEFT:
                        camera.Move(-3, 0);
                        a = 20;
                        break;

                    case CameraDirection.UP:
                        camera.Move(0, 2);
                        a = 3;
                        break;

                    case CameraDirection.DOWN:
                        camera.Move(0, -2);
                        a = 3;
                        break;
                    }
                }
            }
            //カメラの向きに合わせて動く

            if (Input.GetKeyState(Keys.Right))
            {
                camera.Move(5, 0);
            }
            if (Input.GetKeyState(Keys.Left))
            {
                camera.Move(-5, 0);
            }
            if (Input.GetKeyState(Keys.Up))
            {
                camera.Move(0, -5);
            }
            if (Input.GetKeyState(Keys.Down))
            {
                camera.Move(0, 5);
            }
        }
Example #34
0
 public Rover(Coordinate coordinate, CameraDirection cameraDirection)
 {
     Coordinate = coordinate;
     CameraDirection = cameraDirection;
     this.movingCallbacks = new List<Func<Coordinate, bool>>();
 }
Example #35
0
        public void Initialize()
        {
            StageState.isClear     = false;
            StageState.isMusic     = false;
            StageState.sceneNumber = 3;
            isEndFlag = false;
            playNow   = false;
            isstart   = false;
            _end      = false;
            safe      = false;
            cnt       = 0;
            alpha     = 0;
            end       = 0;
            gameObjectManager.Initialize();
            firstpositions = new List <int>()
            {
                5, 5, 7, 6, 6, 5, 13, 7, 10, 24, 5, 14, 5, 11, 14
            };
            map2 = new Map2(GameDevice.Instance());

            map2.Load(StageState.worldsStage + "-" + StageState.stageStage + ".csv", "./csv/");
            gameObjectManager.Add(map2);

            if (StageState.worldsStage == 2 || (StageState.worldsStage == 1 && StageState.stageStage == 5))
            {
                bpm       = 150;
                addradian = 0.125f;
                motionbpm = 0.4f;
            }
            else
            {
                bpm       = 120;
                addradian = 0.1f;
                motionbpm = 0.5f;
            }

            positions = new int[, ]
            {
                { 5, 5, 7, 6, 6 },
                { 5, 13, 7, 10, 24 },
                { 5, 4, 5, 11, 14 },
            };
            for (int i = 1; i <= 3; i++)
            {
                for (int j = 1; j <= 5; j++)
                {
                    if (StageState.worldsStage == i)
                    {
                        if (StageState.stageStage == j)
                        {
                            playerposition = new Vector2(96 * 5 + 16, 96 * positions[i - 1, j - 1] + 16);
                        }
                    }
                }
            }

            player       = new Player(new Vector2(playerposition.X + 96, playerposition.Y), GameDevice.Instance(), gameObjectManager, addradian);
            player.stop  = true;
            player.alpha = 1;
            gameObjectManager.Add(player);

            //最初に止まっている
            player2 = new Player2(playerposition, GameDevice.Instance(), gameObjectManager, player.AddRadian());
            gameObjectManager.Add(player2);
            camera.SetPosition(player2.GetPosition());
            cameraPos       = player2.GetPosition();
            cameraDirection = CameraDirection.IDLE;



            player.SetPos(player2.GetPosition());
            metoronome.Initialize();
            metoronome.SetBpm(bpm);
            motion = new Motion();
            motion.Add(0, new Rectangle(200 * 0, 200 * 0, 200, 200));
            motion.Add(1, new Rectangle(200 * 1, 200 * 0, 200, 200));
            motion.Add(2, new Rectangle(200 * 0, 200 * 1, 200, 200));
            motion.Add(3, new Rectangle(200 * 1, 200 * 1, 200, 200));
            motion.Add(4, new Rectangle(1, 1, 1, 1));
            motion.Add(5, new Rectangle(1, 1, 1, 1));
            motion.Initialize(new Range(4, 5), new CountDownTimer(motionbpm));
            startmotion  = StartMotion.NULL;
            startmotions = new Dictionary <StartMotion, Range>()
            {
                { StartMotion.START, new Range(0, 3) },
                { StartMotion.NULL, new Range(4, 5) },
            };
            isp = false;

            startcnt  = 0;
            cameracnt = 0;
            a         = 60;

            motion2 = new Motion();
            motion2.Add(0, new Rectangle(0, 0, 800, 400));
            motion2.Add(1, new Rectangle(0, 0, 800, 400));
            motion2.Add(2, new Rectangle(0, 0, 1, 1));
            motion2.Add(3, new Rectangle(0, 0, 1, 1));
            motion2.Initialize(new Range(2, 3), new CountDownTimer(0.5f));
            clearmotion  = ClearMotion.NULL;
            clearmotions = new Dictionary <ClearMotion, Range>()
            {
                { ClearMotion.CLEAR, new Range(0, 1) },
                { ClearMotion.NULL, new Range(2, 3) },
            };
        }
Example #36
0
        public void Update(GameTime gameTime)
        {
            map2.Update(gameTime);
            gameObjectManager.Update(gameTime);
            float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;

            particlemanager.Update(delta);

            if (Input.GetKeyTrigger(Keys.M) || StageState.isClear)
            {
                cameraDirection = CameraDirection.IDLE;
                if (!isp)
                {
                    ChangeMotion2(ClearMotion.CLEAR);
                    particlemanager.RightCraccar("star", new Vector2(Screen.Width / 2 - 900, 1000), 0.1f, 1, 500, 10000);
                    particlemanager.LeftCraccar("star", new Vector2(Screen.Width / 2 + 900, 1000), 0.1f, 1, 500, 10000);
                    isp = true;
                }

                cnt++;
                if (cnt > 120)
                {
                    sound.StopBGM();

                    isEndFlag = true;
                }
            }

            if (player.IsHit())
            {
                if (player.IsStop())
                {
                    player.SetPosition2(player2.GetPosition());
                }
                else
                {
                    player.SetPosition2(player2.GetPosition());
                }
            }
            if (player2.IsHit())
            {
                if (player2.IsStop())
                {
                    player2.SetPosition2(player.GetPosition());
                }
                else
                {
                    player2.SetPosition2(player.GetPosition());
                }
            }

            if ((!player.IsStop() && !player2.IsStop() && !StageState.isClear) || _end)
            {
                cameraDirection = CameraDirection.IDLE;
                alpha          += 0.05f;
                if (alpha >= 0.5f)
                {
                    alpha = 0.5f;
                }
                sound.StopBGM();
                cnt++;
                StageState.isMusic = false;
                if (cnt >= 120)
                {
                    isEndFlag = true;
                }
            }

            if (!playNow && Input.GetKeyTrigger(Keys.Space))
            {
                isstart = true;
                ChangeMotion(StartMotion.START);
            }

            if (isstart)
            {
                metoronome.CountUpdate();
                player.stop  = false;
                playNow      = true;
                player.alpha = 1;
                sound.PlayBGM(StageState.worldsStage + "-" + StageState.stageStage);


                if (metoronome.IsCount(4))
                {
                    ChangeMotion(StartMotion.NULL);
                    StageState.isMusic = true;
                    isstart            = false;
                    startcnt           = 0;
                }
            }
            motion.Update(gameTime);
            motion2.Update(gameTime);


            if (StageState.isMusic)
            {
                if (!_end && !safe && !StageState.isClear)
                {
                    end++;
                    if (Input.GetKeyTrigger(Keys.Space))
                    {
                        end = 0;
                    }
                    if (bpm == 120)
                    {
                        if (end == 60)
                        {
                            _end = true;
                        }
                    }
                    else if (bpm == 150)
                    {
                        if (end == 48)
                        {
                            _end = true;
                        }
                    }
                }

                CameraMove(3);
            }

            if (StageState.stageStage == 5)
            {
                if (particlemanager.IsCount(60))
                {
                    var rnd = GameDevice.Instance().GetRandom();
                    switch (StageState.worldsStage)
                    {
                    case 1:
                        int namenumber = rnd.Next(30);
                        if (namenumber % 3 == 0)
                        {
                            namenumber = 1;
                        }
                        else
                        {
                            namenumber = 2;
                        }
                        if (particlemanager.IsCount(60))
                        {
                            particlemanager.Backparticle("onpu" + namenumber, new Vector2(rnd.Next(1920), rnd.Next(1080)), 0, 0, 1, 0.5f, 1, 0.5f, 2, 2, 3);
                        }
                        break;

                    case 2:
                        particlemanager.Backparticle("star", new Vector2(rnd.Next(1920), rnd.Next(1080)), 0, 0, 2, 0, 0, 0.5f, 30, 5, 1);
                        particlemanager.Backparticle("star", new Vector2(rnd.Next(3960), rnd.Next(600)), 200, 150, 1, 0, 0, 0.5f, 10, 2, 1);
                        break;

                    case 3:
                        namenumber = rnd.Next(50);
                        if (namenumber % 2 == 0)
                        {
                            namenumber = 1;
                        }
                        else
                        {
                            namenumber = 2;
                        }
                        if (particlemanager.IsCount(60))
                        {
                            particlemanager.Backparticle("snow" + namenumber, new Vector2(rnd.Next(1920), -100), 50, 180, 1, 0f, 1, 0.1f, 1, 15, 1);
                        }
                        particlemanager.Backparticle("star", new Vector2(rnd.Next(1920), rnd.Next(1080)), 100, 180, 2, 0, 0, 0.5f, 30, 5, 1);
                        break;
                    }
                }
            }
        }
    // Initializes the camera.
    public override bool Init(CameraDirection cameraDirection)
    {
        // play mode emulates back facing camera mode only for now
        if (QCARRuntimeUtilities.IsPlayMode())
            cameraDirection = CameraDirection.CAMERA_BACK;

        if (InitCameraDevice((int)cameraDirection) == 0)
        {
            return false;
        }

        mCameraReady = true;

        // in play mode, CameraReady does not only evaluate the above flag, but also the web cam state
        if (this.CameraReady)
        {
            QCARBehaviour qcarBehaviour = (QCARBehaviour)Object.FindObjectOfType(typeof(QCARBehaviour));
            if (qcarBehaviour)
            {
                // resets the number of frames for which the color buffer needs to be cleared
                // to avoid rendering artifacts while the camera is being initialized
                qcarBehaviour.ResetClearBuffers();

                // configure the videobackground, set initial reflection setting
                qcarBehaviour.ConfigureVideoBackground(true);
            }
        }

        return true;
    }
 public DirectionAndObject(CameraDirection dir, StaticObject obj)
 {
     this.dir = dir;
     this.obj = obj;
 }
        public void SetCamera(Camera cam, CameraDirection dir)
        {
            AxisAlignedBox boundingBox = displayObject.BoundingBox;

            // find the size along the largest axis
            float size = Math.Max(Math.Max(boundingBox.Size.x, boundingBox.Size.y), boundingBox.Size.z);
            Vector3 dirVec;

            switch (dir)
            {
                default:
                case CameraDirection.Above:
                    // for some reason axiom messes up the camera matrix when you point
                    // the camera directly down, so this vector is ever so slightly off
                    // from negative Y.
                    dirVec = new Vector3(0.0001f, -1f, 0f);
                    dirVec.Normalize();
                    break;
                case CameraDirection.North:
                    dirVec = Vector3.UnitZ;
                    break;
                case CameraDirection.South:
                    dirVec = Vector3.NegativeUnitZ;
                    break;
                case CameraDirection.West:
                    dirVec = Vector3.UnitX;
                    break;
                case CameraDirection.East:
                    dirVec = Vector3.NegativeUnitX;
                    break;
            }

            cam.Position = boundingBox.Center + (size * 2 * (-dirVec));

            cam.Direction = dirVec;
        }
Example #40
0
 /// <summary>
 /// Initializes the camera.
 /// </summary>
 public abstract bool Init(CameraDirection cameraDirection);
Example #41
0
 /// <summary>
 /// Moves the camera, if possible.
 /// </summary>
 /// <param name="dir">Direction to move</param>
 /// <param name="amount">Number of pixels to move</param>
 public void Move(CameraDirection dir, int amount)
 {
     if (!CanMove(dir, amount)) {
         return;
     }
     switch (dir) {
     case CameraDirection.Down:
         offset.Y += amount;
         break;
     case CameraDirection.Left:
         offset.X -= amount;
         break;
     case CameraDirection.Right:
         offset.X += amount;
         break;
     case CameraDirection.Up:
         offset.Y -= amount;
         break;
     }
 }
Example #42
0
 /// <summary>
 /// Check if the camera can move in a direction in a number of pixels.
 /// </summary>
 /// <param name="dir">Direction</param>
 /// <param name="amount">Number of pixels</param>
 /// <returns>False if there are bounded objects blocking move, otherwise true.</returns>
 bool CanMove(CameraDirection dir, int amount)
 {
     // checks the bounded
     Vector2 newOffset = offset;
     foreach (ICameraMonitorable monitorable in boundeds) {
         MonitorInfo mi = monitorable.GetMonitorInfo();
         switch (dir) {
         case CameraDirection.Up:
             newOffset.Y -= amount;
             if (newOffset.Y <= mi.AbsolutePosition.Y) {
                 return false;
             }
             break;
         case CameraDirection.Down:
             if (newOffset.Y + Game.Window.ClientBounds.Height >= mi.PixelDimensions.Y) {
                 return false;
             }
             newOffset.Y += amount;
             break;
         case CameraDirection.Left:
             if (newOffset.X <= mi.AbsolutePosition.X) {
                 return false;
             }
             newOffset.X -= amount;
             break;
         case CameraDirection.Right:
             if (newOffset.X + Game.Window.ClientBounds.Width >= mi.PixelDimensions.X) {
                 return false;
             }
             newOffset.X += amount;
             break;
         }
     }
     return true;
 }
Example #43
0
 private void EnableLoop(CameraDirection dir)
 {
     CameraDir         = dir;
     loopTimer.Enabled = true;
 }
 private CameraDirection SwitchCameraDirection(CameraDirection cameraDirection, bool clockwise)
 {
     switch (cameraDirection)
     {
         case CameraDirection.North:
             return clockwise ? CameraDirection.East : CameraDirection.West;
         case CameraDirection.East:
             return clockwise ? CameraDirection.South : CameraDirection.North;
         case CameraDirection.South:
             return clockwise ? CameraDirection.West : CameraDirection.East;
         case CameraDirection.West:
             return clockwise ? CameraDirection.North : CameraDirection.South;
         default:
             throw new System.Exception("swich cam direction fail");
     }
 }
 private Vector3 CameraDirectionToRayVector(CameraDirection cameraDirection)
 {
     switch (cameraDirection)
     {
         case CameraDirection.North:
             return new Vector3(-1, 1, -1);
         case CameraDirection.East:
             return new Vector3(1, 1, -1);
         case CameraDirection.South:
             return new Vector3(1, 1, 1);
         case CameraDirection.West:
             return new Vector3(-1, 1, 1);
         default:
             throw new System.Exception("fail");
     }
 }