Exemplo n.º 1
0
        public void Simulate()
        {
            if (Body.PositionChangedBuffer)
            {
                tempNode = GridManager.GetNode(Body._position.x, Body._position.y);

                if (tempNode.IsNull())
                {
                    return;
                }

                if (System.Object.ReferenceEquals(tempNode, LocatedNode) == false)
                {
                    if (LocatedNode != null)
                    {
                        LocatedNode.Remove(this);
                    }

                    tempNode.Add(this);
                    LocatedNode = tempNode;
                }
            }

            if (!ReplayManager.IsPlayingBack)
            {
                foreach (var AI in AgentAI)
                {
                    AI.OnSimulate();
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnLateInitialize()
        {
            base.OnInitialize();

            CachedBody = this.GetComponent <UnityLSBody>().InternalBody;

            if (this.BlockPathfinding)
            {
                //const long gridSpacing = FixedMath.One;
                bufferCoordinates.FastClear();
                CachedBody.GetCoveredNodePositions(FixedMath.One / 8, bufferCoordinates);


                foreach (Vector2d vec in bufferCoordinates)
                {
                    GridNode node = GridManager.GetNode(vec.x, vec.y);
                    int      gridX, gridY;
                    GridManager.GetCoordinates(vec.x, vec.y, out gridX, out gridY);
                    if (node == null)
                    {
                        continue;
                    }

                    node.AddObstacle();
                }
            }
        }
Exemplo n.º 3
0
        void BlockNode(long x, long y)
        {
            var node = GridManager.GetNode(x, y);

            if (node.IsNotNull())
            {
                node.AddObstacle();
            }
        }
Exemplo n.º 4
0
        public void Initialize()
        {
            LocatedNode = GridManager.GetNode(Body._position.x, Body._position.y);

            LocatedNode.Add(this);

            foreach (var AI in AgentAI)
            {
                AI.OnInitialize();
            }
        }
Exemplo n.º 5
0
        public static void BlockArea(Area block)
        {
            long xMin = block.XMin;
            long xMax = block.XMax;
            long yMin = block.YMin;
            long yMax = block.YMax;

            for (long x = xMin; x <= xMax; x += FixedMath.One)
            {
                for (long y = yMin; y <= yMax; y += FixedMath.One)
                {
                    var node = GridManager.GetNode(x, y);
                    if (node.IsNotNull())
                    {
                        node.AddObstacle();
                    }
                }
            }
        }
        private void UpdateCoordinates()
        {
            const long gridSpacing = FixedMath.One;

            bufferCoordinates.FastClear();
            CachedBody.GetCoveredSnappedPositions(gridSpacing, bufferCoordinates);
            foreach (Vector2d vec in bufferCoordinates)
            {
                GridNode node = GridManager.GetNode(vec.x, vec.y);

                if (node == null)
                {
                    continue;
                }

                node.AddObstacle();
                LastCoordinates.Add(node);
            }
        }
Exemplo n.º 7
0
        public void Simulate()
        {
            if (Body.PositionChangedBuffer)
            {
                tempNode = GridManager.GetNode(Body._position.x, Body._position.y);

                if (tempNode.IsNull())
                {
                    return;
                }

                if (System.Object.ReferenceEquals(tempNode, LocatedNode) == false)
                {
                    if (LocatedNode != null)
                    {
                        LocatedNode.Remove(this);
                    }
                    tempNode.Add(this);
                    LocatedNode = tempNode;
                }
            }
        }
Exemplo n.º 8
0
        public void Initialize()
        {
            LocatedNode = GridManager.GetNode(Body._position.x, Body._position.y);

            LocatedNode.Add(this);
        }