コード例 #1
0
ファイル: FloatRectangle.cs プロジェクト: bethge/GalaticChaos
 public bool Intersect(FloatRectangle rect)
 {
     if (
     ((mX <= rect.mX && rect.mX <= mX+mWidth) || (rect.mX <= mX && mX <= rect.mX+rect.mWidth))
     &&
     ((mY <= rect.mY && rect.mY <=mY+mHeight) || (rect.mY <= mY && mY <= rect.mY+rect.mHeight))
        )
         return true;
     return false;
 }
コード例 #2
0
        /// <summary>
        /// Jan's proposal, don't know if it is faster than mine
        /// </summary>
        public void CalcAllVisibilities(List<IVisible> playerView, List<IVisible> computerView)
        {
            GameLogic gameLogic = GameLogic.GetInstance();
            playerView.Clear();
            computerView.Clear();

            foreach (IGameObject unit in gameLogic.mObjectList)
            {
                if (unit is IVisible)
                    ((IVisible)unit).GetVisibility().Reset();
            }
            foreach (IGameObject unit in gameLogic.mObjectList)
            {
                if (unit is IVisible)
                {
                    IVisible visible = (IVisible)unit;
                    float radius = visible.LineOfSight + GlobalValues.GetInstance().mPlanetRadius[PlanetSize.Large];
                    FloatRectangle sightArea = new FloatRectangle(visible.Position, radius);
                    if (visible.Allegiance == Allegiance.Player)
                    {
                        List<IQuadNodeReferring> candidates = gameLogic.SuperFogManager.PlayerFogManager.GetCandidatesInReach(sightArea);
                        foreach (IQuadNodeReferring candidate in candidates)
                        {
                            PlayerFogManager.HandleSingleVisibility(visible, (IVisible) candidate, playerView);
                        }

                    }
                    else if (visible.Allegiance == Allegiance.Computer)
                    {
                        List<IQuadNodeReferring> candidates = gameLogic.SuperFogManager.PcFogManager.GetCandidatesInReach(sightArea);
                        foreach (IQuadNodeReferring candidate in candidates)
                        {
                            PcFogManager.HandleSingleVisibility(visible, (IVisible)candidate, computerView);
                        }
                    }
                }

            }
        }
コード例 #3
0
 public List<IQuadNodeReferring> GetCandidatesInReach(FloatRectangle area)
 {
     return Root.GetElemsFromCoveredNodes(area);
 }
コード例 #4
0
ファイル: QuadNode.cs プロジェクト: bethge/GalaticChaos
        public void Init()
        {
            mChild = new Dictionary<Orientation, QuadNode>();
            mChild.Add(Orientation.LeftUpper, null);
            mChild.Add(Orientation.RightUpper, null);
            mChild.Add(Orientation.LeftLower, null);
            mChild.Add(Orientation.RightLower, null);

            if (mParent == null)
                mDepth = 0;
            else
                mDepth = mParent.mDepth + 1;
            mUnits = new List<IQuadNodeReferring>();

            mArea = CalcArea();
        }
コード例 #5
0
ファイル: QuadNode.cs プロジェクト: bethge/GalaticChaos
 public List<IQuadNodeReferring> GetElemsFromCoveredNodes(FloatRectangle area)
 {
     if (IsLeaf())
     {
         return mUnits;
     }
     /*else*/
     {
         List<IQuadNodeReferring> result = new List<IQuadNodeReferring>();
         foreach (QuadNode child in mChild.Values)
         {
             if (area.Contains(child.mArea))
                 result.AddRange(child.GetRecursiveElems());
             else if (child.mArea.Intersect(area))
                 result.AddRange(child.GetElemsFromCoveredNodes(area));
         }
         return result;
     }
 }
コード例 #6
0
ファイル: FloatRectangle.cs プロジェクト: bethge/GalaticChaos
 public bool Contains(FloatRectangle area)
 {
     return (mX <= area.mX && mY <= area.mY && mX + mWidth >= area.mX + area.mWidth
             && mY + mHeight >= area.mY + area.mHeight);
 }