public void CreateSavePoint(MapInfo.Position data) { GameObject go = Game.Database.CreateEffect("guanghuan"); go.transform.SetParent(m_savePointRoot); data.CopyTo(go.transform); go.AddComponent <SavePoint>(); }
public void Born(MapInfo.Position position) { SaveData.Record record = Game.Record; GameObject go = Game.Database.LoadResource("Roles/" + record._class.ToString()); go.name = record.name; go.transform.SetParent(m_playerRoot); CharacterController cc = go.AddComponent <CharacterController>(); cc.center = new Vector3(0, 1, 0); const float scale = 0.6f; go.transform.localScale = new Vector3(scale, scale, scale); position.CopyTo(go.transform); Game.camera.target = go.transform; Role role = go.AddComponent <Role>(); role.team = Role.Team.Blue; role.m_MoveSpeed = 5; LevelInfo levelInfo = Game.Database.GetLevelInfo(record.level); role.hp = levelInfo.hp; role.atk = levelInfo.atk; role.def = levelInfo.def; go.AddComponent <Player>(); m_roles.Add(role); m_player = role; }
public void SaveMapInfo() { MapInfo mapInfo = new MapInfo(); mapInfo.born.CopyFrom(m_bornPosition); MapInfo.Npc mapNpc = new MapInfo.Npc(); int count = m_npcRoot.childCount; for (int i = 0; i < count; i++) { Transform t = m_npcRoot.GetChild(i); Npc npc = t.GetComponent <Npc>(); if (npc != null) { mapNpc.id = npc.id; mapNpc.pos.CopyFrom(t); mapInfo.npc.Add(mapNpc); } } MapInfo.Monster mapMonster = new MapInfo.Monster(); count = m_monsterRoot.childCount; for (int i = 0; i < count; i++) { Transform t = m_monsterRoot.GetChild(i); Monster monster = t.GetComponent <Monster>(); if (monster != null) { mapMonster.id = monster.id; mapMonster.pos.CopyFrom(t); mapInfo.monster.Add(mapMonster); } } MapInfo.Position savePoint = new MapInfo.Position(); count = m_savePointRoot.childCount; for (int i = 0; i < count; i++) { Transform t = m_savePointRoot.GetChild(i); savePoint.CopyFrom(t); mapInfo.savepoint.Add(savePoint); } MapInfo.Teleporter mapTel = new MapInfo.Teleporter(); count = m_teleporterRoot.childCount; for (int i = 0; i < count; i++) { Transform t = m_teleporterRoot.GetChild(i); Teleporter tel = t.GetComponent <Teleporter>(); if (tel != null) { mapTel.pos.CopyFrom(t); mapTel.scaling = tel.transform.localScale; mapTel.toMap = tel.m_toMap; mapInfo.teleporter.Add(mapTel); } } Game.Database.SaveMapInfo(mapInfo, m_name); }