//bool decisionMade;
    public void AssignEvent(GameEvent newEvent, MapRegion eventRegion, List<PartyMember> movedMembers)
    {
        GameEventManager.mainEventManager.drawingEvent=true;
        currentTeamRegion=eventRegion;
        teamList=movedMembers;
        assignedEvent=newEvent;
        descriptionText.text=newEvent.GetDescription(currentTeamRegion,teamList);
        //decisionMade=false;

        List<EventChoice> choices=newEvent.GetChoices(currentTeamRegion,teamList);
        if (choices!=null)
        {
            foreach (EventChoice choice in choices)
            {
                Button newButton=Instantiate(decisionButtonPrefab);
                newButton.transform.SetParent(transform.FindChild("Event Panel").FindChild("Decision Group"),false);
                //this is required, otherwise lambda listener only captures the last choice iteration
                newButton.GetComponentInChildren<Text>().text=choice.choiceTxt;
                newButton.interactable=!choice.grayedOut;
                newButton.onClick.AddListener(()=>ResolveChoice(newButton.GetComponentInChildren<Text>().text));
            }
        }
        else
        {
            //Create exit button
            Button newButton=Instantiate(decisionButtonPrefab);
            newButton.transform.SetParent(transform.FindChild("Event Panel").FindChild("Decision Group"),false);
            newButton.GetComponentInChildren<Text>().text="Close";
            newButton.onClick.AddListener(CloseChoiceScreen);
        }
    }
예제 #2
0
        public void TrySetSpawnPointSucceedsOnValidPositionTest()
        {
            var region = new MapRegion();
            var point  = new SpawnPoint(Vector2Int.ZeroVector, SpawnType.Player);

            var result = region.TrySetSpawnPoint(point);

            Assert.True(result);
        }
예제 #3
0
        public void TrySetFloorSucceedsOnDefaultParquetAndPositionTest()
        {
            var region  = new MapRegion();
            var parquet = TestParquets.TestFloor.ID;

            var result = region.TrySetFloor(parquet, Vector2Int.ZeroVector);

            Assert.True(result);
        }
예제 #4
0
        public override void RegionChanged(MKMapView mapView, bool animated)
        {
            var mkregion = MKCoordinateRegion.FromMapRect(mapView.VisibleMapRect);

            var region = new MapRegion(new Position(mkregion.Center.Latitude, mkregion.Center.Longitude),
                                       mkregion.Span.LatitudeDelta, mkregion.Span.LongitudeDelta);

            _renderer.Map.VisibleRegion = region;
        }
예제 #5
0
        public void TryRemoveSpawnPointFailsOnInvalidPositionTest()
        {
            var region = new MapRegion();
            var point  = new SpawnPoint(invalidPosition, SpawnType.Player);

            var result = region.TryRemoveSpawnPoint(point);

            Assert.False(result);
        }
예제 #6
0
        public void TrySetCollectibleFailsOnInvalidPositionTest()
        {
            var region  = new MapRegion();
            var parquet = TestParquets.TestCollectible.ID;

            var result = region.TrySetCollectible(parquet, invalidPosition);

            Assert.False(result);
        }
 public BalanceWorkersMainNatural(MapRegion main, MapRegion natural)
 {
     _main = main;
     _mainIdealMineralWorkerCount = Round(
         _main.ResourceSites.First().MineralsBuildTiles.Count *WorkerToMineralCountRatio);
     _natural = natural;
     _naturalIdealMineralWorkerCount =
         Round(_natural.ResourceSites.First().MineralsBuildTiles.Count *WorkerToMineralCountRatio);
 }
예제 #8
0
        public void TryRemoveSpawnPointSucceedsOnSpawnPointMissingTest()
        {
            var region = new MapRegion();
            var point  = new SpawnPoint(Vector2Int.ZeroVector, SpawnType.Player);

            var result = region.TryRemoveSpawnPoint(point);

            Assert.True(result);
        }
예제 #9
0
    public void UseCardOnRegion(MapRegion r, GameStatistics gs)
    {
        foreach (RegionSector rs in r.sectors)
        {
            rs.ImplementStatisticValues(currentSectorConsequences, true, gs.happiness);
        }

        gs.ModifyMoney(currentMoneyReward, true);
    }
예제 #10
0
        public void TryRemoveExitPointFailsOnInvalidPositionTest()
        {
            var region = new MapRegion();
            var point  = new ExitPoint(invalidPosition, new Guid());

            var result = region.TryRemoveExitPoint(point);

            Assert.False(result);
        }
예제 #11
0
        public void TrySetExitPointSucceedsOnValidPositionTest()
        {
            var region = new MapRegion();
            var point  = new ExitPoint(Vector2Int.ZeroVector, new Guid());

            var result = region.TrySetExitPoint(point);

            Assert.True(result);
        }
예제 #12
0
        public void Constructor_must_rearange_given_coordinates_if_required(double minX, double maxY, double maxX, double minY)
        {
            var region = new MapRegion(minX, maxY, maxX, minY);

            region.MinX.Should().Be(-10);
            region.MaxX.Should().Be(10);
            region.MinY.Should().Be(-20);
            region.MaxY.Should().Be(20);
        }
예제 #13
0
        public void TryRemoveExitPointSucceedsOnExitPointMissingTest()
        {
            var region = new MapRegion();
            var point  = new ExitPoint(Vector2Int.ZeroVector, new Guid());

            var result = region.TryRemoveExitPoint(point);

            Assert.True(result);
        }
예제 #14
0
 public override void Generate()
 {
     start  = map.GenerateDungeonRegion(0, 0, 45, true, false, false, null, 1, 1);            // 0 0
     second = map.GenerateDungeonRegion(1, 0, 43, false, true, false, levelTwoSeeds, 1, 1);   // 0, 2
     third  = map.GenerateDungeonRegion(2, 0, 43, false, true, false, levelTwoSeeds, 1, 1);   // 0, 2
     fourth = map.GenerateDungeonRegion(0, 1, 43, false, true, false, levelTwoSeeds, 1, 1);   // 0, 2
     fifth  = map.GenerateDungeonRegion(1, 1, 43, false, true, false, levelTwoSeeds, 1, 1);   // 0, 2
     end    = map.GenerateDungeonRegion(2, 1, 45, false, true, true, levelThreeSeeds, 1, 1);  // 0, 2
 }
예제 #15
0
        public void TrySetBlockFailsOnInvalidPositionTest()
        {
            var region  = new MapRegion();
            var parquet = TestParquets.TestBlock.ID;

            var result = region.TrySetBlock(parquet, invalidPosition);

            Assert.False(result);
        }
예제 #16
0
        public static LatLngBounds ToBounds(this MapRegion region)
        {
            var southwest = new LatLng(region.MinY, region.MinX);
            var northeast = new LatLng(region.MaxY, region.MaxX);

            return(new LatLngBounds.Builder().
                   Include(southwest).
                   Include(northeast).Build());
        }
예제 #17
0
 public static RectangleF GetRectangle(this MapRegion thisRegion)
 {
     return(new RectangleF(
                Math.Min((float)thisRegion.CoordinateStart.Latitude, (float)thisRegion.CoordinateEnd.Latitude),
                Math.Min((float)thisRegion.CoordinateStart.Longitude, (float)thisRegion.CoordinateEnd.Longitude),
                Math.Abs((float)thisRegion.CoordinateEnd.Latitude - (float)thisRegion.CoordinateStart.Latitude),
                Math.Abs((float)thisRegion.CoordinateEnd.Longitude - (float)thisRegion.CoordinateStart.Longitude)
                ));
 }
예제 #18
0
    public MapRegion GetRegionData()
    {
        if (debug)
        {
            _currentRegion = new MapRegion();
        }

        return(_currentRegion);
    }
예제 #19
0
        public void TrySetFurnishingFailsOnInvalidPositionTest()
        {
            var region  = new MapRegion();
            var parquet = TestEntities.TestFurnishing.ID;

            var result = region.TrySetFurnishingDefinition(parquet, invalidPosition);

            Assert.False(result);
        }
        public ActionResult SaveSettings(
            string market,
            bool enableDriverBonus,
            string receiptFooter,
            bool enableFutureBooking,
            string futureBookingReservationProvider,
            int futureBookingTimeThresholdInMinutes,
            bool disableOutOfAppPayment,
            bool enableAppFareEstimates,
            bool showCallDriver,
            Tariff marketTariff,
            MapRegion region,
            IDictionary <string, IDictionary <string, string> > receiptLines)
        {
            try
            {
                if (!IsRegionValid(region))
                {
                    ViewBag.Error = "You must specify a valid region for the market";
                    return(RedirectToAction("MarketIndex", GetMarketModel(market)));
                }

                var marketToEdit = Repository.GetMarket(market);
                if (marketToEdit == null)
                {
                    ViewBag.Error = "An error occured. Market is null.";

                    return(RedirectToAction("Index"));
                }

                marketToEdit.EnableDriverBonus   = enableDriverBonus;
                marketToEdit.EnableFutureBooking = enableFutureBooking;
                marketToEdit.FutureBookingReservationProvider    = futureBookingReservationProvider;
                marketToEdit.FutureBookingTimeThresholdInMinutes = futureBookingTimeThresholdInMinutes;
                marketToEdit.DisableOutOfAppPayment = disableOutOfAppPayment;
                marketToEdit.ReceiptFooter          = receiptFooter;
                marketToEdit.EnableAppFareEstimates = enableAppFareEstimates;

                marketToEdit.ShowCallDriver = showCallDriver;

                marketTariff.Type         = (int)TariffType.Market;
                marketToEdit.MarketTariff = marketTariff;

                marketToEdit.Region = region;

                marketToEdit.ReceiptLines = receiptLines;

                Repository.Update(marketToEdit);
            }
            catch (Exception)
            {
                ViewBag.Error = "An error occured. Unable to save the settings.";
            }

            return(RedirectToAction("Index"));
        }
예제 #21
0
 public override void Generate()
 {
     start    = map.GenerateDungeonRegion(0, 1, 45, true, false, false, startSeeds, 1, 1);       // 1
     second   = map.GenerateDungeonRegion(1, 1, 45, false, false, false, secondSeeds, 1, 1);     // 2
     thirdBig = map.GenerateDungeonRegion(2, 1, 45, false, false, false, thirdSeeds, 2, 1);      // 3
     fourth   = map.GenerateDungeonRegion(3, 0, 47, false, false, false, fourthSeeds, 1, 1);     // 4
     fifthBig = map.GenerateDungeonRegion(4, 0, 45, false, false, false, thirdSeeds, 2, 1);      // 5
     boss     = map.GenerateDungeonRegion(6, 0, 43, false, true, false, bossSeeds, 1, 1);        // B
     end      = map.GenerateDungeonRegion(7, 0, 47, false, true, true, startSeeds, 1, 1);        // 7
 }
예제 #22
0
 void OnMyLocationChanged(object sender, GoogleMap.MyLocationChangeEventArgs e)
 {
     if (RequestedShowUserLocation)
     {
         InternalMoveToRegion(MapRegion.FromPositions(new List <Position> {
             new Position(e.Location.Latitude, e.Location.Longitude)
         }), true, 16);
         ResetShowUserLocation();
     }
 }
 private bool IsRegionValid(MapRegion region)
 {
     return(region != null &&
            region.CoordinateStart != null &&
            region.CoordinateEnd != null &&
            region.CoordinateStart.Latitude != 0 &&
            region.CoordinateStart.Longitude != 0 &&
            region.CoordinateEnd.Latitude != 0 &&
            region.CoordinateEnd.Longitude != 0);
 }
예제 #24
0
        public void NewCustomMapRegionTest()
        {
            var customRegion = new MapRegion(testTitle, testColor, testStory, testElevation, testID);

            Assert.Equal(testTitle, customRegion.Title);
            Assert.Equal(testColor, customRegion.Background);
            Assert.Equal(testStory, customRegion.ElevationLocal);
            Assert.Equal(testElevation, customRegion.ElevationGlobal);
            Assert.Equal(testID, customRegion.RegionID);
        }
예제 #25
0
    int RaiseTerrain(int chunkSize, int budget, MapRegion region)
    {
        searchFrontierPhase += 1;
        HexCell firstCell = GetRandomCell(region);

        //todo 测试使用生成默认的英雄
        if (HexGameUI.Instrance.selectedUnit == null)
        {
            HexGameUI.Instrance.selectedUnit = CreateHero(firstCell);
        }

        firstCell.SearchPhase     = searchFrontierPhase;
        firstCell.Distance        = 0;
        firstCell.SearchHeuristic = 0;
        searchFrontier.Enqueue(firstCell);
        HexCoordinates center = firstCell.coordinates;

        int rise = Random.value < highRiseProbability ? 2 : 1;
        int size = 0;

        while (size < chunkSize && searchFrontier.Count > 0)
        {
            HexCell current           = searchFrontier.Dequeue();
            int     originalElevation = current.Elevation;
            int     newElevation      = originalElevation + rise;
            if (newElevation > elevationMaximum)
            {
                continue;
            }
            current.Elevation = newElevation;
            if (
                originalElevation < waterLevel &&
                newElevation >= waterLevel && --budget == 0
                )
            {
                break;
            }
            size += 1;

            for (HexDirection d = HexDirection.NE; d <= HexDirection.NW; d++)
            {
                HexCell neighbor = current.GetNeighbor(d);
                if (neighbor && neighbor.SearchPhase < searchFrontierPhase)
                {
                    neighbor.SearchPhase     = searchFrontierPhase;
                    neighbor.Distance        = neighbor.coordinates.DistanceTo(center);
                    neighbor.SearchHeuristic =
                        Random.value < jitterProbability ? 1 : 0;
                    searchFrontier.Enqueue(neighbor);
                }
            }
        }
        searchFrontier.Clear();
        return(budget);
    }
예제 #26
0
    private int SinkTerrain(int chunkSize, int budget, MapRegion region)
    {
        searchFrontierPhase += 1;
        HexCell firstCell = GetRandomCell(region);

        firstCell.SearchPhase     = searchFrontierPhase;
        firstCell.Distance        = 0;
        firstCell.SearchHeuristic = 0;
        searchFrontier.Enqueue(firstCell);
        HexCoordinates center = firstCell.coordinates;

        int sink = Random.value < highRiseProbability ? 2 : 1;

        int size = 0;

        while (size < chunkSize && searchFrontier.Count > 0)
        {
            HexCell current = searchFrontier.Dequeue();

            int originalElevation = current.Elevation;
            int newElevation      = current.Elevation - sink;

            if (newElevation < elevationMinimum)
            {
                continue;
            }

            current.Elevation = newElevation;

            if (originalElevation >= waterLevel && newElevation < waterLevel)
            {
                budget += 1;
            }

            size += 1;

            for (HexDirection d = HexDirection.NE; d <= HexDirection.NW; d++)
            {
                HexCell neighbor = current.GetNeighbor(d);

                if (neighbor && neighbor.SearchPhase < searchFrontierPhase)
                {
                    neighbor.SearchPhase     = searchFrontierPhase;
                    neighbor.Distance        = neighbor.coordinates.DistanceTo(center);
                    neighbor.SearchHeuristic = Random.value < jitterProbability ? 1 : 0;
                    ;
                    searchFrontier.Enqueue(neighbor);
                }
            }
        }

        searchFrontier.Clear();

        return(budget);
    }
예제 #27
0
        /// <summary>
        /// Создание карты.
        /// </summary>
        /// <returns>
        /// Возвращает экземпляр карты.
        /// </returns>
        public Task <ISectorMap> CreateAsync(object options)
        {
            if (options is null)
            {
                throw new System.ArgumentNullException(nameof(options));
            }

            var sectorScheme = (ISectorSubScheme)options;

            var map = CreateMapInstance();

            var edgeHash = new HashSet <string>();

            // Генерируем случайные координаты комнат
            var transitions = MapFactoryHelper.CreateTransitions(sectorScheme);

            var rooms = _roomGenerator.GenerateRoomsInGrid(sectorScheme.RegionCount,
                                                           RoomMinSize,
                                                           sectorScheme.RegionSize,
                                                           transitions);

            // Создаём узлы и рёбра комнат
            _roomGenerator.CreateRoomNodes(map, rooms, edgeHash);

            // Соединяем комнаты
            _roomGenerator.BuildRoomCorridors(map, rooms, edgeHash);

            // Указание регионов карты
            var regionIdCounter = 1;

            foreach (var room in rooms)
            {
                var passableRoomNodes = room.Nodes.Where(x => !x.IsObstacle);
                var region            = new MapRegion(regionIdCounter, passableRoomNodes.Cast <IMapNode>().ToArray());
                regionIdCounter++;
                map.Regions.Add(region);

                if (room.IsStart)
                {
                    region.IsStart = true;
                    continue;
                }

                if (room.Transitions?.Any() == true)
                {
                    region.ExitNodes = (from regionNode in region.Nodes
                                        where map.Transitions.Keys.Contains(regionNode)
                                        select regionNode).ToArray();

                    continue;
                }
            }

            return(Task.FromResult(map));
        }
예제 #28
0
 /*keeps track of how long the event is still available the player hasn't made a choice yet
  * /will do the event with option 0 (do nothing) if player fails to make a choice within the time limit*/
 public void GameEventCheckIfIdle(GameEvent gameEvent, MapRegion region)
 {
     if (gameEvent.isIdle)
     {
         gameEvent.SubtractIdleTurnsLeft();
         if (gameEvent.idleTurnsLeft == 0)
         {
             gameEvent.SetPickedChoice(0, this, region);
         }
     }
 }
예제 #29
0
        public void GetDefinitionReturnsNoneOnEmptyMapTest()
        {
            var chunk = new MapRegion();

            var result = chunk.GetDefinitionAtPosition(Vector2Int.ZeroVector);

            Assert.Equal(EntityID.None, result.Floor);
            Assert.Equal(EntityID.None, result.Block);
            Assert.Equal(EntityID.None, result.Furnishing);
            Assert.Equal(EntityID.None, result.Collectible);
        }
예제 #30
0
 public void AddCompletedAction(MapRegion region, RegionAction action)
 {
     for (int i = 0; i < reportRegions.Length; i++)
     {
         if (region.name[0] == reportRegions[i])
         {
             completedActions[i].Add(action);
             break;
         }
     }
 }
예제 #31
0
 public void AddCompletedGameEvent(MapRegion region, GameEvent gameEvent)
 {
     for (int i = 0; i < reportRegions.Length; i++)
     {
         if (region.name[0] == reportRegions[i])
         {
             completedEvents[i].Add(gameEvent);
             break;
         }
     }
 }
예제 #32
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mapPt">经纬度基准点坐标</param>
 /// <param name="screenSize">屏幕大小</param>
 /// <param name="scale">缩放大小,1为放大1e4</param>
 public MapTransfer(MapPoint mapPt,PointF screenSize,double scale)
 {
     m_mapPt = mapPt;
     m_screenSize = screenSize;
     m_scale = scale;
     m_rm = new ReadMap(Properties.Resources.MapFileName);
     m_rm.loadRegion();
     Box box;
     box.xmin = m_mapPt.x;
     box.ymin = m_mapPt.y;
     box.xmax = m_mapPt.x + ((double)m_screenSize.X) / (m_scale * Properties.Settings.Default.ScaleFactor);
     box.ymax = m_mapPt.y + ((double)m_screenSize.Y) / (m_scale * Properties.Settings.Default.ScaleFactor);
     m_currentRegion = m_rm.getSmallRegion(box);
     m_bRebuildRegion = true;
     m_estOutRoute = new EstimateRoute(m_rm.region);
 }
예제 #33
0
 IEnumerator MoveToNewDest(MapRegion start,MapRegion newDest)
 {
     transform.position=start.transform.position;
     Vector3 endCoords=newDest.transform.position;
     float spd=100f;
     Vector3 moveVector=(endCoords-transform.position).normalized*spd;
     while (true)
     {
         Vector3 delta=moveVector*Time.deltaTime;
         if ((endCoords-transform.position).magnitude<=delta.magnitude)
         {
             transform.position=endCoords;
             break;
         }
         else {transform.Translate(delta);}
         yield return new WaitForFixedUpdate();
     }
     if (!newDest.visible) {GetComponent<SpriteRenderer>().enabled=false;}
 }
예제 #34
0
    public void MoveToDestination(MapRegion start,MapRegion newDest)
    {
        StopAllCoroutines();
        //from invisible area
        if (!start.visible)
        {
            // to visible area
            if (newDest.visible)
            {
                StartCoroutine(MoveToNewDest(start,newDest));
                GetComponent<SpriteRenderer>().enabled=true;
            }
            else
            {
                JumpToNewDest(newDest);
                GetComponent<SpriteRenderer>().enabled=false;
            }
        }
        else
        {
            StartCoroutine(MoveToNewDest(start,newDest));
            GetComponent<SpriteRenderer>().enabled=true;
            /*
            //from visible to visible
            if (newDest.visible)
            {
                StartCoroutine(MoveToNewDest(newDest));
                GetComponent<SpriteRenderer>().enabled=true;
            }
            else //from visible to invisible
            {
                StartCoroutine(MoveToNewDest(n));
                GetComponent<SpriteRenderer>().enabled=true;
            }*/

        }
    }
예제 #35
0
        private void regionPanel_RegionChanged(object sender, RegionEventArgs e)
        {
            MapRegion region = Tree.SelectedNode.Tag as MapRegion;

            m_Modified = true;

            switch (e.Action)
            {
                case RegionActions.DeleteRegion:

                    MapRegion parentRegion = Tree.SelectedNode.Parent.Tag as MapRegion;
                    if (parentRegion != null)
                        parentRegion.SubRegions.Remove(region);

                    // Delete the tree node
                    Tree.Nodes.Remove(Tree.SelectedNode);
                    SelectPanel();
                    break;

                case RegionActions.AddSubregion:

                    // Make a new subregion
                    MapRegion subregion = new MapRegion((string)e.Data);
                    region.SubRegions.Add(subregion);

                    TreeNode subregionTree = new TreeNode((string)e.Data);
                    subregionTree.Tag = subregion;
                    Tree.SelectedNode.Nodes.Add(subregionTree);

                    break;

                case RegionActions.ChangeGo:

                    // Change the GO location
                    int[] newGo = e.Data as int[];
                    region.GoLocation.X = newGo[0];
                    region.GoLocation.Y = newGo[1];
                    region.GoLocation.Z = newGo[2];
                    UpdateGoLocation();
                    break;

                case RegionActions.ChangePriority:

                    int newPriority = (int)e.Data;
                    region.Priority = newPriority;
                    break;

                case RegionActions.ClearRegion:

                    region.Area.Clear();
                    Tree.SelectedNode.Nodes.Clear();
                    Map.RemoveAllDrawObjects();
                    RectList.Items.Clear();
                    DisplayedRects.Clear();
                    if ((region.GoLocation.X != -1) && (region.GoLocation.Y != -1))
                    {
                        Map.AddDrawObject(m_CrossHair1, false);
                        Map.AddDrawObject(m_CrossHair2, true);
                    }

                    if (region != null)
                    {
                        region.Area.Clear();
                        region.SubRegions.Clear();
                    }
                    SelectPanel();
                    break;

                case RegionActions.RenameRegion:

                    region.Name = (string)e.Data;
                    Tree.SelectedNode.Text = (string)e.Data;
                    break;

                case RegionActions.ChangeTypeName:

                    region.TypeName = (string)e.Data;
                    break;

                case RegionActions.ChangeRuneName:

                    region.RuneName = (string)e.Data;
                    break;

                case RegionActions.ChangeMusicName:

                    region.MusicName = (string)e.Data;
                    break;

                case RegionActions.SetGo:
                    m_SetGo = true;
                    break;

                case RegionActions.ChangeZ:

                    int[] newZ = e.Data as int[];
                    region.MinZ = newZ[0];
                    region.MaxZ = newZ[1];
                    break;

                case RegionActions.ChangeLogoutDelay:

                    if((bool)e.Data)
                        region.LogoutDelayActive = XmlBool.True;
                    else
                        region.LogoutDelayActive = XmlBool.False;
                    break;

                case RegionActions.ChangeGuardsDisabled:

                    if ((bool)e.Data)
                        region.GuardsDisabled = XmlBool.True;
                    else
                        region.GuardsDisabled = XmlBool.False;
                    break;

                case RegionActions.ChangeSmartNoHousing:

                    if ((bool)e.Data)
                        region.SmartNoHousing = XmlBool.True;
                    else
                        region.SmartNoHousing = XmlBool.False;
                    break;
            }
        }
예제 #36
0
 // Used by ambush events, to make sure encounter enter is triggered after the event is resolved (if any members survive it)
 public IEnumerator WaitForEventEnd(GameEvent newEvent, MapRegion eventRegion, List<PartyMember> eventMembers)
 {
     StartEventDraw(newEvent,eventRegion,eventMembers);
     while (drawingEvent && GameManager.main.gameStarted) yield return new WaitForFixedUpdate();
     yield break;
 }
예제 #37
0
    void GeneratePartyMember(string memberName)
    {
        MapRegion startingRegion = MapManager.main.GetTown();

        var classtypes=System.Enum.GetValues(typeof(MercClass));
        myClass = (MercClass)classtypes.GetValue(Random.Range(0,classtypes.Length));
        combatDeck = GenerateClassCombatDeck(myClass);
        classPrepCards = GenerateClassPrepCards(myClass);
        weaponPrepCards = GenerateDefaultWeaponPrepCards();

        SetClassStats(myClass);

        //Pick color out of ones left
        //worldCoords=startingCoords;
        currentRegion=startingRegion;
        startingRegion.localPartyMembers.Add(this);

        color = GetPortraitColor();

        //Randomly pick out a specialty
        List<Trait> possibleSpecialtyPerks=Trait.GenerateRandomSkillTree(5);

        //Pick out a starting specialty perk
        Skill startingLearnedSkill=possibleSpecialtyPerks[Random.Range(0,possibleSpecialtyPerks.Count)] as Skill;
        startingLearnedSkill.learned=true;
        traits.Add(startingLearnedSkill);

        //Fill out trait list
        List<Trait> possibleGenericPerks=Trait.GetTraitList();
        //Deactivate the opposite traits of the starting perk
        foreach(Trait genericPerk in possibleGenericPerks)
        {
            if (genericPerk.GetType()==startingLearnedSkill.oppositePerk)
            {
                if (possibleGenericPerks.Contains(genericPerk)) possibleGenericPerks.Remove(genericPerk);
                break;
            }
        }

        //Randomly pick out generic perks
        int necessaryPerkCount=2;
        int addedPerksCount=0;
        while (addedPerksCount<necessaryPerkCount && possibleGenericPerks.Count>0)
        {
            Trait newPerk=possibleGenericPerks[Random.Range(0,possibleGenericPerks.Count)];
            traits.Add(newPerk);
            addedPerksCount++;
            possibleGenericPerks.Remove(newPerk);
            if (newPerk.oppositePerk!=null)
            {
                foreach (Trait possibleGenericPerk in possibleGenericPerks)
                {
                    if (possibleGenericPerk.GetType()==newPerk.oppositePerk)
                    {
                        if (possibleGenericPerks.Contains(possibleGenericPerk)) possibleGenericPerks.Remove(possibleGenericPerk);
                        break;
                    }
                }
                foreach (Trait possibleSpecialtyPerk in possibleSpecialtyPerks)
                {
                    if (possibleSpecialtyPerk.GetType()==newPerk.oppositePerk)
                    {
                        if (possibleSpecialtyPerks.Contains(possibleSpecialtyPerk)) possibleSpecialtyPerks.Remove(possibleSpecialtyPerk);
                        break;
                    }
                }
            }
        }

        name=memberName;

        baseMaxStamina=10;
        armorValue=0;
        maxCarryCapacity=4;//

        hasLight=false;
        isCook=false;
        isMedic=false;
        isLockExpert=false;
        isScout=false;
        foreach (Trait myPerk in traits)
        {
            if (myPerk.GetType().BaseType==typeof(Trait)) myPerk.ActivateEffect(this);
            else
            {
                Skill mySkill=myPerk as Skill;
                if (mySkill.learned) mySkill.ActivateEffect(this);
            }
        }
        //make sure perks trigger before these to properly use modified values of maxHealth and maxStamina
        health = healthMax;
        currentMaxStamina=baseMaxStamina;
        UpdateCurrentCarryCapacity();
        equippedRangedWeapon=null;
    }
예제 #38
0
 public virtual string DoChoice(string choiceString, MapRegion eventRegion, List<PartyMember> movedMembers)
 {
     return null;
 }
예제 #39
0
 public abstract string GetDescription(MapRegion eventRegion, List<PartyMember> movedMembers);
예제 #40
0
 public Program()
 {
     ReadMap rm = new ReadMap(Resources.MapFileName);
     rm.loadRegion();
     m_mapRegion = rm.region;
 }
예제 #41
0
    /*
    //Currently unused

    public void RollEvents(ref bool moveAllowed, MapRegion eventRegion, List<PartyMember> movedMembers, bool queueEvent)
    {
        //bool eventFired=false;
        GameEvent resEvent=null;
        //if (eventRegion.hasGasoline)resEvent=new GasolineEvent();
        //else
        {
            float eventsRoll=Random.value;
            EventChance trackedEventRecord=new EventChance();
            resEvent=PickRandomEvent(possibleEvents, ref trackedEventRecord,eventsRoll,eventRegion, movedMembers);
            if (!resEvent.repeatable) possibleEvents.Remove(trackedEventRecord);
        }
        //If a regular event fired, remove it from events list
        if (resEvent!=null)
        {
            //eventFired=true;
            if (queueEvent) {QueueEvent(resEvent,eventRegion,movedMembers);}
            else StartEventDraw(resEvent, eventRegion, movedMembers);
            moveAllowed=resEvent.AllowMapMove();
        }
        else moveAllowed=true;

        //return eventFired;
    }*/
    public void DoEvent(GameEvent newEvent, MapRegion eventRegion, List<PartyMember> eventMembers)
    {
        StartEventDraw(newEvent, eventRegion, eventMembers);
    }
예제 #42
0
 void StartEventDraw(GameEvent newDrawnEvent,MapRegion eventRegion, List<PartyMember> movedMembers)
 {
     /*
     drawingEvent=true;
     drawnEvent=newDrawnEvent;
     choiceMade=false;
     //FormatEventDecription(newDrawnEvent.GetDescription());
     currentDescription=newDrawnEvent.GetDescription();*/
     //currentDescription=
     drawingEvent=true;
     EventCanvasHandler newEventScreen=Instantiate(eventScreenPrefab);
     newEventScreen.AssignEvent(newDrawnEvent, eventRegion, movedMembers);
 }
예제 #43
0
 public NewEventInfo(GameEvent addedEvent, MapRegion region, List<PartyMember> members)
 {
     newEvent=addedEvent;
     eventRegion=region;
     eventMembers=members;
 }
예제 #44
0
 public void QueueEventToStart(GameEvent newEvent, MapRegion eventRegion, List<PartyMember> eventMembers)
 {
     //StartEventDraw(newEvent, eventRegion, eventMembers);
     queuedEvents.Insert(0,new NewEventInfo(newEvent,eventRegion,eventMembers));
 }
예제 #45
0
 public void RollCampEvents(MapRegion eventRegion,List<PartyMember> presentMembers)
 {
     float eventsRoll=Random.value;
     EventChance trackedEventRecord=new EventChance();
     GameEvent resEvent;
     /*
     //Morale events
     resEvent=PickRandomEvent(moraleEvents, ref trackedEventRecord,eventsRoll, eventRegion, presentMembers);
     if (resEvent!=null) QueueEvent(resEvent,eventRegion,presentMembers);//StartEventDraw(resEvent, eventRegion, presentMembers);
     //Cold events
     resEvent=PickRandomEvent(coldEvents, ref trackedEventRecord,eventsRoll, eventRegion, presentMembers);
     if (resEvent!=null) QueueEvent(resEvent,eventRegion,presentMembers);//StartEventDraw(resEvent, eventRegion, presentMembers);
     //Attack events
     resEvent=PickRandomEvent(campSafetyEvents, ref trackedEventRecord,eventsRoll, eventRegion, presentMembers);
     if (resEvent!=null) QueueEvent(resEvent,eventRegion,presentMembers);
     //Relationship events
     resEvent=PickRandomEvent(grudgeEvents, ref trackedEventRecord,eventsRoll, eventRegion, presentMembers);
     if (resEvent!=null) QueueEvent(resEvent,eventRegion,presentMembers);
     resEvent=PickRandomEvent(friendshipEvents, ref trackedEventRecord,eventsRoll, eventRegion, presentMembers);
     if (resEvent!=null) QueueEvent(resEvent,eventRegion,presentMembers);
      */
 }
예제 #46
0
 public void RollScavengeEvents(MapRegion eventRegion,List<PartyMember> presentMembers)
 {
     GameEvent resEvent=null;
     //if (eventRegion.hasGasoline) resEvent=new GasolineEvent();
     //else
     {
         float eventsRoll=Random.value;
         EventChance trackedEventRecord=new EventChance();
         resEvent=PickRandomEvent(scavengingEvents, ref trackedEventRecord,eventsRoll, eventRegion, presentMembers);
         if (!resEvent.repeatable) scavengingEvents.Remove(trackedEventRecord);
     }
     if (resEvent!=null) StartEventDraw(resEvent, eventRegion, presentMembers);
 }
예제 #47
0
 void JumpToNewDest(MapRegion newDest)
 {
     transform.position=newDest.transform.position;
     //GetComponent<SpriteRenderer>().enabled=false;
 }
예제 #48
0
 private void FadeAll(MapRegion exclude)
 {
     foreach (MapRegion mr in regions)
     {
         if (!mr.Equals(exclude))
         {
             mr.Fade(0.3);
         }
     }
 }
예제 #49
0
 public GenRandRoute(MapRegion mRegion)
 {
     m_mRegion = mRegion;
 }
예제 #50
0
 private void LoadMap()
 {
     DirectoryInfo di = new DirectoryInfo(_mapImageLocations);
     FileInfo[] files = di.GetFiles();
     regions = new MapRegion[files.Length];
     for (int i = 0; i < files.Length; i++)
     {
         regions[i] = new MapRegion(files[i].FullName);
         String subDiv = _mapSubDivImageLocations + "/" + files[i].Name;
         regions[i].LoadSubDivImage(subDiv);
         MapImages.Children.Add(regions[i].RegionImage);
         MapImages.Children.Add(regions[i].RegionSubdiv);
     }
     double minHeight = double.MaxValue;
     foreach (MapRegion r in regions)
     {
         if (r.Top < minHeight)
             minHeight = r.Top;
     }
     Canvas.SetTop(MapImages, 0);
     //Canvas.SetTop(MapImages, -minHeight);
     BitmapImage bi = regions[0].RegionImage.Source as BitmapImage;
     _mapAspectRatio = bi.Width / bi.Height;
 }
예제 #51
0
 public virtual List<EventChoice> GetChoices(MapRegion eventRegion, List<PartyMember> movedMembers)
 {
     return null;
 }
예제 #52
0
        private void facetPanel_NewRegion(object sender, FacetEventArgs e)
        {
            TreeNode rNode = new TreeNode(e.Name);

            // Create the new region object and add it as Tag for the tree node
            MapRegion region = new MapRegion(e.Name);
            rNode.Tag = region;

            Tree.SelectedNode.Nodes.Add(rNode);

            if (e.FocusRegion)
                Tree.SelectedNode = rNode;

            m_Modified = true;
        }
예제 #53
0
 public virtual bool PreconditionsMet(MapRegion eventRegion, List<PartyMember> movedMembers)
 {
     return true;
 }
예제 #54
0
    GameEvent PickRandomEvent(List<EventChance> eventsList, ref EventChance eventRecord, float roll
	, MapRegion eventRegion,List<PartyMember> movedMembers)
    {
        //find events with met preconditions
        //MapRegion currentTeamRegion=MapManager.main.GetRegion(PartyManager.mainPartyManager.selectedMembers.);
        List<EventChance> eligibleEvents=new List<EventChance>();
        foreach(EventChance chance in eventsList)
        {
            if (chance.myEvent.PreconditionsMet(eventRegion,movedMembers)) {eligibleEvents.Add (chance);}
        }

        //form a dictionary based on probability intervals
        float eventPositiveProbabilitySpace=0;
        foreach (EventChance chance in eligibleEvents) {eventPositiveProbabilitySpace+=chance.chance;}

        Dictionary<float,EventChance> intervalDict=new Dictionary<float, EventChance>();
        foreach (EventChance chance in eligibleEvents)
        {
            intervalDict.Add (eventPositiveProbabilitySpace,chance);
            eventPositiveProbabilitySpace-=chance.chance;
        }

        //roll on resulting intervals
        GameEvent resEvent=null;
        //Compiler made me assign this, should be null
        //EventChance eventRecord=new EventChance();
        foreach (float chance in intervalDict.Keys)
        {
            if (roll<chance)
            {
                resEvent=intervalDict[chance].myEvent;
                eventRecord=intervalDict[chance];
            }
        }
        return resEvent;
    }
예제 #55
0
        public RegionPanel( int mapWidth, int mapHeight, MapRegion region )
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            m_Updating = true;

            m_MapWidth = mapWidth;
            m_MapHeight = mapHeight;

            NumX.Maximum = mapWidth;
            NumY.Maximum = mapHeight;

            TextBoxRegionName.Text = region.Name;
            TextBoxTypeName.Text = region.TypeName;
            TextBoxRuneName.Text = region.RuneName;
            TextBoxMusicName.Text = region.MusicName;

            checkBoxSmartNoHousing.Visible = false;
            checkBoxGuardsDisabled.Visible = false;

            if (region.LogoutDelayActive == XmlBool.False)
                checkBoxLogoutDelay.Checked = false;
            else
                checkBoxLogoutDelay.Checked = true;

            if (region.TypeName == "NoHousingRegion")
            {
                checkBoxSmartNoHousing.Visible = true;
                if (region.SmartNoHousing == XmlBool.True)
                    checkBoxSmartNoHousing.Checked = true;
                else
                    checkBoxSmartNoHousing.Checked = false;
            }
            else if (region.TypeName == "GuardedRegion" || region.TypeName == "TownRegion")
            {
                checkBoxGuardsDisabled.Visible = true;
                if (region.GuardsDisabled == XmlBool.True)
                    checkBoxGuardsDisabled.Checked = true;
                else
                    checkBoxGuardsDisabled.Checked = false;
            }

            try
            {
                NumX.Value = region.GoLocation.X;
            }
            catch
            {
                NumX.Value = NumX.Minimum;
            }
            try
            {
                NumY.Value = region.GoLocation.Y;
            }
            catch
            {
                NumY.Value = NumY.Minimum;
            }
            try
            {
                NumZ.Value = region.GoLocation.Z;
            }
            catch
            {
                NumY.Value = 0;
            }

            try
            {
                NumMinZ.Value = region.MinZ;
            }
            catch
            {
                NumMinZ.Value = MapRegion.DefaultMinZ;
            }
            try
            {
                NumMaxZ.Value = region.MaxZ;
            }
            catch
            {
                NumMaxZ.Value = MapRegion.DefaultMaxZ;
            }

            try
            {
                NumPriority.Value = region.Priority;
            }
            catch
            {
                NumPriority.Value = 50;
            }

            m_Updating = false;
        }
예제 #56
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 21JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * get a map region object at given index.
  */
 private MapRegion GetMapRegion(RecordIndex recordIndex)
 {
     MapRegion mapRegion = new MapRegion
                               {
                                   BrushStyle =
                                       {
                                           Pattern = recordIndex.Param1,
                                           ForeColor = recordIndex.Param2,
                                           BackColor = recordIndex.Param3
                                       }
                               };
     mapRegion.PenStyle.Pattern = DataReader.ReadInt(_reader);
     mapRegion.PenStyle.Width = DataReader.ReadInt(_reader);
     mapRegion.PenStyle.Color = DataReader.ReadInt(_reader);
     mapRegion.Bounds.X = recordIndex.MinX / DOUBLE_PRECISION;
     mapRegion.Bounds.Y = recordIndex.MinY / DOUBLE_PRECISION;
     mapRegion.Bounds.Width =
             (recordIndex.MaxX - recordIndex.MinX) / DOUBLE_PRECISION;
     mapRegion.Bounds.Height =
             (recordIndex.MaxY - recordIndex.MinY) / DOUBLE_PRECISION;
     int centerX = DataReader.ReadInt(_reader);
     int centerY = DataReader.ReadInt(_reader);
     mapRegion.CenterPt.X = centerX / DOUBLE_PRECISION;
     mapRegion.CenterPt.Y = centerY / DOUBLE_PRECISION;
     int numberOfPoints = DataReader.ReadInt(_reader);
     GeoLatLng[] latLngs = new GeoLatLng[numberOfPoints];
     for (int i = 0; i < numberOfPoints; i++)
     {
         int x = DataReader.ReadInt(_reader);
         int y = DataReader.ReadInt(_reader);
         latLngs[i] = new GeoLatLng(y / DOUBLE_PRECISION,
                 x / DOUBLE_PRECISION);
     }
     mapRegion.Region = new GeoPolygon(latLngs, mapRegion.PenStyle.Color,
             mapRegion.PenStyle.Width, mapRegion.PenStyle.Pattern,
             mapRegion.BrushStyle.ForeColor, mapRegion.BrushStyle.Pattern);
     return mapRegion;
 }
예제 #57
0
 public EstimateRoute(MapRegion region)
 {
     m_region = region;
     init();
 }
        public override void RegionChanged(MKMapView mapView, bool animated)
        {
            var mkregion = MKCoordinateRegion.FromMapRect(mapView.VisibleMapRect);

            var region = new MapRegion(new Position(mkregion.Center.Latitude, mkregion.Center.Longitude),
                                       mkregion.Span.LatitudeDelta, mkregion.Span.LongitudeDelta);
            _renderer.Map.VisibleRegion = region;
        }
예제 #59
0
 public MapNode(MapSlot newSlot, MapRegion newRegion)
 {
     occupiedSlot = newSlot;
     region = newRegion;
 }
예제 #60
0
 /// <summary>
 /// 移动地图,偏移量为屏幕量,非经纬度
 /// </summary>
 /// <param name="xOffset"></param>
 /// <param name="yOffset"></param>
 public void moveMap(float xOffset, float yOffset)
 {
     m_mapPt.x += xOffset / (m_scale * Properties.Settings.Default.ScaleFactor);
     m_mapPt.y += yOffset / (m_scale * Properties.Settings.Default.ScaleFactor);
     Box box;
     box.xmin = m_mapPt.x;
     box.ymin = m_mapPt.y;
     box.xmax = m_mapPt.x + ((double)m_screenSize.X) / (m_scale * Properties.Settings.Default.ScaleFactor);
     box.ymax = m_mapPt.y + ((double)m_screenSize.Y) / (m_scale * Properties.Settings.Default.ScaleFactor);
     m_currentRegion = m_rm.getSmallRegion(box);
     m_bRebuildRegion = true;
 }