コード例 #1
0
 void Application_Start(object sender, EventArgs e)
 {
     // Code that runs on application startup
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     CurrentLocation cur = new CurrentLocation();
 }
コード例 #2
0
        /// <summary>
        /// Writes a save to a folder. The save name is generated based on the save number stored by
        /// this save.
        /// </summary>
        /// <param name="saveDirectory"></param>
        public void Write(string saveDirectory)
        {
            // The output file is indicated by the save number.
            var writer = new BinaryWriter(File.Create(Path.Combine(saveDirectory, SaveFileName)));

            //BinaryWriter writer = new BinaryWriter(stream);

            // Firstly, write the header.
            writer.Write(Header);

            Details.Write(writer);

            // Now the skills.
            writer.Write(Proficiencies.ActiveCount + Skills.ActiveCount);
            Proficiencies.WriteAllProficiencies(writer);
            Skills.WriteAllSkills(writer);

            // Some unknown stuff.
            writer.Write(Vehicle1Color);
            writer.Write(Vehicle2Color);
            writer.Write(UnknownVariable4);
            writer.Write(UnknownVariable5);

            // Ammo.
            writer.Write(Ammo.Count);
            foreach (var ammo in Ammo)
            {
                ammo.Value.Write(writer);
            }

            // Items.
            writer.Write(Items.Count);
            foreach (var item in Items)
            {
                item.Write(writer);
            }

            writer.Write(BackpackSlots);
            writer.Write(WeaponSlots);

            // Weapons.
            writer.Write(Weapons.Count);
            foreach (var weapon in Weapons)
            {
                weapon.Write(writer);
            }

            // Stats.
            StatTable.Write(writer);

            // Visited locations.
            writer.Write(LocationsVisited.Count);
            foreach (var location in LocationsVisited)
            {
                writer.BL_WriteString(location.InternalName());
            }

            writer.BL_WriteString(CurrentLocation.InternalName());

            writer.Write(UnknownVariable6);
            writer.Write(UnknownVariable7);
            writer.BL_WriteString(UnknownVariable8);
            writer.Write(UnknownVariable9);
            writer.Write(UnknownVariable10);
            writer.Write(SaveNumber);
            writer.Write(UnknownVariable12);
            writer.Write(0u);

            // Playthroughs.
            writer.Write(Playthroughs.Count);
            foreach (var playthrough in Playthroughs)
            {
                writer.Write(playthrough.Number);
                writer.BL_WriteString(playthrough.ActiveMissionName);
                writer.Write(playthrough.FoundMissionsCount);
                foreach (var mission in playthrough.Missions)
                {
                    if (mission.Value.Status != Mission.MissionStatus.Unknown)
                    {
                        writer.BL_WriteString(mission.Value.InternalName);
                        writer.Write(mission.Value.MissionStatusFlag);
                        writer.Write(mission.Value.UnknownVariable2);
                        writer.Write(mission.Value.UnknownVariable3);
                        writer.Write(mission.Value.Details.Count);
                        foreach (var detail in mission.Value.Details)
                        {
                            writer.BL_WriteString(detail.UnknownString);
                            writer.Write(detail.UnknownVariable);
                        }
                    }
                }
            }

            writer.Write(PlayTimeSeconds);
            writer.BL_WriteString(SaveTimeString);
            writer.BL_WriteString(Name);
            writer.Write(Color1ARGB);
            writer.Write(Color2ARGB);
            writer.Write(Color3ARGB);

            writer.Write(UnknownVariable14);
            writer.Write(UnknownVariable15.Count);
            foreach (Int32 x in UnknownVariable15)
            {
                writer.Write(x);
            }
            writer.Write(UnknownVariable16.Count);
            foreach (Int32 x in UnknownVariable16)
            {
                writer.Write(x);
            }

            // Echo
            writer.Write(EchoPlaythroughs.Count);
            foreach (var echoPlaythrough in EchoPlaythroughs)
            {
                writer.Write(echoPlaythrough.Playthrough);
                writer.Write(echoPlaythrough.Echoes.Count);
                foreach (var echo in echoPlaythrough.Echoes)
                {
                    writer.BL_WriteString(echo.InternalName);
                    writer.Write(echo.UnknownVariable1);
                    writer.Write(echo.UnknownVariable2);
                }
            }

            writer.Write(UnknownVariable17.Length);
            writer.Write(UnknownVariable17);

            writer.Close();
        }
コード例 #3
0
ファイル: GameSession.cs プロジェクト: vankos/UURRPG
 private void OnCurrentEnemyKilled(object sender, System.EventArgs e)
 {
     CurrentEnemy = CurrentLocation.GetMonster();
     CompleteQuestsAtLocation();
 }
コード例 #4
0
    private void Start()
    {
        changing        = false;
        currentLocation = CurrentLocation.middle;
        turnSpeed       = 10f; //increase to slow

        GameObject edgeLeft   = this.transform.GetChild(0).transform.GetChild(0).gameObject;
        GameObject edgeMiddle = this.transform.GetChild(0).transform.GetChild(1).gameObject;
        GameObject edgeRight  = this.transform.GetChild(0).transform.GetChild(2).gameObject;

        GameObject block = this.transform.GetChild(1).transform.GetChild(0).gameObject;

        GameObject bullet = this.transform.GetChild(2).gameObject;

        //Debug.LogWarning(edgeRight.transform.up.normalized);

        edgeLeft.transform.RotateAround(Vector3.zero, Vector3.back, 60f);
        edgeRight.transform.RotateAround(Vector3.zero, Vector3.forward, 60f);

        //Vector3 left = new Vector3(-8.8f,-5f,0f);
        Vector3 middle  = block.transform.position;
        Vector3 middleR = new Vector3(0f, 0f, 0f);

        //Vector3 right = new Vector3(8.8f, -5f, 0f);
        block.transform.RotateAround(Vector3.zero, Vector3.back, 60f);

        Vector3 leftUp  = block.transform.position;
        Vector3 leftUpR = new Vector3(0f, 0f, -60f);

        block.transform.RotateAround(Vector3.zero, Vector3.forward, 120f);

        Vector3 rightUp  = block.transform.position;
        Vector3 rightUpR = new Vector3(0f, 0f, 60f);

        BlockPos.Add(leftUp);
        BlockPos.Add(middle);
        BlockPos.Add(rightUp);

        BlockRot.Add(leftUpR);
        BlockRot.Add(middleR);
        //BlockRot.Add(rightR);
        BlockRot.Add(rightUpR);
        //BlockRot.Add(middleUpR);
        //BlockRot.Add(leftUpR);
        bullet.transform.position = new Vector3(0f, TutPlayer.instance.transform.position.y, -30f);
        Vector3 bulletPosMiddle = bullet.transform.position;

        bullet.transform.RotateAround(Vector3.zero, Vector3.back, 60f);

        Vector3 bulletPosLeft = bullet.transform.position;

        bullet.transform.RotateAround(Vector3.zero, Vector3.forward, 120f);

        Vector3 bulletPosRight = bullet.transform.position;

        //Vector3 coinPosMiddleUp = new Vector3(0f, -TutPlayer.instance.transform.position.y, 0f);
        CoinAndBulletPos.Add(bulletPosLeft);
        CoinAndBulletPos.Add(bulletPosMiddle);
        CoinAndBulletPos.Add(bulletPosRight);
        BulletRot.Add(new Vector3(0, 0, 30f));
        BulletRot.Add(new Vector3(0, 0, 90f));
        BulletRot.Add(new Vector3(0, 0, 150f));
    }
コード例 #5
0
ファイル: TNT.cs プロジェクト: muukvds/BoulderDash
 public override bool Move(Direction direction)
 {
     _faling = true;
     CurrentLocation.NeighbourTile(direction).MoveGameObjectTo(this);
     return(true);
 }
コード例 #6
0
 private void GetMonsterAtLocation()
 {
     CurrentMonster = CurrentLocation.GetMonster();
 }
コード例 #7
0
 public AvengerAttribute(CurrentLocation location)
 {
     this.Location = location;
 }
コード例 #8
0
        /// <summary>
        /// The Move method is called to move the robot.
        /// The Trémaux's algorithm is used to control the robot.
        /// https://en.wikipedia.org/wiki/Maze_solving_algorithm#Tr%C3%A9maux's_algorithm
        /// </summary>
        /// <param name="mazeSegment"></param>
        public void Move(MazeSegment mazeSegment)
        {
            try
            {
                if (mazeSegment == null)
                {
                    throw new Exception("maze segment can not be null.");
                }

                if (CurrentLocation == null)
                {
                    // The robot is not in the maze - do nothing.
                    return;
                }

                // If the robot is NOT at a junction, mark the location.
                if (mazeSegment.SegmentType != SegmentType.Junction)
                {
                    CurrentLocation.MarkCell();
                }

                // If the robot is at a dead-end (except for the start of the maze), mark the location a second time.
                if (mazeSegment.SegmentType == SegmentType.DeadEnd && CurrentLocation.CellRole != CellRole.Start)
                {
                    CurrentLocation.MarkCell();
                }

                // Turn the robot, based on the type of maze segment.
                CurrentDirection = mazeSegment.ChooseDirection(CurrentDirection);

                // Attempt to move the robot forwards.
                MazeCell newCurrentLocation = null;
                if (CurrentDirection == Direction.North && mazeSegment.NorthCell.CellMark != CellMark.Twice)
                {
                    newCurrentLocation = mazeSegment.NorthCell;
                }
                else if (CurrentDirection == Direction.East && mazeSegment.EastCell.CellMark != CellMark.Twice)
                {
                    newCurrentLocation = mazeSegment.EastCell;
                }
                else if (CurrentDirection == Direction.South && mazeSegment.SouthCell.CellMark != CellMark.Twice)
                {
                    newCurrentLocation = mazeSegment.SouthCell;
                }
                else if (CurrentDirection == Direction.West && mazeSegment.WestCell.CellMark != CellMark.Twice)
                {
                    newCurrentLocation = mazeSegment.WestCell;
                }

                // Update the current location.
                CurrentLocation.ContainsRobot = false;
                CurrentLocation = newCurrentLocation != null ? newCurrentLocation : CurrentLocation;
                CurrentLocation.ContainsRobot = true;

                if (CurrentLocation.CellRole == CellRole.End)
                {
                    OnReachedTheEnd?.Invoke();  // The robot has reached the end of the maze.
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Robot.Move(MazeSegment mazeSegment): " + ex.ToString());
            }
        }
コード例 #9
0
        ///  <summary>
        ///         Sets an Option that was requested from template
        ///  </summary>
        ///  <param name="name"></param>
        ///  <param name="value"></param>
        ///  <param name="parserOptions"></param>
        ///  <returns></returns>
        public async Promise SetOption(string name, IMorestachioExpression value, ParserOptions parserOptions)
        {
            var val = (await value.GetValue(new ContextObject(".", null, new object()), new ScopeData(parserOptions)))
                      .Value;

            if (name.Equals("TrimTailing", StringComparison.OrdinalIgnoreCase))
            {
                if (val == null)
                {
                    Errors.Add(new MorestachioSyntaxError(CurrentLocation.AddWindow(new CharacterSnippedLocation()),
                                                          "SET OPTION", "VALUE", $"The expression returned null for option '{name}' that does not accept a null value"));
                    return;
                }
                if (!(val is bool valBool))
                {
                    Errors.Add(new MorestachioSyntaxError(CurrentLocation.AddWindow(new CharacterSnippedLocation()),
                                                          "SET OPTION", "VALUE", $"The expression returned '{val.GetType()}' for option '{name}' but expected and value of type '{typeof(bool)}'"));
                    return;
                }
                TrimTailing = valBool;
            }
            if (name.Equals("TrimLeading", StringComparison.OrdinalIgnoreCase))
            {
                if (val == null)
                {
                    Errors.Add(new MorestachioSyntaxError(CurrentLocation.AddWindow(new CharacterSnippedLocation()),
                                                          "SET OPTION", "VALUE", $"The expression returned null for option '{name}' that does not accept a null value"));
                    return;
                }
                if (!(val is bool valBool))
                {
                    Errors.Add(new MorestachioSyntaxError(CurrentLocation.AddWindow(new CharacterSnippedLocation()),
                                                          "SET OPTION", "VALUE", $"The expression returned '{val.GetType()}' for option '{name}' but expected and value of type '{typeof(bool)}'"));
                    return;
                }
                TrimLeading = valBool;
            }
            if (name.Equals("TrimAllTailing", StringComparison.OrdinalIgnoreCase))
            {
                if (val == null)
                {
                    Errors.Add(new MorestachioSyntaxError(CurrentLocation.AddWindow(new CharacterSnippedLocation()),
                                                          "SET OPTION", "VALUE", $"The expression returned null for option '{name}' that does not accept a null value"));
                    return;
                }
                if (!(val is bool valBool))
                {
                    Errors.Add(new MorestachioSyntaxError(CurrentLocation.AddWindow(new CharacterSnippedLocation()),
                                                          "SET OPTION", "VALUE", $"The expression returned '{val.GetType()}' for option '{name}' but expected and value of type '{typeof(bool)}'"));
                    return;
                }
                TrimAllTailing = valBool;
            }
            if (name.Equals("TrimAllLeading", StringComparison.OrdinalIgnoreCase))
            {
                if (val == null)
                {
                    Errors.Add(new MorestachioSyntaxError(CurrentLocation.AddWindow(new CharacterSnippedLocation()),
                                                          "SET OPTION", "VALUE", $"The expression returned null for option '{name}' that does not accept a null value"));
                    return;
                }
                if (!(val is bool valBool))
                {
                    Errors.Add(new MorestachioSyntaxError(CurrentLocation.AddWindow(new CharacterSnippedLocation()),
                                                          "SET OPTION", "VALUE", $"The expression returned '{val.GetType()}' for option '{name}' but expected and value of type '{typeof(bool)}'"));
                    return;
                }
                TrimAllLeading = valBool;
            }
        }
コード例 #10
0
ファイル: FireFly.cs プロジェクト: muukvds/BoulderDash
        public override bool Move(Direction direction)
        {
            switch (Front)
            {
            case Direction.RIGHT:

                if (CurrentLocation.NeighbourTile(Direction.UP).GetGameObject() == null)
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.UP));
                    Front = Direction.UP;
                }
                else if (CurrentLocation.NeighbourTile(Direction.RIGHT).GetGameObject() == null)
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.RIGHT));
                }
                else if (CurrentLocation.NeighbourTile(Direction.DOWN).GetGameObject() == null)
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.DOWN));
                    Front = Direction.DOWN;
                }
                else
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.LEFT));
                    Front = Direction.LEFT;
                }

                break;

            case Direction.DOWN:
                if (CurrentLocation.NeighbourTile(Direction.RIGHT).GetGameObject() == null)
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.RIGHT));
                    Front = Direction.RIGHT;
                }
                else if (CurrentLocation.NeighbourTile(Direction.DOWN).GetGameObject() == null)
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.DOWN));
                }
                else if (CurrentLocation.NeighbourTile(Direction.LEFT).GetGameObject() == null)
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.LEFT));
                    Front = Direction.LEFT;
                }
                else
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.UP));
                    Front = Direction.UP;
                }
                break;

            case Direction.LEFT:
                if (CurrentLocation.NeighbourTile(Direction.DOWN).GetGameObject() == null)
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.DOWN));
                    Front = Direction.DOWN;
                }
                else if (CurrentLocation.NeighbourTile(Direction.LEFT).GetGameObject() == null)
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.LEFT));
                }
                else if (CurrentLocation.NeighbourTile(Direction.UP).GetGameObject() == null)
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.UP));
                    Front = Direction.UP;
                }
                else
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.RIGHT));
                    Front = Direction.RIGHT;
                }
                break;

            case Direction.UP:
                if (CurrentLocation.NeighbourTile(Direction.LEFT).GetGameObject() == null)
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.LEFT));
                    Front = Direction.LEFT;
                }
                else if (CurrentLocation.NeighbourTile(Direction.UP).GetGameObject() == null)
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.UP));
                }
                else if (CurrentLocation.NeighbourTile(Direction.RIGHT).GetGameObject() == null)
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.RIGHT));
                    Front = Direction.RIGHT;
                }
                else
                {
                    MoveTo(CurrentLocation.NeighbourTile(Direction.DOWN));
                    Front = Direction.DOWN;
                }
                break;
            }

            return(true);
        }
コード例 #11
0
 public override string ToString()
 {
     return($"{CurrentLocation.Coordinates()}; {RankName()}; {RankValue}; {Color}; {IsEliminated}");
 }
コード例 #12
0
        public CurrentLocationViewModel MapDataObjectToPresentation(CurrentLocationViewModel presentationViewModelObject, CurrentLocation DataModel)
        {
            presentationViewModelObject.LocationID   = DataModel.CurrentLocationID;
            presentationViewModelObject.LocationName = DataModel.CurrentLocation1;

            return(presentationViewModelObject);
        }
コード例 #13
0
        public void DisplayMenu()
        {
            //TODO modify this menu to include options for travelling between galaxies and for travelling between locations within the CurrentGalaxy

            //see if CurrentLocation is of data type Planet
            //  if it is see if it is the InterGalacticLaunchPlanet
            //    if it is then menu should include options for galaxy travel, location travel, and quit
            //  else menu should include location travel and quit
            //else menu should include location travel and quit

            string menuOptions         = "(P) to list neighbor planetary objects. (Q) to quit.";
            bool   InterGalacticTravel = false;

            if (CurrentLocation is Planet)
            {
                Planet littlePlanet = (Planet)CurrentLocation;
                if (littlePlanet.InterGalacticLaunchSite)
                {
                    menuOptions         = "(G) to list neighbor galaxies. " + menuOptions;
                    InterGalacticTravel = true;
                }
            }

            System.Console.WriteLine(menuOptions);
            switch (Console.ReadLine())
            {
            case "G":
            case "g":
                if (!InterGalacticTravel)
                {
                    System.Console.WriteLine($"Must be at {CurrentGalaxy.InterGalacticLaunchPlanet.Name} for InterGalactic Travel.");
                    break;
                }
                CurrentGalaxy.ListNeighbors();
                if (CheckFuel())
                {
                    string galaxyName = CurrentGalaxy.Name;
                    CurrentGalaxy   = CurrentGalaxy.TravelToNeighbor();
                    CurrentLocation = CurrentGalaxy.InterGalacticLaunchPlanet;
                    if (galaxyName != CurrentGalaxy.Name)
                    {
                        RocketFuel -= 20;
                    }
                }
                else
                {
                    System.Console.WriteLine("Search within yourself");
                }

                break;

            case "P":
            case "p":
                CurrentLocation.ListNeighbors();
                if (CurrentLocation is Moon)
                {
                    CurrentLocation = CurrentLocation.TravelToNeighbor();
                }
                else
                {
                    Planet currentPlanet = (Planet)CurrentLocation; //NOTE the right side logic is type casting to change from data type Location to Planet so that we can access the method DisplayOptions.
                    CurrentLocation = currentPlanet.DisplayOptions(this);
                }
                break;

            case "Q":
            case "q":
                SpaceTraveling = false;
                break;

            default:
                System.Console.WriteLine("Houston we have a problem.");
                break;
            }
        }
コード例 #14
0
 public bool AreEqual(Move i_Move)
 {
     return(CurrentLocation.AreEqual(i_Move.CurrentLocation) && NextLocation.AreEqual(i_Move.NextLocation));
 }
コード例 #15
0
ファイル: GameSession.cs プロジェクト: dpnull/con-rogue
 public void GetEnemyAtLocation()
 {
     CurrentEnemy = CurrentLocation.GetEnemy();
     messageLog.Add("-------------------------------------------");
     messageLog.Add($"You have encountered {CurrentEnemy.Name}!");
 }
コード例 #16
0
 protected override void InnerOnEnabled()
 {
     androidMagneticDeclination = AndroidMagneticDeclination.GetDeclination(CurrentLocation.ToLocation());
 }
コード例 #17
0
 public async Task <LocationResponse> GetCurrentLocationAsync() => await CurrentLocation.CastTask <LocationResponse>();
コード例 #18
0
ファイル: App.cs プロジェクト: LynneMartin/planet-express
 private void Go(string option) //option = 'luna'
 {                              //{Location: Luna}
     CurrentLocation = CurrentLocation.Go(option);
 }
コード例 #19
0
 private void UpdateCurrentCoords()
 {
     tbCurrentLocation.Text = CurrentLocation.ToString();
 }
コード例 #20
0
ファイル: App.cs プロジェクト: LynneMartin/planet-express
        //NOTE runs app
        public void Run()
        {
            while (Running)
            {
                //NOTE this is an auto fail
                for (int i = 0; i < 10; i++)
                {
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Clear();
                    Ship();
                    Console.Beep();
                    Thread.Sleep(10);
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Black;
                    Console.Clear();
                    Ship();
                    Console.Beep();
                }
                Console.Clear();
                string greet = $"Welcome to {CurrentLocation.Name}";
                foreach (char letter in greet)
                {
                    Console.Write(letter);
                    Thread.Sleep(100);
                    Console.BackgroundColor = ConsoleColor.White;
                    Thread.Sleep(100);
                }

                System.Console.WriteLine("");
                System.Console.Write("Destinations Available: ");
                CurrentLocation.PrintDirections();
                if (CurrentLocation is Planet)
                {
                    var CurrentPlanet = (Planet)CurrentLocation;
                    CurrentPlanet.PrintGuestBook();
                }
                System.Console.Write("What do you want to do: ");

                //NOTE LOOK AT ME TOMORROW  ("go next", "quit", "go {Moon.name}", "go home", "sign" )

                //NOTE takes in the input and splits into array of strings based on space character

                //                  input = ['go', 'luna']
                string[] input = Console.ReadLine().ToLower().Split(' ');
                Console.Clear();
                string command = input[0]; //command = 'go'
                string option  = "";       //option = ''
                if (input.Length > 1)
                {
                    option = input[1]; //option = 'luna'
                }
                //          'go'
                switch (command)
                {
                case "go":
                    Go(option);     // 'luna'
                    break;

                case "quit":
                    Running = false;
                    break;

                case "sign":
                    Sign();
                    break;

                default:
                    System.Console.WriteLine("Unknown Command");
                    break;
                }
            }
        }
コード例 #21
0
ファイル: Piece.cs プロジェクト: ArifSheikh/Medical-Training
 // Return true if this position is within
 // the piece's current location.
 public bool Contains(Point pt)
 {
     return(CurrentLocation.Contains(pt));
 }
コード例 #22
0
 protected override void InnerOnEnabled()
 {
     androidMagneticDeclination = AndroidMagneticDeclination.GetDeclination(CurrentLocation.ToLocation());
     androidNativeCompass       = new AndroidNativeCompass((float)(1.0 - LowPassFilterFactor));
 }
コード例 #23
0
        public void Update(float deltaTime, GUICustomComponent mapContainer)
        {
            Rectangle rect = mapContainer.Rect;

            if (CurrentDisplayLocation != null)
            {
                if (!CurrentDisplayLocation.Discovered)
                {
                    RemoveFogOfWar(CurrentDisplayLocation);
                    CurrentDisplayLocation.Discovered = true;
                    if (CurrentDisplayLocation.MapPosition.X > furthestDiscoveredLocation.MapPosition.X)
                    {
                        furthestDiscoveredLocation = CurrentDisplayLocation;
                    }
                }
            }

            currLocationIndicatorPos = Vector2.Lerp(currLocationIndicatorPos, CurrentDisplayLocation.MapPosition, deltaTime);
#if DEBUG
            if (GameMain.DebugDraw)
            {
                if (editor == null)
                {
                    CreateEditor();
                }
                editor.AddToGUIUpdateList(order: 1);
            }
#endif

            if (mapAnimQueue.Count > 0)
            {
                hudVisibility = Math.Max(hudVisibility - deltaTime, 0.0f);
                UpdateMapAnim(mapAnimQueue.Peek(), deltaTime);
                if (mapAnimQueue.Peek().Finished)
                {
                    mapAnimQueue.Dequeue();
                }
                return;
            }

            hudVisibility = Math.Min(hudVisibility + deltaTime, 0.75f + (float)Math.Sin(Timing.TotalTime * 3.0f) * 0.25f);

            Vector2 rectCenter = new Vector2(rect.Center.X, rect.Center.Y);
            Vector2 viewOffset = DrawOffset + drawOffsetNoise;

            float closestDist = 0.0f;
            HighlightedLocation = null;
            if (GUI.MouseOn == null || GUI.MouseOn == mapContainer)
            {
                for (int i = 0; i < Locations.Count; i++)
                {
                    Location location = Locations[i];
                    if (IsInFogOfWar(location) && !(CurrentDisplayLocation?.Connections.Any(c => c.Locations.Contains(location)) ?? false) && !GameMain.DebugDraw)
                    {
                        continue;
                    }

                    Vector2 pos = rectCenter + (location.MapPosition + viewOffset) * zoom;
                    if (!rect.Contains(pos))
                    {
                        continue;
                    }

                    float iconScale = generationParams.LocationIconSize / location.Type.Sprite.size.X;
                    if (location == CurrentDisplayLocation)
                    {
                        iconScale *= 1.2f;
                    }

                    Rectangle drawRect = location.Type.Sprite.SourceRect;
                    drawRect.Width  = (int)(drawRect.Width * iconScale * zoom * 1.4f);
                    drawRect.Height = (int)(drawRect.Height * iconScale * zoom * 1.4f);
                    drawRect.X      = (int)pos.X - drawRect.Width / 2;
                    drawRect.Y      = (int)pos.Y - drawRect.Width / 2;

                    if (!drawRect.Contains(PlayerInput.MousePosition))
                    {
                        continue;
                    }

                    float dist = Vector2.Distance(PlayerInput.MousePosition, pos);
                    if (HighlightedLocation == null || dist < closestDist)
                    {
                        closestDist         = dist;
                        HighlightedLocation = location;
                    }
                }
            }

            if (GUI.KeyboardDispatcher.Subscriber == null)
            {
                float   moveSpeed  = 1000.0f;
                Vector2 moveAmount = Vector2.Zero;
                if (PlayerInput.KeyDown(InputType.Left))
                {
                    moveAmount += Vector2.UnitX;
                }
                if (PlayerInput.KeyDown(InputType.Right))
                {
                    moveAmount -= Vector2.UnitX;
                }
                if (PlayerInput.KeyDown(InputType.Up))
                {
                    moveAmount += Vector2.UnitY;
                }
                if (PlayerInput.KeyDown(InputType.Down))
                {
                    moveAmount -= Vector2.UnitY;
                }
                DrawOffset += moveAmount * moveSpeed / zoom * deltaTime;
            }

            targetZoom = MathHelper.Clamp(targetZoom, generationParams.MinZoom, generationParams.MaxZoom);
            zoom       = MathHelper.Lerp(zoom, targetZoom, 0.1f);

            if (GUI.MouseOn == mapContainer)
            {
                foreach (LocationConnection connection in Connections)
                {
                    if (HighlightedLocation != CurrentDisplayLocation &&
                        connection.Locations.Contains(HighlightedLocation) && connection.Locations.Contains(CurrentDisplayLocation))
                    {
                        if (PlayerInput.PrimaryMouseButtonClicked() &&
                            SelectedLocation != HighlightedLocation && HighlightedLocation != null)
                        {
                            //clients aren't allowed to select the location without a permission
                            if ((GameMain.GameSession?.GameMode as CampaignMode)?.AllowedToManageCampaign() ?? false)
                            {
                                SelectedConnection = connection;
                                SelectedLocation   = HighlightedLocation;

                                OnLocationSelected?.Invoke(SelectedLocation, SelectedConnection);
                                GameMain.Client?.SendCampaignState();
                            }
                        }
                    }
                }

                targetZoom += PlayerInput.ScrollWheelSpeed / 500.0f;

                if (PlayerInput.MidButtonHeld() || (HighlightedLocation == null && PlayerInput.PrimaryMouseButtonHeld()))
                {
                    DrawOffset += PlayerInput.MouseSpeed / zoom;
                }
                if (AllowDebugTeleport)
                {
                    if (PlayerInput.DoubleClicked() && HighlightedLocation != null)
                    {
                        var passedConnection = CurrentDisplayLocation.Connections.Find(c => c.OtherLocation(CurrentDisplayLocation) == HighlightedLocation);
                        if (passedConnection != null)
                        {
                            passedConnection.Passed = true;
                        }

                        Location prevLocation = CurrentDisplayLocation;
                        CurrentLocation = HighlightedLocation;
                        Level.Loaded.DebugSetStartLocation(CurrentLocation);
                        Level.Loaded.DebugSetEndLocation(null);

                        CurrentLocation.Discovered = true;
                        CurrentLocation.CreateStore();
                        OnLocationChanged?.Invoke(prevLocation, CurrentLocation);
                        SelectLocation(-1);
                        if (GameMain.Client == null)
                        {
                            ProgressWorld();
                        }
                        else
                        {
                            GameMain.Client.SendCampaignState();
                        }
                    }

                    if (PlayerInput.KeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift) && PlayerInput.PrimaryMouseButtonClicked() && HighlightedLocation != null)
                    {
                        int distance = DistanceToClosestLocationWithOutpost(HighlightedLocation, out Location foundLocation);
                        DebugConsole.NewMessage($"Distance to closest outpost from {HighlightedLocation.Name} to {foundLocation?.Name} is {distance}");
                    }

                    if (PlayerInput.PrimaryMouseButtonClicked() && HighlightedLocation == null)
                    {
                        SelectLocation(-1);
                    }
                }
            }
        }
コード例 #24
0
 public void AssignLocation(ILocation location)
 {
     PreviousLocation = CurrentLocation.GetCopy();
     CurrentLocation  = location?.GetCopy();
 }