Exemplo n.º 1
0
        public BattleActionScript(AICharacter aiChar, BattleActionScriptContainer scriptContainer, BattleActionScriptData actionScriptData)
        {
            _scriptContainer  = scriptContainer;
            _actionScriptData = actionScriptData;

            _speed = actionScriptData.speed;
            _listOfBattleActions = new List <BattleAction>();
            for (int i = 0; i < actionScriptData.listOfActionData.Count; ++i)
            {
                BattleAction battleAction = BattleActionTypes.GetBattleAction(aiChar, this, actionScriptData.listOfActionData[i]);
                _listOfBattleActions.Add(battleAction);
            }
        }
Exemplo n.º 2
0
        void Reset()
        {
            BattleAction currentAction     = null;
            int          battleActionCount = _listOfBattleActions.Count;

            for (int i = 0; i < battleActionCount; ++i)
            {
                currentAction = _listOfBattleActions[i];
                currentAction.Reset();
            }

            _hasCompleted = false;
            _hasStarted   = false;
        }
Exemplo n.º 3
0
        public void Update(float deltaTime)
        {
            if (_actionScriptData.totalFrames <= 0 || _hasCompleted)
            {
                return;
            }

            for (int i = 0; i < _listOfBattleActions.Count; ++i)
            {
                BattleAction currentAction = _listOfBattleActions[i];

                // If its already executed, ignore this action
                if (currentAction.HasExecuted)
                {
                    continue;
                }

                // If action hasn't started and passes the conditions to execute
                if (!currentAction.HasStarted)
                {
                    bool startAction = _currentFrame >= currentAction.Frame;
                    if (startAction)
                    {
                        currentAction.Start();

                        if (currentAction.Pause)
                        {
                            Debug.Break();
                        }
                    }
                }

                // Shouldn't be an else as it could update to hasStarted this frame
                if (currentAction.HasStarted)
                {
                    currentAction.Update();
                    if (currentAction.Debug)
                    {
                        currentAction.DrawDebug();
                    }

                    if (currentAction.EndFrame > 0 && _currentFrame >= currentAction.EndFrame)
                    {
                        currentAction.End();
                    }
                }
            }

            // used for branching out of the current timeline
            if (!string.IsNullOrEmpty(_breakOutCurrentScript))
            {
                ResetAllActions();
                _scriptContainer.PlayScript(_breakOutCurrentScript, _onCompletedFunc);
                _breakOutCurrentScript = null;
                return;
            }

            if (_currentFrame >= _totalFrames && !_hasCompleted)
            {
                EndActionScript();
            }

            // Increment timeline frame (FPS independent)
            if (deltaTime > 0)
            {
                _currentFrameFloat += 1.0f / (((1.0f / deltaTime) / TARGET_FPS));
                _currentFrame       = Mathf.FloorToInt(_currentFrameFloat);
            }

            // TODO: Investigate If frame rate is low, does it skip frames ?

            _realtimeGameFrame++;
        }