private void SpawnBullet(Transform gunPos) { // Get a laser from the pool. // GameObject bullet_obj = _bulletPool.GetGameObjectFromPool(); GameObject bullet_obj = Instantiate(bulletPrefab); // Set it's position and rotation based on the gun positon. bullet_obj.transform.position = gunPos.position; bullet_obj.transform.rotation = gunPos.rotation; // Find the FlyerLaser component of the laser instance. Bullet bullet = bullet_obj.GetComponentInChildren <Bullet>(); CheckTarget checkTarget = bullet_obj.GetComponent <CheckTarget>(); checkTarget.hitTag = _enemyTag; //checkTarget.Restart(); bullet.Restart(); // Set it's object pool so it knows where to return to. /* bullet.ObjectPool = _bulletPool; * // bullet.hitTag = _enemyTag; * // Restart the laser. * bullet.Restart();*/ // Play laser audio. // m_LaserAudio.Play(); }
public void Check_EmptySequence_GetEmptySequence() { var checkTarget = new CheckTarget { Target = 63, Sequence = new List <int>() }; var sequence = checkTargetService.CheckAsync(checkTarget).Result; Assert.IsEmpty(sequence); }
public async Task PingResultTest() { IPingable target = new CheckTarget(1, "www.baidu.com", "80", "百度"); Assert.NotNull(target); string result = await CheckTargetService.PingRemoteTargetAsync(target, 1000, 4); Assert.NotNull(result); Assert.IsNotEmpty(result); // Console.WriteLine(result); }
public static int[] LimitPackageVersion(CheckTarget target) { var checkItems = CheckItems; foreach (var item in checkItems) { if (item.checkTarget == target && item.referenceSrc == ReferenceSrc.PackageVersion) { return(item.array); } } return(new int[] { 0, 0, 0, 0 }); }
public void Check_ZeroTargetNonEmptySequence_GetEmptySequence() { var checkTarget = new CheckTarget { Target = 0, Sequence = new List <int> { 1, 10, 3, 7 } }; var sequence = checkTargetService.CheckAsync(checkTarget).Result; Assert.IsEmpty(sequence); }
public void Check_InvalidSequenceAndTarget_GetEmptySequence() { var checkTarget = new CheckTarget { Target = 101, Sequence = new List <int> { 3, 15, 10, 20 } }; var sequence = checkTargetService.CheckAsync(checkTarget).Result; Assert.IsEmpty(sequence); }
public void Check_ValidSequenceAndTarget_GetNonEmptySequence() { var checkTarget = new CheckTarget { Target = 47, Sequence = new List <int> { 5, 20, 2, 1 } }; var sequence = checkTargetService.CheckAsync(checkTarget).Result; Assert.IsNotEmpty(sequence); }
public async Task SaveCheckTargetAsync(CheckTarget checkTarget) { if (!File.Exists(DbFile)) { await this.CreateDatabaseAsync(); } if (checkTarget == null) { throw new ArgumentNullException(nameof(checkTarget)); } using (var connection = this.GetCheckTargetDbConnection()) { checkTarget.Creation = DateTime.Now; await connection.ExecuteAsync(InsertSql, checkTarget); } }
public async Task <IEnumerable <int> > CheckAsync(CheckTarget checkTarget, bool skipLog = false) { if (checkTarget == null) { throw new ArgumentNullException(nameof(checkTarget)); } if (!skipLog) { await this.checkTargetRepository.SaveCheckTargetAsync(checkTarget); } if (checkTarget.Sequence == null || !checkTarget.Sequence.Any() || checkTarget.Target == 0) { return(new List <int>()); } var quotients = new List <int>(); var sequence = checkTarget.Sequence.OrderByDescending(it => it); foreach (var item in sequence) { quotients.Add(checkTarget.Target / item); } for (var current = 0; current < sequence.Count(); current++) { if (quotients.ElementAt(current) <= 0) { continue; } var target = checkTarget.Target; while (quotients.ElementAt(current) > 0) { var currentValue = sequence.ElementAt(current) * quotients.ElementAt(current); target -= currentValue; if (target == 0) { return(Enumerable .Range(0, quotients.ElementAt(current)) .Select(el => sequence.ElementAt(current))); } var newSquence = new List <int>(); for (var i = current + 1; i < sequence.Count(); i++) { newSquence.Add(sequence.ElementAt(i)); } var sequenceToCheck = (await CheckAsync(new CheckTarget { Target = target, Sequence = newSquence }, true)).ToList(); sequenceToCheck.AddRange(Enumerable .Range(0, quotients.ElementAt(current)) .Select(el => sequence.ElementAt(current))); if (sequenceToCheck.Sum() == checkTarget.Target) { return(sequenceToCheck.OrderBy(it => it)); } quotients[current]--; } } return(new List <int>()); }
public static Checker Get(CheckTarget target) { return(new Checker(target, CheckItems)); }
public Checker(CheckTarget checkTarget, List <CheckItem> checkItems) { CheckTarget = checkTarget; CheckItems = checkItems; }