123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using System;
- using UnityEngine.UI;
- namespace YLBattle
- {
- public class Map : MonoBehaviour
- {
- static private Map mInstance;
- /// 地图数据
- /// </summary>
- public MapData mapData;
- /// <summary>
- /// 地图ID
- /// </summary>
- public int mapId;
- /// <summary>
- /// 地图文件
- /// </summary>
- public string mapFile;
- /// <summary>
- /// 单例
- /// </summary>
- /// <value>The instance.</value>
- static public Map Instance
- {
- set
- {
- mInstance = value;
- }
- get
- {
- return mInstance;
- }
- }
- void Awake()
- {
- mInstance = this;
- mapId = 1;
- }
- // Use this for initialization
- void Start()
- {
- this.transform.parent.Rotate (0, 0, 0);
- mapFile = "";
- }
- public void InitData(ref MapData data)
- {
- // 创建孵化点
- foreach (ZoneSpawner spawn in data.spawnUnitList)
- {
- GameObject spawnObj = new GameObject();
- SpawnPoint spawnCmpt = spawnObj.AddComponent<SpawnPoint>();
- spawnObj.name = "SpawnPoint";
- spawnCmpt.Init(spawn);
- spawnCmpt.transform.parent = this.transform.parent;
- }
- }
- private void Update()
- {
-
- }
- public void AddSpawnPoint(ZoneSpawner sp)
- {
- this.mapData.spawnUnitList.Add(sp);
- }
- public void RemoveSpawner(ZoneSpawner sp)
- {
-
- }
- public void PlaceSelectBuild()
- {
- }
- public void PlaceSelectGroup()
- {
- }
- public void PlaceSelectRole()
- {
- }
- public void PlaceUnitEventHandle()
- {
- }
- void OnMouseDown()
- {
- }
- public void AddUnitSpawner(ZoneSpawner sp)
- {
- this.mapData.spawnUnitList.Add(sp);
- }
- public void RemoveUnitSpawner(ZoneSpawner sp)
- {
- this.mapData.spawnUnitList.Remove(sp);
- }
- public void SpawnerSave()
- {
-
- }
- public void Export()
- {
- MapParse.ExportMapData(this.mapData);
- }
- public void Import(string fileName)
- {
- this.mapFile = fileName;
- this.mapData = MapParse.ImportMapFile(fileName);
- this.mapData.MapDataCreate();
- this.InitData(ref this.mapData);
- }
- }
- }
|