示例#1
0
        private void HandleMouseInput()
        {
            if (MouseOverUi())
            {
                return;
            }

            if (InputHelper.RightMouseClciked())
            {
                Clear();
                DeselectAll();
                Loc.GetGameController().OrderSelectionController.DisableAndReset();
            }
            else
            {
                var worldMousePosition = GetWorldMousePosition();

                if (worldMousePosition != null)
                {
                    if (InputHelper.LeftMouseButtonDoubleClicked())
                    {
                        ClearSelection();
                        GetSelection(_selectionPreference, GetSelectedCells(), true);
                    }
                    else
                    {
                        if (InputHelper.LeftMouseButtonStartClick())
                        {
                            _selectionStartWorld = GetWorldMousePosition().Value;
                        }

                        if (InputHelper.LeftMouseButtonReleased())
                        {
                            ClearSelection();
                            GetSelection(_selectionPreference, GetSelectedCells(), false);
                        }

                        if (InputHelper.LeftMouseButtonIsBeingClicked())
                        {
                            ShowSelectionRectangle();

                            var selectionEndScreenPosition = Input.mousePosition;
                            var start = Loc.GetCamera().Camera.WorldToScreenPoint(_selectionStartWorld);
                            start.z = 0f;

                            SelectSquareImage.position = (start + selectionEndScreenPosition) / 2;

                            var sizeX = Mathf.Abs(start.x - selectionEndScreenPosition.x);
                            var sizeY = Mathf.Abs(start.y - selectionEndScreenPosition.y);

                            SelectSquareImage.sizeDelta = new Vector2(sizeX, sizeY);

                            ShowCursorEffects(GetSelectedCells());
                        }
                    }
                }
            }
        }
示例#2
0
        private Vector3?GetWorldMousePosition()
        {
            var inputRay = Loc.GetCamera().Camera.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(inputRay, out RaycastHit hit))
            {
                return(hit.point);
            }
            return(null);
        }
示例#3
0
 public void CreatureClicked()
 {
     if (Creature != null)
     {
         Loc.GetCamera().ViewPoint(Creature.Vector);
         Loc.GetGameController().ShowCreaturePanel(new List <CreatureRenderer> {
             Creature.CreatureRenderer
         });
     }
 }
示例#4
0
 public void Update()
 {
     if (Data.Amount <= 0)
     {
         Loc.GetItemController().DestroyItem(Data);
     }
     else
     {
         _text.text = Data.Amount.ToString();
         _text.transform.localRotation = Quaternion.Euler(Loc.GetCamera().GetPerpendicularRotation(), -90, -90);
     }
 }
示例#5
0
 public static Save MakeSave()
 {
     return(new Save
     {
         MapGenerationData = MapGenerationData.Instance,
         Factions = Loc.GetFactionController().Factions.Values.ToList(),
         Time = Loc.GetTimeManager().Data,
         Items = Loc.GetIdService().ItemIdLookup.Values.ToList(),
         CameraData = new CameraData(Loc.GetCamera()),
         Rooms = Loc.GetZoneController().RoomZones,
         Stores = Loc.GetZoneController().StorageZones,
         Areas = Loc.GetZoneController().AreaZones,
         Chunks = Loc.GetMap().Chunks.Values.Select(s => s.Data).ToList(),
     });
 }
示例#6
0
    public void Show(IEnumerable <CreatureData> entities)
    {
        gameObject.SetActive(true);

        // switch to overview panel
        FirstPanelToggle.isOn = true;

        CurrentCreatures = entities.ToList();

        _contextButtons.Clear();
        foreach (Transform child in ButtonPanel.transform)
        {
            Destroy(child.gameObject);
        }

        foreach (Transform child in PropertiesPanel.transform)
        {
            Destroy(child.gameObject);
        }

        if (entities.First() is CreatureData creature && creature.IsPlayerControlled())
        {
            // creatures
            var creatures = entities.OfType <CreatureData>();

            HealthPanel.Load(creature);
            SkillsPanel.Load(creature);
            NeedsPanel.Load(creature);

            AddButton(OrderSelectionController.FollowIcon).SetOnClick(() => Loc.GetCamera().FollowTransform(creatures.First().CreatureRenderer.transform));
            AddButton(OrderSelectionController.MoveIcon).SetOnClick(() => MoveClicked(creatures));
            AddButton(OrderSelectionController.AttackIcon).SetOnClick(() => AttackClicked(creatures));
            AddButton(OrderSelectionController.DefaultRemoveIcon).SetOnClick(() =>
            {
                foreach (var c in creatures)
                {
                    if (c.InCombat)
                    {
                        c.Combatants.Clear();
                    }
                    c.AbandonTask();
                }
            });
        }
    }
示例#7
0
    private void UpdateFloatingText()
    {
        if (Text != null)
        {
            var cameraPerpendicular = Loc.GetCamera().GetPerpendicularRotation();

            Text.transform.rotation = Quaternion.Euler(45, cameraPerpendicular - 90, 0);

            if (RemainingTextDuration > 0)
            {
                RemainingTextDuration -= Time.deltaTime;

                if (RemainingTextDuration < 1f)
                {
                    Text.color = new Color(Text.color.r, Text.color.g, Text.color.b, RemainingTextDuration);
                }
            }
            else
            {
                Text.text = Data.Name;
            }
        }
    }