Ejemplo n.º 1
0
    void ProcessData()
    {
        List <AttackInfo> removedInfo = new List <AttackInfo>();

        for (int i = 0; i < _trackAttackTask.Count; i++)
        {
            AttackInfo attackInfo = _trackAttackTask[i];

            int result = DateTime.Now.CompareTo(attackInfo.taskEndTime);

            if (result >= 0)
            {
                removedInfo.Add(attackInfo);

                _completeAttackTask.Add(attackInfo);

                attackInfo.CalculateResult();
            }
            else if (result < 0)
            {
                TimeSpan tSpan = attackInfo.taskEndTime.Subtract(DateTime.Now);

                int remainSeconds = (int)(tSpan.TotalSeconds % attackInfo.duration);

                attackInfo.duration = remainSeconds;
            }
        }

        for (int i = 0; i < removedInfo.Count; i++)
        {
            _trackAttackTask.Remove(removedInfo[i]);
        }

        removedInfo.Clear();
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Check if is attack task complete.
    /// return Attack info if complete otherwise null
    /// </summary>
    /// <returns><c>true</c> if this instance is attack task complete the specified tskId; otherwise, <c>false</c>.</returns>
    /// <param name="tskId">Tsk identifier.</param>
    public AttackInfo IsAttackTaskComplete(string tskId)
    {
        AttackInfo attackInfo = FindAttackTask(tskId);

        if (attackInfo != null)
        {
            int result = DateTime.Now.CompareTo(attackInfo.taskEndTime);

            if (result >= 0)
            {
                attackInfo.CalculateResult();

                _completeAttackTask.Add(attackInfo);

                _trackAttackTask.Remove(attackInfo);

                Save();

                return(attackInfo);
            }

            return(null);
        }


        attackInfo = FindAttackTaskInComplete(tskId);

        if (attackInfo != null)
        {
            return(attackInfo);
        }

        Debug.LogError("No attack task exist " + tskId);

        return(null);
    }