コード例 #1
0
        private void onMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                int xt = (int)((e.X - EditorEngine.Instance.xCam) / EditorEngine.Instance.World.Camera.Scale / 16);
                int yt = (int)((e.Y - EditorEngine.Instance.yCam) / EditorEngine.Instance.World.Camera.Scale / 16);

                int z            = TileEditorState.Instance.SelectedLayer;
                int tilesetIndex = TileEditorState.Instance.SelectedTileset;

                Rectangle selectedRegion = TileEditorState.Instance.SelectedRegion;
                Tileset   tileset        = EditorEngine.Instance.CurrentMap.Tilesets[tilesetIndex].Tileset;

                int tileIndex = tileset.Texture.GetIndex(selectedRegion.X, selectedRegion.Y);

                FillAction fillAction = new FillAction(xt, yt, tileIndex, tilesetIndex);
                EditorEngine.Instance.GetActionManager().Execute(fillAction);
                foreach (SetTileAction a in fillAction.Actions)
                {
                    Map map = EditorEngine.Instance.CurrentMap;

                    MockupTileBehavior b = map.GetBehavior(a.X, a.Y);
                    b.BehaviorId = map.Tilesets[a.TilesetIndex].Tileset.Tiles[a.TileIndex].DefaultBehavior.BehaviorId;
                }
            }
        }
コード例 #2
0
    void Start()
    {
        gameObject.Play(FillAction.Create(end, isRelative, duration, Ease.FromType(easeType), direction));

        // Self-destroy
        Destroy(this);
    }
コード例 #3
0
        void processFill(FillOriginator originator, FillAction action, ReadOnlyCollection <Fill> fills)
        {
            foreach (Fill fill in fills)
            {
                processFill(FillOriginator.TRADER, FillAction.ADD, fill);
                Thread.Sleep(5);
            }

            processSystemMessage(SystemMessage.FILL_BOOK_DOWNLOAD);
        }
コード例 #4
0
 void processFill(FillOriginator originator, FillAction action)
 {
     if (action == FillAction.LIST_START)
     {
         processSystemMessage(SystemMessage.FILL_LIST_START);
     }
     else if (action == FillAction.LIST_END)
     {
         processSystemMessage(SystemMessage.FILL_LIST_END);
     }
 }
コード例 #5
0
 void api_OnFill(FillOriginator originator, FillAction action, EZInstrument ttInstrument, EZFill fill, EZFill newFill)
 {
     //cross thread - so you don't get the cross theading exception
     if (this.InvokeRequired)
     {
         this.BeginInvoke((MethodInvoker) delegate
         {
             api_OnFill(originator, action, ttInstrument, fill, newFill);
         });
         return;
     }
 }
コード例 #6
0
ファイル: GwsFloodFill.cs プロジェクト: MananAdhvaryu/GWS
 public unsafe void Begin(FillAction action, float x, float y, float w, float h)
 {
     X            = x.Round();
     Y            = y.Round();
     Width        = (++w).Round();
     Height       = (++h).Round();
     Length       = (w * h).Round();
     RenderAction = Renderer.CreateFillAction(this);
     FillAction   = action;
     Activated    = true;
     BeginInternal();
 }
コード例 #7
0
        public IAction Read()
        {
            IAction     result = null;
            BinaryInput stream = _stream as BinaryInput;
            int         i      = stream.ReadInt32();

            if (i == 1)
            {
                result = new SetTileAction();
            }
            if (i == 2)
            {
                result = new MultiAction();
            }
            if (i == 3)
            {
                result = new FillAction();
            }
            if (i == 4)
            {
                result = new RectangleAction();
            }
            if (i == 5)
            {
                result = new AddEntityAction();
            }
            if (i == 6)
            {
                result = new RemoveEntityAction();
            }

            IEncodable encodable = result as IEncodable;

            if (encodable != null)
            {
                encodable.Decode(stream);
            }
            return(result);
        }
コード例 #8
0
ファイル: NPoiExcel.cs プロジェクト: akrisiun/AiLib
        public bool FillFromTable(DataTable table, FillAction fillAction)
        {
            bool success = false;       // pesimistic variant

            try
            {
                LastError = null;
                if (IO.File.Exists(File))
                {
                    IO.File.SetAttributes(File, IO.FileAttributes.Normal);
                    IO.File.Delete(File);
                }

                fillAction(table, File, Sheet);
                // NPoiExcel.SaveTableToExcelFile(table, File, Sheet);

                success = IO.File.Exists(File);
            }
            catch (Exception ex) { LastError = ex; }

            return(success);
        }
コード例 #9
0
        void processFill(FillOriginator originator, FillAction action, Fill fill, params Fill[] fills)
        {
            TTFill newFill = null;

            /*
             * fill.BuySell;
             * fill.FFT2;
             * fill.FFT3;
             * fill.FillKey;
             * fill.FillType;
             * fill.InstrumentKey;
             * fill.IsHedge;   // autospreader hedge order
             * fill.IsQuoting; // autospreader quoting order
             * fill.MatchPrice;
             * fill.Quantity;
             * fill.SpreadId;
             * fill.TransactionDateTime;
             */

            // If this is the first fill for this instrument, then add it to our list and
            // subscribe to the instrument updates if AutoSubscribeInstruments is true.
            if (!_ttInstruments.ContainsKey(fill.InstrumentKey))
            {
                if (AutoSubscribeInstruments)
                {
                    //TODO: Make the subscribe to instrument work
                    //SubscribeToInstrument(fill.InstrumentKey);

                    /*InstrumentLookupSubscription ils = new InstrumentLookupSubscription(apiSession, Dispatcher.Current, fill.InstrumentKey);
                     * ils.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(ils_Update);
                     * ils.Start();*/
                }

                TTInstrument tti = new TTInstrument(fill.InstrumentKey);
                _ttInstruments.Add(fill.InstrumentKey, tti);
            }

            TTFill ttf = NewTTFill(fill);

            #region LOOK FOR '#' IN THE FFT FIELDS
            // See if this fill contains our '#' hashtag in either FFT field.
            string hashField = null;
            if (fill.FFT2.StartsWith("#"))
            {
                hashField = fill.FFT2;
            }
            if (fill.FFT3.StartsWith("#"))
            {
                hashField = fill.FFT3;
            }

            // If we found a valid '#' hashtag value, then put it in our dropdown combo box.
            if (hashField != null)
            {
                // Add this fill to our list of fills with this same hashsymbol
                if (!_hashSymbols.ContainsKey(hashField))
                {
                    _hashSymbols.Add(hashField, new List <Fill>());
                }
                List <Fill> hashFills = _hashSymbols[hashField];
                hashFills.Add(fill);
            }
            #endregion

            // There are definitely times when the fill key already exists in the dictionary. In those
            // cases I am just overwriting the previous fill with the new one (asuming it is an updated
            // fill or whatever).
            _currentTTFills[fill.FillKey] = ttf;

            if (OnFill != null)
            {
                OnFill(originator, action, _ttInstruments[fill.InstrumentKey], ttf, newFill);
            }
        }
コード例 #10
0
        void processFill(FillOriginator originator, FillAction action, Fill fill)
        {
            /*
             * fill.BuySell;
             * fill.FFT2;
             * fill.FFT3;
             * fill.FillKey;
             * fill.FillType;
             * fill.InstrumentKey;
             * fill.IsHedge;   // autospreader hedge order
             * fill.IsQuoting; // autospreader quoting order
             * fill.MatchPrice;
             * fill.Quantity;
             * fill.SpreadId;
             * fill.TransactionDateTime;
             */

            // If this is the first fill for this instrument, then add it to our list and
            // subscribe to the instrument updates.
            if (!instruments.ContainsKey(fill.InstrumentKey))
            {
                InstrumentLookupSubscription ils = new InstrumentLookupSubscription(apiInstance.Session, Dispatcher.Current, fill.InstrumentKey);
                ils.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(ils_Update);
                ils.Start();

                InstrumentInfo info = new InstrumentInfo(fill.InstrumentKey);
                instruments.Add(fill.InstrumentKey, info);
            }

            // Display the fill in the grid and play and sounds and/or send any messages related to
            // this fill.
            FillBasic fb = new FillBasic(fill);

            displayFill(fillGrid, fb);
            UpdateFillCount(fillGrid.Rows.Count);
            UpdateProfit(0);

            // See if this fill contains our '#' hashtag in either FFT field.
            string hashField = null;

            if (fill.FFT2.StartsWith("#"))
            {
                hashField = fill.FFT2;
            }
            if (fill.FFT3.StartsWith("#"))
            {
                hashField = fill.FFT3;
            }

            // If we found a valid '#' hashtag value, then put it in our dropdown combo box.
            if (hashField != null)
            {
                // Add this fill to our list of fills with this same hashsymbol
                if (!hashSymbols.ContainsKey(hashField))
                {
                    hashSymbols.Add(hashField, new List <Fill>());
                }
                List <Fill> fills = hashSymbols[hashField];
                fills.Add(fill);

                // Add this hashsymbol to our dropdown list if it is not already there
                if (!tscomboFFT.Items.Contains(hashField))
                {
                    tscomboFFT.Items.Add(hashField);
                }

                // If the user is filtering by this hash symbol then put this fill in the filter grid also
                string selectedHash = tscomboFFT.SelectedItem as string;
                if (selectedHash != null && selectedHash.Equals(hashField))
                {
                    displayFill(filteredGrid, fb);
                }
            }
        }
コード例 #11
0
        public static void Fill(string id, Texture2D pic)
        {
            //判断尺寸
            var farm = StageScript.Instance.FarmData;

            mod.Logger.Log($"像素画尺寸 w:{pic.width} h:{pic.height}");
            if (pic.width != 280 || pic.height != 140)
            {
                mod.Logger.Log("像素画尺寸不等于280x140,停止工作");
                return;
            }
            //判断物品
            FarmItemDefinition fillObj = null;

            foreach (var kv in ShopManager.ItemDictionary)
            {
                if (kv.Value.FullId == id)
                {
                    mod.Logger.Log($"找到了ID为{id}的物品,名字为{Localization.Get(id)}");
                    fillObj = kv.Value;
                    break;
                }
            }
            if (fillObj == null)
            {
                mod.Logger.Log("未找到物品");
                return;
            }
            FailedActionReason far;
            int        workCount   = 0;
            FillAction action      = null;
            Type       contentType = null;

            switch (fillObj.Category)
            {
            case ShopItemType.Crop:
                contentType = Assembly.Load("Assembly-CSharp").GetType("Logic.Farm.Contents.FarmCrop");
                action      = new FillAction((tile) =>
                {
                    if (tile.CheckEmpty(out far))
                    {
                        FarmTileContents content = Activator.CreateInstance(contentType, fillObj, tile) as FarmTileContents;
                        Traverse.Create(content).Field("state").SetValue(byte.Parse("1"));     //设置作物为成熟状态
                        SetContent(tile, content);
                        workCount++;
                    }
                });
                break;

            case ShopItemType.Tree:
                action = new FillAction((tile) =>
                {
                    if (tile.CheckEmpty(out far))
                    {
                        SetContent(tile, new FarmTree(fillObj as TreeDefinition, tile));
                        workCount++;
                    }
                });
                break;

            case ShopItemType.Animal:
                action = new FillAction((tile) =>
                {
                    if (tile.CheckEmpty(out far))
                    {
                        farm.PlaceAnimal(fillObj as AnimalDefinition, tile.TileId, out far);
                        workCount++;
                    }
                });
                break;

            case ShopItemType.Pond:
                action = new FillAction((tile) =>
                {
                    if (tile.CheckEmpty(out far))
                    {
                        farm.PlacePond(fillObj as PondDefinition, tile.TileId, out far);
                        workCount++;
                    }
                });
                break;

            case ShopItemType.Building:
            case ShopItemType.House:
            case ShopItemType.Decoration:
                action = new FillAction((tile) =>
                {
                    if (farm.CanPlaceBuilding(fillObj as BaseBuildingDefinition, tile.TileId, 0, out far))
                    {
                        farm.PlaceBuilding(fillObj as BaseBuildingDefinition, tile.TileId, 0, farm.GetNextBuildingId(), out far);
                        workCount++;
                    }
                });
                break;

            case ShopItemType.Road:
                contentType = Assembly.Load("Assembly-CSharp").GetType("Logic.Farm.Contents.FarmRoad");
                action      = new FillAction((tile) =>
                {
                    if (tile.CheckEmpty(out far))
                    {
                        SetContent(tile, Activator.CreateInstance(contentType, fillObj, tile) as FarmTileContents);
                        workCount++;
                    }
                });
                break;

            case ShopItemType.Flower:
                contentType = Assembly.Load("Assembly-CSharp").GetType("Logic.Farm.Contents.FarmFlower");
                action      = new FillAction((tile) =>
                {
                    if (tile.CheckEmpty(out far))
                    {
                        FarmTileContents content = Activator.CreateInstance(contentType, fillObj, tile) as FarmTileContents;
                        Traverse.Create(content).Field("state").SetValue(1);     //设置花为成熟状态
                        SetContent(tile, content);
                        workCount++;
                    }
                });
                break;
            }
            if (action != null)
            {
                startFill = true;
                for (int x = 0; x < 280; x++)
                {
                    for (int y = 0; y < 140; y++)
                    {
                        if (IsNearBlack(pic.GetPixel(x, y)))
                        {
                            var tile = farm.GetTile(GetId(x, y));
                            if (tile != null)
                            {
                                action(tile);
                            }
                        }
                    }
                }
                startFill = false;
                mod.Logger.Log($"导入完毕,共填充{workCount}个地块");
            }
            else
            {
                mod.Logger.Log($"填充失败,未定义此类物品的填充方法");
            }
        }