Exemplo n.º 1
0
    public static ProduceUnitTask CreateTask(CombatUnitType unitType, int unitAmount, OnProduceUnitComplete completeCallBack = null,
                                             OnTimeLeftToComplete timeLeftCallBack = null, int duration = 1)
    {
        ProduceUnitTask task = new ProduceUnitTask();

        task.InitTask(unitType, unitAmount, completeCallBack, timeLeftCallBack, duration);

        return(task);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Easy way to create the resource task.
    /// </summary>
    /// <returns>The task.</returns>
    /// <param name="resourceId">Resource identifier.</param>
    /// <param name="resourceToGenerate">Resource to generate.</param>
    /// <param name="completeCallBack">Complete call back.</param>
    /// <param name="duration">Duration.</param>
    /// <param name="timeType">Time type.</param>
    public static T CreateTask <T>(ResourceType resourceId, float resourceToGenerate, OnResourceTaskComplete completeCallBack = null,
                                   OnTimeLeftToComplete timeLeftCallBack = null, int duration = 1) where T : ResourceGenerateTask, new()
    {
        T task = new T();

        ((ResourceGenerateTask)task).InitTask(resourceId, resourceToGenerate, completeCallBack, timeLeftCallBack, duration);

        return(task);
    }
Exemplo n.º 3
0
    public static AttackTask CreateTask(string taskId, string targetId, string targetName, Dictionary <CombatUnit, int> targetUnit,
                                        Dictionary <CombatUnit, int> playerUnit, OnAttackComplete completeCallBack = null,
                                        OnTimeLeftToComplete timeLeftCallBack = null, int duration = 1)
    {
        AttackTask task = new AttackTask();

        task.InitTask(taskId, targetId, targetName, targetUnit, playerUnit, completeCallBack, timeLeftCallBack, duration);

        return(task);
    }
Exemplo n.º 4
0
    public void InitTask(CombatUnitType unitType, int unitAmount, OnProduceUnitComplete completeCallBack = null,
                         OnTimeLeftToComplete timeLeftCallBack = null, int duration = 1)
    {
        base.InitTask(duration, timeLeftCallBack);

        _producingUnitType = unitType;

        _producingUnitAmount = unitAmount;

        Evt_OnProduceUnitComplete += completeCallBack;
    }
Exemplo n.º 5
0
    /// <summary>
    /// Init resource generate task.
    /// call after first call will reset all value to new value
    /// </summary>
    /// <param name="resourceId">Resource identifier.</param>
    /// <param name="resourceToGenerate">Resource to generate.</param>
    /// <param name="completeCallBack">Complete call back.</param>
    /// <param name="duration">Duration.</param>
    /// <param name="timeType">Time type.</param>
    public void InitTask(ResourceType resourceId, float resourceToGenerate, OnResourceTaskComplete completeCallBack = null,
                         OnTimeLeftToComplete timeLeftCallBack = null, int duration = 1)
    {
        base.InitTask(duration, timeLeftCallBack);

        _resourceId = resourceId;

        _resource = resourceToGenerate;

        Evt_OnResourceTaskComplete = completeCallBack;
    }
Exemplo n.º 6
0
    /// <summary>
    /// Init time task.
    /// </summary>
    /// <param name="taskDuration">Task duration.</param>
    /// <param name="timeLeftCallBack">Time left call back.</param>
    public virtual void InitTask(int taskDuration, OnTimeLeftToComplete timeLeftCallBack)
    {
        _timeIsUp = false;

        _duration = taskDuration;

        _isDeadline = false;

        _currentDuration = taskDuration;

        _lastTime = DateTime.Now.Subtract(new TimeSpan(0, 0, 1));

        Evt_OnTimeLeftToComplete += timeLeftCallBack;
    }
Exemplo n.º 7
0
    public void InitTask(string taskId, string targetId, string targetName, Dictionary <CombatUnit, int> targetUnit,
                         Dictionary <CombatUnit, int> playerUnit, OnAttackComplete completeCallBack = null,
                         OnTimeLeftToComplete timeLeftCallBack = null, int duration = 1)
    {
        base.InitTask(duration, timeLeftCallBack);

        _taskId = taskId;

        _targetPlayerId = targetId;

        _targetPlayerName = targetName;

        _targetPlayerUnit = targetUnit;

        _playerUnit = playerUnit;

        _waitDuration = duration;

        Evt_OnAttackComplete += completeCallBack;
    }