예제 #1
0
 public void AddBridge(List <string> gates, List <string> regions)
 {
     if (gates.Count == 0 || regions.Count == 0)
     {
         throw new InvalidCastException("未找到有效的关联项。");
     }
     lock (Bridges)
     {
         foreach (var gate in gates)
         {
             var g = Bridges.FirstOrDefault(_ => _.ID == gate);
             if (g == null)
             {
                 g = new Bridge()
                 {
                     ID = gate, Links = new List <string>()
                 };
                 Bridges.Add(g);
             }
             else
             {
                 g.UpdateTime = DateTime.Now;
             }
             foreach (var reg in regions)
             {
                 if (g.Links.All(_ => _ != reg))
                 {
                     g.Links.Add(reg);
                 }
             }
             g.Links = g.Links.OrderBy(_ => _).ToList();
         }
     }
 }
예제 #2
0
파일: World.cs 프로젝트: ktj007/mmo
 public void Draw(Graphics g)
 {
     g.SmoothingMode = SmoothingMode.HighQuality;
     Bridges.ForEach(e => e.Draw(g));
     Cities.ForEach(e => e.Draw(g));
     Players.ForEach(e => e.Draw(g));
 }
        /// <summary>
        /// 获取可用的bridge
        /// </summary>
        /// <param name="parentPanel"></param>
        /// <param name="panelName"></param>
        /// <returns></returns>
        protected Bridge GetBridgeClamp(IUIPanel parentPanel, string panelName, int index)
        {
            Bridge     bridge     = null;
            var        parentName = parentPanel == null ? "" : parentPanel.Name;
            var        mayInfos   = Bridges.FindAll(x => x.outNode == panelName && (x.index == index || index == -1)); //所有可能的
            var        baseInfos  = mayInfos.FindAll(x => x.inNode == parentName);                                     //所有父级名相同的
            BridgeInfo?bridgeInfo = null;

            if (baseInfos.Count > 0)
            {
                bridgeInfo = baseInfos[0];
            }
            else
            {
                var usefulInfos = mayInfos.FindAll(x => string.IsNullOrEmpty(x.inNode));
                if (usefulInfos.Count > 0)
                {
                    bridgeInfo = usefulInfos[0];
                }
            }

            if (bridgeInfo == null)
            {
                var show = new ShowMode();
                var info = new BridgeInfo(parentName, panelName, show, null, 0);
                bridge = bridgePool.Allocate(info, parentPanel);
            }
            else
            {
                bridge = bridgePool.Allocate((BridgeInfo)bridgeInfo, parentPanel);
            }
            return(bridge);
        }
예제 #4
0
        public BindingSource <TSource, TTarget> AddFuncBinding(Expression <Func <TSource, object> > sourceGetter, Expression <Func <TTarget, object> > targetProperty)
        {
            PropertyInfo[] targetInfo = PropertyChainFromExp.Get(targetProperty.Body);
            Bridges.Add(new FuncBindingBridge <TSource>(this, sourceGetter, targetInfo));

            return(this);
        }
예제 #5
0
파일: Chunk.cs 프로젝트: JMounier/Aegina
 public Chunk(int id, GameObject prefab, Bridges bridge)
     : base(id, 1, prefab)
 {
     this.bridge = bridge;
     this.isPrisme = false;
     this.step = 0;
     this.posSave = 0;
 }
예제 #6
0
        public BindingSource <TSource, TTarget> AddBinding(Expression <Func <TSource, object> > sourceProperty, Expression <Func <TTarget, object> > targetProperty, IValueConverter converter, object converterParameter, System.Globalization.CultureInfo converterCulture)
        {
            PropertyInfo sourceInfo = PropertyUtil.GetPropertyInfo(sourceProperty);

            PropertyInfo[] targetInfo = PropertyChainFromExp.Get(targetProperty.Body);
            Bridges.Add(new BindingBridge(this, sourceInfo, targetInfo, converter, converterParameter, converterCulture));

            return(this);
        }
        /// <summary>
        /// 互斥面板自动隐藏
        /// </summary>
        /// <param name="childPanel"></param>
        /// <param name=""></param>
        /// <param name="bridge"></param>
        protected void TryHandleMutexPanels(IUIPanel childPanel, BridgeInfo bridge)
        {
            if (bridge.showModel.mutex != MutexRule.NoMutex)
            {
                if (bridge.showModel.mutex == MutexRule.SameParentAndLayer)
                {
                    var mayBridges = Bridges.FindAll(x => x.inNode == bridge.inNode);

                    foreach (var bg in mayBridges)
                    {
                        if (bg.showModel.mutex != MutexRule.SameParentAndLayer)
                        {
                            continue;
                        }

                        var mayPanels = createdPanels.FindAll(x =>
                                                              x.Name == bg.outNode &&
                                                              x.UType.layer == childPanel.UType.layer &&
                                                              x != childPanel &&
                                                              !IsChildOfPanel(childPanel, x));

                        foreach (var mayPanel in mayPanels)
                        {
                            if (mayPanel != null && mayPanel.IsShowing)
                            {
                                if (mayPanel.UType.layerIndex > childPanel.UType.layerIndex)
                                {
                                    HidePanelInteral(mayPanel, childPanel);
                                }
                                else
                                {
                                    HidePanelInteral(childPanel, mayPanel);
                                }
                            }
                        }
                    }
                }
                else if (bridge.showModel.mutex == MutexRule.SameLayer)
                {
                    var mayPanels = createdPanels.FindAll(x => x.UType.layer == childPanel.UType.layer && x != childPanel && !IsChildOfPanel(childPanel, x));
                    foreach (var mayPanel in mayPanels)
                    {
                        if (mayPanel != null && mayPanel.IsShowing)
                        {
                            if (mayPanel.UType.layerIndex > childPanel.UType.layerIndex)
                            {
                                HidePanelInteral(mayPanel, childPanel);
                            }
                            else
                            {
                                HidePanelInteral(childPanel, mayPanel);
                            }
                        }
                    }
                }
            }
        }
예제 #8
0
파일: Chunk.cs 프로젝트: JMounier/Aegina
 // Constructor
 public Chunk()
     : base()
 {
     this.bridge = Bridges.None;
     this.b = BiomeDatabase.Default;
     this.isPrisme = false;
     this.step = 0;
     this.posSave = 0;
 }
예제 #9
0
        public BindingSource <TSource, TTarget> AddBinding(Expression <Func <TSource, object> > sourceProperty, Expression <Func <TTarget, object> > targetProperty, IValueConverter converter)
        {
            PropertyInfo sourceInfo = PropertyUtil.GetPropertyInfo(sourceProperty);

            PropertyInfo[] targetInfo = PropertyChainFromExp.Get(targetProperty.Body);
            Bridges.Add(new BindingBridge(this, sourceInfo, targetInfo, converter));

            return(this);
        }
예제 #10
0
파일: Chunk.cs 프로젝트: JMounier/Aegina
 public Chunk(Chunk chunk)
     : base(chunk)
 {
     this.bridge = chunk.bridge;
     this.b = chunk.B;
     this.isPrisme = chunk.IsPrisme;
     this.step = 0;
     this.posSave = 0;
 }
예제 #11
0
파일: World.cs 프로젝트: ktj007/mmo
        private void Generate()
        {
            var random = new Random();

            Width  = random.Next(1000) + 4000;
            Height = random.Next(1000) + 3000;

            RegionInterval = (int)Math.Sqrt(Width * Height / (double)(random.Next(100) + 200));
            XCount         = Width / RegionInterval;
            YCount         = Height / RegionInterval;
            Width          = XCount * RegionInterval;
            Height         = YCount * RegionInterval;

            var margin       = RegionInterval / 8;
            var realInterval = RegionInterval - margin * 2;

            for (var x = 0; x < XCount; x++)
            {
                for (var y = 0; y < YCount; y++)
                {
                    var cityX = x * RegionInterval + random.Next(realInterval) + margin;
                    var cityY = y * RegionInterval + random.Next(realInterval) + margin;
                    Cities.Add(new City(cityX, cityY));
                }
            }

            var isolatedCities = new HashSet <City>(Cities);

            while (isolatedCities.Count > 0)
            {
                foreach (var fromCity in Cities)
                {
                    if (!isolatedCities.Contains(fromCity))
                    {
                        continue;
                    }

                    var cityBridges = random.Next((int)Math.Pow(2, 8));
                    for (var bridgeType = 0; bridgeType < 8; bridgeType++)
                    {
                        if ((cityBridges & (1 << bridgeType)) != 0)
                        {
                            var toCityIndex = GetAdjancyCity(Cities.IndexOf(fromCity), bridgeType);
                            if (toCityIndex > 0)
                            {
                                var toCity = Cities[toCityIndex];
                                Bridges.Add(new Bridge(fromCity, toCity));

                                isolatedCities.Remove(fromCity);
                                isolatedCities.Remove(toCity);
                            }
                        }
                    }
                }
            }
        }
예제 #12
0
        private void CheckForBridgeExceptions()
        {
            if (Bridges == null)
            {
                throw new ArgumentNullException("No bridges found.");
            }

            if (Bridges.GroupBy(x => x.Location).Any(g => g.Count() > 1))
            {
                throw new ArgumentException("Multiple bridges in the same location.");
            }
        }
        ///  <summary>
        /// 自动打开子面板
        /// </summary>
        /// <param name="content"></param>
        /// <param name="parentPanel"></param>
        protected void TryAutoOpen(Transform content, IUIPanel parentPanel = null)
        {
            var panelName   = parentPanel == null ? "" : parentPanel.Name;
            var autoBridges = Bridges.FindAll(x => CompareName(x.inNode, panelName) && x.showModel.auto);

            if (autoBridges != null)
            {
                foreach (var autoBridge in autoBridges)
                {
                    InstencePanel(parentPanel, autoBridge.outNode, -1, content);
                }
            }
        }
예제 #14
0
        public BindingObjectSource <TTarget> AddBinding(string sourcePropertyName, Expression <Func <TTarget, object> > targetProperty)
        {
            PropertyInfo sourceInfo = DataSourceObject.GetType().GetProperty(sourcePropertyName);

            if (sourceInfo == null)
            {
                throw new ArgumentException(String.Format("Property {0} not found.", sourcePropertyName));
            }
            PropertyInfo[] targetInfo = PropertyChainFromExp.Get(targetProperty.Body);
            Bridges.Add(new BindingBridge(this, sourceInfo, targetInfo));

            return(this);
        }
예제 #15
0
        public BindingObjectSource <TTarget> AddBinding(string sourcePropertyName, Expression <Func <TTarget, object> > targetProperty, IValueConverter converter, object converterParameter, System.Globalization.CultureInfo converterCulture)
        {
            PropertyInfo sourceInfo = DataSourceObject.GetType().GetProperty(sourcePropertyName);

            if (sourceInfo == null)
            {
                throw new ArgumentException(String.Format("Property {0} not found.", sourcePropertyName));
            }

            PropertyInfo[] targetInfo = PropertyChainFromExp.Get(targetProperty.Body);
            Bridges.Add(new BindingBridge(this, sourceInfo, targetInfo, converter, converterParameter, converterCulture));

            return(this);
        }
예제 #16
0
        private void TraverseBridges()
        {
            //Traverse the bridges in numberical order (1 being the first one the hikers run into)
            foreach (Bridge bridge in Bridges.OrderBy(x => x.Location))
            {
                Traverse(bridge);
            }

            this.IsFinished = true;

            foreach (var observer in _observers)
            {
                observer.NotifyAdventureFinished();
            }
        }
예제 #17
0
        public TargetObj Get <T>(string id) where T : TargetObj
        {
            Type type = typeof(T);

            switch (type.Name)
            {
            case nameof(Bridge):
                return(Bridges.FirstOrDefault(_ => _.ID == id));

            case nameof(GateInfo):
                return(Gates.FirstOrDefault(_ => _.ID == id));

            case nameof(FenceRegionsInfo):
                return(Regions.FirstOrDefault(_ => _.ID == id));
            }
            return(null);
        }
예제 #18
0
        public GateInfo[] GetBridgeFromRegion(string id)
        {
            List <GateInfo> list    = new List <GateInfo>();
            var             gateIds = Bridges?.Where(_ => _.Links.Any(l => l == id)).Select(_ => _.ID);

            if (Gates != null && gateIds.Count() > 0)
            {
                foreach (var gate in gateIds)
                {
                    var reg = Gates.FirstOrDefault(_ => _.ID == gate);
                    if (reg != null)
                    {
                        list.Add(reg);
                    }
                }
            }
            return(list.ToArray());
        }
예제 #19
0
        public FenceRegionsInfo[] GetBridgeFromGate(string id)
        {
            var regions = Bridges?.FirstOrDefault(_ => _.ID == id);
            List <FenceRegionsInfo> list = new List <FenceRegionsInfo>();

            if (regions != null && regions.Links != null)
            {
                foreach (var r in regions.Links)
                {
                    var reg = Regions?.FirstOrDefault(_ => _.ID == r);
                    if (reg != null)
                    {
                        list.Add(reg);
                    }
                }
            }
            return(list.ToArray());
        }
예제 #20
0
    IEnumerator DestroyBridges(Bridges B, float delay)
    {
        yield return(new WaitForSeconds(delay));

        if (B.bridgeUp != null)
        {
            Destroy(B.bridgeUp);
        }
        if (B.bridgeRight != null)
        {
            Destroy(B.bridgeRight);
        }
        if (B.bridgeDown != null)
        {
            Destroy(B.bridgeDown);
        }
        if (B.bridgeLeft != null)
        {
            Destroy(B.bridgeLeft);
        }
    }
예제 #21
0
        protected async void ExecuteScanBridgesAsync()
        {
            IsScanningBridges = true;
            ScanBridgesCommand.RaiseCanExecuteChanged();

            var rv = await _bridgeFinder.GetBridgesAsync(_connection);

            Bridges.Clear();
            _firstBridgeViewModel = null;
            if (!rv.IsError())
            {
                foreach (Bridge bridge in ((HueObjectCollectionBase <Bridge>)rv).Dictionary.Values)
                {
                    SettingsInitialiser.InitialiseScenes(_settings, bridge);
                    var bridgeViewModel = new BridgeViewModel(bridge, _settings, _commandFactory, _messageHandler);

                    if (_firstBridgeViewModel == null)
                    {
                        _firstBridgeViewModel = new ConnectedBridgeViewModel(bridge, _settings, _commandFactory, _messageHandler);
                        RaisePropertyChanged("FirstBridge");
                    }

                    Bridges.Add(bridgeViewModel);

                    if (_settings.Bridge.Value != null && _settings.Bridge.Value == bridge.InternalIPAddress)
                    {
                        SelectedBridge = bridgeViewModel;
                        //SelectedBridge.ConnectAsync().ContinueWith(o => RaisePropertyChanged("SelectedBridge"));
                    }
                }
            }
            else
            {
                Bridges = new ObservableCollection <BridgeViewModel>();
            }

            IsScanningBridges = false;
            ScanBridgesCommand.RaiseCanExecuteChanged();
        }
예제 #22
0
        private static void BuildBridges(int value, List <Component> remainingList, List <Component> existingList)
        {
            if (existingList == null)
            {
                existingList = new List <Component>();
            }

            var listToLoop = remainingList.Where(x => x.Contains(value));

            if (listToLoop.Count() == 0)
            {
                Bridges.Add(existingList);
            }

            foreach (var item in listToLoop)
            {
                var newList = new List <Component>(remainingList.Where(x => x != item));

                var sendList = new List <Component>(existingList);
                sendList.Add(item);

                BuildBridges(item.Next(value), newList, sendList);
            }
        }
예제 #23
0
        ///  <summary>
        /// 自动打开子面板
        /// </summary>
        /// <param name="content"></param>
        /// <param name="parentPanel"></param>
        protected void TryAutoOpen(IUIPanel parentPanel = null)
        {
            var panelName   = parentPanel == null ? "" : parentPanel.Name;
            var autoBridges = Bridges.FindAll(x => CompareName(x.inNode, panelName) && x.showModel.auto);

            if (autoBridges != null)
            {
                foreach (var autoBridge in autoBridges)
                {
                    panelName = autoBridge.outNode;

                    UIInfoBase uiNode;

                    Nodes.TryGetValue(panelName, out uiNode);

                    if (uiNode == null)
                    {
                        Debug.LogError("无配制信息:" + panelName);
                        continue;
                    }

                    Bridge bridge;
                    if (!TryOpenOldPanel(panelName, uiNode, parentPanel, out bridge))
                    {
                        if (CreateInfoAndBridge(panelName, parentPanel, -1, uiNode, out bridge))
                        {
                            CreatePanel(uiNode, bridge, parentPanel);
                        }
                        else
                        {
                            Debug.LogError("找不到信息:" + panelName);
                        }
                    }
                }
            }
        }
예제 #24
0
 public void RemoveBridge(string id, string regId)
 {
     Bridges?.Where(b => b.ID == id).ToList().ForEach(_ => _.Links?.RemoveAll(r => r == regId));
     Bridges?.RemoveAll(_ => _.Links == null || _.Links.Count == 0);//删除空的关联列表
 }
    public void ContinueButtonClick()
    {
        // After the hull is selected, move to the Essential Components canvas.
        // Note that the hull defaults to the first selection, in case the user
        // tries to hit the continue button before selecting a hull.
        SetCanvas(false, hullCanvas);
        SetCanvas(true, essentialComponentCanvas);

        // Set starship hull here
        switch (hullIndex)
        {
            case Hulls.JERICHO_PILGRIM:
                starship.hull = new JerichoPilgrim();
                break;
            case Hulls.VAGABOND_MERCHANT:
                starship.hull = new VagabondMerchant();
                break;
            case Hulls.HAZEROTH_PRIVATEER:
                starship.hull = new HazerothPrivateer();
                break;
            case Hulls.HAVOC_MERCHANT:
                starship.hull = new HavocMerchant();
                break;
            case Hulls.SWORD_FRIGATE:
                starship.hull = new SwordFrigate();
                break;
            case Hulls.TEMPEST_STRIKE:
                starship.hull = new TempestStrike();
                break;
            case Hulls.DAUNTLESS_LIGHT:
                starship.hull = new DauntlessLight();
                break;
            case Hulls.LUNAR_CRUISER:
                starship.hull = new LunarCruiser();
                break;
        }
        // Create Essential Components that depend on the class of hull.
        bridges = new Bridges(starship.hull.GetHullType());
        lifeSustainers = new LifeSustainers(starship.hull.GetHullType());
        allCrewQuarters = new AllCrewQuarters(starship.hull.GetHullType());

        // Set the text fields to display the first component instead of dummy text.
        DisplayComponent();
        dynamicComponentText.text = starship.DisplayAllComponents();
    }
예제 #26
0
    /// <summary>
    /// Retourne un chunk aleatoire. (Une copie)
    /// </summary>
    public static Chunk RandChunk(Bridges bridge, System.Random rand)
    {
        List<Chunk> chunks = new List<Chunk>();
        foreach (Chunk c in Chunks)
            if (c.Bridge == bridge)
                chunks.Add(c);

        return new Chunk(chunks[rand.Next(chunks.Count)]);
    }
예제 #27
0
 public void RemoveRegion(string id)
 {
     Regions?.RemoveAll(_ => _.ID == id);
     Bridges?.ForEach(_ => _.Links?.RemoveAll(r => r == id));
     Bridges?.RemoveAll(_ => _.Links == null || _.Links.Count == 0);
 }
예제 #28
0
 public void RemoveGate(string id)
 {
     Gates?.RemoveAll(_ => _.ID == id);
     Bridges?.RemoveAll(_ => _.ID == id);
 }
예제 #29
0
 public Part2()
 {
     componentRepository = new ComponentRepository();
     bridges             = new Bridges();
 }
예제 #30
0
    /// <summary>
    /// Creates a new grid
    /// </summary>
    public void InstantiateNewGrid()
    {
        m_PlayerStartNodes = new TileNode[PlayersManager.s_Instance.Players.Count];
        m_NodeBridges      = new Bridges[m_GridXSize + 2, m_GridYSize + 2];
        m_NodeGrid         = new TileNode[m_GridXSize + 2, m_GridYSize + 2];
        for (int i = 0; i < m_GridXSize + 2; i++)
        {
            for (int j = 0; j < m_GridYSize + 2; j++)
            {
                TileNode  newNode   = new TileNode();
                Bridges   newbridge = new Bridges();
                TileBools bools     = new TileBools();
                newNode.IsFilled       = false;
                newNode.DebugModus     = false;
                newNode.IsDestructable = true;
                if (i == 0 || i == m_GridXSize + 1 || j == 0 || j == m_GridYSize + 1)
                {
                    newNode.IsEdgeStone    = true;
                    newNode.IsDestructable = false;
                    newNode.TileObject     = null;
                }
                else
                {
                    GameObject    tileObj     = Instantiate(m_NodeObjectPrefab, new Vector3(i, j, 0), Quaternion.identity, transform);
                    ClickedOnTile TileClicker = tileObj.GetComponent <ClickedOnTile>();
                    TileClicker.TilePosX = i;
                    TileClicker.TilePosY = j;
                    newNode.TileObject   = tileObj;
                }

                if (i == 1 && j == m_GridYSize)
                {
                    newNode.IsFilled       = true;
                    newNode.IsDestructable = false;
                    bools.Right            = true;
                    bools.Down             = true;
                    bools.Middle           = true;
                    bools.Middle           = false;
                    newNode.IsStartPoint   = true;
                    m_PlayerStartNodes[0]  = newNode;
                }
                if (i == m_GridXSize && j == 1)
                {
                    newNode.IsFilled       = true;
                    newNode.IsDestructable = false;
                    bools.Left             = true;
                    bools.Up              = true;
                    bools.Middle          = false;
                    newNode.IsFilled      = true;
                    newNode.IsStartPoint  = true;
                    m_PlayerStartNodes[1] = newNode;
                }
                if (i == 1 && j == 1 && PlayersManager.s_Instance.Players.Count >= 3)
                {
                    newNode.IsFilled       = true;
                    newNode.IsDestructable = false;
                    bools.Right            = true;
                    bools.Up              = true;
                    bools.Middle          = false;
                    newNode.IsFilled      = true;
                    newNode.IsStartPoint  = true;
                    m_PlayerStartNodes[2] = newNode;
                    Players[2].SetActive(true);
                }
                if (i == m_GridXSize && j == m_GridYSize && PlayersManager.s_Instance.Players.Count >= 4)
                {
                    newNode.IsFilled       = true;
                    newNode.IsDestructable = false;
                    bools.Left             = true;
                    bools.Down             = true;
                    bools.Middle           = false;
                    newNode.IsFilled       = true;
                    newNode.IsStartPoint   = true;
                    m_PlayerStartNodes[3]  = newNode;
                    Players[3].SetActive(true);
                }
                else if (i == (m_GridXSize + 1) / 2 && j == (m_GridYSize + 1) / 2)
                {
                    newNode.IsFilled       = true;
                    newNode.IsDestructable = false;
                    bools.Left             = true;
                    bools.Up           = true;
                    bools.Middle       = false;
                    bools.Down         = true;
                    bools.Right        = true;
                    newNode.IsFilled   = true;
                    newNode.IsEndpoint = true;
                }
                newNode.Bools = bools;
                newNode.UpdateArt();
                m_NodeGrid[i, j]    = newNode;
                m_NodeBridges[i, j] = newbridge;
            }
        }
    }