private void _createHeroBall(BattleHeroModel model) { BattleBall monsterBall = Instantiate(ballItem) as BattleBall; monsterBall.setBattleModel(model); monsterBall.transform.SetParent(ballContainer); monsterBall.transform.localScale = new Vector3(100, 100, 1); Vector3 point = model.getPos(); monsterBall.transform.localPosition = point; monsterBall.gameObject.SetActive(true); model.setAction(false); model.MOVE_END += _nextAction; }
private void _autoAtk(BattleHeroModel model) { SolaEngine engine = SolaEngine.getInstance(); BattleMgr bMgr = (BattleMgr)engine.getMgr(typeof(BattleMgr)); List <BattleHeroModel> targets = new List <BattleHeroModel> (); bool isMonster = _model.isMonster(); if (!isMonster) { targets = bMgr.getMonsters(); } else { foreach (BattleHeroModel pModel in bMgr.getPartners().Values) { targets.Add(pModel); } } BattleHeroModel target = null; float minDistance = 0; Vector3 pos = transform.localPosition; foreach (BattleHeroModel tModel in targets) { Vector3 tPos = tModel.getPos(); float distance = Vector3.Distance(pos, tPos); if (target == null || distance < minDistance) { minDistance = distance; target = tModel; } } pos = (pos - target.getPos()); _atk(pos); }