private static void ProcessEquipCommand(string[] parts) //write to equip from backpack { string itemName = parts[1]; Item item; if (CurrentArea.HasItem(parts[1])) { item = CurrentArea.GetItem(parts[1]); // turn into backpack if (item is IEquippableItem) { try { ((IEquippableItem)item).Equip(); } catch (WorldException) { return; } } else { throw new WorldException("You can't equip that!"); } } else { throw new WorldException("That's not in your backpack!"); } }
// Changes the current area public void changeArea(KnyttPoint new_area, bool force_jump = false, bool regenerate_same = true) { // Regenerate current area if no change, else deactivate old area if (this.CurrentArea != null) { if (CurrentArea.Area.Position.Equals(new_area)) { if (regenerate_same) { CurrentArea.regenerateArea(regenerate_same: regenerate_same); } return; } CurrentArea.scheduleDeactivation(); } // Update the paging GDWorld.Areas.setLocation(new_area); var area = GDWorld.getArea(new_area); if (area == null) { return; } this.CurrentArea = area; this.CurrentArea.activateArea(); this.beginTransitionEffects(force_jump); Juni.stopHologram(cleanup: true); }
public bool Equals(SimpleVariables other) { if (other == null) { return(false); } return(CurrentLevel.Equals(other.CurrentLevel) && CurrentArea.Equals(other.CurrentArea) && Language.Equals(other.Language) && MillisecondsPerGameMinute.Equals(other.MillisecondsPerGameMinute) && LastClockTick.Equals(other.LastClockTick) && GameClockHours.Equals(other.GameClockHours) && GameClockMinutes.Equals(other.GameClockMinutes) && GameClockSeconds.Equals(other.GameClockSeconds) && TimeInMilliseconds.Equals(other.TimeInMilliseconds) && TimeScale.Equals(other.TimeScale) && TimeStep.Equals(other.TimeStep) && TimeStepNonClipped.Equals(other.TimeStepNonClipped) && FramesPerUpdate.Equals(other.FramesPerUpdate) && FrameCounter.Equals(other.FrameCounter) && OldWeatherType.Equals(other.OldWeatherType) && NewWeatherType.Equals(other.NewWeatherType) && ForcedWeatherType.Equals(other.ForcedWeatherType) && WeatherTypeInList.Equals(other.WeatherTypeInList) && WeatherInterpolationValue.Equals(other.WeatherInterpolationValue) && CameraPosition.Equals(other.CameraPosition) && CameraModeInCar.Equals(other.CameraModeInCar) && CameraModeOnFoot.Equals(other.CameraModeOnFoot) && ExtraColor.Equals(other.ExtraColor) && IsExtraColorOn.Equals(other.IsExtraColorOn) && ExtraColorInterpolation.Equals(other.ExtraColorInterpolation) && Brightness.Equals(other.Brightness) && DisplayHud.Equals(other.DisplayHud) && ShowSubtitles.Equals(other.ShowSubtitles) && RadarMode.Equals(other.RadarMode) && BlurOn.Equals(other.BlurOn) && UseWideScreen.Equals(other.UseWideScreen) && MusicVolume.Equals(other.MusicVolume) && SfxVolume.Equals(other.SfxVolume) && RadioStation.Equals(other.RadioStation) && StereoOutput.Equals(other.StereoOutput) && PadMode.Equals(other.PadMode) && InvertLook.Equals(other.InvertLook) && UseVibration.Equals(other.UseVibration) && SwapNippleAndDPad.Equals(other.SwapNippleAndDPad) && HasPlayerCheated.Equals(other.HasPlayerCheated) && AllTaxisHaveNitro.Equals(other.AllTaxisHaveNitro) && TargetIsOn.Equals(other.TargetIsOn) && TargetPosition.Equals(other.TargetPosition) && PlayerPosition.Equals(other.PlayerPosition) && TrailsOn.Equals(other.TrailsOn) && TimeStamp.Equals(other.TimeStamp) && Unknown78hPS2.Equals(other.Unknown78hPS2) && Unknown7ChPS2.Equals(other.Unknown7ChPS2) && Unknown90hPS2.Equals(other.Unknown90hPS2) && UnknownB8hPSP.Equals(other.UnknownB8hPSP) && UnknownD8hPS2.Equals(other.UnknownD8hPS2) && UnknownD9hPS2.Equals(other.UnknownD9hPS2)); }
// TODO: Difference between Paged areas, active areas, and current area. // Current area is per-Juni public override void _PhysicsProcess(float delta) { // TODO: Do this only if the local player if (!CurrentArea.isIn(Juni.GlobalPosition)) { warpJuni(Juni); } }
private void Update() { sinceLastUpdate += Time.deltaTime; if (sinceLastUpdate > worldUpdatesEvery) { sinceLastUpdate = 0; } CurrentArea.Update(Time.deltaTime); }
private void Ui_TilePainted(object sender, PaintEventArgs e) { if (CurrentArea != null) { if (CurrentArea.Contains(Ui.PaintingTile.X, Ui.PaintingTile.Y)) { e.Graphics.FillRegion(brush, e.Graphics.Clip); } } }
internal void RenderCurrentImage(Area favorite) { LastRenderedArea = CurrentArea.Clone(); CurrentImage = LastRenderedArea.Render( CurrentImageRenderWidth, CurrentImageRenderHeight); Notify(nameof(CurrentImage)); // Notify others in case they want to do something, like // resetting a ScrollViewer which we should not know about here. CurrentImageRerendered?.Invoke(); }
/// <summary> /// Enter Combat mode. /// </summary> /// <param name="parts">Command as typed by the user split into individual words.</param> private static void ProcessFightCommand(string[] parts) { Creature creature; try { creature = CurrentArea.GetCreature(parts[1]); } catch (WorldException e) { if (CurrentArea.HasItem(parts[1])) { PrintLineWarning("You can't fight with that..."); } else { PrintLineDanger(e.Message); } return; } // This method is part of the MainClass but is defined in a different file. // Check out the Combat.cs file. CombatResult result = DoCombat(creature); switch (result) { case CombatResult.Win: PrintLinePositive("You win!"); Player.Stats.Exp += creature.Stats.Exp; CurrentArea.RemoveCreature(parts[1]); // TODO: Part of a larger achievement // After you gain Exp, how do you improve your stats? // there should be some rules to how this works. // But, you are the god of this universe. You make the rules. // TODO: Part of a larger achievement // After defeating an Enemy, they should drop their Inventory // into the CurrentArea so that the player can then PickUp those Items. break; case CombatResult.Lose: PrintLineDanger("You lose!"); // TODO: Easy Achievement: // What happens when you die? Deep questions. break; case CombatResult.RunAway: // TODO: Moderate Achievement // Handle running away. What happens if you run from a battle? break; default: break; } }
public void Talk(string[] input) { if (input.Length > 1) { CurrentArea.Talk(input[1], CurrentPlayer); } else { Console.WriteLine("Don't talk to yourself."); } }
public void Look(string[] input) { if (input.Length > 1) { CurrentArea.Look(input[1]); } else { Console.WriteLine(CurrentArea.Description); } }
public void UseItem(string input) { if (CurrentPlayer.Inventory.Find(i => i.Name.ToLower() == input) != null) { CurrentArea.UseItem(input, CurrentPlayer); } else { Console.WriteLine("You don't even have one of those."); } }
private static void ProcessUseCommand(string[] parts) { if (parts.Length == 1) { PrintLineWarning("Please specify which item."); return; } if (parts.Length == 2) { CurrentArea.GetItem(parts[1]); IUseableItem itemToUse = CurrentArea.GetItem(parts[1]) as IUseableItem; if (itemToUse != null) { try { ((IUseableItem)itemToUse).Use(); PrintLinePositive("Neat thing!"); } catch (ItemDepletedException ide) { PrintLineSpecial(ide.Message); } catch (WorldException we) { PrintLineDanger(we.Message); } } else { PrintLineWarning("This item cannot be used..."); return; } } string targetName = parts[3]; object target; if (CurrentArea.HasItem(targetName)) { target = CurrentArea.GetItem(targetName); } else if (CurrentArea.CreatureExists(targetName)) { target = CurrentArea.GetCreature(targetName); } else { PrintLineWarning("I don't see any of that around here..."); return; } }
private void HandleEntityUseMessage(EntityUseMessage entityUseMessage) { var playerCharacter = PlayerCharacter; var toolImpact = playerCharacter.ReplayUse(entityUseMessage); CurrentArea.UseFeedback(new UseFeedbackMessage { Token = entityUseMessage.Token, Impact = toolImpact, OwnerDynamicId = playerCharacter.DynamicId }); }
public void TakeItem(string input) { Item item = CurrentArea.TakeItem(input); if (item == null) { Console.WriteLine("You probably WISH you could get that."); } else { CurrentPlayer.addItem(item); CurrentArea.Items.Remove(item); } }
public void Go(string direction) { var areaInDirection = CurrentArea.GetNeighbor(direction); if (areaInDirection == null) { System.Console.WriteLine($"{this.Name} doesn't see anything {direction}.."); } else { CurrentArea = areaInDirection; System.Console.WriteLine($"Ye, ok. Im at {CurrentArea.Name}"); } }
public void Go(string[] input) { if (input.Length < 2) { Console.WriteLine("Pretty sure you need a DIRECTION to go in. Type HELP for help."); return; } Area newArea = CurrentArea.Go(input[1]); newArea.Checks(CurrentPlayer); CurrentArea = newArea; Console.WriteLine(); Console.WriteLine(CurrentArea.Description); Console.WriteLine(); }
public void Open(NavigationObject obj) { if (CurrentArea != null && CurrentArea.AreaName == obj.AreaName) { return; } if (CurrentArea != null) { nextAreas.Add(obj); NextArea = GameObject.Instantiate(GetAreaReferenceFromName(obj.AreaName)); NextArea.Init(obj.Params); Close(); return; } history.Add(obj); if (NextArea != null) { CurrentArea = NextArea; } else { CurrentArea = GameObject.Instantiate(GetAreaReferenceFromName(obj.AreaName)); CurrentArea.Init(obj.Params); } NextArea = null; //SimpleTimer.StartTimer (0.1f, delegate() { CurrentArea.transform.SetParent(areaTarget.transform); CurrentArea.transform.position = Vector3.zero; CurrentArea.GetComponent <Image>().rectTransform.offsetMin = new Vector2(0, 0); CurrentArea.GetComponent <Image>().rectTransform.offsetMax = new Vector2(0, 0); CurrentArea.OnNavigationEven += CurrentArea_OnNavigationEven; CurrentArea.transform.localScale = Vector3.one; CurrentArea.Open(); //}); }
public void Apply(Tile tile) { if (CurrentArea != null) { if (!CurrentArea.Contains(tile.X, tile.Y)) { CurrentArea.Add(tile.X, tile.Y); Context.UnsavedChanges = true; } else { CurrentArea.Remove(tile.X, tile.Y); Context.UnsavedChanges = true; } } }
/// <summary> /// Parses the command and do any required actions. /// </summary> /// <param name="command">Command as typed by the user.</param> private static void ParseCommand(string command) { // Break apart the command into individual words: // This is why command words and unique names for objects cannot contain spaces. string[] parts = command.Split(' '); // The first word is the command. string cmdWord = parts.First(); if (!_commands.ContainsKey(cmdWord)) { if (parts.Length > 1) { string target = parts[1]; if (CurrentArea.HasItem(target)) { Item item = CurrentArea.GetItem(target); if (item is IInteractable && ((IInteractable)item).Interactions.ContainsKey(cmdWord)) { ((IInteractable)item).Interactions[cmdWord](parts); return; } } else if (CurrentArea.CreatureExists(target)) { Creature creature = CurrentArea.GetCreature(target); if (creature is IInteractable && ((IInteractable)creature).Interactions.ContainsKey(cmdWord)) { ((IInteractable)creature).Interactions[cmdWord](parts); return; } } } PrintLineWarning("I don't understand...(type \"help\" to see a list of commands I know.)"); return; } // execute the command associated with the given command word! _commands[cmdWord](parts); // TODO: Many Achievements // Implement more commands like "use" and "get" and "talk" }
// Changes the current area public void changeArea(KnyttPoint new_area, bool force_jump = false, bool regenerate_same = true) { // Regenerate current area if no change, else deactivate old area if (this.CurrentArea != null) { if (CurrentArea.Area.Position.Equals(new_area)) { if (regenerate_same) { CurrentArea.regenerateArea(regenerate_same: regenerate_same); } return; } CurrentArea.scheduleDeactivation(); Juni.juniInput.altInput.ClearInput(); } // Update the paging GDWorld.Areas.setLocation(new_area); var area = GDWorld.getArea(new_area); if (area == null) { return; } int change_distance = CurrentArea == null ? 0 : CurrentArea.Area.Position.manhattanDistance(new_area); this.CurrentArea = area; this.CurrentArea.activateArea(); this.beginTransitionEffects(force_jump || change_distance > 1); // never scroll if jump distance is over 1 Juni.stopHologram(cleanup: true); if (area.Area.ExtraData?.ContainsKey("Attach") ?? false) { Juni.enableAttachment(area.Area.getExtraData("Attach")); } if (hasMap()) { Juni.Powers.setVisited(CurrentArea.Area); } }
void Inventory_ItemPut(object sender, EntityContainerEventArgs <ContainedSlot> e) { // skip player own messages if (_dontSendInventoryEvents) { return; } // inform client about his inventory change from outside var msg = new ItemTransferMessage { DestinationContainerEntityLink = PlayerCharacter.GetLink(), DestinationContainerSlot = e.Slot.GridPosition, ItemsCount = e.Slot.ItemsCount, ItemEntityId = e.Slot.Item.BluePrintId, SourceEntityId = PlayerCharacter.DynamicId }; Connection.Send(msg); CurrentArea.OnCustomMessage(PlayerCharacter.DynamicId, msg); }
/// <summary> /// Processes the go command. /// </summary> /// <param name="parts">Parts.</param> private static void ProcessGoCommand(string[] parts) { // If the user has not indicated where to go... if (parts.Length == 1) { PrintLineWarning("Go where?"); } else { // try to find the neighbor the user has indicated. try { // move to that area if the command is understood. CurrentArea = CurrentArea.GetNeighbor(parts[1]); } catch (WorldException e) { // if GetNeighbor throws and exception, print the explanation. PrintLineDanger(e.Message); } } }
void OnTriggerEnter2D(Collider2D other) { Debug.Log(other.gameObject); CurrentArea currentObject = other.gameObject.GetComponent <CurrentArea>(); //Debug.Log(currentObject); if (currentObject != null) { Debug.Log("Entered on " + box.name); currentObject.setArea(this); // Agora.io Implimentation IRtcEngine mRtcEngine = IRtcEngine.GetEngine(AgoraInterfaceScript.appId); var channelName = box.name; mRtcEngine.LeaveChannel(); mRtcEngine.JoinChannel(channelName, "extra", 0); // join the channel with given match name Debug.Log("joining channel:" + channelName); } }
public AObject FindObject(string name, PlayerVariables v) { List <AObject> matches = new List <AObject>(); foreach (var obj in Objects) { if (CurrentArea != null && CurrentArea.FilterObject(obj) == ObjectVisibility.NotVisible) { continue; } if (obj.Name == name || obj.Alias.Contains(name)) { matches.Add(obj); } FindSubObjectIn(obj, name, matches); } if (matches.Count > 1) { Print("你所说的“" + name + "”引起了歧义,它可以指:\n"); foreach (var match in matches) { Print(" * " + match.Name + "\n"); } } else if (matches.Count == 1) { if (CurrentArea != null && CurrentArea.FilterObject(matches[0]) == ObjectVisibility.Unclear) { Print("你在远处只能隐约看见它的剪影。\n\n"); } else { return(matches[0]); } } return(null); }
/// <summary> /// What happens when the user types "look" as the command word. /// </summary> /// <param name="parts">Command Parts.</param> private static void ProcessLookCommand(string[] parts) { // If you just type "look" then LookAround() if (parts.Length == 1) { Console.WriteLine(CurrentArea.LookAround()); } else { // try to find the thing that the user is looking at. try { // if it is there, print the appropriate description. Console.WriteLine(CurrentArea.LookAt(parts[1])); } catch (WorldException e) { // otherwise, print an appropriate error message. PrintLineDanger(e.Message); } } }
public void Close() { CurrentArea.Close(); }
// This needs to be used in place of start at the beginning of a new scene // since this gameObject doesn't get destroyed in between scenes. void OnLevelWasLoaded(int level) { if (instance && instance != this) return; _curArea = Manager_Game.instance.currentArea; imageTransition.gameObject.SetActive(true); Color imColor = imageTransition.color; imColor.a = 1; imageTransition.color = imColor; if (Manager_Game.usingMobile) eveSystem = GameObject.Find("EventSystem_Mobile"); else { if (Manager_Game.instance.IsInMenu) eveSystem = GameObject.Find("EventSystem"); else eveSystem = GameObject.Find("EventSystem_NotMenu"); } playInputMenu = new List<GameObject>(); if(!eveSystem) { int index = Manager_Game.usingMobile ? 2 : Manager_Game.instance.IsInMenu ? 0 : 1; eveSystem = Instantiate(allEventSystems[index], Vector3.zero, Quaternion.identity) as GameObject; } if (eveSystem) { if(!Manager_Game.instance.IsInMenu && !Manager_Game.usingMobile) foreach (Transform child in eveSystem.transform) playInputMenu.Add(child.gameObject); } else Debug.LogWarning("NO EVENT SYSTEM FOUND!"); if (!Manager_Game.instance.IsInMenu) { _quitPauseOption = defaultPauseOption.transform.parent.GetChild(2).GetComponent<Selectable>(); if (_quitPauseOption) { if (Application.isWebPlayer) _quitPauseOption.interactable = false; // Can't quit during the web player scene. } else Debug.LogWarning("NO QUIT PAUSE OPTION FOUND!"); } else { if (_curArea == CurrentArea.Main_Menu) { if (allMenus.Contains(null)) { allMenus = new List<Menu>(); GameObject canvasMenu = GameObject.Find("Canvas_Menu"); if (canvasMenu) { foreach (Transform child in canvasMenu.transform) allMenus.Add(child.GetComponent<Menu>()); } else Debug.LogWarning("CANVAS MENU NOT FOUND ON MAIN MENU!"); } } } DisplayUI (false); if (Manager_Game.instance.IsInMenu) { Transform webPlayerHelpMenu = transform.Find("Panel_HelpInfo_Menu"); if (webPlayerHelpMenu) webPlayerHelpMenu.gameObject.SetActive(true); else Debug.LogWarning("NO HELP INFO FOUND ON MENU!"); if (_webPlayerParent) _webPlayerParent.SetActive(false); // Do not need web player help info when not on a menu screen. } else { Transform webPlayerHelpMenu = transform.Find("Panel_HelpInfo_Menu"); if (webPlayerHelpMenu) webPlayerHelpMenu.gameObject.SetActive(false); // Disable the menu's controls. if (_curArea == CurrentArea.Demo) { _webPlayerHelpInfo = new List<GameObject>(); Transform webPlayerParent = transform.Find("WebPlayer_HelpInfo"); _webPlayerParent = webPlayerParent.gameObject; if (webPlayerParent) { foreach (Transform child in webPlayerParent) _webPlayerHelpInfo.Add(child.gameObject); _webPlayerHelpInfo[0].SetActive(true); _webPlayerHelpInfo[1].SetActive(false); // Disable the large body of text controls information. } else Debug.LogWarning("WEB PLAYER PARENT NOT FOUND IN DEMO LEVEL!"); } else { if (_webPlayerParent) _webPlayerParent.SetActive(false); } } StartCoroutine (StartTransition (TransitionTypes.Fading, true)); }
void Start() { if (Manager_Game.usingMobile) eveSystem = GameObject.Find("EventSystem_Mobile"); else { if (Manager_Game.instance.IsInMenu) eveSystem = GameObject.Find("EventSystem"); else eveSystem = GameObject.Find("EventSystem_NotMenu"); } playInputMenu = new List<GameObject>(); if(!eveSystem) { int index = Manager_Game.usingMobile ? 2 : Manager_Game.instance.IsInMenu ? 0 : 1; eveSystem = Instantiate(allEventSystems[index], Vector3.zero, Quaternion.identity) as GameObject; } if (eveSystem) { if(!Manager_Game.instance.IsInMenu && !Manager_Game.usingMobile) foreach (Transform child in eveSystem.transform) playInputMenu.Add(child.gameObject); } else Debug.LogWarning("NO EVENT SYSTEM FOUND!"); _defParameterText = resultsParameters.text; animResultsPanel = resultsDisplay.transform.GetChild(0).GetComponent<Animator> (); // Stop displaying any UI elements upon starting. DisplayUI (false); // Start our fading-in transition. imageTransition.gameObject.SetActive(true); Color imColor = imageTransition.color; imColor.a = 1; imageTransition.color = imColor; StartCoroutine (StartTransition (TransitionTypes.Fading, true)); _curArea = Manager_Game.instance.currentArea; // Set this when this is created only since DefaultHealthFillColor is static. if(Time.realtimeSinceStartup < 3) { DefaultHealthFillColor = plHealthSliderFill [0].color; } if (Manager_Game.instance.IsInMenu) { Transform webPlayerHelpMenu = transform.Find("Panel_HelpInfo_Menu"); if (webPlayerHelpMenu) webPlayerHelpMenu.gameObject.SetActive(true); else Debug.LogWarning("NO HELP INFO FOUND ON MENU!"); } else { Transform webPlayerHelpMenu = transform.Find("Panel_HelpInfo_Menu"); if (webPlayerHelpMenu) webPlayerHelpMenu.gameObject.SetActive(false); // Disable the menu's controls. if (_curArea == CurrentArea.Demo) { _webPlayerHelpInfo = new List<GameObject>(); Transform webPlayerParent = transform.Find("WebPlayer_HelpInfo"); _webPlayerParent = webPlayerParent.gameObject; if (webPlayerParent) { foreach (Transform child in webPlayerParent) _webPlayerHelpInfo.Add(child.gameObject); _webPlayerHelpInfo[0].SetActive(true); _webPlayerHelpInfo[1].SetActive(false); // Disable the large body of text controls information. } else Debug.LogWarning("WEB PLAYER PARENT NOT FOUND IN DEMO LEVEL!"); } else { if (_webPlayerParent) _webPlayerParent.SetActive(false); } } }
int _playerWhoPaused = 1; // To not let another player pause or unpause when another player does. void Awake() { if(instance == null) instance = this; // Default characters chosen. if (PlayersChosen == null) PlayersChosen = new List<PlayerCharacters> (4) { PlayerCharacters.Ethan, PlayerCharacters.Dude, PlayerCharacters.Ethan_Twin, PlayerCharacters.Dude_Twin}; if(playersDefeated == null) playersDefeated = new List<GameObject> (); enemiesDead = new List<GameObject> (); // Get the current area by checking the loaded level's name. string levelName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; if(levelName.Contains("Main")) currentArea = CurrentArea.Main_Menu; else if(levelName.Contains("Demo")) { if (!levelName.Contains("Menu")) currentArea = CurrentArea.Demo; else currentArea = CurrentArea.Demo_Menu; } else if(levelName.Contains("Canyon_0")) currentArea = CurrentArea.Canyon_0; else if(levelName.Contains("Canyon_1")) currentArea = CurrentArea.Canyon_1; enemiesAll = new List<GameObject> (); enemiesDead = new List<GameObject> (); allPlayerStatus = new List<CharacterStatus>(); }
/// <summary> /// Asigna el valor del PNR /// </summary> /// <param name="result">Valor que contendrá</param> public static void SetValueCurrentPNR(string result) { string area = CurrentArea.Substring(0, 1); string lastPNR = CurrentPNR; switch (area) { case "A": PNR_A = result; CurrentPNR = PNR_A; if (string.IsNullOrEmpty(result)) { Area_A = "A_" + Guid.NewGuid().ToString(); CurrentArea = Area_A; } else { if (string.IsNullOrEmpty(lastPNR)) { return; } if (!CurrentPNR.Equals(lastPNR)) { RenewCurrentArea(); } } break; case "B": PNR_B = result; CurrentPNR = PNR_B; if (string.IsNullOrEmpty(result)) { Area_B = "B_" + Guid.NewGuid().ToString(); CurrentArea = Area_B; } else { if (string.IsNullOrEmpty(lastPNR)) { return; } if (!CurrentPNR.Equals(lastPNR)) { RenewCurrentArea(); } } break; case "C": PNR_C = result; CurrentPNR = PNR_C; if (string.IsNullOrEmpty(result)) { Area_C = "C_" + Guid.NewGuid().ToString(); CurrentArea = Area_C; } else { if (string.IsNullOrEmpty(lastPNR)) { return; } if (!CurrentPNR.Equals(lastPNR)) { RenewCurrentArea(); } } break; case "D": PNR_D = result; CurrentPNR = PNR_D; if (string.IsNullOrEmpty(result)) { Area_D = "D_" + Guid.NewGuid().ToString(); CurrentArea = Area_D; } else { if (string.IsNullOrEmpty(lastPNR)) { return; } if (!CurrentPNR.Equals(lastPNR)) { RenewCurrentArea(); } } break; case "E": PNR_E = result; CurrentPNR = PNR_E; if (string.IsNullOrEmpty(result)) { Area_E = "E_" + Guid.NewGuid().ToString(); CurrentArea = Area_E; } else { if (string.IsNullOrEmpty(lastPNR)) { return; } if (!CurrentPNR.Equals(lastPNR)) { RenewCurrentArea(); } } break; case "F": PNR_F = result; CurrentPNR = PNR_F; if (string.IsNullOrEmpty(result)) { Area_F = "F_" + Guid.NewGuid().ToString(); CurrentArea = Area_F; } else { if (string.IsNullOrEmpty(lastPNR)) { return; } if (!CurrentPNR.Equals(lastPNR)) { RenewCurrentArea(); } } break; } }
public static void RenewCurrentArea() { string area = CurrentArea.Substring(0, 1); CurrentArea = area + "_" + Guid.NewGuid().ToString(); }
/// <summary> /// Updates player and frame moving logic /// </summary> /// <param name="gameTime">Snapshot of times</param> public new void Update(GameTime gameTime) { MouseState mouse = Mouse.GetState(); KeyboardState keyboard = Keyboard.GetState(); KeyboardState lastKeyboard = CurrentArea.LastKeyboard; if (keyboard.IsKeyUp(Keys.Escape) && lastKeyboard.IsKeyDown(Keys.Escape)) //toggle main menu with escape key { CurrentArea.AreaMenu.isShowing = !CurrentArea.AreaMenu.isShowing; CurrentArea.Paused = CurrentArea.AreaMenu.isShowing; //inventoryMenu.isShowing = false; } if (lastKeyboard.IsKeyDown(Keys.E) && keyboard.IsKeyUp(Keys.E) && !CurrentArea.AreaMenu.isShowing) { //inventoryMenu.isShowing = !inventoryMenu.isShowing; CurrentArea.Paused = CurrentArea.AreaMenu.isShowing; // || inventoryMenu.isShowing; } RPG.MouseVisible = CurrentArea.AreaMenu.isShowing; // || inventoryMenu.isShowing; //enable mouse if menu is shown if (sprite.State != SpriteState.Die && !CurrentArea.Paused) { Vector2 moveDirection = Vector2.Zero; if (mouse.LeftButton == ButtonState.Pressed) { Attack(); } if (keyboard.IsKeyDown(Keys.F1) && !lastKeyboard.IsKeyDown(Keys.F1)) { RPG.DebugMode = !RPG.DebugMode; } //movement vectors if (keyboard.IsKeyDown(Keys.W)) { Turn(SpriteDirection.North); moveDirection.Y--; } if (keyboard.IsKeyDown(Keys.A)) { Turn(SpriteDirection.West); moveDirection.X--; } if (keyboard.IsKeyDown(Keys.S)) { Turn(SpriteDirection.South); moveDirection.Y++; } if (keyboard.IsKeyDown(Keys.D)) { Turn(SpriteDirection.East); moveDirection.X++; } //keep speed constant moveDirection.Normalize(); moveDirection *= 2; if (keyboard.IsKeyDown(Keys.LeftShift)) { moveDirection *= 3; //sprint or speed key } if (moveDirection.Length() > 0 && CurrentArea.CheckForCollisions(this, moveDirection)) { Move(moveDirection); } else if (moveDirection.Length() > 0 && keyboard.IsKeyDown(Keys.Space) && RPG.DebugMode) { Move(moveDirection); //debug override key } this.Position = new Vector2((int)Position.X, (int)Position.Y); } if (sprite.State == SpriteState.Die && sprite.CurrentFrame == sprite.MaxFrame && deathCooldown == 120) { RPG.LoadNewGame(); } else if (sprite.State == SpriteState.Die && sprite.CurrentFrame == sprite.MaxFrame && deathCooldown < 120) { deathCooldown++; } base.Update(gameTime); //inventoryMenu.Update (gameTime); }
// public new void Draw(SpriteBatch spriteBatch) // { // SpriteFont font = RPG.ContentManager.Load<SpriteFont>("fonts/Arial"); // Vector2 size = font.MeasureString(this.Position.ToString()); // Vector2 pos = new Vector2(Bounds.Center.X - size.X/2, Position.Y - size.Y); // spriteBatch.DrawString(font, this.Position.ToString(), pos, Color.White); // base.Draw(spriteBatch); // } private void MoveUpdate(GameTime gameTime) { if (sprite.State != SpriteState.Die) { //set bounds RectangleF tempBounds = Bounds; RectangleF tempPlayer = CurrentArea.User.Bounds; tempBounds.Inflate(2f, 2f); tempBounds.Offset(-1f, -1f); Vector2 moveAmount = CurrentArea.User.Position - this.Position; moveAmount.Normalize(); moveAmount = Vector2.Multiply(moveAmount, .8f); bool turn = true; //if player is in bounds, isn't too close to enemy and there are no collisions //move towards the player if (!(tempPlayer.Intersects(tempBounds)) && CurrentArea.CheckForCollisions(this, moveAmount) && walkLimit.Contains(tempBounds) && walkLimit.Contains(tempPlayer)) { Move(moveAmount); } //if player is out of bounds return to start else if (!walkLimit.Contains(tempPlayer)) { moveAmount = InitialPosition - Position; moveAmount.Normalize(); tempBounds.Offset(moveAmount); if (walkLimit.Contains(tempBounds) && CurrentArea.CheckForCollisions(this, moveAmount) && (Position - InitialPosition).Length() > 1) { Move(moveAmount); } if ((Position - InitialPosition).Length() <= 1) { turn = false; Turn(startDirection); } } else if (tempPlayer.Intersects(tempBounds) && sprite.State != SpriteState.Attack) { if (currentCD == 0) { Attack(); currentCD++; } } if (turn) { Turn(moveAmount); } if (currentCD != 0 && currentCD != cooldown) { currentCD++; } else if (currentCD == cooldown) { currentCD = 0; } } }