public override void ReadFromString(string value) { StringStreamReader reader = new StringStreamReader(value); int length = reader.ReadInt(); for (int index = 0; index < length; ++index) { int id = reader.ReadInt(); if (0 == id) { continue; } MissionInst inst = new MissionInst(); inst.m_id = id; inst.m_isFinished = reader.ReadBool(); inst.m_questRequire1 = reader.ReadShort(); inst.m_questRequire2 = reader.ReadShort(); inst.m_questRequire3 = reader.ReadShort(); inst.m_questRequire4 = reader.ReadShort(); if (myMissions.Length < index) { myMissions[index] = inst; } } }
//设置任务完成状态 public void SetFinishMission(int id) { MissionInst inst = FindMission(id); if (inst != null) { inst.m_isFinished = true; } }
//public List<MissionInst> m_myMissionList = new List<MissionInst>(); public void AddMission(MissionInst inst) { for (int index = 0; index < m_myMissions.Count(); index++) { if (null == m_myMissions[index] || m_myMissions[index].m_id == 0) { m_myMissions[index] = inst; return; } } return; }
public override void Read(BinaryHelper stream, int fixSize) { for (int i = 0; i < myMissions.Length; i++) { int id = stream.ReadInt(); if (id != 0) { MissionInst inst = new MissionInst(); inst.m_id = id; inst.m_isFinished = stream.ReadBool(); inst.m_questRequire1 = stream.ReadShort(); inst.m_questRequire2 = stream.ReadShort(); inst.m_questRequire3 = stream.ReadShort(); inst.m_questRequire4 = stream.ReadShort(); myMissions[i] = inst; } } }
public override byte[] Write() { BinaryHelper helper = new BinaryHelper(); for (int i = 0; i < myMissions.Length; i++) { MissionInst inst = myMissions[i]; helper.Write(inst.m_id); if (inst.m_id != 0) { helper.Write(inst.m_isFinished); helper.Write(inst.m_questRequire1); helper.Write(inst.m_questRequire2); helper.Write(inst.m_questRequire3); helper.Write(inst.m_questRequire4); } } return(helper.GetBytes()); }
public void AcceptMissionCallback(int id, bool finished) { MissionInfo info = GameTable.MissionTableAsset.Lookup(id); MissionInst inst = new MissionInst(); inst.m_id = id; inst.m_isFinished = finished; inst.m_questRequire1 = info.condition1; inst.m_questRequire2 = info.condition2; inst.m_questRequire3 = 0; MyMissions myMission = MyMissions.Singleton; myMission.AddMission(inst); if (finished == true) { AddFinishedMission(id); } /* myMission.m_myMissionList.Add(inst);*/ Debug.Log("Add Mission " + id); }