public override void UpdateAttack(RobotControls controls) { if (_canShoot) { controls.attack(_ShootVector); _canShoot = false; } }
public void TragectoryPrediction(RobotControls controls, SubjectiveRobot?target) { if (target != null && target.Value.isSeen) { float tTimeElapsed = 0; float pSpeed = 10; float tSpeed = 0; float pRatio = 0; float tRatio = 0; float tPosX = 0; Vector3 tPosA = Vector3.zero; Vector3 tPosB = Vector3.zero; Vector3 tPos = Vector3.zero; Vector3 tDistanceTraveled = Vector3.zero; Vector3 tmDistance = Vector3.zero; if (controls.reload <= .5) { if (tTimeElapsed == 0) { tPosA = target.Value.currentPosition; Debug.Log("tPosA: " + tPosA); tTimeElapsed += Time.deltaTime; } else if (tTimeElapsed > 0 && tTimeElapsed < .5) { tTimeElapsed += Time.deltaTime; Debug.Log("tTimeElapsed: " + tTimeElapsed); } else if (tTimeElapsed >= .5) { tTimeElapsed = 0; tPosB = target.Value.currentPosition; Debug.Log("tPosB: " + tPosB); tDistanceTraveled = tPosB - tPosA; Debug.Log("tDistanceTraveled: " + tDistanceTraveled); tmDistance = tPosB - controls.myself.currentPosition; tSpeed = tDistanceTraveled.magnitude / tTimeElapsed; pRatio = pSpeed / tSpeed; Debug.Log("tSpeed: " + tSpeed); tRatio = tSpeed / pSpeed; Debug.Log("pSpeed: " + pSpeed); tPosX = (-pRatio + Mathf.Sqrt(pRatio * pRatio - 4 * tRatio * tmDistance.magnitude)) / 2 * tRatio; Debug.Log("tPosX: " + tPosX); tPos = new Vector3(Mathf.Abs(tPosX), 2 * controls.myself.currentPosition.y, Mathf.Abs(tPosX * pRatio)); } Debug.Log("tPos: " + tPos); // controls.attack(tPos); controls.attack(target.Value.currentPosition); } } }
public override void UpdateAttack(RobotControls controls) { if (_noClosestEnemy == false) { Cooldowntime -= Time.deltaTime; if (Cooldowntime > Cooldown) { return; } var EnemyDistance = _closestEnemy.currentPosition - controls.myself.currentPosition; if (EnemyDistance.magnitude > 5) { return; } controls.attack(_closestEnemy.currentPosition); Cooldowntime = 0.5f; } else { return; } }
void Attack(SubjectiveRobot target, RobotControls controls) { controls.attack(target.currentPosition); }