Beispiel #1
0
        public async Task SeedDb()
        {
            var capture = new CaptureEntity
            {
                Uri       = "smb://nesAtFit",
                Id        = Guid.Parse("28b1dfd6-0b66-4d73-90e5-30cb919a3290"),
                Processed = new DateTime(2018, 08, 07, 03, 15, 00)
            };

            await this._captureRepositoryWriterAsync.InsertAsync(capture).ConfigureAwait(false);


            var l7Conversation = new L7ConversationEntity
            {
                Id                  = Guid.Parse("bb672537-7a79-4b47-bdeb-f46b6dc341f6"),
                CaptureId           = capture.Id,
                SourceEndPoint      = new IPEndPointEntity(IPAddress.Parse("147.229.10.10"), 10),
                DestinationEndPoint = new IPEndPointEntity(IPAddress.Parse("8.8.8.8"), 20),
                FirstSeen           = new DateTime(2018, 08, 07, 8, 30, 00),
                LastSeen            = new DateTime(2018, 08, 07, 9, 0, 00),
                ProtocolType        = (Int32)IPProtocolType.TCP
            };

            await this._l7ConversationRepositoryWriterAsync.InsertAsync(l7Conversation).ConfigureAwait(false);


            var pduShard = new L7ConversationPdusShardEntity
            {
                L7ConversationId = l7Conversation.Id,
                Shard            = 0,
                Pdus             = new[]
                {
                    new L7PduEntity
                    {
                        Direction      = (Int32)FlowDirection.Up,
                        FirstSeenTicks = new DateTime(2018, 08, 07, 8, 30, 00).Ticks,
                        Payload        = Encoding.ASCII.GetBytes("ABCD")
                    },
                    new L7PduEntity
                    {
                        Direction      = (Int32)FlowDirection.Down,
                        FirstSeenTicks = new DateTime(2018, 08, 07, 8, 45, 00).Ticks,
                        Payload        = Encoding.ASCII.GetBytes("EFGH")
                    },
                    new L7PduEntity
                    {
                        Direction      = (Int32)FlowDirection.Up,
                        FirstSeenTicks = new DateTime(2018, 08, 07, 9, 00, 00).Ticks,
                        Payload        = Encoding.ASCII.GetBytes("IJK")
                    }
                },
            };

            await this._pduShardRepositoryWriterAsync.InsertAsync(pduShard).ConfigureAwait(false);

            await this._unitOfWork.SaveChangesAsync().ConfigureAwait(false);
        }
Beispiel #2
0
    public AiHeuristicInfo(CaptureEntity src, Direction direction)
    {
        this.src       = src;
        this.direction = direction;

        this.srcUnits    = new LinkedList <GameUnitEntity>();
        this.queuedUnits = new LinkedList <GameUnitEntity>();
        this.enemyUnits  = new LinkedList <GameUnitEntity>();
    }
    // Sets a captured Entity
    public void setCapturedEntity(CaptureEntity captureEntity)
    {
        captureEntity.owner = this;
        captureEntity.clearUnitQueue();
        this.capturedEntities.Add(captureEntity);

        if (selectedCaptureEntity == null)
        {
            selectedCaptureEntity = captureEntity;
        }
    }
    public void createCaptureEntity(Vector3 pos, Direction dir, ControllerManager owner)
    {
        GameObject    captureEntityObj = Instantiate(capturePoint, pos * TILE_SCALE, Quaternion.identity) as GameObject;
        CaptureEntity entity           = captureEntityObj.GetComponent <CaptureEntity>();

        entity.setDirection(dir);

        if (owner != null)
        {
            owner.setCapturedEntity(entity);
        }
    }
    protected AiHeuristicInfo[] getAllSituations()
    {
        Queue <AiHeuristicInfo> possibleMovesInfo = new Queue <AiHeuristicInfo>();

        foreach (CaptureEntity c in this.aiController.capturedEntities)
        {
            // Check Each Direction
            foreach (Direction d in Enum.GetValues(typeof(Direction)))
            {
                // Generate Raycast
                Vector2 direction = EntityUtils.getDirectionVector(d) * VIEW_RANGE;
                direction *= BoardManager.TILE_SCALE * VIEW_RANGE;
                Vector2 end = c.rb2D.position + direction;

                // Preform Raycast
                c.boxCollider.enabled = false;
                RaycastHit2D[] hits = Physics2D.LinecastAll(c.rb2D.position, end, LayerMask.GetMask("Blocking")); //Physics2D.Linecast
                Debug.DrawLine(c.rb2D.position, end, Color.red, .5f);
                c.boxCollider.enabled = true;


                if (hits == null || hits.Length == 0)
                {
                    continue;
                }                                                   // Continue if nothing was hit

                AiHeuristicInfo moveInfo = new AiHeuristicInfo(c, d);

                // Direction Vision Check
                foreach (RaycastHit2D hit in hits)
                {
                    CaptureEntity  captureEntity  = hit.rigidbody.GetComponent <CaptureEntity>();
                    GameUnitEntity gameUnitEntity = hit.collider.GetComponent <GameUnitEntity>();

                    // Unit
                    if (gameUnitEntity != null)
                    {
                        if (gameUnitEntity.owner == c.owner)
                        {
                            moveInfo.srcUnits.AddLast(gameUnitEntity);
                        }
                        else
                        {
                            moveInfo.enemyUnits.AddLast(gameUnitEntity);
                        }
                    }
                    else if (captureEntity != null && captureEntity != c)
                    {
                        // Enemy Capture Points
                        moveInfo.target = captureEntity;
                    }
                }

                if (moveInfo.target == null)
                {
                    continue;
                }                                          // If a target was not found, don't move

                possibleMovesInfo.Enqueue(moveInfo);
            }
        }

        return(possibleMovesInfo.ToArray());
    }
Beispiel #6
0
 public AiDecision(CaptureEntity captureEntity, int entityType, Direction direction)
 {
     this.captureEntity = captureEntity;
     this.entityType    = entityType;
     this.direction     = direction;
 }
 // Removes a captured Entity
 public void removeCaptureEntity(CaptureEntity captureEntity)
 {
     this.capturedEntities.Remove(captureEntity);
 }