public static LevelStateMachine Instance; //make singleton private void Awake() //set singleton and grab the UI Animator { if (Instance == null) { Instance = this; } }
public void Initialize(LevelInfo levelInfo, int index, SecurityElement xml) { this.m_xml = xml; this.index = index; this.m_levelInfo = levelInfo; playerPoints = new List <LevelPoint>(); monsterPoints = new List <LevelPoint>(); m_heroInAreaState = LevelStateMachine.Exit; Transform root = null; foreach (SecurityElement xmlChild in m_xml.Children) { if (xmlChild.Tag == LevelFunctionType.Ground.ToString().ToLower()) { root = CreateRoot(transform, LevelFunctionType.Ground.ToString()); ground = root.gameObject.AddComponent <LevelGround>(); ground.Initialize(this, xmlChild); } else if (xmlChild.Tag == LevelFunctionType.Decoration.ToString().ToLower()) { } else if (xmlChild.Tag == LevelFunctionType.Door.ToString().ToLower()) { root = CreateRoot(transform, LevelFunctionType.Door.ToString()); InitializeDoors(root, xmlChild); } else if (xmlChild.Tag == LevelFunctionType.Trap.ToString().ToLower()) { } else if (xmlChild.Tag == LevelFunctionType.Transfer.ToString().ToLower()) { } else if (xmlChild.Tag == LevelFunctionType.Player.ToString().ToLower()) { playerPoints = GetPoints(xmlChild); } else if (xmlChild.Tag == LevelFunctionType.Monster.ToString().ToLower()) { monsterPoints = GetPoints(xmlChild); } } }
// <summary> /// 保持在区域 /// </summary> public void OnStayArea() { m_heroInAreaState = LevelStateMachine.Stay; m_levelInfo.OnStayArea(this); }
// <summary> /// 离开区域 /// </summary> public void OnExitArea() { m_heroInAreaState = LevelStateMachine.Exit; m_levelInfo.OnExitArea(this); }
// <summary> /// 进入区域 /// </summary> public void OnEnterArea() { m_heroInAreaState = LevelStateMachine.Enter; m_levelInfo.OnEnterArea(this); }