void UpdateDirect() { direcr = Mathf.Sign(TargetManager.PlayerController.transform.position.x - pysicItem.Position.x); cooldownItem = CooldownManager.AddCooldown(1, null, UpdateDirect); }
public void RemoveCooldown(ICooldownItem item) { if (item == null) return; items.Remove(item.Id); lastTickTimes.Remove(item.Id); }
public virtual bool TryUse() { if (currentCooldown != null) { currentCooldown = CooldownService.AddCooldown(activeItemData.cooldown, null, OnCooldownEnd, 0, 0.1f); return false; } return true; }
protected void SpawnUnit() { if (leftSpawn > 0 || IsDefender) { var data = view.data; leftSpawn--; UnitFactory.CreateUnit(view.spawnPoint.position, data.produceUnitType, GetCurrentUnitData().Copy(), IsDefender); spawnUnitsCooldown = CooldownService.AddCooldown(view.data.upgradeData[view.data.level - 1].trainingSpeed, null, SpawnUnit); } }
public void RemoveCooldown(ICooldownItem item) { if (item == null) { return; } items.Remove(item.Id); itemsKey.Remove(item.Id); lastTickTimes.Remove(item.Id); }
void Show(float duration) { if (cooldownShow != null) { CooldownManager.RemoveCooldown(cooldownShow); } view.gameObject.SetActive(true); cooldownShow = CooldownManager.AddCooldown(duration, null, () => { view.gameObject.SetActive(false); cooldownShow = null; }); }
public void Init(float dutarion, float maxColorSize, float gravityY, Vector2 startVelocity) { this.maxColorSize = maxColorSize; var physicItem = MonoBehaviourPhysicItem.GetPhysicItem(); physicItem.SetGravity(new Vector2(0, gravityY)); physicItem.SetPosition(transform.position); physicItem.AddVelocity(-physicItem.velocity); physicItem.AddVelocity(startVelocity); physicItem.IsCollisionTerrain = false; physicItem.IsReactExplosion = false; cooldown = CooldownManager.AddCooldown(dutarion, CooldownUpdate, UnSpawn, 0, Time.fixedDeltaTime); }
private void Heal() { var colls = Physics.OverlapSphere(fontainView.GetPosition(), fontainView.fontainHealRadius); foreach (var collider in colls) { var targetView = collider.GetComponent<ITargetView>(); if (targetView != null) { var targetModel = targetView.GetModel<ITarget>(); if (targetModel.GetTargetBehaviour().IsDefender) { targetModel.GetTargetBehaviour().SetDamage(-fontainView.fontainHealPower); } } } fontainHealCooldown = CooldownService.AddCooldown(0.5f, null, Heal, 0, 0.1f); }
public void Init(Color color, string text) { label.color = color; label.effectColor = Color.black; label.text = text; tweenAlpha.duration = 1; tweenScale.duration = 1; tweenScale.ResetToBeginning(); tweenAlpha.ResetToBeginning(); tweenScale.Play(); tweenAlpha.Play(); cooldown = CooldownManager.AddCooldown(tweenAlpha.duration, null, UnSpawn, 0, Time.fixedDeltaTime); }
public void Init(string name, int count) { Count = count; Name = name; if (CurrentVisible.ContainsKey(name)) { Count += CurrentVisible[name].Count; CurrentVisible[name].ForceUnSpawn(); } foreach (var lbl in CurrentVisible) { if (lbl.Key != name) { if (lbl.Value.transform.position.y - transform.position.y < 25) { lbl.Value.transform.position = lbl.Value.transform.position + Vector3.up * 25; } } } CurrentVisible[name] = this; label.color = Color.white; label.effectColor = Color.black; label.text = string.Format("{0} :({1})", name, Count); tweenAlpha.duration = 2; tweenScale.duration = 2; tweenScale.ResetToBeginning(); tweenAlpha.ResetToBeginning(); tweenScale.Play(); tweenAlpha.Play(); cooldown = CooldownManager.AddCooldown(tweenAlpha.duration, null, UnSpawn, 0, Time.fixedDeltaTime); }
public void Initialize() { BattleManager.SaveCurrentHeroData(fontainView.hero); BattleManager.RegisterFontaion(this); fontainHealCooldown = CooldownService.AddCooldown(0.5f, null, Heal, 0, 0.1f); }
private void AddCooldown(ICooldownItem cooldown) { items.Add(cooldown.Id, cooldown); lastTickTimes[cooldown.Id] = GetTime(); }
public void Update() { var dir = new Vector2(); var pos = pysicItem.Position; switch (State) { case MinerState.idleReturn: if (cooldownIdleReturn == null) { cooldownIdleReturn = CooldownManager.AddCooldown(1, null, () => { CooldownManager.RemoveCooldown(cooldownIdleReturn); cooldownIdleReturn = null; direcr = 1; State = MinerState.runMine; view.StopTruck(); }); } break; case MinerState.idleMine: if (cooldownIdleMine == null) { cooldownIdleMine = CooldownManager.AddCooldown(1, null, () => { direcr = -1; State = MinerState.runReturn; CooldownManager.RemoveCooldown(cooldownIdleMine); cooldownIdleMine = null; view.StopKirka(); view.PlayTruck(); }); view.PlayKirka(); } break; case MinerState.runMine: dir = new Vector2(speed * direcr, 0); pysicItem.AddVelocity(dir); if (pos.x > maxPos.x && direcr != -1) { pysicItem.SetVelocity(new Vector2()); State = MinerState.idleMine; } break; case MinerState.runReturn: dir = new Vector2(speed * direcr, 0); pysicItem.AddVelocity(dir); if (pos.x < minPos.x && direcr != 1) { pysicItem.SetVelocity(new Vector2()); pysicItem.SetPosition(new Vector2(minPos.x, pysicItem.Position.y)); // direcr = 1; speed = UnityEngine.Random.Range(0.1f, 4.5f); State = MinerState.idleReturn; } break; } }
private void AddCooldown(ICooldownItem cooldown) { items.Add(cooldown.Id, cooldown); itemsKey.Add(cooldown.Id); lastTickTimes[cooldown.Id] = GetTime(); }
public void StartSpawn() { leftSpawn = view.data.waveSpanwLimit; spawnUnitsCooldown = CooldownService.AddCooldown(view.data.upgradeData[view.data.level - 1].trainingSpeed, null, SpawnUnit); }
public void OnCooldownEnd() { currentCooldown = null; }
private void OnCooldownEnd() { Cooldown = null; OnEndCooldown.TryCall(); }
public void StartCooldown() { Cooldown = CooldownService.AddCooldown(data.cooldown, null, OnCooldownEnd, 0, 0.1f); OnStartCooldown.TryCall(); }
public void StartHeroRespawn() { heroRespawnCooldown = CooldownService.AddCooldown(GameDataService.GetConfig().heroRespawnTime, null, SpawnHero); }
public override void Start() { idleCooldown = CooldownService.AddCooldown(0.5f, null, Stop, 0, 0.1f); }
private void OnNextRoundStartCountdown(ICooldownItem cooldownItem, int round) { roundCountdownCooldown = cooldownItem; Round = round; IsRoundCountdown = true; cooldownItem.OnEnd += RoundCountdownEnd; cooldownItem.OnTick += OnTick; Timer = Mathf.RoundToInt(roundCountdownCooldown.Duration - roundCountdownCooldown.ElapsedTime); }