Beispiel #1
0
        public void VerifyPlatform()
        {
            Platform lastPlatform = AgentPlatform;

            if (lastPlatform != null)
            {
                if (startPlatform != null && !lastPlatform.Equals(startPlatform))
                {
                    if (link != null && link.Equals(ClosestLink))
                    {
                        SaveLink();
                    }
                    startPlatform = null;
                    link          = null;
                }
                else
                {
                    startPlatform = lastPlatform;
                }
                if ((DateTime.Now - lastLinkTime).TotalSeconds >= 0.5)
                {
                    SetClosestLink();
                }
            }
        }
Beispiel #2
0
 internal void EndGame(int collectiblesCaught, int timeElapsed, Dictionary <int, List <IntraPlatformPlayedGameStateInfo> > intraPlatformStates, Dictionary <int, List <InterPlatformPlayedGameStateInfo> > interPlatformStates)
 {
     TimeElapsed = timeElapsed;
     NumberCollectiblesRemaining = NumberCollectiblesGlobal - collectiblesCaught;
     foreach (int platformId in intraPlatformStates.Keys)
     {
         Platform p = platformManager.GetPlatform(platformId);
         int      numberOfStates = intraPlatformStates[platformId].Count;
         p.StartTime = intraPlatformStates[platformId][0].PlayedTime;
         if (p.PercentageCollectiblesCaught == 100)
         {
             p.EndTime = intraPlatformStates[platformId][numberOfStates - 1].PlayedTime;
         }
         else
         {
             p.EndTime = p.StartTime.AddSeconds(timeElapsed);
         }
     }
     foreach (int link in interPlatformStates.Keys)
     {
         int       numberOfStates = interPlatformStates[link].Count;
         GraphLink myLink         = GetGraph().GetGraphLink(link);
         myLink.StartTime = interPlatformStates[link][0].PlayedTime;
         myLink.EndTime   = interPlatformStates[link][0].PlayedTime.AddSeconds(timeElapsed);
     }
 }
Beispiel #3
0
        private void CreateDiagonalConnection(GraphNode analysingNode, GraphNode test, Platform p)
        {
            GraphNode topNode, bottomNode;

            if (analysingNode.Platform.Top < test.Platform.Top)
            {
                topNode    = analysingNode;
                bottomNode = test;
            }
            else
            {
                topNode    = test;
                bottomNode = analysingNode;
            }


            GraphLink topToBottom;
            float     deltaY = bottomNode.Platform.Top - topNode.Platform.Top;
            float     deltaX = bottomNode.Platform.Left - topNode.Platform.Right;

            if (p.Left == topNode.Platform.Right)
            {
                topToBottom = new GraphLink(GetLinkID(), topNode, topNode.Platform.Right, bottomNode, deltaX, deltaY);
            }
            else
            {
                topToBottom = new GraphLink(GetLinkID(), topNode, topNode.Platform.Left, bottomNode, deltaX, deltaY);
            }

            links.Add(topToBottom);
            topNode.addAjacentNode(topToBottom);
        }
Beispiel #4
0
        private void CreateHorizontalConnection(GraphNode analysingNode, GraphNode test, Platform p)
        {
            GraphNode leftNode, rightNode;

            if (analysingNode.Platform.Right < test.Platform.Left)
            {
                leftNode  = analysingNode;
                rightNode = test;
            }
            else
            {
                leftNode  = test;
                rightNode = analysingNode;
            }

            float deltaX = rightNode.Platform.Left - leftNode.Platform.Right;

            GraphLink leftToRight = new GraphLink(GetLinkID(), leftNode, leftNode.Platform.Right, rightNode, deltaX, 0);

            leftNode.addAjacentNode(leftToRight);
            links.Add(leftToRight);

            deltaX = -deltaX;
            GraphLink rightToLeft = new GraphLink(GetLinkID(), rightNode, rightNode.Platform.Left, leftNode, deltaX, 0);

            rightNode.addAjacentNode(rightToLeft);
            links.Add(rightToLeft);
        }
Beispiel #5
0
        private void CreateDiagonalConnection(GraphNode analysingNode, GraphNode test, Platform p)
        {
            GraphNode topNode, bottomNode;

            if (analysingNode.Platform.Top < test.Platform.Top)
            {
                topNode    = analysingNode;
                bottomNode = test;
            }
            else
            {
                topNode    = test;
                bottomNode = analysingNode;
            }


            GraphLink topToBottom;
            float     deltaY = bottomNode.Platform.Top - topNode.Platform.Top;
            float     deltaX = bottomNode.Platform.Left - topNode.Platform.Right;

            if (p.Left == topNode.Platform.Right)
            {
                topToBottom = new GraphLink(GetLinkID(), topNode, topNode.Platform.Right, bottomNode, deltaX, deltaY);
            }
            else
            {
                topToBottom = new GraphLink(GetLinkID(), topNode, topNode.Platform.Left, bottomNode, deltaX, deltaY);
            }

            topNode.addAjacentNode(topToBottom);
            links.Add(topToBottom);

            if (p.Height <= 8 * CircleWorldModel.DEFAULT_RADIUS)
            {
                GraphLink bottomToTop;
                deltaY = topNode.Platform.Top - bottomNode.Platform.Top;
                deltaX = topNode.Platform.Left - bottomNode.Platform.Right;
                if (p.Left == bottomNode.Platform.Right)
                {
                    bottomToTop = new GraphLink(GetLinkID(), bottomNode, bottomNode.Platform.Right, topNode, deltaX, deltaY);
                }
                else
                {
                    bottomToTop = new GraphLink(GetLinkID(), bottomNode, bottomNode.Platform.Left, topNode, deltaX, deltaY);
                }
                bottomNode.addAjacentNode(bottomToTop);
                links.Add(bottomToTop);
            }
        }
Beispiel #6
0
        private void CreateVerticalConnection(GraphNode analysingNode, GraphNode test, Platform p)
        {
            GraphNode topNode, bottomNode;

            if (analysingNode.Platform.Top < test.Platform.Top)
            {
                topNode    = analysingNode;
                bottomNode = test;
            }
            else
            {
                topNode    = test;
                bottomNode = analysingNode;
            }

            float xPos;
            float f      = p.xPos - p.Width / 2;
            float deltaX = SquareWorldModel.MIN_HEIGHT;

            if (f == topNode.Platform.Right)
            {
                xPos = topNode.Platform.Right + SquareWorldModel.MIN_HEIGHT / 2f;
            }
            else
            {
                xPos = topNode.Platform.Left - SquareWorldModel.MIN_HEIGHT / 2f;
            }



            float     deltaY      = bottomNode.Platform.Top - topNode.Platform.Top;
            GraphLink topToBottom = new GraphLink(GetLinkID(), topNode, xPos, bottomNode, deltaX, deltaY);

            links.Add(topToBottom);

            topNode.addAjacentNode(topToBottom);

            if (p.Height <= 1.1f * SquareWorldModel.MIN_HEIGHT)
            {
                deltaY = -deltaY;
                GraphLink bottomToTop = new GraphLink(GetLinkID(), bottomNode, xPos, topNode, deltaX, deltaY);
                bottomNode.addAjacentNode(bottomToTop);
                links.Add(bottomToTop);
            }
        }
Beispiel #7
0
        internal GraphLink GetClosestLink()
        {
            List <GraphLink> links = platformManager.GetGraph().GetNextLinks(AgentPlatform);

            double    distance = double.MaxValue;
            GraphLink link     = null;

            foreach (GraphLink l in links)
            {
                double linkDistance = Utils.Utils.CalculateL2(AgentXPosition, AgentYPosition, l.FromXPos, l.FromNode.Platform.Top);
                if (linkDistance < distance)
                {
                    distance = linkDistance;
                    link     = l;
                }
            }
            return(link);
        }
Beispiel #8
0
        private void CreateVerticalConnection(GraphNode analysingNode, GraphNode test, Platform p)
        {
            GraphNode topNode, bottomNode;

            if (analysingNode.Platform.Top < test.Platform.Top)
            {
                topNode    = analysingNode;
                bottomNode = test;
            }
            else
            {
                topNode    = test;
                bottomNode = analysingNode;
            }

            float xPos;

            if (p.xPos - p.Width / 2 == topNode.Platform.Right)
            {
                xPos = topNode.Platform.Right;
            }
            else
            {
                xPos = topNode.Platform.Left;
            }

            float     deltaY      = bottomNode.Platform.Top - topNode.Platform.Top;
            GraphLink topToBottom = new GraphLink(GetLinkID(), topNode, xPos, bottomNode, 0, deltaY);

            topNode.addAjacentNode(topToBottom);
            links.Add(topToBottom);

            if (deltaY < 8 * CircleWorldModel.DEFAULT_RADIUS)
            {
                deltaY = -deltaY;
                GraphLink bottomToTop = new GraphLink(GetLinkID(), bottomNode, xPos, topNode, 0, deltaY);
                bottomNode.addAjacentNode(bottomToTop);
                links.Add(bottomToTop);
            }
        }
Beispiel #9
0
 public void addAjacentNode(GraphLink link)
 {
     adjacentNodes.Add(link);
 }
Beispiel #10
0
 public void SetClosestLink()
 {
     link = GetClosestLink();
 }
Beispiel #11
0
        public override bool Equals(object obj)
        {
            GraphLink other = ((GraphLink)obj);

            return(this.id == other.id);
        }
Beispiel #12
0
        public int CompareTo(object obj)
        {
            GraphLink other = ((GraphLink)obj);

            return(this.id.CompareTo(other.id));
        }