public MediaStateChangedEventArgs(BufferState bufferState, NetworkState networkState, PlaybackState playbackState, SeekState seekState)
		{
			this.bufferState = bufferState;
			this.networkState = networkState;
			this.playbackState = playbackState;
			this.seekState = seekState;
		}
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 public void OnTriggerExit(Collider col)
 {
     if (col.gameObject.tag == seekAndDestroy)
     {
         seekState   = SeekState.Forgeting;
         forgetTimer = 0;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 public void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == seekAndDestroy)
     {
         seekState = SeekState.Chasing;
         target    = col.gameObject.transform;
     }
 }
    private void Awake()
    {
        seekState   = new SeekState(this);
        alertState  = new AlertState(this);
        patrolState = new PatrolState(this);

        nav = GetComponent <NavMeshAgent> ();
    }
Ejemplo n.º 5
0
    public override void StartRoutine(AIEntity e)
    {
        entity          = e;
        waypointNetwork = entity.GetController().GetWaypoints();
        pathedEndPos    = new Vector3(0, 0, 0);
        path            = new List <Waypoint>();

        seekState = SeekState.ToTarget;
        waitingOn = new List <AIEntity>();
    }
Ejemplo n.º 6
0
 public void SendAttack(GameObject objective, string seekAttackStateName)
 {
     // Set state and target to ais
     for (int i = 0; i < ais.Count; i++)
     {
         SeekState formationState = ais[i].GetStateByName(seekAttackStateName) as SeekState;
         formationState.specifySeekTarget = true;
         formationState.seekTarget        = objective.transform;
         ais[i].ChangeActiveState(formationState);
     }
 }
Ejemplo n.º 7
0
 void Seek()
 {
     if (_ascending)
     {
         _keyValueTr.SetKeyIndex(_owner._prefix, _startPos + _pos);
     }
     else
     {
         _keyValueTr.SetKeyIndex(_owner._prefix, _startPos - _pos);
     }
     _seekState = SeekState.Ready;
 }
Ejemplo n.º 8
0
    public override StateMachine CreateMachine()
    {
        AbstractState idle = new IdleState((int)States.DEFAULT, this);
        AbstractState seek = new SeekState((int)States.SEEK, this);
        AbstractState pursuit = new PursuitState((int)States.PURSUIT, this);

        SeekStateMachine stateMachine = new SeekStateMachine();
        stateMachine.AddDefaultState(idle);
        stateMachine.AddState(seek);
        stateMachine.AddState(pursuit);

        return stateMachine;
    }
Ejemplo n.º 9
0
    public override AIEntity.BaseState UpdateRoutine()
    {
        Vector3 playerPos    = PlayerController.activeCharacter.transform.position;
        Vector3 targetVector = playerPos - entity.transform.position;

        if (targetVector.magnitude < rangeFactor * entity.GetWeaponRange())
        {
            return(AIEntity.BaseState.Attacking);
        }

        switch (seekState)
        {
        case SeekState.ToPos:
            Vector3 nextVec = customManeuver [0];
            if (Vector3.Distance(entity.transform.position, nextVec) < StepSize())
            {
                customManeuver.RemoveAt(0);
                if (customManeuver.Count == 0)
                {
                    seekState = SeekState.ToTarget;
                    goto case SeekState.ToTarget;
                }
                else
                {
                    nextVec = customManeuver [0];
                }
            }
            DetermineDirections(nextVec.normalized);
            break;

        case SeekState.ToTarget:
            RaycastHit2D obstacle = Physics2D.Raycast(entity.transform.position, targetVector.normalized, targetVector.magnitude, 1 << LayerMask.NameToLayer("Wall"));
            //Debug.DrawLine (entity.transform.position, PlayerController.activeCharacter.transform.position, Color.black, .1f);
            if (obstacle.collider != null)
            {
                // If opponent has strayed too far from previous calculated path, figure out a new path to opponent
                if ((playerPos - pathedEndPos).magnitude > currentPathAcc + pathTol)
                {
                    path = new List <Waypoint> ();
                }
                targetVector = ContinueOnPath(playerPos, targetVector);
            }

            DetermineDirections(targetVector.normalized);
            break;
        }

        entity.TryWalk();
        return(baseState);
    }
Ejemplo n.º 10
0
    protected override bool Evaluate(AIBehaviors fsm)
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            if (Physics.Raycast(transform.position, Vector3.forward, out hit))
            {
                AIBehaviors ai        = GetComponent <AIBehaviors>();
                SeekState   seekState = ai.GetState <SeekState>();
                seekState.seekTarget = hit.collider.transform;
            }
            return(true);
        }

        return(false);
    }
Ejemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 void Update()
 {
     if (seekState == SeekState.Forgeting)
     {
         if (forgetTimer >= timeToForgetTarget)
         {
             seekState = SeekState.Patrolling;
             agent.stoppingDistance = 0;
         }
         else
         {
             forgetTimer += Time.deltaTime;
         }
     }
     else if (seekState == SeekState.Chasing)
     {
         agent.stoppingDistance = stopDistance;
     }
 }
Ejemplo n.º 12
0
    private void Start()
    {
        var idle = new IdleState(transform);
        var seek = new SeekState(transform);
        var hit  = new HitState(transform);

        idle.Transitions.AddRange(new[]
        {
            new Transition(seek, seek.IsBallSeekable)
        });

        seek.Transitions.AddRange(new[]
        {
            new Transition(idle, seek.IsBallSeekable, true),
            new Transition(hit, hit.IsBallHittable),
        });

        hit.Transitions.AddRange(new []
        {
            new Transition(idle, hit.IsBallHittable, true),
        });

        _enemyAi = new StateMachine(idle);
    }
Ejemplo n.º 13
0
            public AdvancedEnumerator(ODBSet <TKey> owner, AdvancedEnumeratorParam <TKey> param)
            {
                _owner      = owner;
                _keyValueTr = _owner._keyValueTr;
                _ascending  = param.Order == EnumerationOrder.Ascending;
                _prevModificationCounter = _owner._modificationCounter;
                _prevProtectionCounter   = _keyValueTr.CursorMovedCounter;
                _keyValueTr.FindFirstKey(_owner._prefix);
                var  prefixIndex = _keyValueTr.GetKeyIndex();
                long startIndex;
                long endIndex;

                if (param.EndProposition == KeyProposition.Ignored)
                {
                    _keyValueTr.FindLastKey(_owner._prefix);
                    endIndex = _keyValueTr.GetKeyIndex() - prefixIndex - 1;
                }
                else
                {
                    var keyBytes = _owner.KeyToByteArray(param.End);
                    switch (_keyValueTr.Find(keyBytes, (uint)_owner._prefix.Length))
                    {
                    case FindResult.Exact:
                        endIndex = _keyValueTr.GetKeyIndex() - prefixIndex;
                        if (param.EndProposition == KeyProposition.Excluded)
                        {
                            endIndex--;
                        }

                        break;

                    case FindResult.Previous:
                        endIndex = _keyValueTr.GetKeyIndex() - prefixIndex;
                        break;

                    case FindResult.Next:
                        endIndex = _keyValueTr.GetKeyIndex() - prefixIndex - 1;
                        break;

                    case FindResult.NotFound:
                        endIndex = -1;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                if (param.StartProposition == KeyProposition.Ignored)
                {
                    startIndex = 0;
                }
                else
                {
                    var keyBytes = _owner.KeyToByteArray(param.Start);
                    switch (_keyValueTr.Find(keyBytes, (uint)_owner._prefix.Length))
                    {
                    case FindResult.Exact:
                        startIndex = _keyValueTr.GetKeyIndex() - prefixIndex;
                        if (param.StartProposition == KeyProposition.Excluded)
                        {
                            startIndex++;
                        }

                        break;

                    case FindResult.Previous:
                        startIndex = _keyValueTr.GetKeyIndex() - prefixIndex + 1;
                        break;

                    case FindResult.Next:
                        startIndex = _keyValueTr.GetKeyIndex() - prefixIndex;
                        break;

                    case FindResult.NotFound:
                        startIndex = 0;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                _count     = (uint)Math.Max(0, endIndex - startIndex + 1);
                _startPos  = (uint)(_ascending ? startIndex : endIndex);
                _pos       = 0;
                _seekState = SeekState.Undefined;
            }
Ejemplo n.º 14
0
        public RelationAdvancedOrderedEnumerator(IRelationDbManipulator manipulator,
                                                 ByteBuffer prefixBytes, uint prefixFieldCount,
                                                 EnumerationOrder order,
                                                 KeyProposition startKeyProposition, ByteBuffer startKeyBytes,
                                                 KeyProposition endKeyProposition, ByteBuffer endKeyBytes, bool initKeyReader, int loaderIndex)
        {
            _prefixFieldCount = prefixFieldCount;
            _manipulator      = manipulator;
            ItemLoader        = _manipulator.RelationInfo.ItemLoaderInfos[loaderIndex];
            _tr        = manipulator.Transaction;
            _ascending = order == EnumerationOrder.Ascending;

            _keyValueTr            = _tr.KeyValueDBTransaction;
            _keyValueTrProtector   = _tr.TransactionProtector;
            _prevProtectionCounter = _keyValueTrProtector.ProtectionCounter;

            _keyBytes = prefixBytes;
            if (endKeyProposition == KeyProposition.Included)
            {
                endKeyBytes = RelationAdvancedEnumerator <TValue> .FindLastKeyWithPrefix(_keyBytes, endKeyBytes,
                                                                                         _keyValueTr, _keyValueTrProtector);
            }

            _keyValueTrProtector.Start();
            _keyValueTr.SetKeyPrefix(_keyBytes);

            long startIndex;
            long endIndex;

            if (endKeyProposition == KeyProposition.Ignored)
            {
                endIndex = _keyValueTr.GetKeyValueCount() - 1;
            }
            else
            {
                switch (_keyValueTr.Find(endKeyBytes))
                {
                case FindResult.Exact:
                    endIndex = _keyValueTr.GetKeyIndex();
                    if (endKeyProposition == KeyProposition.Excluded)
                    {
                        endIndex--;
                    }

                    break;

                case FindResult.Previous:
                    endIndex = _keyValueTr.GetKeyIndex();
                    break;

                case FindResult.Next:
                    endIndex = _keyValueTr.GetKeyIndex() - 1;
                    break;

                case FindResult.NotFound:
                    endIndex = -1;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            if (startKeyProposition == KeyProposition.Ignored)
            {
                startIndex = 0;
            }
            else
            {
                switch (_keyValueTr.Find(startKeyBytes))
                {
                case FindResult.Exact:
                    startIndex = _keyValueTr.GetKeyIndex();
                    if (startKeyProposition == KeyProposition.Excluded)
                    {
                        startIndex++;
                    }

                    break;

                case FindResult.Previous:
                    startIndex = _keyValueTr.GetKeyIndex() + 1;
                    break;

                case FindResult.Next:
                    startIndex = _keyValueTr.GetKeyIndex();
                    break;

                case FindResult.NotFound:
                    startIndex = 0;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            _count     = (uint)Math.Max(0, endIndex - startIndex + 1);
            _startPos  = (uint)(_ascending ? startIndex : endIndex);
            _pos       = 0;
            _seekState = SeekState.Undefined;

            if (initKeyReader)
            {
                var primaryKeyFields       = manipulator.RelationInfo.ClientRelationVersionInfo.GetPrimaryKeyFields();
                var advancedEnumParamField = primaryKeyFields[(int)_prefixFieldCount];
                if (advancedEnumParamField.Handler.NeedsCtx())
                {
                    throw new BTDBException("Not supported.");
                }
                _keyReader = (Func <AbstractBufferedReader, IReaderCtx, TKey>)manipulator.RelationInfo
                             .GetSimpleLoader(new RelationInfo.SimpleLoaderType(advancedEnumParamField.Handler, typeof(TKey)));

                _lengthOfNonDataPrefix = manipulator.RelationInfo.Prefix.Length;
            }
        }
 public MediaStateChangedEventArgs(BufferState bufferState, NetworkState networkState, PlaybackState playbackState, SeekState seekState)
 {
     this.bufferState   = bufferState;
     this.networkState  = networkState;
     this.playbackState = playbackState;
     this.seekState     = seekState;
 }
Ejemplo n.º 16
0
    public void SendAIsTo(Vector3 targetPoint, string seekStateName)
    {
        List <Vector3> aisTargets = new List <Vector3>();
        Vector3        startingPoint;
        int            rows = 0, cols = 0;

        // Set rows and columns
        if (formationType == FormationType.Rows)
        {
            rows = count;
            cols = ais.Count / rows;
        }
        else if (formationType == FormationType.Columns)
        {
            cols = count;
            rows = ais.Count / cols;
        }

        // Set starting point
        startingPoint = new Vector3(targetPoint.x - ((cols - 1) * unitSpacing / 2), targetPoint.y, targetPoint.z + ((rows - 1) * unitSpacing / 2));

        // Set points
        int currentCol = 1;
        int currentRow = 1;

        for (int i = 0; i < ais.Count; i++)
        {
            Vector3 target = new Vector3(startingPoint.x + (currentCol - 1) * unitSpacing, startingPoint.y, startingPoint.z - (currentRow - 1) * unitSpacing);
            aisTargets.Add(target);

            if (formationType == FormationType.Columns)
            {
                if (currentCol == count)
                {
                    currentCol = 1;
                    currentRow++;
                }
                else
                {
                    currentCol++;
                }
            }
            else if (formationType == FormationType.Rows)
            {
                if (currentRow == count)
                {
                    currentRow = 1;
                    currentCol++;
                }
                else
                {
                    currentRow++;
                }
            }
        }

        // Set state and target to ai
        for (int i = 0; i < ais.Count; i++)
        {
            GameObject newFormationTarget = new GameObject("FormationTarget");
            newFormationTarget.transform.position = aisTargets [i];

            SeekState formationState = ais[i].GetStateByName(seekStateName) as SeekState;
            formationState.specifySeekTarget = true;
            formationState.seekTarget        = newFormationTarget.transform;
            ais[i].ChangeActiveState(formationState);
        }
    }