private void DoRotate() { float rot = rotateCurve.Evaluate(activateTime / rotateTime); transform.eulerAngles = new Vector3(0, 0, rot + initRotation); if (activateTime > rotateTime) { strikeBeginPos = subSetTrans.position; BattleObjectManager battleManager = BattleStageManager.Instance.GetBattleManager(); List <BattleObject> enemyList = battleManager.GetObjectList(BattleObjectType.Enemy); int enemyCount = enemyList != null ? enemyList.Count : 0; if (enemyCount > 0) { int randIndex = BattleStageManager.Instance.GetRandom(0, enemyCount); strikeEndPos = enemyList[randIndex].transform.position; } else { Vector3 strikeDir = (strikeBeginPos - playerTrans.position).normalized; if (strikeDir.x != 0 && Mathf.Abs(strikeDir.y / strikeDir.x) < 0.75f) { float deltaX = strikeDir.x > 0 ? 320f - strikeBeginPos.x : 320f + strikeBeginPos.x; strikeDir *= deltaX / Mathf.Abs(strikeDir.x); strikeEndPos = strikeBeginPos + strikeDir; } else { float deltaY = strikeDir.y > 0 ? 240f - strikeBeginPos.y : 240f + strikeBeginPos.y; strikeDir *= deltaY / Mathf.Abs(strikeDir.y); strikeEndPos = strikeBeginPos + strikeDir; } } } }
void Awake() { Instance = this; resourceManager = new GameResourceManager(); resourceManager.Init(); battleManager = new BattleObjectManager(); playerManager = new PlayerStateManager(); }
private void ProcessTracing() { BattleObjectManager battleManager = BattleStageManager.Instance.GetBattleManager(); List <BattleObject> enemyList = battleManager.GetObjectList(BattleObjectType.Enemy); BattleObject tracingEnemy = null; Vector3 disVec = new Vector3(); if (enemyList != null) { float lastDisSq = 0; for (int i = enemyList.Count - 1; i >= 0; --i) { BattleObject enemy = enemyList[i]; disVec = enemy.transform.position - transform.position; if (tracingEnemy == null || lastDisSq > disVec.sqrMagnitude) { tracingEnemy = enemy; lastDisSq = disVec.sqrMagnitude; } } } if (tracingEnemy != null) { disVec = tracingEnemy.transform.position - transform.position; disVec.Normalize(); transform.right = Vector3.RotateTowards(transform.right, disVec, radSpeed, 0f); if (Vector3.Dot(transform.right, disVec) < accelCos) { if (curSpeed > minSpeed) { curSpeed -= speedDelta * Time.timeScale; if (curSpeed < minSpeed) { curSpeed = minSpeed; } } return; } } if (curSpeed < maxSpeed) { curSpeed += speedDelta * Time.timeScale; if (curSpeed > maxSpeed) { curSpeed = maxSpeed; } } }