public override void OnInspectorGUI() { base.OnInspectorGUI(); ArenaMenu ui = target as ArenaMenu; if (Arena.self == null) { Arena.self = FindObjectOfType <Arena>(); Arena.menu = ui; } if (Hint.self == null) { Hint.self = FindObjectOfType <Hint>(); } if (Setting.self == null) { Setting.self = FindObjectOfType <Setting>(); } unitCount = EditorGUILayout.IntSlider("人數", unitCount, Arena.minUnit, Arena.maxUnit); if (GUILayout.Button("重置")) { ui.ClearMain(); } if (GUILayout.Button("隨機生成")) { Arena.RandomRule(); unitCount = Arena.schedule.units.Count; } if (GUILayout.Button("固定生成")) { Arena.RandomRule(unitCount); } if (GUILayout.Button("下一輪")) { Arena.ContestComplete(); } }
void Selecting() { highlight = null; bool onPlayer = false; bool hasPlayer = Unit.player != null; if (Mouse.Hit(out RaycastHit hit, LayerMask.GetMask("Unit"))) { highlight = hit.transform.GetComponent <Unit>(); if (hasPlayer) { onPlayer = playerTeam.memebers.Contains(highlight); } } bool showInfo = Input.GetKey(KeyCode.LeftAlt); bool action = Input.GetKeyDown(KeyCode.Space); bool selectPlayer = Mouse.LeftDown && onPlayer; foreach (Unit unit in Unit.All) { if (action) { unit.Display(Unit.Highlight.Nothing); } else if (unit == highlight) { Unit.Highlight state = Unit.Highlight.Attack | Unit.Highlight.Outline | Unit.Highlight.Info; if (onPlayer) { state |= Unit.Highlight.Moving; } unit.Display(state); } else { Unit.Highlight state = Unit.Highlight.Nothing; if (showInfo) { state |= Unit.Highlight.Info | Unit.Highlight.Attack; } unit.Display(state); } } Hint.self.space.SetActive(!selectPlayer && !action); Hint.self.alt.SetActive(!showInfo && !action); Hint.self.control.SetActive(onPlayer && !selectPlayer && !action); Hint.self.shift.SetActive(false); Hint.self.ctrl.SetActive(selectPlayer && !action); Hint.self.right.SetActive(selectPlayer && !action); Hint.self.confirm.SetActive(selectPlayer && !action); if (selectPlayer) { selected = highlight as Player; selected.ControlStart(); stateUpdate = Control; } else if (action) { stateUpdate = null; Team.NonUser.NpcDecision(); if (hasPlayer) { playerTeam.memebers.ForEach(x => (x as Player).StatusReset()); } Unit.Action(() => { Unit.Alive.RemoveAll(x => x.isDie); Team.All.RemoveAll(x => x.memebers.Count == 0); Team.NonUser.RemoveAll(x => x.memebers.Count == 0); if (Team.All.Count == 1 && !testing) { stateUpdate = null; DelayEvent.Create(2f, () => { Arena.ContestComplete(Team.All.First()); Team.All.Clear(); Team.NonUser.Clear(); Unit.All.Clear(); Unit.Alive.Clear(); }); } else { Team.All.ForEach(x => x.Update()); stateUpdate = Selecting; } }); } }