Esempio n. 1
0
        public void Move(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                Unload();

                GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>().backgroundColor = Color.black;
                MapChanged?.Invoke(null);
                return;
            }

            var map = Maps.FirstOrDefault(m => m.gameObject.name == name);

            if (map == null)
            {
                throw new ArgumentException($"{name} というマップが見つかりませんでした.");
            }

            Unload();

            currentMapObject = Instantiate(map.gameObject) as GameObject;
            CurrentMap       = map;
            CurrentMap.Initialize(this);


            CurrentMapSize = CurrentMap.Size;

            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>().backgroundColor = map.BackColor;
            MapChanged?.Invoke(map);
        }
Esempio n. 2
0
        public void Start()
        {
            var timeToBreak = false;

            foreach (var line in _gameMap)
            {
                var j = 0;
                foreach (var isWall in line)
                {
                    timeToBreak = !isWall;
                    if (timeToBreak)
                    {
                        for (var k = 0; k < j; ++k)
                        {
                            _player.MoveRight();
                        }
                        break;
                    }
                    ++j;
                }
                if (timeToBreak)
                {
                    break;
                }
                _player.MoveDown();
            }
            if (!timeToBreak)
            {
                throw new ArgumentException("Not a single cell for a player on the map. Argh!");
            }
            MapChanged?.Invoke(this, new GameMapChangedArgs(_gameMap, _player));
            GameContinues?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 3
0
        private void Compute()
        {
            int range = WinMax - WinMin;

            if (range < 1)
            {
                range = 1;
            }
            double factor = (float)(IntMax - IntMin) / range;
            int    i;

            for (i = 0; i < 65536; ++i)
            {
                if (i <= WinMin)
                {
                    _lut[i] = (byte)IntMin;
                }
                else if (i >= WinMax)
                {
                    _lut[i] = (byte)IntMax;
                }
                else
                {
                    _lut[i] = (byte)(IntMin + (i - WinMin) * factor);
                }
            }

            MapChanged?.Invoke();
        }
Esempio n. 4
0
        /// <summary>
        /// Map assets loading task
        /// </summary>
        /// <param name="map">Map to be loaded</param>
        /// <param name="mapMetaData">Map meta data to be loaded</param>
        private async Task LoadMapAssets(AssetModel map, MapMetaData mapMetaData)
        {
            var loading = true;

            try
            {
                var callback = new Action <bool, string, string>((isDone, sceneName, mapBundlePath) =>
                {
                    var scene = SceneManager.GetSceneByName(sceneName);
                    SceneManager.SetActiveScene(scene);
                    CurrentMapMetaData = mapMetaData;

                    if (Loader.Instance.SimConfig != null)
                    {
                        Loader.Instance.SimConfig.MapName = CurrentMapMetaData.name;
                    }

                    CurrentMapBounds = CalculateMapBounds(scene);
                    LaneSnapping.Initialize();
                    loadedSceneName = sceneName;
                    PlayerPrefs.SetString(MapPersistenceKey, CurrentMapMetaData.name);
                    loading = false;
                    MapChanged?.Invoke(CurrentMapMetaData);
                });
                Loader.LoadMap(map.AssetGuid, map.Name, LoadSceneMode.Additive, callback);
                while (loading)
                {
                    await Task.Delay(100);
                }
            }
            catch (Exception ex)
            {
                ScenarioManager.Instance.logPanel.EnqueueError(ex.Message);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Передает изменения игрового поля юниту
 /// </summary>
 /// <param name="FieldMatrix">Матрица игрового поля</param>
 /// <param name="MarkedCells">Список "отмеченных" ячеек игрового поля</param>
 public void SetChanges(FieldPoint[,] FieldMatrix, List <FieldPoint> MarkedCells)
 {
     MapChanged.Invoke(FieldMatrix);
     if (MarkedCells != null)
     {
         SendMarkedPointsToUnits();
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Clear the dictionary.
        /// </summary>
        public void Clear()
        {
            _underlyingSet.Clear();

            MapChanged?.Invoke(this,
                               new SettingsManagerItemChanedEventArgs(
                                   null,
                                   CollectionChange.Reset));
        }
Esempio n. 7
0
        /// <summary>
        /// Add entry to the dictionary.
        /// </summary>
        /// <param name="item">Instance of <see cref="KeyValuePair{string, object}"/></param>
        public void Add(KeyValuePair <string, object> item)
        {
            _underlyingSet.Add(item);

            MapChanged?.Invoke(this,
                               new SettingsManagerItemChanedEventArgs(
                                   item.Key,
                                   CollectionChange.ItemInserted));
        }
Esempio n. 8
0
        /// <summary>
        /// Add entry to the dictionary with given key and value.
        /// </summary>
        /// <param name="key">Key of the entry.</param>
        /// <param name="value">Value of the entry.</param>
        public void Add(string key, object value)
        {
            _underlyingSet.Add(key, value);

            MapChanged?.Invoke(this,
                               new SettingsManagerItemChanedEventArgs(
                                   key,
                                   CollectionChange.ItemInserted));
        }
Esempio n. 9
0
        /// <summary>
        /// Fires the <see cref="ObservableDictionary{TKey,TValue}.DictionaryChanged"/> and <see cref="MapChanged"/> events when a change occurs.
        /// </summary>
        protected override void OnDictionaryChanged(CollectionChange change, TKey key, TValue value)
        {
            // Fire base dictionary event
            base.OnDictionaryChanged(change, key, value);

            // Fire map changed event
            // The portable base dictionary change value matches the Windows Store collection value
            MapChanged?.Invoke(this, new MapChangedEventArgs <TKey>((global::Windows.Foundation.Collections.CollectionChange)(int) change, key));
        }
        public new bool TryAdd(string key, object value)
        {
            base.AddOrUpdate(key, value, (s, o) => value);

            if (EnableUpdates)
            {
                MapChanged?.Invoke(this, new MapChangedEventArgs <string>(key, DistributedCollectionChange.ItemInserted));
            }

            return(true);
        }
Esempio n. 11
0
 public void Add(string key, object value)
 {
     if (ContainsKey(key))
     {
         throw new ArgumentException("An item with the same key has already been added.");
     }
     if (value != null)
     {
         ApplicationDataContainerInterop.SetValue(_locality, key, DataTypeSerializer.Serialize(value));
         MapChanged?.Invoke(this, null);
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Remove an entry from the dictionary.
        /// </summary>
        /// <param name="item">Instance of <see cref="KeyValuePair{string, object}"/></param>
        /// <returns>Value indicates the operation result.</returns>
        public bool Remove(KeyValuePair <string, object> item)
        {
            var opResult = _underlyingSet.Remove(item);

            if (opResult)
            {
                MapChanged?.Invoke(this,
                                   new SettingsManagerItemChanedEventArgs(
                                       item.Key,
                                       CollectionChange.ItemRemoved));
            }

            return(opResult);
        }
Esempio n. 13
0
        /// <summary>
        /// Remove entry with the given key.
        /// </summary>
        /// <param name="key">Key of the entry to be removed.</param>
        /// <returns>Value indicates the operation result.</returns>
        public bool Remove(string key)
        {
            var opResult = _underlyingSet.Remove(key);

            if (opResult)
            {
                MapChanged?.Invoke(this,
                                   new SettingsManagerItemChanedEventArgs(
                                       key,
                                       CollectionChange.ItemRemoved));
            }

            return(opResult);
        }
Esempio n. 14
0
        /// <summary>
        /// Set value of item with given key. If key doesn't exist, a new entry will be created.
        /// </summary>
        /// <param name="value">Value to set.</param>
        /// <param name="key">Key of the item to set.</param>
        public void SetValue(object value, [CallerMemberName] string key = null)
        {
            if (_underlyingSet.ContainsKey(key))
            {
                _underlyingSet[key] = value;
            }
            else
            {
                _underlyingSet.Add(key, value);
            }

            MapChanged?.Invoke(this,
                               new SettingsManagerItemChanedEventArgs(
                                   key,
                                   CollectionChange.ItemChanged));
        }
Esempio n. 15
0
        //public void UpdateCell(int x, int y, string state, Player player)
        //{
        //    Map[y] = Map[y].Substring(0, x) + Convert.ToChar(state) + Map[y].Substring(x + 1);
        //    Players[player.Index] = player;

        //    CellChanged?.Invoke(this, new CellChangedEvent {State = state, X = x, Y = y});
        //}

        public void UpdateMap(IList <string> map, Point tecman, IList <Point> ghosts, IList <Point> ghostsOld, bool iAmTecman)
        {
            int width  = map[0].Length;
            int height = map.Count;

            Map = new CellState[height, width];
            for (int row = 0; row < height; row++)
            {
                ParseRow(row, map[row]);
            }
            Tecman     = tecman;
            TecmanNext = tecman;
            SetFlag(tecman, CellState.Tecman);
            SetFlag(tecman, CellState.TecmanNext);
            Ghost     = ghosts.ToArray();
            GhostNext = ghosts.ToArray();
            CellState flg = CellState.Ghost1 | CellState.Ghost1Next;

            foreach (Point p in Ghost)
            {
                SetFlag(p, flg);
                flg = (CellState)((ushort)flg * 2);
            }
            GhostOld = ghostsOld.ToArray();
            //flg = CellState.Ghost1Old;
            //foreach (Point p in GhostOld)
            //{
            //    SetFlag(p, flg);
            //    flg = (CellState)((ushort)flg * 2);
            //}
            if (iAmTecman)
            {
                Actors = new MapActor[]
                {
                    new MapActor(0, "Tc", Tecman, true)
                };
            }
            else
            {
                Actors = Ghost.Select((p, i) => new MapActor(i, "G" + (i + 1), p, false)).ToList();
            }
            MapChanged?.Invoke(this, new MapChangedEventArgs {
                Map = Map
            });
        }
Esempio n. 16
0
        public void SyncToModel()
        {
            (List <NodeViewModel> addedNodes, List <NodeViewModel> removedNodes) = SyncNodes();
            (List <EdgeViewModel> addedEdges, List <EdgeViewModel> removedEdges) = SyncEdges();

            Arrange();
            if (addedNodes.Count == 0 && removedNodes.Count == 0 && addedEdges.Count == 0 && removedEdges.Count == 0)
            {
                return;
            }

            var mapChangedArgs = new MapChangedEventArgs()
            {
                AddedNodes   = addedNodes,
                RemovedNodes = removedNodes,
                AddedEdges   = addedEdges,
                RemovedEdges = removedEdges
            };

            MapChanged.Invoke(this, mapChangedArgs);
        }
Esempio n. 17
0
    public void Move(string name)
    {
        var map = Maps.FirstOrDefault(m => m.gameObject.name == name);

        if (map == null)
        {
            throw new ArgumentException($"{name} というマップが見つかりませんでした.");
        }

        if (currentMapObject)
        {
            Destroy(currentMapObject);
        }
        currentMapObject = Instantiate(map.gameObject) as GameObject;
        CurrentMap       = map;
        var tmaps = map.gameObject.GetComponentsInChildren <Tilemap>();
        var cs    = map.gameObject.GetComponent <Grid>().cellSize;
        var rect  = Rect.zero;

        foreach (var tmap in tmaps)
        {
            tmap.CompressBounds();
            var   b = tmap.cellBounds;
            float x = cs.x, y = cs.y;
            var   r = Rect.MinMaxRect(b.xMin * x, b.yMin * y, b.xMax * x, b.yMax * y);

            // 取得したものが大きければその分広げる
            rect.xMin = r.xMin < rect.xMin ? r.xMin : rect.xMin;
            rect.yMin = r.yMin < rect.yMin ? r.yMin : rect.yMin;
            rect.xMax = rect.xMax < r.xMax ? r.xMax : rect.xMax;
            rect.yMax = rect.yMax < r.yMax ? r.yMax : rect.yMax;
        }


        CurrentMapSize = rect;

        GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>().backgroundColor = map.BackColor;
        MapChanged?.Invoke(map);
    }
Esempio n. 18
0
        public void NewGameIteration(object sender, KeyPressedArgs args)
        {
            switch (args.GameChange)
            {
            case KeyPressedArgs.GameChangeEnum.NewPosition:
            {
                Actions[args.Key].React(_gameMap, _player);
                break;
            }

            case KeyPressedArgs.GameChangeEnum.Cancel:
            {
                return;
            }

            default:
            {
                Console.WriteLine("Wrong key, result ignored. Remind: Q to exit, arrows to move.");
                return;
            }
            }
            MapChanged?.Invoke(this, new GameMapChangedArgs(_gameMap, _player));
            GameContinues?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 19
0
 public void OnMapChanged(string map)
 {
     MapChanged?.Invoke(Bot, map);
 }
Esempio n. 20
0
 private void RaiseMapChanged(CollectionChange change, K key)
 {
     MapChanged?.Invoke(this, new ObservableDictionaryChangedEventArgs(change, key));
 }
Esempio n. 21
0
 private void OnMapChanged(ValueEventArgs <int> e) => MapChanged?.Invoke(this, e);
Esempio n. 22
0
 /// <summary>
 /// Raising a map changed event.
 /// </summary>
 /// <param name="n"></param>
 private void OnMapChanged(int n) => MapChanged?.Invoke(this, new MapChangedEventArgs(n));
Esempio n. 23
0
 protected void RaiseMapChanged(string propertyName)
 => MapChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
Esempio n. 24
0
        public StartGameConfigPanel()
        {
            var mapsListLabel = new Label
            {
                Dock = DockStyle.Top,
                Text = "Maps list. Click to select."
            };

            mapsList = new ListBox
            {
                Dock = DockStyle.Fill
            };
            mapsList.SelectedValueChanged += (sender, args) =>
            {
                if (mapsList.SelectedItem != null)
                {
                    MapChanged?.Invoke((NamedMap)mapsList.SelectedItem);
                }
            };
            var allAisListLabel = new Label
            {
                Dock = DockStyle.Bottom,
                Text = "AIs list. Double click to add AI."
            };

            allAisList = new ListBox
            {
                Dock   = DockStyle.Bottom,
                Height = 200
            };
            allAisList.DoubleClick += (sender, args) =>
            {
                if (allAisList.SelectedItem != null)
                {
                    AiSelected?.Invoke((AiFactory)allAisList.SelectedItem);
                }
            };
            var selectedAisListLabel = new Label
            {
                Dock = DockStyle.Bottom,
                Text = "Selected AIs list. Double click to remove."
            };

            selectedAisList = new ListBox
            {
                Dock   = DockStyle.Bottom,
                Height = 100
            };
            var enableFutures = new CheckBox
            {
                Text       = "ENABLE FUTURES",
                Dock       = DockStyle.Bottom,
                CheckState = CheckState.Checked
            };
            var enablSplurges = new CheckBox
            {
                Text       = "ENABLE SPLURGES",
                Dock       = DockStyle.Bottom,
                CheckState = CheckState.Checked
            };
            var enablOptions = new CheckBox
            {
                Text       = "ENABLE OPTIONS",
                Dock       = DockStyle.Bottom,
                CheckState = CheckState.Checked
            };

            enableFutures.CheckStateChanged += (sender, args) =>
            {
                EnableFuturesChanged?.Invoke(enableFutures.Checked);
            };
            enablSplurges.CheckStateChanged += (sender, args) =>
            {
                EnableSplurgesChanged?.Invoke(enablSplurges.Checked);
            };
            enablOptions.CheckStateChanged += (sender, args) =>
            {
                EnableOptionsChanged?.Invoke(enablOptions.Checked);
            };
            selectedAisList.DoubleClick += (sender, args) =>
            {
                AiAtIndexRemoved?.Invoke(selectedAisList.SelectedIndex);
            };
            EnableFuturesChanged += enable =>
            {
                Settings.futures = enable;
            };
            EnableSplurgesChanged += enable =>
            {
                Settings.splurges = enable;
            };
            EnableOptionsChanged += enable =>
            {
                Settings.options = enable;
            };
            AiSelected += factory =>
            {
                var ai = factory.Create();
                SelectedAis.Add(ai);
                selectedAisList.Items.Add($"{ai.Name}:{ai.Version}");
            };
            AiAtIndexRemoved += index =>
            {
                selectedAisList.Items.RemoveAt(index);
                SelectedAis.RemoveAt(index);
            };
            MapChanged += map => { SelectedMap = map; };

            var fastAiSelectors = new TableLayoutPanel
            {
                Dock     = DockStyle.Bottom,
                AutoSize = true
            };

            for (var i = 1; i < 5; i++)
            {
                var cnt    = (int)Math.Pow(2, i);
                var button = new Button
                {
                    Text  = cnt.ToString(),
                    Dock  = DockStyle.Left,
                    Width = 30
                };
                button.Click += (_, __) => AddRandomAis(cnt);
                fastAiSelectors.Controls.Add(button, i, 0);
            }

            Controls.Add(mapsList);
            Controls.Add(mapsListLabel);
            Controls.Add(allAisListLabel);
            Controls.Add(fastAiSelectors);
            Controls.Add(allAisList);
            Controls.Add(selectedAisListLabel);
            Controls.Add(selectedAisList);
            Controls.Add(enableFutures);
            Controls.Add(enablSplurges);
            Controls.Add(enablOptions);
        }
Esempio n. 25
0
 void InvokeMapChangedHandler(Map lastMap, params Map[] maps)
 {
     MapChanged?.Invoke(lastMap, maps);
 }
Esempio n. 26
0
File: Map.cs Progetto: Teles1/Cookie
 private void OnMapChanged()
 {
     MapChanged?.Invoke(_account, new MapChangedEventArgs(Id));
     ((Account)_account).MainForm.UpdateMapLabel($"{X},{Y}");
 }
 private void ComboBoxMapSelection_SelectionChanged(object sender, EventArgs e)
 => MapChanged?.Invoke(sender, new EventArgs <string>(((ToolStripItem)sender).Text));
Esempio n. 28
0
 public static void InvokeMapChanged(MapChangedEventArgs e)
 {
     MapChanged?.Invoke(e);
 }
Esempio n. 29
0
 private void OnMapChanged()
 {
     MapChanged?.Invoke(_account, new MapChangedEventArgs(Id));
 }