예제 #1
0
        public void AddingSameViewTwiceThrows()
        {
            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            IView myView = new MockView();

            region.Add(myView);

            try
            {
                region.Add(myView);
                Assert.Fail();
            }
            catch (InvalidOperationException ex)
            {
                Assert.AreEqual("View already exists in region.", ex.Message);
            }
            catch
            {
                Assert.Fail();
            }
        }
예제 #2
0
        public void ViewRemovedEventPassesTheViewRemovedInTheEventArgs()
        {
            object removedView = null;

            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            IView myView = new MockView();

            region.Views.CollectionChanged += (sender, e) =>
            {
                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    removedView = e.OldItems[0];
                }
            };
            region.Add(myView);
            Assert.IsNull(removedView);

            region.Remove(myView);

            Assert.AreSame(myView, removedView);
        }
예제 #3
0
        public void AddViewRaisesCollectionViewEvent()
        {
            bool viewAddedCalled = false;

            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            IView myView = new MockView();

            region.Views.CollectionChanged += (sender, e) =>
            {
                if (e.Action == NotifyCollectionChangedAction.Add)
                {
                    viewAddedCalled = true;
                }
            };

            object model = new object();

            Assert.IsFalse(viewAddedCalled);
            region.Add(myView);

            Assert.IsTrue(viewAddedCalled);
        }
예제 #4
0
    public virtual void Start()
    {
        //eventData = Instantiate(eventDataCopy);
        isResolving = false;
        isResolved  = false;

        if (ResourceManager.instance != null)
        {
            resManager = ResourceManager.instance;
        }
        if (EventManager.instance != null)
        {
            eventManager = EventManager.instance;
        }
        if (RegionManager.instance != null)
        {
            regionManager = RegionManager.instance;
        }
        if (TurnManager.instance != null)
        {
            turnManager = TurnManager.instance;
        }
        this.GetComponent <Button>().onClick.AddListener(Click);
        this.GetComponent <BindToRegion> ().regionOrigin = regionOrigin;
        turnManager.EndTurnEvent.AddListener(UpdateEvent);
        cityOrign       = regionOrigin.cityOrigin;
        tutorialManager = cityOrign.tutorialManager;
        if (turnsLeft > 0)
        {
            GetComponent <Image>().sprite = timerSprites[turnsLeft - 1];
        }

        isEventUiPanel = false;
    }
예제 #5
0
        public override HtmlRegion GetHtmlFromDb(RegionBase region, string pageName)
        {
            HtmlRegion htmlRegion = new HtmlRegion(region);

            if (pageCache == null)
            {
                var locations = from towns in context.ChosenTowns
                                where towns.town == pageName
                                select towns;
                pageCache = locations.FirstOrDefault();
            }

            var data = string.Empty;

            if (pageCache != null)
            {
                string wikiPurl = "http://en.wikipedia.org/wiki/" + pageName;
                switch (region.mappedObject)
                {
                // mapping from objects to database fields
                case "description": data = pageCache.cleaneddata + "<br /><a target='_blank' href='" + wikiPurl + "' rel='nofollow'><i class='fa fa-wikipedia-w' alt='more from wikipedia' title='more from wikipedia'></i></a>"; break;

                case "links": data = GetLinks(pageName); break;
                }
            }

            htmlRegion.data = new Html(data);
            return(htmlRegion);
        }
예제 #6
0
        public void ShowViewFiresViewShowedEvent()
        {
            bool viewActivated = false;

            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            IView myView = new MockView();

            region.ActiveViews.CollectionChanged += (o, e) =>
            {
                if (e.Action == NotifyCollectionChangedAction.Add && e.NewItems.Contains(myView))
                {
                    viewActivated = true;
                }
            };
            region.Add(myView);
            Assert.IsFalse(viewActivated);

            region.Activate(myView);

            Assert.IsTrue(viewActivated);
        }
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == RegionBase.RegionTag)
     {
         m_currentRegion = other.GetComponent <RegionBase>();
     }
 }
예제 #8
0
        public void RemoveViewFiresViewRemovedEvent()
        {
            bool viewRemoved = false;

            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            IView myView = new MockView();

            region.Views.CollectionChanged += (sender, e) =>
            {
                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    viewRemoved = true;
                }
            };

            region.Add(myView);
            Assert.IsFalse(viewRemoved);

            region.Remove(myView);

            Assert.IsTrue(viewRemoved);
        }
예제 #9
0
        public void CanAddContentToRegion()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);

            region.Add(new MockView());
            Assert.AreEqual(1, region.Views.Cast <object>().Count());
        }
예제 #10
0
        public void AddNamedViewWithNullOrEmptyStringNameThrows()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   myView  = new MockView();

            region.Add(myView, string.Empty);
        }
예제 #11
0
        public void GetViewWithNullOrEmptyStringThrows()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   myView  = new MockView();

            region.GetView(string.Empty);
        }
예제 #12
0
        public void GetViewReturnsNullWhenViewDoesNotExistInRegion()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   myView  = new MockView();

            Assert.IsNull(region.GetView("InexistentView"));
        }
예제 #13
0
        public void AddingDuplicateNamedViewThrows()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   myView  = new MockView();

            region.Add(myView, "MyView");
            region.Add(myView, "MyView");
        }
예제 #14
0
        public void RemoveNonexistViewNothingHappen()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   view    = new MockView();

            region.Remove(view);
            Assert.AreEqual(0, region.Views.Cast <object>().Count());
        }
예제 #15
0
        public void CanRemoveContentFromRegion()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   view    = new MockView();

            region.Add(view);
            region.Remove(view);
            Assert.AreEqual(0, region.Views.Cast <object>().Count());
        }
예제 #16
0
        public void ActivateNullViewThrows()
        {
            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            IView nonAddedView = new MockView();

            region.Activate(null);
        }
 private void OnTriggerExit(Collider other)
 {
     if (other.tag == RegionBase.RegionTag)
     {
         RegionBase otherRegion = other.GetComponent <RegionBase>();
         if (otherRegion == m_currentRegion)
         {
             m_currentRegion = null;
         }
     }
 }
예제 #18
0
        public void GetViewReturnsNullAfterRemovingViewFromRegion()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   myView  = new MockView();

            region.Add(myView, "MyView");
            region.Remove(myView);

            Assert.IsNull(region.GetView("MyView"));
        }
예제 #19
0
        public void AddNamedViewIsAlsoListedInViewsCollection()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   myView  = new MockView();

            region.Add(myView, "MyView");

            Assert.AreEqual(1, region.Views.Cast <object>().Count());
            Assert.AreSame(myView, region.Views.Cast <object>().ElementAt(0));
        }
예제 #20
0
        public void CanAddAndRetrieveNamedViewInstance()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   myView  = new MockView();

            region.Add(myView, "MyView");
            object returnedView = region.GetView("MyView");

            Assert.IsNotNull(returnedView);
            Assert.AreSame(returnedView, myView);
        }
예제 #21
0
        public void ChangingNameOnceItIsSetThrows()
        {
            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;

            region.Name = "MyRegion";

            region.Name = "ChangedRegionName";
        }
예제 #22
0
        public void CreatingNewScopesAsksTheRegionManagerForNewInstance()
        {
            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            var myView = new MockView();

            region.Add(myView, "MyView", true);

            Assert.IsTrue(regionManager.CreateRegionManagerCalled);
        }
예제 #23
0
        public void AddViewReturnsNewRegionManager()
        {
            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            var myView = new MockView();

            var returnedRegionManager = region.Add(myView, "MyView", true);

            Assert.AreNotSame(regionManager, returnedRegionManager);
        }
예제 #24
0
        public void AddingNonDependencyObjectToRegionDoesNotThrow()
        {
            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            var myView = new MockView();

            region.Add(myView);

            Assert.AreEqual(1, region.Views.Cast <object>().Count());
        }
예제 #25
0
        public override GalleryRegion GetGalleryFromDb(RegionBase region, string pageName, string rootPath)
        {
            Gallery       g             = new Gallery();
            GalleryRegion galleryRegion = new GalleryRegion(region);

            switch (region.mappedObject)
            {
            case "thumbImages": g = GetThumbGallery(pageName, rootPath); break;
            }

            galleryRegion.data = g;
            return(galleryRegion);
        }
예제 #26
0
 /// <summary>
 /// Removes a given WorldObject from the region it belongs to
 /// </summary>
 /// <param name="b"></param>
 public static void RemoveObject(WorldObjectBase b)
 {
     if (b == null)
     {
         return;
     }
     lock (currentRegions) {
         RegionBase ba = GetRegion(b.worldX, b.worldY);
         if (ba != null && ba.GetWorldObjects().Contains(b))
         {
             ba.GetWorldObjects().Remove(b);
         }
     }
 }
예제 #27
0
        public void RegionExposesCollectionOfContainedViews()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   view    = new MockView();

            region.Add(view);

            var views = region.Views;

            Assert.IsNotNull(views);
            Assert.AreEqual(1, views.Cast <object>().Count());
            Assert.AreSame(view, views.Cast <object>().ElementAt(0));
        }
예제 #28
0
        public void RemovingViewAlsoRemovesItFromActiveViews()
        {
            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            IView myView = new MockView();

            region.Add(myView);
            region.Activate(myView);
            Assert.IsTrue(region.ActiveViews.Contains(myView));

            region.Remove(myView);

            Assert.IsFalse(region.ActiveViews.Contains(myView));
        }
예제 #29
0
        /// <summary>
        /// Loads the region at the region coordinates given and adds it to the world stack
        /// Ignores if the region is already loaded
        /// </summary>
        /// <param name="rx"></param>
        /// <param name="ry"></param>
        private static void LoadRegion(int rx, int ry)
        {
            RegionTag reg = new RegionTag(rx, ry);

            if (currentRegions.ContainsKey(reg))
            {
                return;
            }
            RegionBase s = Save.SaveData.LoadRegion(reg);

            if (s == null)
            {
                s = new RegionBase(reg);
            }
            s.Load();
            lock (currentRegions)
                currentRegions.Add(reg, s);
        }
예제 #30
0
    void Start()
    {
        regionOrigin = cityOrigin.regionOrigin;
        if (RegionManager.instance != null)
        {
            regionManager = RegionManager.instance;
        }
        if (ResourceManager.instance != null)
        {
            resourceManager = ResourceManager.instance;
        }
        foreach (var region in regionManager.regionList)
        {
            //GameObject dropdownOptionPrefab = Instantiate();
        }
        if (TurnManager.instance != null)
        {
            turnManager = TurnManager.instance;
        }
        tutorialManager = cityOrigin.tutorialManager;
        turnManager.EndTurnEvent.AddListener(SetUIText);

        regionListCopy = new List <RegionBase>(regionManager.regionList);
        regionListCopy.Remove(regionOrigin);

        regionOriginName.text = regionOrigin.cityOrigin.name;
        foreach (var item in regionListCopy)
        {
            cityName.Add(item.cityOrigin.name);
        }


        for (int i = 0; i <= regionListCopy.Count - 1; i++)
        {
            transferFields[i].transferPanel           = this;
            transferFields[i].cityToTransferName.text = regionListCopy[i].cityOrigin.name;
            transferFields[i].cityTarget = regionListCopy[i].cityOrigin;
        }

        dropdown.AddOptions(cityName);
        SetUIText();
    }