// Update is called once per frame void Update() { frame.transform.localPosition = new Vector3(WarSceneController.cameraPosCur.x / WarSceneController.cameraPosMaxX * frameMaxX, WarSceneController.cameraPosCur.y / WarSceneController.cameraPosMaxY * frameMaxY, frame.transform.localPosition.z); if (WarSceneController.state != WarSceneController.State.Running) { return; } if (Input.GetMouseButtonDown(0)) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (mousePos.x >= transform.position.x - size.x / 2 && mousePos.x <= transform.position.x + size.x / 2 && mousePos.y >= transform.position.y - size.y / 2 && mousePos.y <= transform.position.y + size.y / 2) { isMouseDown = true; float offX = mousePos.x - transform.position.x; offX = Mathf.Clamp(offX, -frameMaxX, frameMaxX); float offY = mousePos.y - transform.position.y; offY = Mathf.Clamp(offY, -frameMaxY, frameMaxY); Vector3 pos = new Vector3(offX / frameMaxX * WarSceneController.cameraPosMaxX, offY / frameMaxY * WarSceneController.cameraPosMaxY, 0); wsCtrl.SetCameraPosition(pos); } else { isMouseDown = false; } } else if (isMouseDown && Input.GetMouseButton(0)) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (mousePos.x >= transform.position.x - size.x / 2 && mousePos.x <= transform.position.x + size.x / 2 && mousePos.y >= transform.position.y - size.y / 2 && mousePos.y <= transform.position.y + size.y / 2) { float offX = mousePos.x - transform.position.x; offX = Mathf.Clamp(offX, -frameMaxX, frameMaxX); float offY = mousePos.y - transform.position.y; offY = Mathf.Clamp(offY, -frameMaxY, frameMaxY); Vector3 pos = new Vector3(offX / frameMaxX * WarSceneController.cameraPosMaxX, offY / frameMaxY * WarSceneController.cameraPosMaxY, 0); wsCtrl.SetCameraPosition(pos); } } }
// Update is called once per frame void Update() { if (state == 1) { Vector3 pos = arrow.transform.localPosition; pos.x += speed * Time.deltaTime; arrow.transform.localPosition = pos; if ((side == WarSceneController.WhichSide.Left && pos.x > enemyGeneral.transform.localPosition.x) || (side == WarSceneController.WhichSide.Right && pos.x < enemyGeneral.transform.localPosition.x)) { state = 2; Invoke("WaitForMagicOver", 1); Rect region = new Rect(); if (side == WarSceneController.WhichSide.Left) { region.x = pos.x - 20; } else { region.x = pos.x - 180; } region.y = -15; region.width = 200; region.height = 30; warCtrl.OnMagicHitChecking(side, MagicController.Instance.GetMagicAttack(), region, false); for (int i = 0; i < 5; i++) { GameObject go = (GameObject)Instantiate(Resources.Load(explodeName)); go.transform.parent = transform; pos.x += Random.Range(-20, 20); pos.z += Random.Range(-20, 20); go.transform.localPosition = pos; } } else { warCtrl.SetCameraPosition(new Vector3(pos.x, -30, 0)); Rect region = new Rect(); region.x = pos.x; region.y = -15; region.width = 20; region.height = 30; warCtrl.OnMagicHitChecking(side, 0, region, false); } } else if (state == 2) { Vector3 pos = arrow.transform.localPosition; pos.x += speed * Time.deltaTime; arrow.transform.localPosition = pos; } }
// Update is called once per frame void Update() { if (state == 1) { Vector3 pos = arrow.transform.localPosition; pos.x += speed * Time.deltaTime; arrow.transform.localPosition = pos; if ((side == WarSceneController.WhichSide.Left && pos.x > enemyGeneral.transform.localPosition.x) || (side == WarSceneController.WhichSide.Right && pos.x < enemyGeneral.transform.localPosition.x)) { state = 0; Destroy(arrow); StartCoroutine(ShowArrowExplode()); enemyGeneral.OnDamage(MagicController.Instance.GetMagicAttack(), -1, false); } else { warCtrl.SetCameraPosition(new Vector3(pos.x, -30, 0)); } } }
// Update is called once per frame void Update() { float deltaPos = speed * Time.deltaTime; if (state == 1) { cameraPos = new Vector3(cameraPos.x + deltaPos, cameraPos.y, 0); for (int i = 0; i < listMoon.Count; i++) { Vector3 pos = listMoon[i].transform.localPosition; pos.x += deltaPos; listMoon[i].transform.localPosition = pos; } if ((side == WarSceneController.WhichSide.Left && cameraPos.x > enemyGeneral.transform.localPosition.x) || (side == WarSceneController.WhichSide.Right && cameraPos.x < enemyGeneral.transform.localPosition.x)) { state = 2; Invoke("WaitForMagicOver", 1); enemyGeneral.OnDamage(MagicController.Instance.GetMagicAttack(), -1, false); listMoon[0].SetActive(false); for (int i = 1; i < listMoon.Count; i++) { Rect region = new Rect(); if (side == WarSceneController.WhichSide.Left) { region.x = listMoon[i].transform.localPosition.x - 20; } else { region.x = listMoon[i].transform.localPosition.x - 180; } region.y = listMoon[i].transform.localPosition.y - 15; region.width = 200; region.height = 30; warCtrl.OnMagicHitChecking(side, 0, region, false); } StartCoroutine(ShowArrowExplode()); } else { warCtrl.SetCameraPosition(cameraPos); for (int i = 0; i < listMoon.Count; i++) { Rect region = new Rect(); region.x = listMoon[i].transform.localPosition.x; region.y = listMoon[i].transform.localPosition.y - 15; region.width = 20; region.height = 30; warCtrl.OnMagicHitChecking(side, 0, region, false); } } } else if (state == 2) { for (int i = 0; i < listMoon.Count; i++) { Vector3 pos = listMoon[i].transform.localPosition; pos.x += deltaPos; listMoon[i].transform.localPosition = pos; } } }
// Update is called once per frame void Update() { float deltaPos = speed * Time.deltaTime; if (state == 1) { for (int i = 0; i < listMan.Count; i++) { if (!listMan[i].activeSelf) { break; } Vector3 pos = listMan[i].transform.localPosition; pos.x += deltaPos; listMan[i].transform.localPosition = pos; } cameraPos = new Vector3(listMan[4].transform.localPosition.x, -30, 0); if ((side == WarSceneController.WhichSide.Left && cameraPos.x > enemyGeneral.transform.localPosition.x) || (side == WarSceneController.WhichSide.Right && cameraPos.x < enemyGeneral.transform.localPosition.x)) { state = 2; Invoke("WaitForMagicOver", 1); listMan[0].SetActive(false); enemyGeneral.OnDamage(MagicManager.Instance.GetMagicDataInfo(40).ATTACK, -1, false); Rect region = new Rect(); if (side == WarSceneController.WhichSide.Left) { region.x = listMan[0].transform.localPosition.x - 20; } else { region.x = listMan[0].transform.localPosition.x - 180; } region.y = listMan[0].transform.localPosition.y - 20; region.width = 200; region.height = 40; warCtrl.OnMagicHitChecking(side, 0, region, false); StartCoroutine(ShowArrowExplode()); } else { warCtrl.SetCameraPosition(cameraPos); Rect region = new Rect(); region.x = listMan[0].transform.localPosition.x; region.y = listMan[0].transform.localPosition.y - 20; region.width = 20; region.height = 40; warCtrl.OnMagicHitChecking(side, 0, region, false); } } else if (state == 2) { for (int i = 0; i < listMan.Count; i++) { Vector3 pos = listMan[i].transform.localPosition; pos.x += deltaPos; listMan[i].transform.localPosition = pos; } } }