void HandleClick() { if (GvrControllerInput.ClickButtonDown) { playerAttack.Attack(true); } if (GvrControllerInput.ClickButton) { playerAttack.Attack(false); } }
/// <summary> /// Recieves an attack grid. /// NOTE: AttackGrid must be [7,7] /// </summary> /// <param name="attackGrid"></param> public void Attack(float[,] attackGrid, float damage) { if (BeatSpawner.canBePressed == true && beatHit == false) { beatHit = true; unitAttack.Attack(attackGrid, lastDirection, damage); } }
IEnumerator AIUnitAttack(Unit unit) { while (isInAction) { yield return(null); } isInAction = true; //simulate thinking yield return(new WaitForSeconds(1f)); UnitAttack dattack = unit.GetComponent <UnitAttack>(); GameObject unitPos = BoardManager.Instance.GetPositionOfUnit(unit); List <GameObject> attackFields = dattack.GetAttackTiles(unitPos, true, BoardManager.TileType.Attack) .OrderBy(i => Vector3.Distance(i.transform.position, unitPos.transform.position)).ToList(); while (GameController.Instance.State == GameController.GameState.PerformingAction) { yield return(null); } if (attackFields.Count > 0) { //simulate thinking yield return(new WaitForSeconds(1f)); Unit closestEnemy = Unit.UnitsList.Where(i => BoardManager.Instance.GetPositionOfUnit(i) == attackFields[0]).ToList()[0]; if (unit.CanAttack) { dattack.Attack(closestEnemy); } } unit.CanAttack = false; //simulate thinking yield return(new WaitForSeconds(0.5f)); isInAction = false; }
public void AttackEnemy(UnitControl target) { unitAttack.ShouldBeAiming = true; Vector3 targetPosition = target.TargetPos; Vector3 aimDirection = (targetPosition - unitAttack.FiringPosition).normalized; Quaternion burstRotation = Quaternion.AngleAxis(burstIncrementAngle, burstOffsetAxis); unitAttack.AimingDirection = burstRotation * aimDirection; Debug.DrawRay(unitAttack.FiringPosition, unitAttack.AimingDirection * 10, Color.red); Debug.DrawRay(unitAttack.FiringPosition, unitAttack.FiringDirection * 10, Color.green); float targetOffset = Vector3.Dot(unitAttack.FiringDirection, unitAttack.AimingDirection); if (ReadyToFire && targetOffset > 0.95f) { if (unitAttack.Attack(true)) { if (burstCount == burstLength) { burstOffsetAngle = Vector3.Angle( unitAttack.AimingDirection, unitAttack.FiringDirection ); burstOffsetAxis = Vector3.Cross( unitAttack.FiringDirection, unitAttack.AimingDirection ); } burstCount--; burstIncrementAngle = (((float)burstCount / (float)burstLength) * (burstOffsetAngle * 2)); if (burstCount <= 0) { if (hitShots == 0) { Debug.Log("Didnt hit anything!"); } burstCount = burstLength; firingCoolDown = firingCoolDownTime + Random.Range(-0.5f, 0.5f); hitShots = 0; } } } }
public bool Attack(SquadControl targetSquad, bool usePrimary) { isAttacking = true; return(unitAttack.Attack(targetSquad, usePrimary)); }
public void Attack(float[,] attackGrid, float damage) { unitAttack.Attack(attackGrid, lastDirection, damage); }