示例#1
0
    void UpdateDirect()
    {
        direcr = Mathf.Sign(TargetManager.PlayerController.transform.position.x - pysicItem.Position.x);


        cooldownItem = CooldownManager.AddCooldown(1, null, UpdateDirect);
    }
示例#2
0
        public void RemoveCooldown(ICooldownItem item) {
            if (item == null)
                return;

            items.Remove(item.Id);
            lastTickTimes.Remove(item.Id);
        }
示例#3
0
 public virtual bool TryUse()
 {
     if (currentCooldown != null)
     {
         currentCooldown = CooldownService.AddCooldown(activeItemData.cooldown, null, OnCooldownEnd, 0, 0.1f);
         return false;
     }
     return true;
 }
示例#4
0
 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);
     }
 }
示例#5
0
    public void RemoveCooldown(ICooldownItem item)
    {
        if (item == null)
        {
            return;
        }

        items.Remove(item.Id);
        itemsKey.Remove(item.Id);
        lastTickTimes.Remove(item.Id);
    }
示例#6
0
 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;
     });
 }
示例#7
0
    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);
    }
示例#8
0
 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);
 }
示例#9
0
    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);
    }
示例#10
0
    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);
    }
示例#11
0
 public void Initialize() {
     BattleManager.SaveCurrentHeroData(fontainView.hero);
     BattleManager.RegisterFontaion(this);
     fontainHealCooldown = CooldownService.AddCooldown(0.5f, null, Heal, 0, 0.1f);
 }
示例#12
0
 private void AddCooldown(ICooldownItem cooldown) {
     items.Add(cooldown.Id, cooldown);
     lastTickTimes[cooldown.Id] = GetTime();
 }
示例#13
0
    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;
        }
    }
示例#14
0
 private void AddCooldown(ICooldownItem cooldown)
 {
     items.Add(cooldown.Id, cooldown);
     itemsKey.Add(cooldown.Id);
     lastTickTimes[cooldown.Id] = GetTime();
 }
示例#15
0
 public void StartSpawn() {
     leftSpawn = view.data.waveSpanwLimit;
     spawnUnitsCooldown = CooldownService.AddCooldown(view.data.upgradeData[view.data.level - 1].trainingSpeed,
         null, SpawnUnit);
 }
示例#16
0
 public void OnCooldownEnd()
 {
     currentCooldown = null;
 }
示例#17
0
 private void OnCooldownEnd() {
     Cooldown = null;
     OnEndCooldown.TryCall();
 }
示例#18
0
 public void StartCooldown() {
     Cooldown = CooldownService.AddCooldown(data.cooldown, null, OnCooldownEnd, 0, 0.1f);
     OnStartCooldown.TryCall();
 }
示例#19
0
 public void StartHeroRespawn() {
     heroRespawnCooldown = CooldownService.AddCooldown(GameDataService.GetConfig().heroRespawnTime, null, SpawnHero);
 }
示例#20
0
 public override void Start() {
     idleCooldown = CooldownService.AddCooldown(0.5f, null, Stop, 0, 0.1f);
 }
示例#21
0
 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);
 }