void OnFightingAct() { if (anim.IsPlaying()) { if (anim.GetCurFrameIndex() == 2 && !hadCheckAttack) { hadCheckAttack = true; if (soliderType == 3 || soliderType == 4 || soliderType == 5) { WarSceneController.Direction dir = WarSceneController.Direction.Left; if (transform.localScale.x < 0) { dir = WarSceneController.Direction.Right; } rwCrt.SetRangedWeapon(side, dir, soliderType, transform.localPosition); } else { if (transform.localScale.x < 0) { if (warCtrl.OnSoliderHitChecking(side, soliderType, WarSceneController.Direction.Right, hitDistance1, locationX, locationY)) { targetEnemy = null; } } else { if (warCtrl.OnSoliderHitChecking(side, soliderType, WarSceneController.Direction.Left, hitDistance1, locationX, locationY)) { targetEnemy = null; } } } } } else { hadCheckAttack = false; isFighting = false; timeCoolDownTick = timeCoolDown; anim.Play("Idle"); } }
// Update is called once per frame void Update() { if (WarSceneController.isGamePause) { return; } if (WarSceneController.state == WarSceneController.State.Beginning || WarSceneController.state == WarSceneController.State.Menu || WarSceneController.state == WarSceneController.State.End || WarSceneController.state == WarSceneController.State.Assault) { return; } if (state == 0) { Vector3 pos = transform.localPosition; pos.x += speed * Time.deltaTime; if (pos.x >= WarSceneController.manPosMaxX - 100 || pos.x <= -WarSceneController.manPosMaxX + 100 || Mathf.Abs(pos.x - orgPosX) > 1000) { Destroy(gameObject); return; } transform.localPosition = pos; int locationX = warCtrl.GetLocationPositionX(transform.localPosition.x); int locationY = warCtrl.GetLocationPositionY(transform.localPosition.y); // int locationX = (int)((pos.x + WarSceneController.manPosMaxX) / WarSceneController.locationStepX); // int locationY = (int)((pos.y + WarSceneController.manPosMaxY) / WarSceneController.locationStepY); if (warCtrl.GetLocationIsEnemy(side, locationX, locationY)) { WarSceneController.Direction dir = WarSceneController.Direction.Left; if (speed > 0) { dir = WarSceneController.Direction.Right; } if (warCtrl.OnSoliderHitChecking(side, type, dir, 1, locationX, locationY)) { Destroy(gameObject); } else { state = 1; anim.PlayDefault(); } } } else { timeTick += Time.deltaTime; transform.localPosition = new Vector3(transform.localPosition.x - speed / 5 * Time.deltaTime, transform.localPosition.y + upspeed * Time.deltaTime, transform.localPosition.z); if (timeTick < 0.5f) { sprite.color = new Color(1, 1, 1, 1 - 2 * timeTick); } else { Destroy(gameObject); } } }