Ejemplo n.º 1
0
    void Die()
    {
        if (isDead)
        {
            Debug.LogWarning("Trying to kill already dead character. Ignore.");
            return;
        }

        CancelInvoke("EnableHit");

        isDead       = true;
        hitDisabled += INTERNAL_HIT_FLAG;

        var _deadForce = deadForce;

        _deadForce.x        *= -direction;
        rigidbody2D.velocity = new Vector2(0, 0);
        rigidbody2D.AddForce(_deadForce);

        m_NetworkAnimator.SetTrigger("dead_lower");
        m_NetworkAnimator.SetTrigger("dead_upper");

        var _effectDead = (GameObject)Instantiate(effectDeadPrf, transform.position, transform.rotation);

        _effectDead.transform.Translate(effectDeadOffset);

        if (postDead != null)
        {
            postDead(this);
        }

        Invoke("DestroySelf", deadDelay);
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the set. Call when the <see cref="CurrentSet"/> finished.
        /// </summary>
        public void CurrentSetFinished()
        {
            Set <TTeam> finishingSet = CurrentSet;

            Sets.Add(finishingSet);
            if (finishingSet.Winner == TeamA)
            {
                SetCounter.IncrementA();
            }
            else
            {
                SetCounter.IncrementB();
            }
            (SetCountA, SetCountB) = (SetCounter.SetCountA, SetCounter.SetCountB);
            CurrentSet             = OnSetEnd(finishingSet); //外注
            if (SetCounter.IsMatchOver)
            {
                //The match is over
                if (SetCountA == SetCountB)
                {
                    throw new InvalidProgramException("Cannot win the match while in tie!");
                }
                Winner = SetCountA < 0 ? TeamA : TeamB;
                OnMatchOver();
            }
        }
Ejemplo n.º 3
0
        public void ShouldAddToCounter()
        {
            SetCounter counter = new SetCounter();

            counter.Add(10);
            Assert.That(counter.Peek(), Is.EqualTo(10));
        }
Ejemplo n.º 4
0
        public void ShouldHaveZeroAsStartValue()
        {
            SetCounter counter      = new SetCounter();
            long       initialValue = counter.Peek();

            Assert.That(initialValue, Is.EqualTo(0));
        }
 public ExecutionResultBuilder Begin()
 {
     _initialized = true;
     _errors      = new Dictionary <Exception, int>();
     _counter     = new SetCounter();
     _startTime   = DateTime.Now;
     return(this);
 }
 void ListenTotalDeathChanged(SetCounter <int> _statistic, int _change)
 {
     if (_statistic >= respawnLimit)
     {
         Debug.Log("respawnLimit over.");
         if (Network.isServer)
         {
             Game.Progress.TryOverGame();
         }
     }
 }
Ejemplo n.º 7
0
        public void ShouldCompareTwoNumbers()
        {
            SetCounter a = new SetCounter();
            SetCounter b = new SetCounter();

            a.Add(10);
            b.Add(5);
            b.Add(5);

            Assert.That(a.Peek(), Is.EqualTo(b.Peek()));
            Assert.That(a.IsEqual(b.Peek()), Is.True);
        }
Ejemplo n.º 8
0
        public void ShouldResetToZero()
        {
            SetCounter counter = new SetCounter();

            for (int i = 0; i < 100; i++)
            {
                Assert.That(counter.GetNext(), Is.EqualTo(i + 1));
            }

            counter.Reset();
            Assert.That(counter.Peek(), Is.EqualTo(0));
        }
Ejemplo n.º 9
0
        public void ShouldIncrement()
        {
            SetCounter counter = new SetCounter();

            for (int j = 0; j < 100; j++)
            {
                for (int i = 0; i < 100; i++)
                {
                    counter.Increment();
                    Assert.That(counter.Peek(), Is.EqualTo(i + 1));
                }
                counter.Reset();
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Cancels the last set. Call when the last set information was invalid or incorrect.
        /// </summary>
        public ((IEnumerable <Receive>, Game <TTeam>), Set <TTeam>) CancelPreviousSet()
        {
            if (Sets.Count < 1)
            {
                throw new InvalidOperationException("Cannot rollback from empty state!");
            }
            var s = CurrentSet = Sets.Last();

            Sets.Remove(s);
            SetCounter.Rollback();
            OnSetCanceled(s);
            (SetCountA, SetCountB) = (SetCounter.SetCountA, SetCounter.SetCountB);
            return(s.CancelPreviousGame(), s);
        }
Ejemplo n.º 11
0
    void HitLocal(AttackData _attackData)
    {
//		Debug.Log("Hit Local");
        hitDisabled += INTERNAL_HIT_FLAG;
        CancelInvoke("EnableHit");
        Invoke("EnableHit", hitCooldown);

        lastAttackData = _attackData;

        var _direction = Mathf.Sign(_attackData.velocity.x);

        rigidbody2D.AddForce(new Vector2(_direction * hitForce.x, hitForce.y));

        m_Hp.damage(_attackData);

        if (m_Hp > 0)
        {
            m_NetworkAnimator.SetTrigger("Hit");
        }
    }
 void ListenDeathChanged(SetCounter<int> _statistic, int _change)
 {
     death = _statistic;
 }
 void ListenDeathChanged(SetCounter <int> _statistic, int _change)
 {
     death = _statistic;
 }
    void HitLocal(AttackData _attackData)
    {
        //		Debug.Log("Hit Local");
        hitDisabled += INTERNAL_HIT_FLAG;
        CancelInvoke("EnableHit");
        Invoke("EnableHit", hitCooldown);

        lastAttackData = _attackData;

        var _direction = Mathf.Sign(_attackData.velocity.x);

        rigidbody2D.AddForce(new Vector2(_direction * hitForce.x, hitForce.y));

        m_Hp.damage(_attackData);

        if (m_Hp > 0)
            m_NetworkAnimator.SetTrigger("Hit");
    }
 void EnableHit()
 {
     hitDisabled -= INTERNAL_HIT_FLAG;
 }
    void Die()
    {
        if (isDead) {
            Debug.LogWarning("Trying to kill already dead character. Ignore.");
            return;
        }

        CancelInvoke("EnableHit");

        isDead = true;
        hitDisabled += INTERNAL_HIT_FLAG;

        var _deadForce = deadForce;
        _deadForce.x *= -direction;
        rigidbody2D.velocity = new Vector2(0, 0);
        rigidbody2D.AddForce(_deadForce);

        m_NetworkAnimator.SetTrigger("dead_lower");
        m_NetworkAnimator.SetTrigger("dead_upper");

        var _effectDead = (GameObject) Instantiate (effectDeadPrf, transform.position, transform.rotation);
        _effectDead.transform.Translate (effectDeadOffset);

        if (postDead != null) postDead(this);

        Invoke("DestroySelf", deadDelay);
    }
 void ListenTotalDeathChanged(SetCounter<int> _statistic, int _change)
 {
     if (_statistic >= respawnLimit)
     {
         Debug.Log("respawnLimit over.");
         if (Network.isServer)
             Game.Progress.TryOverGame();
     }
 }
Ejemplo n.º 18
0
        public void ShouldHaveOneAsTheFirstValue()
        {
            SetCounter counter = new SetCounter();

            Assert.That(counter.GetNext(), Is.EqualTo(1));
        }
Ejemplo n.º 19
0
 void EnableHit()
 {
     hitDisabled -= INTERNAL_HIT_FLAG;
 }