Esempio n. 1
0
    public static DROP_TYPE CheckDropType(int dropId)
    {
        Assert.assert(dropId > 0);

        DataDropGroup dataDropGroup = DataManager.instance.dataDropGroup;

        DropCollection collection = dataDropGroup.GetDropCollection(dropId);

        if (collection.drops.Count > 1)
        {
            //validate
            foreach (DataDrop d in collection.drops)
            {
                Assert.assert(d.itemType != (int)DataConfig.DATA_TYPE.Exp);
            }

            return(DROP_TYPE.MIX);
        }

        DataDrop drop = collection.drops [0];

        if (drop.itemType == (int)DataConfig.DATA_TYPE.Exp)
        {
            return(DROP_TYPE.EXP);
        }

        return(DROP_TYPE.MIX);
    }
Esempio n. 2
0
    public void Load(string name)
    {
        byte[] bin     = DynamicFileControl.QueryFileContent(name);
        string content = StringHelper.ReadFromBytes(bin);

        LitJson.JSONNode json = LitJson.JSON.Parse(content);

        _dropCollectionMap = new Dictionary <int, DropCollection> ();

        foreach (LitJson.JSONNode subNode in json.Childs)
        {
            DataDrop data = new DataDrop();
            data.Load(subNode);

            if (!_dropCollectionMap.ContainsKey(data.id))
            {
                _dropCollectionMap.Add(data.id, new DropCollection());
            }
            DropCollection collection = _dropCollectionMap[data.id];

            collection.drops.Add(data);
        }
    }
Esempio n. 3
0
        /// <summary>
        /// Runs the main event loop.
        /// </summary>
        /// <remarks>
        /// Note that this function does not return
        /// until the SDL_QUIT message is recieved. If you want to run
        /// a game tick loop, it should run on a separate thread.
        /// </remarks>
        public void RunWindowLoop()
        {
            try
            {
                bool quit = false;
                while (!quit)
                {
                    SDL.SDL_Event e;
                    if (SDL.SDL_PollEvent(out e) != 0)
                    {
                        switch (e.type)
                        {
                        // Quit
                        case SDL.SDL_EventType.SDL_QUIT:
                        {
                            foreach (var wnd in windows)
                            {
                                wnd.Value.OnQuit();
                            }
                            quit = true;
                            break;
                        }

                        // File dropping
                        case SDL.SDL_EventType.SDL_DROPFILE:
                        case SDL.SDL_EventType.SDL_DROPTEXT:
                        {
                            string   data = SDLUtil.NullTerminatedUTF8String(e.drop.file);
                            DataDrop drop = new DataDrop(e.type == SDL.SDL_EventType.SDL_DROPFILE, data);
                            windows[e.drop.windowID].OnDataDrop(drop);
                            ExtraSDLBindings.SDL_free(e.drop.file);
                            // Note to SDL devs (or SDL2# dev): This is not ok
                            // Either give SDL_free in SDL2# or have SDL free the pointer itself
                            // Or have the binding return a string here
                            break;
                        }

                        case SDL.SDL_EventType.SDL_DROPBEGIN:
                        {
                            windows[e.drop.windowID].OnBeginDrop();
                            break;
                        }

                        case SDL.SDL_EventType.SDL_DROPCOMPLETE:
                        {
                            windows[e.drop.windowID].OnEndDrop();
                            break;
                        }

                        // Key actions
                        case SDL.SDL_EventType.SDL_KEYDOWN:
                        {
                            KeyAction action = new KeyAction(e.key);
                            windows[e.key.windowID].OnKeyDown(action);
                            break;
                        }

                        case SDL.SDL_EventType.SDL_KEYUP:
                        {
                            KeyAction action = new KeyAction(e.key);
                            windows[e.key.windowID].OnKeyUp(action);
                            break;
                        }

                        // Mouse Actions
                        case SDL.SDL_EventType.SDL_MOUSEMOTION:
                        {
                            windows[e.motion.windowID].OnMouseMove(e.motion.x, e.motion.y, e.motion.xrel, e.motion.yrel);
                            break;
                        }

                        case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN:
                        {
                            windows[e.button.windowID].OnMouseDown(new MouseAction(e.button));
                            break;
                        }

                        case SDL.SDL_EventType.SDL_MOUSEBUTTONUP:
                        {
                            windows[e.button.windowID].OnMouseUp(new MouseAction(e.button));
                            break;
                        }

                        case SDL.SDL_EventType.SDL_TEXTEDITING:
                        {
                            windows[e.edit.windowID].OnTextEdit(new TextEditingAction(e.edit));
                            break;
                        }

                        case SDL.SDL_EventType.SDL_TEXTINPUT:
                        {
                            unsafe
                            {
                                windows[e.text.windowID].OnTextInput(SDLUtil.NullTerminatedUTF8String(new IntPtr(e.text.text)));
                            }
                            break;
                        }
                        }
                    }
                    foreach (var wnd in windows)
                    {
                        wnd.Value.OnPaint();
                    }
                }
            }catch (Exception ex)
            {
                MessageBox.ShowMessageBox(MessageBoxFlags.Error, "Unhandled Exception", ex.ToString());
                throw;
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Fired when a user drops content onto the window.
 /// </summary>
 /// <param name="data"></param>
 public virtual void OnDataDrop(DataDrop data)
 {
 }
Esempio n. 5
0
 public override void OnDataDrop(DataDrop data)
 {
     Console.WriteLine("DataDrop: {0} {1}", data.IsFile, data.Data);
 }