Esempio n. 1
0
        public void chooses_most_specific_adapter()
        {
            var specificRegionAdapterMock = new Mock <IRegionAdapter>();

            specificRegionAdapterMock
            .SetupGet(adapter => adapter.SupportedType)
            .Returns(typeof(FrameworkElement));
            specificRegionAdapterMock
            .Setup(adapter => adapter.AdaptView(_view))
            .Returns(_region);

            // no invocation expected
            var generalRegionAdapterMock = new Mock <IRegionAdapter>(MockBehavior.Strict);

            generalRegionAdapterMock
            .SetupGet(adapter => adapter.SupportedType)
            .Returns(typeof(DependencyObject));

            var regionFactory =
                new RegionFactory(new[]
            {
                generalRegionAdapterMock.Object,
                specificRegionAdapterMock.Object
            });
            var createdRegion = regionFactory.CreateRegion(_view);

            Assert.AreSame(_region, createdRegion);
        }
Esempio n. 2
0
        public GameSession()
        {
            CurrentWorld  = new World();
            CurrentPlayer = new Player();

            World.Regions region;
            foreach (string regString in Enum.GetNames(typeof(World.Regions)))
            {
                Enum.TryParse(regString, out region);
                CurrentWorld.AddRegion(region, RegionFactory.CreateRegion(region));
            }
            CurrentRegion   = CurrentWorld.GetRegion(World.Regions.HollowMouth);
            CurrentLocation = CurrentRegion.LocationAt(0, 0);
        }
Esempio n. 3
0
        public void chooses_an_adapter_supporting_supertype()
        {
            var generalRegionAdapterMock = new Mock <IRegionAdapter>();

            generalRegionAdapterMock
            .SetupGet(adapter => adapter.SupportedType)
            .Returns(typeof(DependencyObject));
            generalRegionAdapterMock
            .Setup(adapter => adapter.AdaptView(_view))
            .Returns(_region);

            var regionFactory = new RegionFactory(new[] { generalRegionAdapterMock.Object });
            var createdRegion = regionFactory.CreateRegion(_view);

            Assert.AreSame(_region, createdRegion);
        }
Esempio n. 4
0
        public void when_matching_adapter_exists_a_region_is_created()
        {
            var regionAdapterMock = new Mock <IRegionAdapter>();

            regionAdapterMock
            .SetupGet(adapter => adapter.SupportedType)
            .Returns(typeof(FrameworkElement));
            regionAdapterMock
            .Setup(adapter => adapter.AdaptView(_view))
            .Returns(_region);

            var regionFactory = new RegionFactory(new[] { regionAdapterMock.Object });
            var createdRegion = regionFactory.CreateRegion(_view);

            Assert.AreSame(_region, createdRegion);
        }
Esempio n. 5
0
        public void BuildNormal()
        {
            string regionGuid    = objective["Guid"].ToString();
            string objectiveGuid = objective["ObjectiveGuid"].ToString();
            float  radius        = objective.ContainsKey("Radius") ? (float)objective["Radius"] : (float)0;

            RegionGameLogic regionLogic = RegionFactory.CreateRegion(this.parent, regionGuid, objectiveGuid, this.name, regionDefId, radius);
            GameObject      regionGo    = regionLogic.gameObject;

            if (position != null)
            {
                SetPosition(regionGo, position);
            }
            if (rotation != null)
            {
                SetRotation(regionGo, rotation);
            }

            regionLogic.Regenerate();
        }
        public override void Run(RunPayload payload)
        {
            if (!state.GetBool("Chunk_Withdraw_Exists"))
            {
                Main.Logger.Log($"[AddWithdrawChunk] Adding encounter structure");

                string playerSpawnerGuid = GetPlayerSpawnGuid();

                EmptyCustomChunkGameLogic emptyCustomChunk = ChunkFactory.CreateEmptyCustomChunk("Chunk_Withdraw");
                GameObject escapeChunkGo = emptyCustomChunk.gameObject;
                emptyCustomChunk.encounterObjectGuid = chunkGuid;
                emptyCustomChunk.startingStatus      = EncounterObjectStatus.Inactive;
                emptyCustomChunk.notes = debugDescription;

                RegionFactory.CreateRegion(escapeChunkGo, regionGameLogicGuid, objectiveGuid, "Region_Withdraw", "regionDef_EvacZone");

                bool useDropship = true;
                OccupyRegionObjective occupyRegionObjective = ObjectiveFactory.CreateOccupyRegionObjective(
                    objectiveGuid,
                    escapeChunkGo,
                    null,
                    playerSpawnerGuid,
                    regionGameLogicGuid,
                    "Withdraw",
                    "Get to the Evac Zone",
                    $"with {ProgressFormat.UNITS_OCCUPYING_SO_FAR}/{ProgressFormat.NUMBER_OF_UNITS_TO_OCCUPY} unit(s)",
                    "The objective for the player to withdraw and complete, or withdraw, the mission",
                    0,
                    0,
                    useDropship,
                    new string[] { MissionControl.Instance.IsCustomContractType ? "Player 1" : "player_unit" },
                    new string[] { "opposing_unit" }
                    );

                ObjectiveFactory.CreateContractObjective(occupyRegionObjective);
            }
            else
            {
                Main.Logger.Log($"[AddWithdrawChunk] 'Chunk_Withdraw' already exists in map. No need to recreate.");
            }
        }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        foreach (GameObject boundaryMarker in _allBoundaryMarkers)
        {
            boundaryMarker.SetActive(false);
        }

        Session.GetTrackables <DetectedPlane>(_allPlanes);

        bool horizontalPlanesFound = false;
        bool verticalPlanesFound   = false;

        int boundaryPointCount = 0;

        for (int i = 0; i < _allPlanes.Count; i++)
        {
            //if (m_AllPlanes[i].TrackingState == TrackingState.Tracking)
            //{
            //    showSearchingUI = false;
            //    break;
            //}

            if (_allPlanes[i].PlaneType == DetectedPlaneType.HorizontalUpwardFacing ||
                _allPlanes[i].PlaneType == DetectedPlaneType.HorizontalDownwardFacing)
            {
                horizontalPlanesFound = true;

                _allPlanes[i].GetBoundaryPolygon(_allPlaneBoundaryPoints);
                foreach (var boundaryPoint in _allPlaneBoundaryPoints)
                {
                    if (_allBoundaryMarkers.Count < boundaryPointCount)
                    {
                        _allBoundaryMarkers[boundaryPointCount].transform.position = boundaryPoint;
                        _allBoundaryMarkers[boundaryPointCount].SetActive(true);
                    }
                    else
                    {
                        var newMarker = Instantiate(_planeBoundaryMarker);
                        newMarker.transform.position = boundaryPoint;
                        newMarker.SetActive(true);
                        _allBoundaryMarkers.Add(newMarker);
                    }
                    boundaryPointCount++;
                }

                if (_region != null)
                {
                    Destroy(_region);
                }
                _region = RegionFactory.CreateRegion(_allPlanes[i].CenterPose, _allPlaneBoundaryPoints, _holeMaterial);

                _hiddenObject.transform.position = _allPlanes[i].CenterPose.position + new Vector3(0, -0.6f, 0);
                _normalObject.transform.position = _allPlanes[i].CenterPose.position + new Vector3(0, +0.6f, 0);
                _normalObject.SetActive(true);
            }

            if (_allPlanes[i].PlaneType == DetectedPlaneType.Vertical)
            {
                verticalPlanesFound = true;

                _allPlanes[i].GetBoundaryPolygon(_allPlaneBoundaryPoints);
                foreach (var boundaryPoint in _allPlaneBoundaryPoints)
                {
                    if (_allBoundaryMarkers.Count < boundaryPointCount)
                    {
                        _allBoundaryMarkers[boundaryPointCount].transform.position = boundaryPoint;
                        _allBoundaryMarkers[boundaryPointCount].SetActive(true);
                    }
                    else
                    {
                        var newMarker = Instantiate(_planeBoundaryMarker);
                        newMarker.transform.position = boundaryPoint;
                        newMarker.SetActive(true);
                        _allBoundaryMarkers.Add(newMarker);
                    }
                    boundaryPointCount++;
                }
            }
        }

        //_verticalPlaneFoundMarker.SetActive(verticalPlanesFound);
        //_horizontalPlaneFoundMarker.SetActive(horizontalPlanesFound);

        if (Session.Status != SessionStatus.Tracking)
        {
            const int lostTrackingSleepTimeout = 15;
            Screen.sleepTimeout = lostTrackingSleepTimeout;

            return;
        }
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
    }
Esempio n. 8
0
        public void when_no_matching_adapter_is_found_an_exception_is_thrown()
        {
            var regionFactory = new RegionFactory(new IRegionAdapter[] {});

            Assert.Throws <InvalidOperationException>(() => regionFactory.CreateRegion(_view));
        }