private void AddAdorner(EnemyCamp camp, AdornerLayer adornerLayer) { SimpleSquareAdorner adorner = new SimpleSquareAdorner(MapImage, camp); adorner.DataContext = Model; adorner.MouseUp += adorner_MouseUp; adornerLayer.Add(adorner); }
void adorner_MouseUp(object sender, MouseButtonEventArgs e) { SimpleSquareAdorner simpleSquareAdorner = sender as SimpleSquareAdorner; if (simpleSquareAdorner != null && !IsEditorMode) { m_selectedCamp = simpleSquareAdorner.Camp; DialogResult = true; Close(); } }
public override void InitObjective(MeshGenerator _MeshGenerator) { GameObjectives.Objectives.Add(this); enemyCamps.Clear(); for (int i = 0; i < amountOfCamps; i++) { Vector3 _Position = _MeshGenerator.GetValidMapPosition(new Vector3(25, 1, 25), 10000); if (_Position != Vector3.zero) { _MeshGenerator.FlatMapInRadius(_Position, 35); } Building[] buildings = FindObjectsOfType <Building>(); bool _TooClose = false; for (int x = 0; x < buildings.Length; x++) { if (buildings[x].Team == SelectionManager.Instance.m_Team) { if ((buildings[x].transform.position - _Position).magnitude < 200) { _TooClose = true; break; } } } if (_TooClose) { if (!(enemyCamps.Count == 0 && i == amountOfCamps - 1)) { continue; } } EnemyCamp _Camp = Instantiate(enemyCampPrefab, _Position, Quaternion.Euler(0, UnityEngine.Random.Range(0, 360), 0)).GetComponent <EnemyCamp>(); _Camp.currentObjective = this; _Camp.SetUp(); enemyCamps.Add(_Camp); } }
private void Button_Add_Enemy_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; if (button == null) { return; } EnemyCamp camp = button.DataContext as EnemyCamp; if (camp == null) { return; } camp.Squads.Add(new UnitSquad(Model.Units[0], 0)); }
private void Button_Delete_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; if (button == null) { return; } EnemyCamp camp = button.DataContext as EnemyCamp; if (camp == null) { return; } if (MessageBox.Show("Удалить лагерь?", "Подтверждение", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { camp.Left = -1; //for delete adorner m_camps.Remove(camp); } }
private void Button_Add_Click(object sender, RoutedEventArgs e) { Camp camp = new Camp(); camp.Name = "Без названия"; if (m_camps.Count > 0) { camp.SectorId = m_camps[m_camps.Count - 1].SectorId; int id; if (int.TryParse(m_camps[m_camps.Count - 1].Name, NumberStyles.Integer, CultureInfo.InvariantCulture, out id)) { id++; camp.Name = id.ToString(CultureInfo.InvariantCulture); } } EnemyCamp enemyCamp = new EnemyCamp(Model, camp); m_camps.Add(enemyCamp); AddAdorner(enemyCamp, AdornerLayer.GetAdornerLayer(MapImage)); }
private void Button_Paste_Position_Click(object sender, RoutedEventArgs e) { if (!m_lastClickPosition.HasValue) { return; } Button button = sender as Button; if (button == null) { return; } EnemyCamp camp = button.DataContext as EnemyCamp; if (camp == null) { return; } camp.Left = Math.Round(m_lastClickPosition.Value.X); camp.Top = Math.Round(m_lastClickPosition.Value.Y); }