void OnCollisionExit2D(Collision2D other) { if (_needCheck) { BattleBall targetBall = other.gameObject.GetComponent <BattleBall> (); if (targetBall == null) { return; } BattleHeroModel target = targetBall.getBattleModel(); if (_model.isMonster() != target.isMonster()) { target.attacked(_model); } } }
private void _atk(Vector3 upPoint) { if (_canMove == false) { return; } _canMove = false; _needCheck = true; BattleHeroModel model = _model; bool isMonster = model.isMonster(); SolaEngine engine = SolaEngine.getInstance(); BattleMgr bMgr = (BattleMgr)engine.getMgr(typeof(BattleMgr)); List <BattleHeroModel> monsters = bMgr.getMonsters(); foreach (BattleHeroModel monster in monsters) { monster.setPushable(isMonster); } Dictionary <int, BattleHeroModel> partners = bMgr.getPartners(); foreach (BattleHeroModel parnter in partners.Values) { parnter.setPushable(!isMonster); } // selectedImg.gameObject.SetActive (false); float xF = -upPoint.x; float yF = -upPoint.y; float forces = Mathf.Sqrt(xF * xF + yF * yF); float multipleX = xF / forces; float multipleY = yF / forces; float maxF = 3f; if (forces > maxF) { forces = maxF; xF = multipleX * forces; yF = multipleY * forces; } rBody.AddForce(new Vector2(xF * 1000, yF * 1000)); }
private void _nextAction(BattleHeroModel moveEndModel) { SolaEngine engine = SolaEngine.getInstance(); BattleMgr bMgr = (BattleMgr)engine.getMgr(typeof(BattleMgr)); if (bMgr.getMonsters().Count == 0) { bool isWin = bMgr.nextRound(); if (isWin == true) { resultDialog.gameObject.SetActive(true); resultDialog.updateView(); } return; } if (bMgr.isWin() == false && bMgr.getPartners().Count == 0) { resultDialog.gameObject.SetActive(true); resultDialog.updateView(); return; } if (moveEndModel != null) { bMgr.applyAction(moveEndModel); } else { bMgr.resetAction(); } List <BattleHeroModel> actionSeq = bMgr.getActionSeq(); BattleHeroModel actionModel = actionSeq [0]; actionModel.setAction(true); for (int i = 0; i < actionSeq.Count; i++) { BattleHeroModel model = actionSeq[i]; GameObject container = actionHeadContainers[i]; Transform containerTranform = container.transform; foreach (Transform child in containerTranform) { child.gameObject.SetActive(false); Destroy(child.gameObject); } BattleActionHead head = Instantiate(actionHeadItem) as BattleActionHead; head.setModel(model); head.transform.SetParent(containerTranform); head.transform.localScale = new Vector3(1, 1, 1); head.transform.localPosition = new Vector3(0, 0, 0); head.transform.localEulerAngles = new Vector3(0, 0, 0); } if (actionModel.isMonster()) { // Debug.Log("actionModel.autoAtk();"); actionModel.autoAtk(); } }