private void OnMapChange(object sender, MapChangeEvent @event)
        {
            var packet = new MapChangePacket {
                MapName = @event.MapName
            };

            foreach (var peer in m_ConnectionHandler.GetPeers())
            {
                m_ConnectionHandler.Send(peer, packet);
            }
        }
Exemplo n.º 2
0
        public virtual void ChangeMap(string mapName)
        {
            m_TaskScheduler.RunOnMainThread(this, () =>
            {
                SceneManager.LoadScene(mapName);
                CurrentMap = mapName;

                MapChangeEvent mapChange = new MapChangeEvent(mapName);
                m_EventBus.Emit(this, mapChange);
            }, "ChangeMap-" + mapName);
        }
Exemplo n.º 3
0
    private void UpdateMap(MapChangeEvent e)
    {
        this.room.Map = (byte)e.MapCode;

        GameManager.instance.ShowMessage("1-" + (this.room.Map + 1) + " 로 맵이 변경되었습니다! (현재 1-1만 구현됬어요.. 그저 관상용.. )", 1.0f, MessageType.Commmon);

        if (GameManager.instance.NetPart == SocketPart.Server)
        {
            PacketManager.instance.PutPacket(new Packet(Packet.Target.SERVER, Packet.Target.ALL, Packet.Type.SYNC_ROOM_MAP, new byte[1] {
                this.room.Map
            }));
        }
    }
Exemplo n.º 4
0
        private void ParseMessage(byte[] buf)
        {
            switch (buf[1])
            {
            case (byte)MessageType.Time:
            {
                var time = ParseTime(buf, 2);
                //Debug.WriteLine("Received time: {0}:{1}:{2}.{3}.", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);

                lock (currentTimeLock)
                {
                    currentTime = time;
                }
            }
            break;

            case (byte)MessageType.Event:
            {
                var eventType = buf[2];
                var time      = ParseTime(buf, 3);

                switch (eventType)
                {
                case (byte)EventType.GameEnd:
                {
                    var ev = new GameEndEvent()
                    {
                        Time = time
                    };
                    lock (eventsLock)
                    {
                        events.Add(ev);
                    }
                    Debug.WriteLine("Received a game end event: {0}:{1}:{2}.{3}.", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
                }
                break;

                case (byte)EventType.MapChange:
                {
                    var    len = BitConverter.ToInt32(buf, 11);
                    string map = System.Text.Encoding.ASCII.GetString(buf, 15, len);

                    var ev = new MapChangeEvent {
                        Time = time, Map = map
                    };
                    lock (eventsLock)
                    {
                        events.Add(ev);
                    }
                    Debug.WriteLine("Received a map change event: {0}:{1}:{2}.{3}; {4}.", time.Hours, time.Minutes, time.Seconds, time.Milliseconds, map);
                }
                break;

                case (byte)EventType.TimerReset:
                {
                    var ev = new TimerResetEvent()
                    {
                        Time = time
                    };
                    lock (eventsLock)
                    {
                        events.Add(ev);
                    }
                    Debug.WriteLine("Received a timer reset event: {0}:{1}:{2}.{3}.", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
                }
                break;

                case (byte)EventType.TimerStart:
                {
                    var ev = new TimerStartEvent()
                    {
                        Time = time
                    };
                    lock (eventsLock)
                    {
                        events.Add(ev);
                    }
                    Debug.WriteLine("Received a timer start event: {0}:{1}:{2}.{3}.", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
                }
                break;

                case (byte)EventType.BS_ALeapOfFaith:
                {
                    var ev = new BS_ALeapOfFaithEvent()
                    {
                        Time = time
                    };
                    lock (eventsLock)
                    {
                        events.Add(ev);
                    }
                    Debug.WriteLine("Received a BS A Leap of Faith event: {0}:{1}:{2}.{3}.", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
                }
                break;

                default:
                    Debug.WriteLine("Received an unknown event type: " + buf[2]);
                    break;
                }
            }
            break;

            default:
                Debug.WriteLine("Received an unknown message type: " + buf[1]);
                break;
            }
        }
Exemplo n.º 5
0
 private void OnMapChange(MapChangeEvent e)
 {
     currentMap = e.map;
     currentMap.BuildMap(currentMapTiles);
 }
Exemplo n.º 6
0
        static MapEvent ParseEvent(IDataReader dataReader)
        {
            MapEvent mapEvent;
            var      type = (MapEventType)dataReader.ReadByte();

            switch (type)
            {
            case MapEventType.MapChange:
            {
                // 1. byte is the x coordinate
                // 2. byte is the y coordinate
                // Then 3 unknown bytes
                // Then a word for the map index
                // Then 2 unknown bytes (seem to be 00 FF)
                uint x         = dataReader.ReadByte();
                uint y         = dataReader.ReadByte();
                var  direction = (CharacterDirection)dataReader.ReadByte();
                var  unknown1  = dataReader.ReadBytes(2);
                uint mapIndex  = dataReader.ReadWord();
                var  unknown2  = dataReader.ReadBytes(2);
                mapEvent = new MapChangeEvent
                {
                    MapIndex  = mapIndex,
                    X         = x,
                    Y         = y,
                    Direction = direction,
                    Unknown1  = unknown1,
                    Unknown2  = unknown2
                };
                break;
            }

            case MapEventType.Chest:
            {
                // 1. byte are the lock flags
                // 2. byte is unknown (always 0 except for one chest with 20 blue discs which has 0x32 and lock flags of 0x00)
                // 3. byte is unknown (0xff for unlocked chests)
                // 4. byte is the chest index (0-based)
                // 5. byte (0 = chest, 1 = pile/removable loot or item) or "remove if empty"
                // word at position 6 is the key index if a key must unlock it
                // last word is the event index (0-based) of the event that is called when unlocking fails
                var  lockType             = (ChestMapEvent.LockFlags)dataReader.ReadByte();
                var  unknown1             = dataReader.ReadWord(); // Unknown
                uint chestIndex           = dataReader.ReadByte();
                bool removeWhenEmpty      = dataReader.ReadByte() != 0;
                uint keyIndex             = dataReader.ReadWord();
                var  unlockFailEventIndex = dataReader.ReadWord();
                mapEvent = new ChestMapEvent
                {
                    Unknown1               = unknown1,
                    Lock                   = lockType,
                    ChestIndex             = chestIndex,
                    RemoveWhenEmpty        = removeWhenEmpty,
                    KeyIndex               = keyIndex,
                    UnlockFailedEventIndex = unlockFailEventIndex
                };
                break;
            }

            case MapEventType.TextEvent:
            {
                // event image index (0xff = no image)
                // 3 unknown bytes
                // 5. byte is the map text index
                // 4 unknown bytes
                var eventImageIndex = dataReader.ReadByte();
                var unknown1        = dataReader.ReadBytes(3);
                var textIndex       = dataReader.ReadByte();
                var unknown2        = dataReader.ReadBytes(4);
                mapEvent = new TextEvent
                {
                    EventImageIndex = eventImageIndex,
                    TextIndex       = textIndex,
                    Unknown1        = unknown1,
                    Unknown2        = unknown2
                };
                break;
            }

            case MapEventType.Spinner:
            {
                var direction = (CharacterDirection)dataReader.ReadByte();
                var unknown1  = dataReader.ReadBytes(8);
                mapEvent = new SpinnerEvent
                {
                    Direction = direction,
                    Unknown1  = unknown1,
                };
                break;
            }

            case MapEventType.Damage:
            {
                var unknown1 = dataReader.ReadBytes(9);
                mapEvent = new DamageEvent
                {
                    Unknown1 = unknown1,
                };
                break;
            }

            case MapEventType.Riddlemouth:
            {
                var introTextIndex    = dataReader.ReadByte();
                var solutionTextIndex = dataReader.ReadByte();
                var unknown1          = dataReader.ReadBytes(7);
                mapEvent = new RiddlemouthEvent
                {
                    IntroTextIndex    = introTextIndex,
                    SolutionTextIndex = solutionTextIndex,
                    Unknown1          = unknown1
                };
                break;
            }

            case MapEventType.ChangePlayerAttribute:
            {
                var unknown1  = dataReader.ReadBytes(6);
                var attribute = (Attribute)dataReader.ReadByte();
                var unknown2  = dataReader.ReadByte();
                var value     = dataReader.ReadByte();

                mapEvent = new ChangePlayerAttributeEvent
                {
                    Attribute = attribute,
                    Value     = value,
                    Unknown1  = unknown1,
                    Unknown2  = unknown2
                };
                break;
            }

            case MapEventType.ChangeTile:
            {
                var x              = dataReader.ReadByte();
                var y              = dataReader.ReadByte();
                var unknown1       = dataReader.ReadBytes(3);
                var frontTileIndex = dataReader.ReadWord();
                var unknown2       = dataReader.ReadBytes(2);
                mapEvent = new ChangeTileEvent
                {
                    X = x,
                    Y = y,
                    FrontTileIndex = frontTileIndex,
                    Unknown1       = unknown1,
                    Unknown2       = unknown2
                };
                break;
            }

            case MapEventType.StartBattle:
            {
                var unknown1          = dataReader.ReadBytes(6);
                var monsterGroupIndex = dataReader.ReadByte();
                var unknown2          = dataReader.ReadBytes(2);
                mapEvent = new StartBattleEvent
                {
                    MonsterGroupIndex = monsterGroupIndex,
                    Unknown1          = unknown1,
                    Unknown2          = unknown2
                };
                break;
            }

            case MapEventType.Condition:
            {
                var conditionType        = (ConditionEvent.ConditionType)dataReader.ReadByte();  // TODO: this needs more research
                var value                = dataReader.ReadByte();
                var unknown1             = dataReader.ReadBytes(4);
                var objectIndex          = dataReader.ReadByte();
                var jumpToIfNotFulfilled = dataReader.ReadWord();
                mapEvent = new ConditionEvent
                {
                    TypeOfCondition = conditionType,
                    ObjectIndex     = objectIndex,
                    Value           = value,
                    Unknown1        = unknown1,
                    ContinueIfFalseWithMapEventIndex = jumpToIfNotFulfilled
                };
                break;
            }

            case MapEventType.Action:
            {
                var actionType  = (ActionEvent.ActionType)dataReader.ReadByte();        // TODO: this needs more research
                var value       = dataReader.ReadByte();
                var unknown1    = dataReader.ReadBytes(4);
                var objectIndex = dataReader.ReadByte();
                var unknown2    = dataReader.ReadBytes(2);
                mapEvent = new ActionEvent
                {
                    TypeOfAction = actionType,
                    ObjectIndex  = objectIndex,
                    Value        = value,
                    Unknown1     = unknown1,
                    Unknown2     = unknown2
                };
                break;
            }

            case MapEventType.Question:
            {
                var textIndex    = dataReader.ReadByte();
                var unknown1     = dataReader.ReadBytes(6);
                var noEventIndex = dataReader.ReadWord();
                mapEvent = new QuestionEvent
                {
                    TextIndex    = textIndex,
                    NoEventIndex = noEventIndex,
                    Unknown1     = unknown1
                };
                break;
            }

            case MapEventType.ChangeMusic:
            {
                var musicIndex = dataReader.ReadWord();
                var volume     = dataReader.ReadByte();
                var unknown1   = dataReader.ReadBytes(6);
                mapEvent = new ChangeMusicEvent
                {
                    MusicIndex = musicIndex,
                    Volume     = volume,
                    Unknown1   = unknown1
                };
                break;
            }

            default:
            {
                // TODO
                mapEvent = new DebugMapEvent
                {
                    Data = dataReader.ReadBytes(9)
                };
                break;
            }
            }

            mapEvent.Type = type;

            return(mapEvent);
        }