Beispiel #1
0
        private void OnMapChanged(object sender, MapChangedEventArgs e)
        {
            foreach (var newNodeViewModel in e.AddedNodes)
            {
                var newNodeView = new NodeView(newNodeViewModel);
                newNodeView.MouseOverChanged += OnNodeHoveredChanged;
                _canvas.Children.Add(newNodeView);
            }

            foreach (var removedNodeViewModel in e.RemovedNodes)
            {
                NodeView toRemove = GetNodeViewFromViewModel(removedNodeViewModel);
                if (toRemove != null)
                {
                    toRemove.MouseOverChanged -= OnNodeHoveredChanged;
                    _canvas.Children.Remove(toRemove);
                }
            }

            foreach (var newEdgeViewModel in e.AddedEdges)
            {
                var line = CreateLine(newEdgeViewModel);
                _canvas.Children.Add(line);
            }

            foreach (var removedEdgeViewModel in e.RemovedEdges)
            {
                var line = GetLineFromViewModel(removedEdgeViewModel);
                _canvas.Children.Remove(line);
            }

            ViewModel.Arrange();
        }
Beispiel #2
0
        private void MapChanged(object sender, MapChangedEventArgs e)
        {
            if (!ScriptLoaded)
            {
                return;
            }

            Console.WriteLine("Trying to get move");
            _processTimer.Start();
        }
Beispiel #3
0
 void StatusEditorControl_MapChanged(object sender, MapChangedEventArgs e)
 {
     foreach (AccessoryDecoderConnection connection in this.Element.AccessoryConnections)
     {
         if (connection != null)
         {
             AccessoryDecoderConnection.Save(connection);
         }
     }
 }
Beispiel #4
0
 private void App_MapChanged(object sender, MapChangedEventArgs e)
 {
     (e.NewValue as Map).MouseMove += new MouseEventHandler(Map_MouseMove);
     e.NewValue.FunctionMode        = FunctionMode.None;
     if (Application.App.Legend != null)
     {
         Application.App.Legend.RootNodes.Clear();
         e.NewValue.Legend = Application.App.Legend;
     }
 }
Beispiel #5
0
 /// <summary>
 /// Handles map changes. Updates field representations.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Model_MapChanged(object sender, MapChangedEventArgs e)
 {
     Fields.Clear();
     for (int i = 0; i < e.Size; i++)
     {
         for (int j = 0; j < e.Size; j++)
         {
             Fields.Add(new ViewField());
         }
     }
 }
Beispiel #6
0
        private static void EventSink_MapChanged(MapChangedEventArgs e)
        {
            Item item = e.Entity as Item;

            if (item == null || !(item is IFactionArtifact))
            {
                return;
            }

            CheckItem(item, e.OldMap);
        }
        protected override void LogMapChanged(object sender, MapChangedEventArgs e)
        {
            foreach (MapChange c in e.Changes)
            {
                MessageGroup msgGroup;
                PixelMap.OffsetToRelative(c.Offset, out byte rx, out byte ry);
                short x = PixelMap.RelativeToAbsolute(e.Chunk.Item1, rx);
                short y = PixelMap.RelativeToAbsolute(e.Chunk.Item2, ry);

                if (!placed.Remove((x, y, c.Color)))
                {
                    try
                    {
                        int irx = x - options.LeftX;
                        int iry = y - options.TopY;

                        if (irx < 0 || irx >= width || iry < 0 || iry >= height)
                        {
                            //beyond image rectangle
                            msgGroup = MessageGroup.PixelInfo;
                        }
                        else
                        {
                            byte desiredColor = imagePixels[irx, iry];
                            if (palette.IsIgnored(desiredColor))
                            {
                                msgGroup = MessageGroup.PixelInfo;
                            }
                            else if (palette.IsCorrectPixelColor(c.Color, desiredColor))
                            {
                                msgGroup = MessageGroup.Assist;
                                builtInLastMinute++;
                            }
                            else
                            {
                                msgGroup = MessageGroup.Attack;
                                griefedInLastMinute++;
                                gotGriefed?.Set();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.LogDebug($"LogMapChanged: unhandled exception - {ex}");
                        msgGroup = MessageGroup.PixelInfo;
                    }
                    logger.LogPixel($"Received pixel update:", e.DateTime, msgGroup, x, y, colorNameResolver.GetName(c.Color));
                }
Beispiel #8
0
 private static void Wrapper_OnMapChanged(object sender, MapChangedEventArgs e)
 {
     foreach (MapChange c in e.Changes)
     {
         PixelMap.OffsetToRelative(c.Offset, out byte rx, out byte ry);
         short x = PixelMap.RelativeToAbsolute(e.Chunk.Item1, rx);
         short y = PixelMap.RelativeToAbsolute(e.Chunk.Item2, ry);
         if (x <= options.RightX && x >= options.LeftX && y <= options.BottomY && y >= options.TopY)
         {
             logger.LogPixel("Received pixel update:", e.DateTime, MessageGroup.PixelInfo, x, y, colorNameResolver.GetName(c.Color));
             lock (listLockObj)
             {
                 updates.Add((x, y, c.Color));
             }
         }
     }
 }
Beispiel #9
0
        private void OnAppMapChanged(MapChangedEventArgs args)
        {
            if (args.OldValue != null)
            {
                // Unsubscribe events from old map
                args.OldValue.Layers.LayerSelected -= Layers_LayerSelected;
                if (args.OldValue is Map)
                    ((Map)args.OldValue).ViewExtentsChanged -= MapFrame_ViewExtentsChanged;
            }

            if (args.NewValue != null)
            {
                args.NewValue.Layers.LayerSelected += Layers_LayerSelected;
                if (args.NewValue is Map)
                    ((Map)args.NewValue).ViewExtentsChanged += MapFrame_ViewExtentsChanged;
            }
        }
        protected override void LogMapChanged(object sender, MapChangedEventArgs e)
        {
            foreach (MapChange c in e.Changes)
            {
                MessageGroup msgGroup;
                VoxelMap.OffsetToRelative(c.Offset, out byte rx, out byte ry, out byte z);
                short x = VoxelMap.RelativeToAbsolute(e.Chunk.Item1, rx);
                short y = VoxelMap.RelativeToAbsolute(e.Chunk.Item2, ry);

                if (!placed.Remove((x, y, z, c.Color)))
                {
                    try
                    {
                        int irx = x - options.MinX;
                        int iry = y - options.MinY;
                        int irz = z - options.BottomZ;

                        if (irx < 0 || irx >= sizeX || iry < 0 || iry >= sizeY || irz < 0 || irz > height)
                        {
                            //beyond image
                            msgGroup = MessageGroup.PixelInfo;
                        }
                        else
                        {
                            byte desiredColor = imageVoxels[x - options.MinX, y - options.MinY, z - options.BottomZ];
                            if (desiredColor == c.Color)
                            {
                                msgGroup = MessageGroup.Assist;
                                builtInLastMinute++;
                            }
                            else
                            {
                                msgGroup = MessageGroup.Attack;
                                griefedInLastMinute++;
                                gotGriefed?.Set();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.LogDebug($"LogMapChanged: unhandled exception - {ex}");
                        msgGroup = MessageGroup.PixelInfo;
                    }
                    logger.LogVoxel($"Received voxel update:", e.DateTime, msgGroup, x, y, z, colorNameResolver.GetName(c.Color));
                }
        /// <summary>
        /// Handles the MapChanged event of the <see cref="MapManager"/> class.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MapChangedEventArgs"/> instance containing the event data.</param>
        private void MapChanged(object sender, MapChangedEventArgs e)
        {
            if (Map == null) return;
            if (e.NewMap.Name != Map.Name) return;

            if (ObjectWidth != (e.NewMap.Width * e.NewMap.TileWidth))
                ObjectWidth = (e.NewMap.Width * e.NewMap.TileWidth);

            if (ObjectHeight != (e.NewMap.Height * e.NewMap.TileHeight))
                ObjectHeight = (e.NewMap.Height * e.NewMap.TileHeight);

            Render();
        }
Beispiel #12
0
 /// <summary>
 /// Event handler for map changes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Model_MapChanged(object sender, MapChangedEventArgs e)
 {
     GenerateMap(e.Size);
 }
Beispiel #13
0
 void OnMapChange(object source, MapChangedEventArgs e)
 {
     OverviewCamera = new OverviewCamera(GraphicsDevice, e.Map);
     ActiveCamera   = OverviewCamera;
 }
Beispiel #14
0
 private void Map_MapChanged(object sender, MapChangedEventArgs e)
 {
     _account.Character.Map.MapChanged -= Map_MapChanged;
     OnChangementFinished(e.NewMapId == NewMap);
 }
 /// <summary>
 /// Event handler for the MapChanged event of the <see cref="MapManager"/> object.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="MapChangedEventArgs"/> instance containing the event data.</param>
 private void MapChanged(object sender, MapChangedEventArgs e)
 {
 }
 protected abstract void LogMapChanged(object sender, MapChangedEventArgs e);
        /// <summary>
        /// Handles the MapChanged event of the <see cref="MapManager"/> object.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MapChangedEventArgs"/> instance containing the event data.</param>
        private void MapChanged(object sender, MapChangedEventArgs e)
        {
            foreach (TreeNode node in mapsNode.Nodes)
            {
                if (node.Text == e.OldMap.Name)
                {
                    node.Name = "Map" + e.NewMap.Name;
                    node.Text = e.NewMap.Name;
                }
            }

            if (treeProject.SelectedNode.Name == "Map" + e.OldMap.Name)
                SortNodes("Map" + e.NewMap.Name);
            else
                SortNodes();
        }
Beispiel #18
0
 protected abstract void Wrapper_OnMapChanged(object sender, MapChangedEventArgs e);
Beispiel #19
0
        /// <summary>
        /// Handles the MapChanged event of the <see cref="MapManager"/> class.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MapChangedEventArgs"/> instance containing the event data.</param>
        private void MapChanged(object sender, MapChangedEventArgs e)
        {
            if (Map == null) return;
            if (e.NewMap.Name != Map.Name) return;

            if (this.Name != "Map" + e.NewMap.Name)
                this.Name = "Map" + e.NewMap.Name;

            if (this.Text != e.NewMap.Name)
                this.Text = e.NewMap.Name;

            if (this.TabText != e.NewMap.Name)
            {
                this.TabText = e.NewMap.Name;
                if (e.NewMap.UnsavedChanges)
                    this.TabText += @"*";
            }

            if (txtName.Text != e.NewMap.Name)
                txtName.Text = e.NewMap.Name;
        }
Beispiel #20
0
    private void Board_MapChanged(object sender, MapChangedEventArgs e)
    {
        int sheepCount = Board.Map.SheepRemaining;

        foreach (GameObject SubPiece in GameObject.FindGameObjectsWithTag("Piece"))
        {
            Destroy(SubPiece);
        }

        foreach (IPiece SubPiece in Board.Map.Pieces)
        {
            if (SubPiece == null)
            {
                continue;
            }
            int bw  = 79;
            int bwp = 39;
            int dx  = (SubPiece.Location.Y < 2 || SubPiece.Location.Y > 6) ? bwp : bw;
            int dy  = (SubPiece.Location.Y - 1) * bw;
            if (SubPiece.Location.Y < 2)
            {
                dy = SubPiece.Location.Y * bwp;
            }
            if (SubPiece.Location.Y > 6)
            {
                dy = (SubPiece.Location.Y - 6) * bwp + 5 * bw;
            }

            bool isOpposite = SubPiece.Camp == Camp.Wolf ? true : false;
            bool isScale    = SubPiece.Location.Y < 2 || SubPiece.Location.Y > 6 ? true : false;
            if (isOpposite)
            {
                GameObject tempWolf = MonoBehaviour.Instantiate(Wolf, Canvas.transform) as GameObject;
                tempWolf.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(bw * 2 + (SubPiece.Location.X - 2) * dx, -dy, 0);
                tempWolf.transform.localScale = new Vector3(1f, 1f, 1f);
                if (isScale)
                {
                    tempWolf.GetComponent <RectTransform>().localScale = new Vector3(0.5f, 0.5f, 1);
                }
                if (Board.Map.ActivedCamp != Camp.Wolf)
                {
                    tempWolf.GetComponent <Selectable>().interactable = false;
                }
                tempWolf.tag = "Piece";
            }
            else
            {
                sheepCount += 1;
                GameObject tempSheep = MonoBehaviour.Instantiate(Sheep, Canvas.transform) as GameObject;
                tempSheep.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(bw * 2 + (SubPiece.Location.X - 2) * dx, -dy, 0);
                tempSheep.transform.localScale = new Vector3(1f, 1f, 1f);
                if (isScale)
                {
                    tempSheep.GetComponent <RectTransform>().localScale = new Vector3(0.5f, 0.5f, 1);
                }
                if (Board.Map.ActivedCamp != Camp.Sheep || Board.Map.SheepRemaining > 0)
                {
                    tempSheep.GetComponent <Selectable>().interactable = false;
                }
                tempSheep.tag = "Piece";
            }
        }

        HPText.text = sheepCount.ToString() + "/24";
        MPText.text = Board.Map.SheepRemaining.ToString() + "/16";

        if (Board.Map.ActivedCamp == Camp.Wolf)
        {
            Enemy.SetActive(true);
        }
        else
        {
            Enemy.SetActive(false);
        }

        HPImage.GetComponent <Image>().transform.localScale = new Vector3(((float)sheepCount) / 24, 1, 1);
        MPImage.GetComponent <Image>().transform.localScale = new Vector3(((float)Board.Map.SheepRemaining) / 16, 1, 1);

        if (MainController.soundOn)
        {
            PieceAudio.Play();
        }
    }