private void Update() { if (BattleGlobals.isSelectEnemy) { if (Input.GetMouseButtonDown(1)) { BattleGlobals.isSelectEnemy = false; BattleCamera.SetIsStop(); //active hero ui BattleUI.heroPanel.SetActive(true); } } }
// Update is called once per frame void Update() { if (!BattleGlobals.isStop && !BattleCamera.anim.isPlaying) { BattleGlobals.canEnterNext = true; BattleGlobals.currentObj = null; BattleGlobals.otherObjs.Clear(); //heads move by speed foreach (GameObject head in heads) { string id = head.name; Entity e = BattleFuncs.FindObj(id).GetComponent <Entity>(); //move head.transform.Translate(Vector3.right * e.infos[5]); head.transform.position = new Vector2(Mathf.Clamp( head.transform.position.x, start.position.x, end.position.x), head.transform.position.y); //turn if (Vector2.Distance(head.transform.position, end.position) <= 1) { BattleGlobals.currentObj = null; BattleGlobals.otherObjs.Clear(); BattleGlobals.isStop = true; BattleGlobals.currentObj = BattleFuncs.FindObj(id); if (BattleGlobals.currentObj.tag == "Enemy") { if (true) { BattleGlobals.isNearAttack = true; //近战 } if (BattleGlobals.liveHeroes.Count > 0) { GameObject ranHero = BattleFuncs.FindObj(BattleGlobals.liveHeroes [Random.Range(0, BattleGlobals.liveHeroes.Count)]); BattleGlobals.otherObjs.Clear(); BattleGlobals.otherObjs.Add(ranHero); } } else if (BattleGlobals.currentObj.tag == "Hero") { if (!BattleGlobals.isOver) { BattleCamera.SetIsStop(); //active hero ui heroPanel.SetActive(true); //Bind heroPanelBtns Button atkBtn = UIManager.GetButton("atkBtn"); Button skillBtn = UIManager.GetButton("skillBtn"); Button defBtn = UIManager.GetButton("defBtn"); atkBtn.onClick.AddListener(OnatkBtnClick); skillBtn.onClick.AddListener(OnskillBtnClick); defBtn.onClick.AddListener(OndefBtnClick); } } head.transform.position = start.position; } } if (heroPanel.activeInHierarchy) { BattleGlobals.isStop = true; } } else//停止时获得当前对象 { if (heroPanel != null && heroPanel.activeInHierarchy && !BattleCamera.anim.isPlaying) { foreach (GameObject head in heads) { string id = head.name; if (!id.Contains("m")) { if (Vector2.Distance(head.transform.position, start.position) <= 1) { BattleGlobals.currentObj = null; BattleGlobals.otherObjs.Clear(); BattleGlobals.currentObj = BattleFuncs.FindObj(id); } } else { BattleFuncs.FindObj(id).GetComponent <Animator>().SetBool("run", false); } } } } }