コード例 #1
0
    private void MoveToNextRandomPoint()
    {
        _pointWalkCount--;

        if (_pointWalkCount > 0)
        {
            if (!_lastTarget)
            {
                int random_range = _currentTarget.GetEdges().Length;
                _lastTarget    = _currentTarget;
                _currentTarget = _currentTarget.GetEdges()[(int)Random.Range(0, random_range)].GetComponent <Node>();
            }
            else
            {
                if (Random.Range(0f, 1f) < _backProbability)
                {
                    Node aux_target = _currentTarget;
                    _currentTarget = _lastTarget;
                    _lastTarget    = aux_target;
                }
                else
                {
                    GameObject[] targets_array = null;

                    if (_currentTarget.GetEdges().Length != 1)
                    {
                        targets_array = new GameObject[_currentTarget.GetEdges().Length - 1];
                        int ind = 0;

                        for (int i = 0; i < _currentTarget.GetEdges().Length; i++)
                        {
                            if (_lastTarget.transform.position != _currentTarget.GetEdges()[i].transform.position)
                            {
                                targets_array[ind] = _currentTarget.GetEdges()[i];
                                ind++;
                            }
                        }
                    }
                    else
                    {
                        targets_array = _currentTarget.GetEdges().Clone() as GameObject[];
                    }

                    int random_range = targets_array.Length;
                    _lastTarget    = _currentTarget;
                    _currentTarget = targets_array[(int)Random.Range(0, random_range)].GetComponent <Node>();
                }
            }
        }
        else
        {
            _logicState = LogicState.Stand;
            SpriteAnimatorNpc snpc = GetComponent <SpriteAnimatorNpc>();
            snpc.StopSpriteAnimator(true);
        }
    }
コード例 #2
0
    public void SetPause(bool p)
    {
        if (p)
        {
            snpc.StopSpriteAnimator();
        }
        else
        {
            snpc.ResumeSpriteAnimator();
        }

        _paused = p;
    }