private Boolean TryOpenDoor(GridSlot p_slot, EDirection p_dir) { List <InteractiveObject> doors = p_slot.GetDoors(); for (Int32 i = 0; i < doors.Count; i++) { Door door = (Door)doors[i]; if (door.Location == p_dir && door.State == EInteractiveObjectState.DOOR_CLOSED && door.Commands.Count > 0) { door.Execute(LegacyLogic.Instance.MapLoader.Grid); door.Update(); return(true); } } GridSlot neighborSlot = p_slot.GetNeighborSlot(LegacyLogic.Instance.MapLoader.Grid, p_dir); doors = neighborSlot.GetDoors(); for (Int32 j = 0; j < doors.Count; j++) { Door door2 = (Door)doors[j]; if (door2.Location == EDirectionFunctions.GetOppositeDir(p_dir) && door2.State == EInteractiveObjectState.DOOR_CLOSED && door2.Commands.Count > 0) { door2.Execute(LegacyLogic.Instance.MapLoader.Grid); door2.Update(); return(true); } } return(false); }
private void GetMeleePosition(Grid p_grid, Party p_party, List <GridSlot> p_slots) { EDirection oppositeDir = EDirectionFunctions.GetOppositeDir(p_party.Direction); EDirection p_dir = EDirectionFunctions.Add(p_party.Direction, 3); EDirection p_dir2 = EDirectionFunctions.Add(p_party.Direction, 1); EDirection direction = p_party.Direction; Int32 num = Random.Range(0, 13); GridSlot neighborSlot; if (num >= 5) { neighborSlot = p_grid.GetSlot(p_party.Position).GetNeighborSlot(p_grid, oppositeDir); } else if (num >= 3) { neighborSlot = p_grid.GetSlot(p_party.Position).GetNeighborSlot(p_grid, p_dir); } else if (num >= 1) { neighborSlot = p_grid.GetSlot(p_party.Position).GetNeighborSlot(p_grid, p_dir2); } else { neighborSlot = p_grid.GetSlot(p_party.Position).GetNeighborSlot(p_grid, direction); } if (neighborSlot.IsPassable(m_owner, false)) { m_targetSlot = neighborSlot; } else { m_targetSlot = p_slots[Random.Range(0, p_slots.Count)]; } }
protected override void DoExecute() { Boolean flag = false; Party party = LegacyLogic.Instance.WorldManager.Party; for (Int32 i = 0; i < 4; i++) { Character member = party.GetMember(i); BaseItem itemAt = member.Equipment.Equipment.GetItemAt(6); if (itemAt != null) { flag = true; break; } } if (flag) { Grid grid = LegacyLogic.Instance.MapLoader.Grid; grid.MoveEntity(party, EDirectionFunctions.GetOppositeDir(party.Direction)); } FinishExecution(); if (flag) { m_stateMachine.ChangeState(3); } else { m_stateMachine.ChangeState(2); } }
public BaseDoorInteraction(SpawnCommand p_command, Int32 p_parentID, Int32 p_commandIndex) : base(p_command, p_parentID, p_commandIndex) { m_parent = Grid.FindInteractiveObject(m_parentID); m_targetDoor = (Door)Grid.FindInteractiveObject(m_targetSpawnID); if (m_targetDoor == null) { m_valid = false; return; } GridSlot slot = Grid.GetSlot(m_targetDoor.Position); m_leaveTransition = slot.GetTransition(m_targetDoor.Location); Position p_pos = m_targetDoor.Position + m_targetDoor.Location; GridSlot slot2 = Grid.GetSlot(p_pos); if (slot2 != null) { m_enterTransition = slot2.GetTransition(EDirectionFunctions.GetOppositeDir(m_targetDoor.Location)); } }
protected override void SetStates() { if (m_targetDoor == null) { throw new InvalidOperationException("Tried to open or close something that is not a door!"); } if (!m_delayStateChange) { m_targetDoor.ToggleState(); m_leaveTransition.ToggleState(); if (m_enterTransition != null) { m_enterTransition.ToggleState(); } GridSlot neighborSlot = Grid.GetSlot(m_targetDoor.Position).GetNeighborSlot(Grid, m_targetDoor.Location); if (neighborSlot != null) { List <InteractiveObject> doors = neighborSlot.GetDoors(); for (Int32 i = 0; i < doors.Count; i++) { if (doors[i].Type == EObjectType.DOOR && EDirectionFunctions.GetOppositeDir(doors[i].Location) == m_targetDoor.Location) { Door door = (Door)doors[i]; if (m_targetDoor.State == EInteractiveObjectState.DOOR_OPEN) { door.Open(); } else { door.Close(); } break; } } } } else { m_delayStateChange = true; } }
public override void HandleAttacks(List <Attack> p_attackList, Monster p_monster, Character p_character, Boolean p_isMagic) { if (p_monster.DistanceToParty > 1f) { return; } Grid grid = LegacyLogic.Instance.MapLoader.Grid; Position position = LegacyLogic.Instance.WorldManager.Party.Position; EDirection direction = LegacyLogic.Instance.WorldManager.Party.Direction; EDirection p_dir = (direction - EDirection.EAST != -1) ? (direction - 1) : EDirection.WEST; EDirection p_dir2 = (direction + 1 != EDirection.COUNT) ? (direction + 1) : EDirection.NORTH; Boolean flag = true; if (direction != EDirectionFunctions.GetOppositeDir(p_monster.Direction) && direction != p_monster.Direction) { p_dir = direction; p_dir2 = EDirectionFunctions.GetOppositeDir(direction); flag = false; } p_monster.CombatHandler.MeleeStrikes = 3; Position position2 = p_monster.Position; Position p_pos = position + p_dir; Position position3 = position + p_dir2; Boolean flag2 = Random.Range(0, 2) == 1; if (flag2) { if (grid.GetSlot(p_pos).AddEntity(p_monster)) { grid.GetSlot(position2).RemoveEntity(p_monster); p_monster.Rotate(EDirectionFunctions.RotationCount(p_monster.Direction, EDirectionFunctions.GetOppositeDir(direction)), false); if (flag) { p_monster.Rotate(-1, false); } } else { flag2 = false; } } if (!flag2) { if (Position.Distance(p_monster.Position, position3) < 2f) { if (grid.GetSlot(position3).AddEntity(p_monster)) { grid.GetSlot(position2).RemoveEntity(p_monster); p_monster.Rotate(EDirectionFunctions.RotationCount(p_monster.Direction, EDirectionFunctions.GetOppositeDir(direction)), false); if (flag) { p_monster.Rotate(1, false); } } } else if (grid.GetSlot(p_pos).AddEntity(p_monster)) { grid.GetSlot(position2).RemoveEntity(p_monster); p_monster.Rotate(EDirectionFunctions.RotationCount(p_monster.Direction, EDirectionFunctions.GetOppositeDir(direction)), false); if (flag) { p_monster.Rotate(-1, false); } } } if (position2 != p_monster.Position) { MoveEntityEventArgs p_eventArgs = new MoveEntityEventArgs(position2, p_monster.Position); LegacyLogic.Instance.EventManager.InvokeEvent(p_monster, EEventType.MOVE_ENTITY, p_eventArgs); AbilityTriggeredEventArgs p_args = new AbilityTriggeredEventArgs(p_monster, this); LegacyLogic.Instance.ActionLog.PushEntry(p_args); LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.ENTITY_ABILITY_ADDED, new AbilityEventArgs(p_monster, this)); } }