public override void RunTrigger() { if (setToValue != GameplayFlags.GetManager().GetFlag(flagId)) { GameplayFlags.GetManager().ToggleFlag(flagId); } }
public WorldState(WorldInstance overworldRef, WorldInstance activeWorldRef, GameplayFlags flagsRef) : base() { m_ActiveWorld = activeWorldRef; m_GameplayFlags = flagsRef; m_Overworld = overworldRef; m_Camera = GameObject.Find("Main Camera").GetComponent <Camera>(); m_FogOfWarHolder = GameObject.Find("WorldFog"); m_EntitiesHolder = GameObject.Find("WorldEntities"); m_InventoryOpen = false; }
private void OnTriggerEnter2D(Collider2D collision) { if (requiredFlag == "None" || (GameplayFlags.GetManager().Contains(requiredFlag) && GameplayFlags.GetManager().GetFlag(requiredFlag) == requiredFlagState)) { if (requiredTag == "None" || collision.gameObject.tag == requiredTag || CorrectType(collision.gameObject)) { attachedEvent.RunTrigger(); foreach (var attachedEvent in optionalEvents) { attachedEvent.RunTrigger(); } CheckpointManager.GetManager().RegisterObject(gameObject); gameObject.SetActive(false); } } }
public override void Start() { base.Start(); m_ActiveWorld.Player.UpdateMe(); m_GameplayFlags = GameplayFlags.Moving; RumourMill.GenerateRumours(m_ActiveWorld); SetEntityWorld(overworld); if (s_GUIManager == null) { GameObject obj = GameObject.Find("GUIInventory"); JoyInventoryManager manager = obj.GetComponent <JoyInventoryManager>(); manager.SetPlayer(m_ActiveWorld.Player); //manager.DoAll(); } SetUpUi(); }
protected void ChangeWorld(WorldInstance newWorld, Vector2Int spawnPoint) { Done = true; WorldInstance oldWorld = m_ActiveWorld; Entity player = oldWorld.Player; m_ActiveWorld.RemoveEntity(player.WorldPosition); m_ActiveWorld = newWorld; m_ActiveWorld.AddEntity(player); player.MyWorld = m_ActiveWorld; player = m_ActiveWorld.Player; player.Move(spawnPoint); player.UpdateMe(); m_GameplayFlags = GameplayFlags.Moving; RumourMill.GenerateRumours(m_ActiveWorld); QuestTracker.PerformExploration(player, newWorld); Tick(); }
private void Start() { flagsGo = GameplayFlags.GetManager(); }
public override void HandleInput() { base.HandleInput(); bool hasMoved = false; Entity player = m_ActiveWorld.Player; /* * if (m_Input.currentMouseState.ScrollWheelValue > m_Input.lastMouseState.ScrollWheelValue) * { * m_Camera.zoom += 0.05f; * } * * if (m_Input.currentMouseState.ScrollWheelValue < m_Input.lastMouseState.ScrollWheelValue) * { * m_Camera.zoom -= 0.05f; * } * * if(m_Input.IsOldPress(MouseButtons.RightButton)) * { * m_GUIManager.Screen.Desktop.Children.Remove(m_ContextMenu); * m_ContextMenu.MoveTo(m_Input.currentMouseState.Position); * m_GUIManager.Screen.Desktop.Children.Add(m_ContextMenu); * * Vector2 mouseVector = (m_Input.currentMouseState.Position - (new Point(m_Renderer.m_ScreenWidth / 2, m_Renderer.m_ScreenHeight / 2))).ToVector2(); * m_MenuTile = new Point((int)Math.Floor(mouseVector.X / (ObjectIcons.SPRITE_SIZE * m_Camera.zoom)), (int)Math.Floor(mouseVector.Y / (ObjectIcons.SPRITE_SIZE * m_Camera.zoom))) + s_ActiveWorld.player.position; * } * * if(m_Input.IsOldPress(Keys.Space)) * { * autoTurn = !autoTurn; * } * * if(m_Input.IsOldPress(Keys.L)) * { * s_ActiveWorld.player.LevelUp(); * } * */ /* * if(Input.GetMouseButtonDown(0)) * { * Vector3 mouseWorld = m_Camera.ScreenToWorldPoint(Input.mousePosition); * int x = (int)mouseWorld.x; * int y = (int)mouseWorld.y; * * Pathfinder pathfinder = new Pathfinder(); * Queue<Vector2Int> path = pathfinder.FindPath(player.WorldPosition, new Vector2Int(x, y), m_ActiveWorld); * player.SetPath(path); * autoTurn = true; * } */ if (Input.GetKeyDown(KeyCode.I)) { m_InventoryOpen = !m_InventoryOpen; if (m_InventoryOpen == false) { s_GUIManager.OpenGUI("NeedsPanel"); } else { s_GUIManager.OpenGUI("GUIInventory"); } } if (s_GUIManager.RemovesControl()) { return; } if (Input.GetKeyDown(KeyCode.Return)) { //Going up a level if (m_ActiveWorld.Parent != null && player.WorldPosition == m_ActiveWorld.SpawnPoint && !player.HasMoved) { ChangeWorld(m_ActiveWorld.Parent, m_ActiveWorld.GetTransitionPointForParent()); return; } //Going down a level else if (m_ActiveWorld.Areas.ContainsKey(player.WorldPosition) && !player.HasMoved) { ChangeWorld(m_ActiveWorld.Areas[player.WorldPosition], m_ActiveWorld.Areas[player.WorldPosition].SpawnPoint); return; } PhysicsResult physicsResult = PhysicsManager.IsCollision(player.WorldPosition, player.WorldPosition, m_ActiveWorld); if (physicsResult == PhysicsResult.ObjectCollision) { //Get the item picked up ItemInstance pickUp = m_ActiveWorld.PickUpObject(player); //And try to destroy the corresponding GameObject if (pickUp != null) { GameObject.Destroy(GameObject.Find(pickUp.JoyName + ":" + pickUp.GUID)); } } } Vector2Int newPlayerPoint = m_ActiveWorld.Player.WorldPosition; //North if (Input.GetKeyDown(KeyCode.Keypad8)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x, player.TargetPoint.y - 1); } else { newPlayerPoint.y += 1; hasMoved = true; } } //North east else if (Input.GetKeyDown(KeyCode.Keypad9)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x + 1, player.TargetPoint.y - 1); } else { newPlayerPoint.x += 1; newPlayerPoint.y += 1; hasMoved = true; } } //East else if (Input.GetKeyDown(KeyCode.Keypad6)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x + 1, player.TargetPoint.y); } else { newPlayerPoint.x += 1; hasMoved = true; } } //South east else if (Input.GetKeyDown(KeyCode.Keypad3)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x + 1, player.TargetPoint.y + 1); } else { newPlayerPoint.x += 1; newPlayerPoint.y -= 1; hasMoved = true; } } //South else if (Input.GetKeyDown(KeyCode.Keypad2)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x, player.TargetPoint.y + 1); } else { newPlayerPoint.y -= 1; hasMoved = true; } } //South west else if (Input.GetKeyDown(KeyCode.Keypad1)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x - 1, player.TargetPoint.y + 1); } else { newPlayerPoint.x -= 1; newPlayerPoint.y -= 1; hasMoved = true; } } //West else if (Input.GetKeyDown(KeyCode.Keypad4)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x - 1, player.TargetPoint.y); } else { newPlayerPoint.x -= 1; hasMoved = true; } } //North west else if (Input.GetKeyDown(KeyCode.Keypad7)) { if (m_GameplayFlags == GameplayFlags.Targeting) { player.TargetPoint = new Vector2Int(player.TargetPoint.x - 1, player.TargetPoint.y - 1); } else { newPlayerPoint.x -= 1; newPlayerPoint.y += 1; hasMoved = true; } } else if (Input.GetKeyDown(KeyCode.Keypad5)) { Tick(); return; } if (hasMoved) { PhysicsResult physicsResult = PhysicsManager.IsCollision(player.WorldPosition, newPlayerPoint, m_ActiveWorld); if (physicsResult == PhysicsResult.EntityCollision) { Entity tempEntity = m_ActiveWorld.GetEntity(newPlayerPoint); if (m_GameplayFlags == GameplayFlags.Interacting) { if (tempEntity.Sentient) { TalkToPlayer(tempEntity); } } else if (m_GameplayFlags == GameplayFlags.Giving) { } else if (m_GameplayFlags == GameplayFlags.Moving) { playerWorld.SwapPosition(player, tempEntity); Tick(); } else if (m_GameplayFlags == GameplayFlags.Attacking) { if (tempEntity.GUID != player.GUID) { CombatEngine.SwingWeapon(player, tempEntity); tempEntity.InfluenceMe(player.GUID, -50); if (!tempEntity.Alive) { m_ActiveWorld.RemoveEntity(newPlayerPoint); //Find a way to remove the GameObject for (int i = 0; i < m_EntitiesHolder.transform.childCount; i++) { if (m_EntitiesHolder.transform.GetChild(i).name.Contains(tempEntity.GUID.ToString())) { GameObject.Destroy(m_EntitiesHolder.transform.GetChild(i).gameObject); break; } } } } } Tick(); } else if (physicsResult == PhysicsResult.WallCollision) { //Do nothing! } else { if (newPlayerPoint.x >= 0 && newPlayerPoint.x < m_ActiveWorld.Tiles.GetLength(0) && newPlayerPoint.y >= 0 && newPlayerPoint.y < m_ActiveWorld.Tiles.GetLength(1)) { player.Move(newPlayerPoint); Tick(); } } } else if (m_GameplayFlags == GameplayFlags.Targeting) { if (player.TargetingAbility.targetType == AbilityTarget.Adjacent) { if (AdjacencyHelper.IsAdjacent(player.WorldPosition, player.TargetPoint)) { Entity tempEntity = m_ActiveWorld.GetEntity(player.TargetPoint); if (tempEntity != null && Input.GetKeyDown(KeyCode.Return)) { player.TargetingAbility.Use(player, tempEntity); Tick(); m_GameplayFlags = GameplayFlags.Moving; } } } else if (player.TargetingAbility.targetType == AbilityTarget.Ranged) { Entity tempEntity = m_ActiveWorld.GetEntity(player.TargetPoint); if (tempEntity != null && Input.GetKeyDown(KeyCode.Return)) { player.TargetingAbility.Use(player, tempEntity); Tick(); m_GameplayFlags = GameplayFlags.Moving; } } } if (autoTurn) { Tick(); } m_Camera.transform.position = new Vector3(player.WorldPosition.x, player.WorldPosition.y, m_Camera.transform.position.z); }
protected void SetToAttack(object sender, EventArgs e) { m_GameplayFlags = GameplayFlags.Attacking; }