Beispiel #1
0
    // 执行结束事件
    public virtual bool OnClosureEvent(string eventName, IGIICommandCenter commandCenter)
    {
        if (isClosureEvent(eventName))
        {
                        #if UNITY_EDITOR
            Debug.LogFormat("[{0}] => OnClosureEvent, finish", Name);
                        #endif

            _closed = true;
        }

        return(_closed);
    }
    public virtual bool ExecuteInCommandCenter(IGIICommandCenter commandCenter)
    {
        if (_currentCommand == null)
        {
            // 出现这种情况的时候表示当前指令已经执行完
//			Debug.Assert(false, "!! Current Command is finished already !!");
            return(true);
        }

        _currentCommand.ExecuteInCommandCenter(commandCenter);
        while (_currentCommand.IsFinished() && _subCommands.Count > 0)
        {
            _currentCommand = _subCommands.Dequeue();
            _currentCommand.ExecuteInCommandCenter(commandCenter);
        }

        if (_currentCommand.IsFinished())
        {
            _currentCommand = null;
            return(true);
        }

        return(_currentCommand.IsFinished());         // always false
    }
//	public virtual bool IsClosureEvent(string eventName)
//	{
//		if(_currentCommand == null)
//		{
//			// 出现这种情况的时候表示当前指令已经执行完
//			Debug.Assert(false, "!! Current Command is finished already !!");
//			return true;
//		}
//
//		return _currentCommand.IsClosureEvent (eventName);
//	}

    // 执行结束事件
    // 返回:当前指令是否结束
    public virtual bool OnClosureEvent(string eventName, IGIICommandCenter commandCenter)
    {
        if (_currentCommand == null)
        {
            // 出现这种情况的时候表示当前指令已经执行完
            Debug.Assert(false, "!! Current Command is finished already !!");
            return(true);
        }

        if (_currentCommand.OnClosureEvent(eventName, commandCenter))
        {
            // 是当前指令期待的结束符
            _currentCommand = null;

            if (_subCommands.Count > 0)
            {
                // 下一个指令
                _currentCommand = _subCommands.Dequeue();
                ExecuteInCommandCenter(commandCenter);
            }
        }

        return(IsFinished());
    }
Beispiel #4
0
    public virtual bool ExecuteInCommandCenter(IGIICommandCenter commandCenter)
    {
        if (_execution != null)
        {
            // TODO: GIIControlCenter作为外部参数传入更合适
            commandCenter.BeginProcessingCommand(Name);

                        #if UNITY_EDITOR
            Debug.LogFormat("[{0}] => Execute", _name);
                        #endif

            _execution();
            commandCenter.EndProcessingCommand(Name);
            // 只执行一次
            _execution = null;
        }

        if (NeedsClosure())
        {
            _closed = false;

                        #if UNITY_EDITOR
            Debug.LogFormat("[{0}] => Waiting for closure: {1}", _name, _closure);
                        #endif
        }
        else
        {
            _closed = true;

                        #if UNITY_EDITOR
            Debug.LogFormat("[{0}] => Finish", Name, _closure);
                        #endif
        }

        return(_closed);
    }