Beispiel #1
0
    void Update()
    {
        if (GameManager.Instance.GameState != GameState.Playing)
        {
            return;
        }


        if (GameManager.Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            viewportOrigin = cam.ScreenToWorldPoint(GameManager.Input.mousePosition);
            drag           = true;
        }

        if (GameManager.Input.GetMouseButton(0) && drag)
        {
            Vector2 drag = viewportOrigin - cam.ScreenToWorldPoint(GameManager.Input.mousePosition);

            cameraman.DragCamera(drag);

            viewportOrigin = cam.ScreenToWorldPoint(GameManager.Input.mousePosition);
        }
        else
        {
            drag = false;
            Vector2 movementCam = new Vector2(GameManager.Input.GetAxis("Horizontal"), GameManager.Input.GetAxis("Vertical"));

            if (cameraman.enableBorderMovement)
            {
                if (GameManager.Input.mousePosition.x < 5)
                {
                    movementCam.x -= 0.75f;
                }
                if (GameManager.Input.mousePosition.x > Screen.width - 5)
                {
                    movementCam.x += 0.75f;
                }
                if (GameManager.Input.mousePosition.y < 5)
                {
                    movementCam.y -= 0.75f;
                }
                if (GameManager.Input.mousePosition.y > Screen.height - 5)
                {
                    movementCam.y += 0.75f;
                }
            }

            cameraman.MoveTargetCamera(movementCam.x, movementCam.y);
        }
        cameraman.ChangeZoomCamera(-GameManager.Input.mouseScrollDelta.y * 1.5f);

        if (harvestMode)
        {
            //cameraman.SetTarget(motherShip.transform.position);
            //cameraman.SetZoomLevel(7f);
            if (GameManager.Input.GetMouseButtonDown(0))
            {
                if (!movable.Moving && TurnManager.Instance.State == TurnManager.TurnState.Player)
                {
                    TileProperties tile = GetTile();

                    if (motherShip.TilesInRange.Contains(tile) && entitiesHarvestable.CurrentTile != tile && !entitiesHarvestable.CursorIsOnButton())
                    {
                        entitiesHarvestable.Clear();
                        entitiesHarvestable.NewEntitiesToHarvest(tile);
                    }
                    else if (entitiesHarvestable.Displaying && !entitiesHarvestable.CursorIsOnButton())
                    {
                        entitiesHarvestable.Clear();
                    }
                }
            }
        }

        if (moveMode)
        {
            if (GameManager.Input.GetMouseButtonDown(1))
            {
                ShowPath();
            }
            else if (GameManager.Input.GetMouseButtonUp(1))
            {
                SetTarget();
            }

            if (GameManager.Input.GetMouseButton(1) && reachableTiles.Displaying)
            {
                reachableTiles.RefreshPath(GetTile());
            }
        }

        OutlineHex();
    }