Esempio n. 1
0
        public EditMapEventForm(Genus2D.GameData.MapEvent mapEvent)
        {
            InitializeComponent();

            _mapEvent = mapEvent;

            NameBox.Text = _mapEvent.Name;
            List <string> events = Genus2D.GameData.EventData.GetEventsDataNames();

            EventSelection.Items.Add("None");
            EventSelection.Items.AddRange(events.ToArray());
            if (mapEvent.EventDataID + 1 < EventSelection.Items.Count)
            {
                EventSelection.SelectedIndex = mapEvent.EventDataID + 1;
            }
            else
            {
                EventSelection.SelectedIndex = 0;
            }

            EventDirectionSelection.SelectedIndex = (int)mapEvent.EventDirection;

            EventSpriteSelection.Items.Add("None");
            List <string> spriteNames = Genus2D.GameData.SpriteData.GetSpriteNames();

            EventSpriteSelection.Items.AddRange(spriteNames.ToArray());
            if (mapEvent.SpriteID + 1 < EventSpriteSelection.Items.Count)
            {
                EventSpriteSelection.SelectedIndex = mapEvent.SpriteID + 1;
            }
            else
            {
                EventSpriteSelection.SelectedIndex = 0;
            }

            EventTriggerTypeSelection.SelectedIndex = (int)mapEvent.TriggerType;
            RenderPrioritySelection.SelectedIndex   = (int)mapEvent.Priority;
            SpeedSelection.SelectedIndex            = (int)mapEvent.Speed;
            FrequencySelection.SelectedIndex        = (int)mapEvent.Frequency;

            ParticleEmitterSelection.Items.Add("None");
            List <string> emitterNames = Genus2D.GameData.ParticleEmitterData.GetEmitterNames();

            ParticleEmitterSelection.Items.AddRange(emitterNames.ToArray());
            if (mapEvent.ParticleEmitterID + 1 < ParticleEmitterSelection.Items.Count)
            {
                ParticleEmitterSelection.SelectedIndex = mapEvent.ParticleEmitterID + 1;
            }
            else
            {
                ParticleEmitterSelection.SelectedIndex = 0;
            }

            EventPassableCheck.Checked  = mapEvent.Passable;
            RandomMovementCheck.Checked = mapEvent.RandomMovement;
            EnabledCheck.Checked        = mapEvent.Enabled;

            ApplyData();
        }
Esempio n. 2
0
 public void AddMapEvent(MapEvent mapEvent)
 {
     _mapEvents.Add(mapEvent);
 }
Esempio n. 3
0
        public static MapEvent FromBytes(byte[] bytes)
        {
            using (MemoryStream stream = new MemoryStream(bytes))
            {
                byte[] tempBytes = new byte[sizeof(int)];
                stream.Read(tempBytes, 0, sizeof(int));
                int nameLength = BitConverter.ToInt32(tempBytes, 0);

                tempBytes = new byte[nameLength];
                stream.Read(tempBytes, 0, nameLength);
                string name = new string(Encoding.UTF8.GetChars(tempBytes, 0, nameLength));

                tempBytes = new byte[sizeof(int)];
                stream.Read(tempBytes, 0, sizeof(int));
                int eventDataID = BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                int mapX = BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                int mapY = BitConverter.ToInt32(tempBytes, 0);

                tempBytes = new byte[sizeof(float)];
                stream.Read(tempBytes, 0, sizeof(float));
                float realX = BitConverter.ToSingle(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(float));
                float realY = BitConverter.ToSingle(tempBytes, 0);

                tempBytes = new byte[sizeof(int)];
                stream.Read(tempBytes, 0, sizeof(int));
                FacingDirection direction = (FacingDirection)BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                int spriteID = BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                EventTriggerType triggerType = (EventTriggerType)BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                RenderPriority priority = (RenderPriority)BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                MovementSpeed speed = (MovementSpeed)BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                int particleEmitterID = BitConverter.ToInt32(tempBytes, 0);

                tempBytes = new byte[sizeof(bool)];
                stream.Read(tempBytes, 0, sizeof(bool));
                bool enabled = BitConverter.ToBoolean(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(bool));
                bool onBridge = BitConverter.ToBoolean(tempBytes, 0);

                MapEvent mapEvent = new MapEvent(name, eventDataID, mapX, mapY);
                mapEvent.RealX             = realX;
                mapEvent.RealY             = realY;
                mapEvent.EventDirection    = direction;
                mapEvent.SpriteID          = spriteID;
                mapEvent.TriggerType       = triggerType;
                mapEvent.Enabled           = enabled;
                mapEvent.Priority          = priority;
                mapEvent.Speed             = speed;
                mapEvent.OnBridge          = onBridge;
                mapEvent.ParticleEmitterID = particleEmitterID;
                return(mapEvent);
            }
        }
Esempio n. 4
0
        public static MapData FromBytes(byte[] bytes)
        {
            using (MemoryStream stream = new MemoryStream(bytes))
            {
                byte[] tempBytes = new byte[sizeof(int)];
                stream.Read(tempBytes, 0, sizeof(int));
                int nameSize = BitConverter.ToInt32(tempBytes, 0);

                tempBytes = new byte[nameSize];
                stream.Read(tempBytes, 0, nameSize);
                string mapName = new string(Encoding.UTF8.GetChars(tempBytes));

                tempBytes = new byte[sizeof(int)];
                stream.Read(tempBytes, 0, sizeof(int));
                int width = BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                int height = BitConverter.ToInt32(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(int));
                int mapDataSize = BitConverter.ToInt32(tempBytes, 0);

                Tuple <int, int>[] mapData = new Tuple <int, int> [mapDataSize];

                for (int i = 0; i < mapDataSize; i++)
                {
                    stream.Read(tempBytes, 0, sizeof(int));
                    int tileID = BitConverter.ToInt32(tempBytes, 0);
                    stream.Read(tempBytes, 0, sizeof(int));
                    int tilesetID          = BitConverter.ToInt32(tempBytes, 0);
                    Tuple <int, int> tuple = new Tuple <int, int>(tileID, tilesetID);
                    mapData[i] = tuple;
                }

                MapData data = new MapData(mapName, width, height);
                data._mapData = mapData;

                stream.Read(tempBytes, 0, sizeof(int));
                int mapEventsSize = BitConverter.ToInt32(tempBytes, 0);

                for (int i = 0; i < mapEventsSize; i++)
                {
                    tempBytes = new byte[sizeof(int)];
                    stream.Read(tempBytes, 0, sizeof(int));
                    int size = BitConverter.ToInt32(tempBytes, 0);

                    tempBytes = new byte[size];
                    stream.Read(tempBytes, 0, size);
                    MapEvent mapEvent = MapEvent.FromBytes(tempBytes);
                    data.AddMapEvent(mapEvent);
                }

                tempBytes = new byte[sizeof(bool)];

                stream.Read(tempBytes, 0, sizeof(bool));
                data.PvpEnabled = BitConverter.ToBoolean(tempBytes, 0);

                stream.Read(tempBytes, 0, sizeof(bool));
                data.MultiCombat = BitConverter.ToBoolean(tempBytes, 0);

                return(data);
            }
        }