Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="taxiPathNode"></param>
        /// <returns></returns>
        internal static TaxiPathNode CreatInstance(BaseTaxiNode fromTaxiNodeId, Dictionary <long, List <BaseTaxiPath[]> > toTaxiPathNode)
        {
            TaxiPathNode returnTaxiPathNode = new TaxiPathNode();

            returnTaxiPathNode.m_FromTaxiNode = fromTaxiNodeId;
            returnTaxiPathNode.m_TaxiPathNode = toTaxiPathNode;

            return(returnTaxiPathNode);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="taxiNodeId"></param>
        /// <returns></returns>
        public TaxiPathNode GetTaxiPathNode(long fromTaxiNodeId)
        {
            if (m_TaxiPathNodes == null)
            {
                if (GenerateTaxiPathNode() == false)
                {
                    Debug.WriteLine("BaseTaxiPathNodeManager.GetTaxiPathNode(...) - GenerateTaxiPathNode(...) == false error!");

                    return(null);
                }
            }

            TaxiPathNode returnTaxiPathNode = null;

            if (m_TaxiPathNodes.TryGetValue(fromTaxiNodeId, out returnTaxiPathNode) == false)
            {
                return(null);
            }

            return(returnTaxiPathNode);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="taxiPathNode"></param>
        /// <returns></returns>
        internal static TaxiPathNode CreatInstance( BaseTaxiNode fromTaxiNodeId, Dictionary<long, List<BaseTaxiPath[]>> toTaxiPathNode )
        {
            TaxiPathNode returnTaxiPathNode = new TaxiPathNode();

            returnTaxiPathNode.m_FromTaxiNode = fromTaxiNodeId;
            returnTaxiPathNode.m_TaxiPathNode = toTaxiPathNode;

            return returnTaxiPathNode;
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        public bool GenerateTaxiPathNode()
        {
            if (m_TaxiPathNodes != null)
            {
                return(true);
            }

            if (m_TaxiNodes.Count <= 0)
            {
                return(false);
            }

            if (m_TaxiPaths.Count <= 0)
            {
                return(false);
            }

            bool bIsOK = true;

            m_LockTaxiPathNodes.EnterWriteLock();
            {
                do
                {
                    // 在多线程内防止多次调用GenerateTaxiPathNode(...),再次检测可能已经完成了GenerateTaxiPathNode(...)的调用
                    if (m_TaxiPathNodes != null)
                    {
                        break;
                    }

                    BaseTaxiNode[] taxiNodeArray = TaxiNodeToArray();
                    if (taxiNodeArray == null)
                    {
                        bIsOK = false;
                        break;
                    }

                    BaseTaxiPath[] baseTaxiPathArray = TaxiPathToArray();
                    if (baseTaxiPathArray == null)
                    {
                        bIsOK = false;
                        break;
                    }

                    Dictionary <long, TaxiPathNode> tempTaxiPathNodes = new Dictionary <long, TaxiPathNode>();

                    for (int iIndex = 0; iIndex < taxiNodeArray.Length; iIndex++)
                    {
                        BaseTaxiNode taxiNode = taxiNodeArray[iIndex];

                        List <BaseTaxiPath> nullTaxiPathList = new List <BaseTaxiPath>();
                        Dictionary <long, List <BaseTaxiPath[]> > toTaxiNodeDictionary = new Dictionary <long, List <BaseTaxiPath[]> >();

                        GetTaxiPathNodeInfo(taxiNode.TaxiNodeId, baseTaxiPathArray, ref nullTaxiPathList, ref toTaxiNodeDictionary);

                        tempTaxiPathNodes.Add(taxiNode.TaxiNodeId, TaxiPathNode.CreatInstance(taxiNode, toTaxiNodeDictionary));
                    }

                    m_TaxiPathNodes = tempTaxiPathNodes;
                } while (false);
            }
            m_LockTaxiPathNodes.ExitWriteLock();

            return(bIsOK);
        }