示例#1
0
        void TowerData_Response_Handler(BinaryReader br)
        {
            TowerData td = new TowerData();

            td.Tower = br.ReadInt32();
            int floors = br.ReadInt32();

            td.Floors = new TowerFloorRecord[floors];
            for (int i = 0; i < floors; i++)
            {
                TowerFloorRecord record = new TowerFloorRecord();
                record.Floor       = br.ReadInt32();
                record.BestTime    = br.ReadInt32();
                record.RankFriends = br.ReadInt32();
                record.RankGlobal  = br.ReadInt32();
                td.Floors[i]       = record;
            }

            OnTowerDataResponse(this, td);
        }
示例#2
0
        void LoadTowerData(BinaryReader br, int version)
        {
            int towerCount = br.ReadInt32();

            _towerData = new TowerData[towerCount];
            for (int i = 0; i < towerCount; i++)
            {
                _towerData[i]       = new TowerData();
                _towerData[i].Tower = br.ReadInt32();

                int floorCount = br.ReadInt32();
                _towerData[i].Floors = new TowerFloorRecord[floorCount];
                for (int j = 0; j < floorCount; j++)
                {
                    TowerFloorRecord tfr = new TowerFloorRecord();
                    tfr.Floor               = br.ReadInt32();
                    tfr.BestTime            = br.ReadInt32();
                    _towerData[i].Floors[j] = tfr;
                }
            }
        }
示例#3
0
        void SaveStaticTowerData(int tower, TowerData td)
        {
            string file = s_TowerDataFile + tower;

            FileStream fs = File.Open(file, FileMode.Create);
            BinaryWriter bw = new BinaryWriter(fs);
            bw.Write(td.Floors.Length);
            if (td.Floors.Length > 0)
            {
                List<TowerFloorRecord> floors = new List<TowerFloorRecord>(td.Floors);
                floors.Reverse();
                foreach (TowerFloorRecord tfr in floors)
                {
                    bw.Write(tfr.BestTime);
                }
            }
            bw.Close();
        }
示例#4
0
        private void M_Client_OnTowerDataResponse(object sender, TowerData e)
        {
            // tower data from server is not in order, re-order it now

            // find the highest floor and move into a dictionary
            int highestFloor = 0;
            Dictionary<int, TowerFloorRecord> map = new Dictionary<int, TowerFloorRecord>();
            foreach (TowerFloorRecord floor in e.Floors)
            {
                if( floor.Floor > highestFloor )
                    highestFloor = floor.Floor;
                map[floor.Floor] = floor;
            }

            e.Floors = new TowerFloorRecord[highestFloor + 1];
            e.Floors[0] = new TowerFloorRecord();
            e.Floors[0].Floor = highestFloor + 1;
            foreach (KeyValuePair<int, TowerFloorRecord> kvp in map)
            {
                int index = (highestFloor - kvp.Key) + 1;
                e.Floors[index] = kvp.Value;
            }

            // Fix any nulls that might exist
            for (int i = 1; i < e.Floors.Length; i++)
            {
                TowerFloorRecord r = e.Floors[i];
                if (r == null)
                {
                    r = new TowerFloorRecord();
                    r.Floor = e.Floors[i - 1].Floor - 1;
                    e.Floors[i] = r;
                }
            }

            // store the data
            m_TowerData = e;
        }
示例#5
0
        void LoadStaticTowerData(int tower)
        {
            string file = s_TowerDataFile + tower;
            TowerData td = new TowerData();
            td.Tower = tower;
            List<TowerFloorRecord> floorRecords = new List<TowerFloorRecord>();
            if (File.Exists(file))
            {
                BinaryReader br = new BinaryReader(File.OpenRead(file));
                int floorCount = br.ReadInt32();
                if (floorCount > 0)
                {
                    for (int i = 0; i < floorCount; i++)
                    {
                        TowerFloorRecord tfr = new TowerFloorRecord();
                        tfr.Floor = i + 1;
                        tfr.BestTime = br.ReadInt32();
                        tfr.RankFriends = 0;
                        tfr.RankGlobal = 0;
                        floorRecords.Add(tfr);
                    }
                }
                br.Close();
            }

            // Add 'next' floor
            TowerFloorRecord nextFloor = new TowerFloorRecord();
            nextFloor.Floor = floorRecords.Count + 1;
            floorRecords.Add(nextFloor);
            floorRecords.Reverse();
            td.Floors = floorRecords.ToArray();

            m_TowerData = td;
        }
示例#6
0
        public void RequestTowerData(int tower, bool shortList)
        {
            // Clear existing tower data
            m_TowerData = null;

            if (m_bDisabled)
            {
                // load data from disk
                LoadStaticTowerData(tower);
            }
            else
            {
                // Request data from server
                m_Client.RequestTowerData(tower, shortList);
            }
        }
示例#7
0
        void SetupFloorData(TowerData td)
        {
            double parTime = Balance.ParTime(td.Tower);
            m_Floors = new List<FloorDisplay>();
            foreach (TowerFloorRecord floor in td.Floors)
            {
                m_Floors.Add(new FloorDisplay(m_FloorScrollRect.Left, m_FloorScrollRect.Width, floor.Floor, floor.RankFriends, floor.RankGlobal, floor.BestTime, parTime));
            }

            float floorHeight = m_Floors[0].Height;
            int visibleFloors = (int)(m_FloorScrollRect.Height / floorHeight);
            m_ScrollMin = -((m_Floors.Count - visibleFloors) * m_Floors[0].Height);

            // Set tutorial stuff
            float tutorialArrowY = m_FloorScrollRect.Top + m_Floors[0].Height * 0.5f;
            m_Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.FloorSelect, new Vector2(m_FloorScrollRect.Left, tutorialArrowY), 0,
                                         new Rectangle(m_FloorScrollRect.Left - (m_iFloorSelectTutorialWidth + m_iLeftRightMargin), m_FloorScrollRect.Top + m_Game.Tutorial.ArrowHeight, m_iFloorSelectTutorialWidth, 0),
                                         "Here you can select the next incomplete tower floor or any floor you have previously completed.\n\nTap the first floor now to select it.", TutorialSystem.TutorialPiece.None,
                                         new Rectangle(m_FloorScrollRect.Left, m_FloorScrollRect.Top, m_FloorScrollRect.Width, (int)m_Floors[0].Height));
            m_Game.Tutorial.TriggerPiece(TutorialSystem.TutorialPiece.FloorSelect);
        }
示例#8
0
        void TowerData_Response_Handler(BinaryReader br)
        {
            TowerData td = new TowerData();
            td.Tower = br.ReadInt32();
            int floors = br.ReadInt32();
            td.Floors = new TowerFloorRecord[floors];
            for (int i = 0; i < floors; i++)
            {
                TowerFloorRecord record = new TowerFloorRecord();
                record.Floor = br.ReadInt32();
                record.BestTime = br.ReadInt32();
                record.RankFriends = br.ReadInt32();
                record.RankGlobal = br.ReadInt32();
                td.Floors[i] = record;
            }

            OnTowerDataResponse(this, td);
        }