public void RemoveProgressBarListener(string key) { if (ProgressMap.ContainsKey(key)) { ProgressMap.Remove(key); } }
//reset and clear our progress map before the game starts void Awake() { //clear dictionaries with enemy IDs objDic.Clear(); //set this script instance for coroutine access instance = this; }
//initialize waypoint positions and progress map access on every spawn IEnumerator OnSpawn() { //wait one frame so Start() gets called before OnSpawn() on a new instantiation yield return(new WaitForEndOfFrame()); //get Vector3 array with waypoint positions waypoints = pathContainer.waypoints; //get waypoint array of Vector3 InitWaypoints(); //start movement StartMove(); //add this enemy to ProgressMap to track path progress if (pMapProperties.enabled) { //add to progress map - identify by gameobject ID //all further path progress calculation happens in ProgressCalc() and ProgressMap.cs ProgressMap.AddToMap(pMapProperties.prefab, pMapProperties.myID); //start calculating our path progress a few times per second //(more accurate and less overhead than calling it in an update function) InvokeRepeating("ProgressCalc", 0.5f, pMapProperties.updateInterval); } }
public async Task <ProgressMap> Get(ProgressMap map) { if (map.Id == null) { throw new ArgumentException("tried to fetch progress map but wasnt given an id"); } return(await Get(map.Id ?? 0)); }
public async Task AddsToDb() { User user = new User("Lucca", "123456", "*****@*****.**"); await DAO.User.Add(user); ProgressMap map = await DAO.ProgressMap.Get(user); Assert.NotNull(map.Id); }
//Path Distance/Progress Calculation and ProgressMap access void ProgressCalc() { //calculate current progress which consists of the time we walked already, //and the total time of the tween float progress = tween.fullElapsed / tween.fullDuration; //let our ProgressMap display this object: //pass in the gameobject ID of this object to identify it and its total path progress ProgressMap.CalcInMap(pMapProperties.myID, progress); }
public async Task <ProgressMap> Get(User user) { if (user.Id == null) { throw new ArgumentException("tried to fetch progress map of user " + user.Username + ", but they dont have an id"); } ProgressMap progessMap = await GetByUserId(user.Id ?? 0); user.ProgressMap = progessMap; return(progessMap); }
public async Task Update(ProgressMap map) { if (map.Id == null) { throw new ArgumentException("tried to update progress map but wasnt given an id"); } await Update((int)map.Id, map.Additions, map.Subtractions); map.Additions.Clear(); map.Subtractions.Clear(); }
private IProgress <float> GetProgress(string assetBundleName) { if (!ProgressMap.ContainsKey(assetBundleName)) { ProgressMap[assetBundleName] = new Progress <float>(progress => { ProgressedValueMap[assetBundleName] = progress; ProgressSummary.Value = ProgressedValueMap.Values.Sum(); }); } return(ProgressMap[assetBundleName]); }
public async Task <ActionResult <bool> > Update([FromBody] UpdateArgument argument) { User user = Request.GetUser(); ProgressMap map = await ProgressMapRepo.Get(user); if (argument.id != map.Id) { return(Unauthorized()); } await ProgressMapRepo.Update(argument.id, argument.additions, argument.subtractions); return(Ok(true)); }
public async Task CanMutateLocations() { User user = new User("Lucca", "123456", "*****@*****.**"); await DAO.User.Add(user); ProgressMap map = await DAO.ProgressMap.Get(user); int locationId = (int)(await DAO.Geography.GetCountryByAlpha2("DK")).Id; map.Locations.Add(locationId); await DAO.ProgressMap.Update(map); map = await DAO.ProgressMap.Get(map); Assert.Contains(locationId, map.Locations.ToList()); map.Locations.Clear(); await DAO.ProgressMap.Update(map); map = await DAO.ProgressMap.Get(map); Assert.IsEmpty(map.Locations); }
public void UpdateProgressBar(string key, long progress) { ProgressMap[key](progress); }
//before this enemy gets despawned (on death or in case it reached its destination), //say to all towers that this enemy died IEnumerator RemoveEnemy() { //remove ourselves from each tower's inRange list for (int i = 0; i < nearTowers.Count; i++) { nearTowers[i].inRange.Remove(gameObject); } //clear our inRange list nearTowers.Clear(); //remove possible 'damage over time' particle effects (see DamageOverTime()) foreach (Transform child in transform) { if (child.name.Contains("(Clone)")) { PoolManager.Pools["Particles"].Despawn(child.gameObject); } } //if this object used the Progress Map (in TweenMove.cs) if (myMove.pMapProperties.enabled) { //stop calculating our ProgressMap path progress myMove.CancelInvoke("ProgressCalc"); //call method to remove it from the map ProgressMap.RemoveFromMap(myMove.pMapProperties.myID); } //this enemy died, handle death stuff if (health <= 0) { //if set, instantiate deathEffect at current position if (deathEffect) { PoolManager.Pools["Particles"].Spawn(deathEffect, transform.position, Quaternion.identity); } //play sound on death via AudioManager AudioManager.Play(deathSound, transform.position); //handle death animation //wait defined death animation delay if set if (dieAnim) { anim.Play(dieAnim.name); yield return(new WaitForSeconds(dieAnim.length)); } } //the enemy didn't die, and escaped instead else { if (successAnim) { anim.Play(successAnim.name); yield return(new WaitForSeconds(successAnim.length)); } } //reset all initialized variables for later reuse //set start health and shield value back to maximum health/absorb health = maxhealth; shield.value = shield.maxValue; //reset 3D bars to indicate 100% health/shield points if (healthbar) { healthbar.value = 1; } if (shield.bar) { shield.bar.value = 1; } //despawn/disable us PoolManager.Pools["Enemies"].Despawn(gameObject); }