コード例 #1
0
    private void SelectButton(MouseSelection mouseSelection)
    {
        SetButtonColor(buttonWall, buttonDefaultColor);
        SetButtonColor(buttonOrigen, buttonDefaultColor);
        SetButtonColor(buttonTarget, buttonDefaultColor);

        switch (mouseSelection)
        {
        case MouseSelection.Wall:
            SetButtonColor(buttonWall, buttonSelectedColor);
            break;

        case MouseSelection.Origen:
            SetButtonColor(buttonOrigen, buttonSelectedColor);
            break;

        case MouseSelection.Target:
            SetButtonColor(buttonTarget, buttonSelectedColor);
            break;

        default:
            Debug.LogError("Unknown mouse selection");
            break;
        }
    }
コード例 #2
0
    /// <summary>
    /// All the components desired to be hidden should be stored in a panel on the next level down in the heirarchy.
    /// "Panel" should be used as the GameObject name so that it can always be found when this function is called.
    /// </summary>
    public virtual void HideComponents()
    {
        GameObject panel = transform.Find("Panel").gameObject;

        panel.SetActive(false);
        MouseSelection.DelayNextClickSelect();
    }
コード例 #3
0
ファイル: StaticObject.cs プロジェクト: D7tila/Diablerie
 void OnRenderObject()
 {
     if (objectInfo.draw && objectInfo.selectable[mode])
     {
         MouseSelection.Submit(this);
     }
 }
コード例 #4
0
 void Update()
 {
     //Time.timeScale = 0.5f;
     if (Input.GetMouseButtonUp(0))
     {
         MouseSelection.ClickSelect(out selected);
     }
 }
コード例 #5
0
    public void ChangeMouseSelection(int selection)
    {
        MouseSelection mouseSelection = (MouseSelection)selection;

        SelectButton(mouseSelection);

        mouseManager.SetSelection(mouseSelection);
    }
コード例 #6
0
 void Start()
 {
     inspector       = GetComponent <Inspector>();
     countdown       = 0.2f;
     playerCharacter = FindObjectOfType <PlayerCharacter>();
     selectedColour  = new Color(0.27f, 0.53f, 0.94f);
     mouseSelection  = FindObjectOfType <MouseSelection>();
 }
コード例 #7
0
 public void DestroySelf()
 {
     notificationQueue = FindObjectOfType <NotificationQueue>();
     transform.SetParent(null);//destroy doesn't destroy obj until end of frame, so child count won't be updated unless this is detatched from the parent
     Destroy(gameObject);
     Destroy(this);
     MouseSelection.DelayNextClickSelect();
     notificationQueue.ToggleLbl();
 }
コード例 #8
0
 public void NewSelection(MouseSelection m)
 {
     if (currentSelection != null)
     {
         // talk to last selected object - it stops being selected
         currentSelection.Unselect();
     }
     currentSelection = m;
 }
コード例 #9
0
 public override void DisplayCircle()
 {
     if (abilitySelected == null)
     {
         if (clicked)
         {
             BuildCircle(MouseSelection.GetMouseCoords2D());
         }
     }
 }
コード例 #10
0
 void DeselectIfClickingAnotherChar()
 {
     /* if another dialogue is selected that is not this dialogue, then this dialogue should be deselected */
     if (Input.GetMouseButtonUp(0))
     {
         if (MouseSelection.IsClickedGameObjectName("CharacterDialog") && MouseSelection.IsClickedDifferentGameObjectTo(gameObject))
         {
             DeselectCharDialogue();
         }
     }
 }
コード例 #11
0
ファイル: NLPrompt.cs プロジェクト: Tubbz-alt/MKULTRA-1
    internal void OnGUI()
    {
        // You'd want this to be called by a MouseMove event, but it's not supported in game,
        // and in any case, we probably need to keep updating because of potential object movement.
        if (contextMenu == null)
        {
            UpdateMouseSelection();
        }

        GUI.depth = 0;
        var e = Event.current;

        switch (e.type)
        {
        case EventType.MouseDown:
            //typingPromptStartTime = Time.time;
            contextMenu = MakeMenu(MouseSelection);
            lastPlayerActivity.StoreExclusive(Time.time, true);
            break;

        case EventType.MouseUp:
            if (contextMenu != null && MouseSelection != null)
            {
                var guiScreenRect = MouseSelection.GUIScreenRect();
                if (guiScreenRect.HasValue)
                {
                    var selection = contextMenu.SelectedAction(guiScreenRect.Value.Center());
                    if (selection != null)
                    {
                        simController.QueueEvent("player_input", selection);
                    }
                }
            }

            lastPlayerActivity.StoreExclusive(Time.time, true);
            contextMenu = null;
            break;

        case EventType.KeyDown:
            if (GUI.GetNameOfFocusedControl() == "")
            {
                HandleKeyDown(e);
                if (!e.alt && !e.control)
                {
                    TryCompletionIfCompleteWord();
                }
            }
            break;

        case EventType.Repaint:
            DrawGUI();
            break;
        }
    }
コード例 #12
0
 public override void InitialiseDecision()
 {
     if (abilitySelected == null)
     {
         BuildCircle(MouseSelection.GetMouseCoords2D());
         BuildSelectionPlayerDecision(DefaultSelectionDecisionPrefab);
         CharacterMovementDecision movementDecision = (CharacterMovementDecision)myDecision;
         movementDecision.InitialiseMe(selectionCircle.transform, doubleClicks);
         QueueDecisionToRun();
     }
 }
コード例 #13
0
ファイル: Character.cs プロジェクト: whatsalem/Diablerie
    void OnRenderObject()
    {
        bool selectable = !dead && !dying;

        if (selectable && monStat != null)
        {
            selectable = monStat.interact || (!monStat.npc && monStat.killable);
        }
        if (selectable)
        {
            MouseSelection.Submit(this);
        }
    }
コード例 #14
0
        /// <summary>
        ///    Initializes a new instance of the <see RubberBandSelectionEventArgs class.
        ///
        /// Parameters:
        ///  horizontalChange:
        ///    The horizontal change in the System.Windows.Controls.Primitives.Thumb position
        ///    since the last System.Windows.Controls.Primitives.Thumb.DragDelta event.
        ///
        ///  verticalChange:
        ///    The vertical change in the System.Windows.Controls.Primitives.Thumb position
        ///    since the last System.Windows.Controls.Primitives.Thumb.DragDelta event.
        /// </summary>
        /// <param name="top"></param>
        /// <param name="left"></param>
        /// <param name="bottom"></param>
        /// <param name="right"></param>
        /// <param name="ms">Add or remove current selection before applying new selection</param>
        public RubberBandSelectionEventArgs(double left,
                                            double top,
                                            double right,
                                            double bottom,
                                            MouseSelection ms)
            : base()
        {
            this.Top    = top;
            this.Left   = left;
            this.Right  = right;
            this.Bottom = bottom;

            this.Select = ms;
        }
コード例 #15
0
        private void UserControl_MouseEnter(object sender, MouseEventArgs e)
        {
            if (Byte != null)
            {
                if (Action != ByteAction.Modified &&
                    Action != ByteAction.Deleted &&
                    Action != ByteAction.Added &&
                    !IsSelected && !IsHighLight)
                {
                    Background = (SolidColorBrush)TryFindResource("MouseOverColor");
                }
            }

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                MouseSelection?.Invoke(this, e);
            }
        }
コード例 #16
0
ファイル: NLPrompt.cs プロジェクト: Tubbz-alt/MKULTRA-1
    private void DrawGUI()
    {
        var arrowActive = typingPromptStartTime > Time.time - 3;

        if (contextMenu == null)
        {
            ShowMouseSelectionCaption();
        }

        if (!string.IsNullOrEmpty(input) || arrowActive || Time.time > haloOnset + 2f)
        {
            GameObject addressee;

            var da = dialogAct as Structure;
            if (da != null)
            {
                addressee = (GameObject)da.Argument(1);
            }
            else if (talkingToElNode.Children.Count > 0)
            {
                addressee = (GameObject)talkingToElNode.Children[0].Key;
            }
            else
            {
                addressee = gameObject;
            }

            addressee.DrawThumbNail(new Vector2(InputRect.x - 40, InputRect.y));
        }
        var text = (string.IsNullOrEmpty(input) && arrowActive) ? "<color=grey><i>Talk to me</i></color>" : formatted;

        GUI.Label(InputRect, text, InputGUIStyle);
        GUI.Label(CommentaryRect, commentary, CommentaryGUIStyle);
        GUI.Label(ResponseRect, characterResponse, InputGUIStyle);
        GUI.depth = 0;
        if (contextMenu != null && MouseSelection != null)
        {
            var guiScreenRect = MouseSelection.GUIScreenRect();
            if (guiScreenRect.HasValue)
            {
                contextMenu.Draw(guiScreenRect.Value.Center(), 50);
            }
        }
    }
コード例 #17
0
        private static bool AddToCache(Bitmap drawBitmap, string path, List <DrawCall> cacheList,
                                       PointF coords, bool selectable, MouseSelection mouseSelection, RectangleF screenArea, int colorOverlay = 0)
        {
            if (mouseSelection.isDown && !screenArea.Contains(coords))
            {
                return(false);
            }

            if (colorOverlay != 0)
            {
                drawBitmap = GreenFilter(drawBitmap);
            }

            var normalDraw = new DrawCall(drawBitmap, path, coords.X, coords.Y);

            if (selectable && InsideSelection(mouseSelection.selectionArea, new RectangleF(coords.X, coords.Y, drawBitmap.Width, drawBitmap.Height)))
            {
                var opaque = MakeOpaque(drawBitmap, path, 0.5f);
                var opDraw = new DrawCall(opaque, path, coords.X, coords.Y);
                if (mouseSelection.clicked)
                {
                    if (currentClick != null)
                    {
                        ClickToCache(currentClick, true);
                    }
                    currentClick            = new CurrentClick();
                    currentClick.index      = cacheList.Count;
                    currentClick.CacheList  = cacheList;
                    currentClick.NormalCall = normalDraw;
                    currentClick.OpaqueCall = opDraw;
                }
                else
                {
                    cacheList.Add(opDraw);
                    return(true);
                }
            }
            else
            {
                cacheList.Add(normalDraw);
            }
            return(false);
        }
コード例 #18
0
    // Game start
    void Awake()
    {
        m_gameLogic.Start();
        InitializePieces();

        // find references to Unity objects
        m_diceValueImg = GameObject.Find("diceValue");
        m_diceValueImg.SetActive(false);
        m_playerImg = GameObject.Find("nextPlayerIcon");

        m_rollButton = GameObject.Find("rollButton");
        m_rollButton.SetActive(false);

        m_dice = GameObject.Find("dice");
        m_dice.SetActive(false);

        m_mouseSelection = GameObject.Find("MouseManager").GetComponent <MouseSelection>();

        StartCoroutine(NextPlayer());
    }
コード例 #19
0
 void OnMouseUpAsButton()
 {
     ActivateNotification();
     MouseSelection.DelayNextClickSelect();
 }
コード例 #20
0
 public void SetSelection(MouseSelection selection)
 {
     mouseSelection = selection;
 }
コード例 #21
0
 void Start()
 {
     MouseSelection.ActiveSelection = this;
     image         = GetComponent <Image> ();
     defaultSprite = image.sprite;
 }
コード例 #22
0
ファイル: DrawMap.cs プロジェクト: MisterDr/fonline-mapgen
        public static void OnGraphics( Graphics gdi, FOMap map, FOHexMap hexMap, Dictionary<int, ItemProto> itemsPid, CritterData critterData,
            Dictionary<string, FalloutFRM> frms, EditorData editorData, SizeF scale, RectangleF screenArea, MouseSelection mouseSelection)
        {
            Flags flags = editorData.drawFlags;
            Flags selectFlags = editorData.selectFlags;
            Flags overlayFlags = editorData.overlayFlags;

            if (!cachedCalls)
            {
                CachedSceneryDraws  = new List<DrawCall>();
                CachedTileDraws     = new List<DrawCall>();
                CachedRoofTileDraws = new List<DrawCall>();
                CachedDrawsLists    = new List<List<DrawCall>>();
                CachedOverlayDraws  = new List<OverlayCall>();
                CachedDrawsLists.Add(CachedTileDraws);
                CachedDrawsLists.Add(CachedSceneryDraws);
                CachedDrawsLists.Add(CachedRoofTileDraws);

                currentClick = null;
                SelectedObjects = new List<MapObject>();
                SelectedTiles = new List<Tile>();
                Errors = new List<string>();

                if (DrawFlag(flags, Flags.Tiles) || DrawFlag(flags, Flags.Roofs))
                {
                    foreach (var tile in map.Tiles)
                    {
                        bool selectable = false;

                        if (!tile.Roof && !DrawFlag(flags, Flags.Tiles))
                            continue;
                        if (!tile.Roof && DrawFlag(selectFlags, Flags.Tiles))
                            selectable = true;
                        if (tile.Roof && !DrawFlag(flags, Flags.Roofs))
                            continue;
                        if(tile.Roof && DrawFlag(selectFlags, Flags.Roofs))
                            selectable = true;

                        List<DrawCall> list = null;
                        if (tile.Roof) list = CachedRoofTileDraws;
                        else list = CachedTileDraws;

                        if (!frms.ContainsKey(tile.Path))
                        {
                            Errors.Add("Tile graphics " + tile.Path + " not loaded.");
                            return;
                        }
                        var tileCoords = hexMap.GetTileCoords(new Point(tile.X, tile.Y), tile.Roof);
                        Bitmap drawBitmap = frms[tile.Path].Frames[0];
                        if (AddToCache(drawBitmap, tile.Path, list, tileCoords, selectable, mouseSelection, screenArea, tile.colorOverlay))
                            SelectedTiles.Add(tile);
                    }
                }

                foreach (var obj in map.Objects.OrderBy(x => x.MapX + x.MapY * 2))
                {
                    bool selectable = false;
                    // skip specific object types
                    if (obj.MapObjType == MapObjectType.Critter && !DrawFlag(flags, Flags.Critters))
                        continue;
                    else if (obj.MapObjType == MapObjectType.Item && !DrawFlag(flags, Flags.Items))
                        continue;
                    else if (obj.MapObjType == MapObjectType.Scenery && !DrawFlag(flags, Flags.Scenery))
                        continue;

                    if (obj.MapObjType == MapObjectType.Critter && DrawFlag(selectFlags, Flags.Critters))
                        selectable = true;
                    else if (obj.MapObjType == MapObjectType.Item && DrawFlag(selectFlags, Flags.Items))
                        selectable = true;
                    else if (obj.MapObjType == MapObjectType.Scenery && DrawFlag(selectFlags, Flags.Scenery))
                        selectable = true;

                    Bitmap drawBitmap;
                    PointF coords;
                    string path;

                    if (obj.MapObjType == MapObjectType.Critter)
                    {
                        string dirS;
                        int dir = 0;
                        obj.Properties.TryGetValue("Dir", out dirS);
                        int.TryParse(dirS, out dir);

                        string crType = "";
                        critterData.GetCritterType(obj.ProtoId, out crType);

                        FalloutFRM frm;
                        string cr = "art\\critters\\" + crType + "aa.frm";
                        path = cr;
                        if (!frms.TryGetValue(cr, out frm))
                        {
                            Errors.Add("Critter graphics " + cr + " not loaded.");
                            continue;
                        }
                        if (frm == null)
                            continue;

                        coords = hexMap.GetObjectCoords(new Point(obj.MapX, obj.MapY), frm.Frames[0].Size, new Point(frm.PixelShift.X, frm.PixelShift.Y), new Point(0, 0));
                        drawBitmap = frm.GetAnimFrameByDir(dir, 1);

                        if (DrawFlag(overlayFlags, Flags.Critters))
                        {
                            string text = editorData.overlayCritterFormat;
                            string preprocessed = PreprocessOverlay(text, obj, new Func<string, string>((string mStr) => {
                                string data = "";
                                if (obj.Properties.ContainsKey(mStr)) data = obj.Properties[mStr];
                                if (obj.CritterParams.ContainsKey(mStr)) data = obj.CritterParams[mStr].ToString();
                                return data;
                            }));
                            int lines = text.Count(f => f == '\n');
                            CachedOverlayDraws.Add(new OverlayCall(preprocessed, coords.X, coords.Y - (40 + (15 * (lines - 1)))));
                        }
                    }
                    // Scenery or Item
                    else
                    {
                        ItemProto prot;
                        if (!itemsPid.TryGetValue(obj.ProtoId, out prot))
                            continue;
                        if (prot.Type == (int)ItemTypes.ITEM_WALL && !DrawFlag(flags, Flags.SceneryWalls))
                            continue;
                        if (!frms.ContainsKey(prot.PicMap))
                        {
                            Errors.Add("Scenery graphics " + prot.PicMap + " not loaded.");
                            continue;
                        }
                        var frm = frms[prot.PicMap];
                        path = prot.PicMap;
                        coords = hexMap.GetObjectCoords(new Point(obj.MapX, obj.MapY), frm.Frames[0].Size,
                            new Point(frm.PixelShift.X, frm.PixelShift.Y), new Point(prot.OffsetX, prot.OffsetY));
                        drawBitmap = frm.Frames[0];
                    }

                    if (AddToCache(drawBitmap, path, CachedSceneryDraws, coords, selectable, mouseSelection, screenArea, obj.colorOverlay))
                        SelectedObjects.Add(obj);
                }
            }

            // Rendering
            if (currentClick != null)
                ClickToCache(currentClick, false);

            if (scale.Width != 1.0f && gdi != null)
                gdi.ScaleTransform(scale.Width, scale.Height);

            cachedCalls = true;

            if (gdi != null)
            {
                foreach (var call in CachedTileDraws)
                    gdi.DrawImage(call.Bitmap, call.X, call.Y);
                foreach (var call in CachedSceneryDraws)
                    gdi.DrawImage(call.Bitmap, call.X, call.Y);
                foreach (var call in CachedRoofTileDraws)
                    gdi.DrawImage(call.Bitmap, call.X, call.Y);

                foreach (var call in CachedOverlayDraws)
                {
                    DrawOutlinedText(gdi, call.Text, overlayFont, Brushes.GreenYellow, Brushes.Black, new PointF(call.X, call.Y));
                }
            }
        }
コード例 #23
0
 private void OnRenderObject()
 {
     MouseSelection.Submit(this);
 }
コード例 #24
0
ファイル: DrawMap.cs プロジェクト: MisterDr/fonline-mapgen
        private static bool AddToCache(Bitmap drawBitmap, string path, List<DrawCall> cacheList, 
            PointF coords, bool selectable, MouseSelection mouseSelection, RectangleF screenArea, int colorOverlay = 0)
        {
            if (mouseSelection.isDown && !screenArea.Contains(coords))
                return false;

            if (colorOverlay != 0)
            {
                drawBitmap = GreenFilter(drawBitmap);
            }

            var normalDraw = new DrawCall(drawBitmap, path, coords.X, coords.Y);
            if (selectable && InsideSelection(mouseSelection.selectionArea, new RectangleF(coords.X, coords.Y, drawBitmap.Width, drawBitmap.Height)))
            {
                var opaque = MakeOpaque(drawBitmap, path, 0.5f);
                var opDraw = new DrawCall(opaque, path, coords.X, coords.Y);
                if (mouseSelection.clicked)
                {
                    if (currentClick != null) ClickToCache(currentClick, true);
                    currentClick = new CurrentClick();
                    currentClick.index = cacheList.Count;
                    currentClick.CacheList = cacheList;
                    currentClick.NormalCall = normalDraw;
                    currentClick.OpaqueCall = opDraw;
                }
                else
                {
                    cacheList.Add(opDraw);
                    return true;
                }
            }
            else
                cacheList.Add(normalDraw);
            return false;
        }
コード例 #25
0
        public static void OnGraphics(Graphics gdi, FOMap map, FOHexMap hexMap, Dictionary <int, ItemProto> itemsPid, CritterData critterData,
                                      Dictionary <string, FalloutFRM> frms, EditorData editorData, SizeF scale, RectangleF screenArea, MouseSelection mouseSelection)
        {
            Flags flags        = editorData.drawFlags;
            Flags selectFlags  = editorData.selectFlags;
            Flags overlayFlags = editorData.overlayFlags;

            if (!cachedCalls)
            {
                CachedSceneryDraws  = new List <DrawCall>();
                CachedTileDraws     = new List <DrawCall>();
                CachedRoofTileDraws = new List <DrawCall>();
                CachedDrawsLists    = new List <List <DrawCall> >();
                CachedOverlayDraws  = new List <OverlayCall>();
                CachedDrawsLists.Add(CachedTileDraws);
                CachedDrawsLists.Add(CachedSceneryDraws);
                CachedDrawsLists.Add(CachedRoofTileDraws);

                currentClick    = null;
                SelectedObjects = new List <MapObject>();
                SelectedTiles   = new List <Tile>();
                Errors          = new List <string>();

                if (DrawFlag(flags, Flags.Tiles) || DrawFlag(flags, Flags.Roofs))
                {
                    foreach (var tile in map.Tiles)
                    {
                        bool selectable = false;

                        if (!tile.Roof && !DrawFlag(flags, Flags.Tiles))
                        {
                            continue;
                        }
                        if (!tile.Roof && DrawFlag(selectFlags, Flags.Tiles))
                        {
                            selectable = true;
                        }
                        if (tile.Roof && !DrawFlag(flags, Flags.Roofs))
                        {
                            continue;
                        }
                        if (tile.Roof && DrawFlag(selectFlags, Flags.Roofs))
                        {
                            selectable = true;
                        }


                        List <DrawCall> list = null;
                        if (tile.Roof)
                        {
                            list = CachedRoofTileDraws;
                        }
                        else
                        {
                            list = CachedTileDraws;
                        }

                        if (!frms.ContainsKey(tile.Path))
                        {
                            Errors.Add("Tile graphics " + tile.Path + " not loaded.");
                            return;
                        }
                        var    tileCoords = hexMap.GetTileCoords(new Point(tile.X, tile.Y), tile.Roof);
                        Bitmap drawBitmap = frms[tile.Path].Frames[0];
                        if (AddToCache(drawBitmap, tile.Path, list, tileCoords, selectable, mouseSelection, screenArea, tile.colorOverlay))
                        {
                            SelectedTiles.Add(tile);
                        }
                    }
                }

                foreach (var obj in map.Objects.OrderBy(x => x.MapX + x.MapY * 2))
                {
                    bool selectable = false;
                    // skip specific object types
                    if (obj.MapObjType == MapObjectType.Critter && !DrawFlag(flags, Flags.Critters))
                    {
                        continue;
                    }
                    else if (obj.MapObjType == MapObjectType.Item && !DrawFlag(flags, Flags.Items))
                    {
                        continue;
                    }
                    else if (obj.MapObjType == MapObjectType.Scenery && !DrawFlag(flags, Flags.Scenery))
                    {
                        continue;
                    }

                    if (obj.MapObjType == MapObjectType.Critter && DrawFlag(selectFlags, Flags.Critters))
                    {
                        selectable = true;
                    }
                    else if (obj.MapObjType == MapObjectType.Item && DrawFlag(selectFlags, Flags.Items))
                    {
                        selectable = true;
                    }
                    else if (obj.MapObjType == MapObjectType.Scenery && DrawFlag(selectFlags, Flags.Scenery))
                    {
                        selectable = true;
                    }

                    Bitmap drawBitmap;
                    PointF coords;
                    string path;

                    if (obj.MapObjType == MapObjectType.Critter)
                    {
                        string dirS;
                        int    dir = 0;
                        obj.Properties.TryGetValue("Dir", out dirS);
                        int.TryParse(dirS, out dir);

                        string crType = "";
                        critterData.GetCritterType(obj.ProtoId, out crType);

                        FalloutFRM frm;
                        string     cr = "art\\critters\\" + crType + "aa.frm";
                        path = cr;
                        if (!frms.TryGetValue(cr, out frm))
                        {
                            Errors.Add("Critter graphics " + cr + " not loaded.");
                            continue;
                        }
                        if (frm == null)
                        {
                            continue;
                        }

                        coords     = hexMap.GetObjectCoords(new Point(obj.MapX, obj.MapY), frm.Frames[0].Size, new Point(frm.PixelShift.X, frm.PixelShift.Y), new Point(0, 0));
                        drawBitmap = frm.GetAnimFrameByDir(dir, 1);

                        if (DrawFlag(overlayFlags, Flags.Critters))
                        {
                            string text         = editorData.overlayCritterFormat;
                            string preprocessed = PreprocessOverlay(text, obj, new Func <string, string>((string mStr) => {
                                string data = "";
                                if (obj.Properties.ContainsKey(mStr))
                                {
                                    data = obj.Properties[mStr];
                                }
                                if (obj.CritterParams.ContainsKey(mStr))
                                {
                                    data = obj.CritterParams[mStr].ToString();
                                }
                                return(data);
                            }));
                            int lines = text.Count(f => f == '\n');
                            CachedOverlayDraws.Add(new OverlayCall(preprocessed, coords.X, coords.Y - (40 + (15 * (lines - 1)))));
                        }
                    }
                    // Scenery or Item
                    else
                    {
                        ItemProto prot;
                        if (!itemsPid.TryGetValue(obj.ProtoId, out prot))
                        {
                            continue;
                        }
                        if (prot.Type == (int)ItemTypes.ITEM_WALL && !DrawFlag(flags, Flags.SceneryWalls))
                        {
                            continue;
                        }
                        if (!frms.ContainsKey(prot.PicMap))
                        {
                            Errors.Add("Scenery graphics " + prot.PicMap + " not loaded.");
                            continue;
                        }
                        var frm = frms[prot.PicMap];
                        path   = prot.PicMap;
                        coords = hexMap.GetObjectCoords(new Point(obj.MapX, obj.MapY), frm.Frames[0].Size,
                                                        new Point(frm.PixelShift.X, frm.PixelShift.Y), new Point(prot.OffsetX, prot.OffsetY));
                        drawBitmap = frm.Frames[0];
                    }

                    if (AddToCache(drawBitmap, path, CachedSceneryDraws, coords, selectable, mouseSelection, screenArea, obj.colorOverlay))
                    {
                        SelectedObjects.Add(obj);
                    }
                }
            }

            // Rendering
            if (currentClick != null)
            {
                ClickToCache(currentClick, false);
            }

            if (scale.Width != 1.0f && gdi != null)
            {
                gdi.ScaleTransform(scale.Width, scale.Height);
            }

            cachedCalls = true;

            if (gdi != null)
            {
                foreach (var call in CachedTileDraws)
                {
                    gdi.DrawImage(call.Bitmap, call.X, call.Y);
                }
                foreach (var call in CachedSceneryDraws)
                {
                    gdi.DrawImage(call.Bitmap, call.X, call.Y);
                }
                foreach (var call in CachedRoofTileDraws)
                {
                    gdi.DrawImage(call.Bitmap, call.X, call.Y);
                }

                foreach (var call in CachedOverlayDraws)
                {
                    DrawOutlinedText(gdi, call.Text, overlayFont, Brushes.GreenYellow, Brushes.Black, new PointF(call.X, call.Y));
                }
            }
        }
コード例 #26
0
 /// <summary>
 /// A delay is used so that when the UI is deactivated the click used to deactivate it won't cause side effect behaviour
 /// e.g. player walking to where the button was clicked.
 /// </summary>
 public void DeactivateSelf()
 {
     gameObject.SetActive(false);
     MouseSelection.DelayNextClickSelect();
 }