public Character Refresh(excel_refresh refreshExcel, Scene scn) { int index = Mathf.RandRange(0, refreshExcel.birthpoint.Length - 1); string birthPointName = refreshExcel.birthpoint[index]; MarkPoint markPoint = GetMarkPoint(scn.ScnID, birthPointName); if (markPoint == null) { return(null); } Vector3 targetPos = markPoint.position; Vector3 dir = new Vector3(Mathf.RandRange(-1.0f, 1.0f), 0.0f, Mathf.RandRange(-1.0f, 1.0f)); dir.Normalize(); float dist = Mathf.RandRange(0.0f, 1.0f) * refreshExcel.refreshDist; targetPos += (dist * dir); Vector3 hitPos = Vector3.zero; uint layer = NavigationSystem.GetLayer(markPoint.position); if (NavigationSystem.LineCast(markPoint.position, targetPos, layer, out hitPos)) { targetPos = hitPos; } float h = 0.0f; if (NavigationSystem.GetLayerHeight(targetPos, layer, out h)) { targetPos.y = h; } NPC npc = new NPC(); return(npc); }
public MainClass() { GameEnvironment.Setting.ActionDispatcher = new CustomActionDispatcher(); ExcelLoader.Init(); SkillEventRegister.Initialize(); NavigationSystem.LoadAllNavigation(); }
public static int Puzzle2(string input) { var data = Common.ParseIntArray(input, " "); var ns = new NavigationSystem(data); return(ns.GetRootNodeValue()); }
/// <summary> /// Возвращает тип сигнала навигационной системы /// </summary> /// <param name="tracking"></param> /// <returns></returns> public static SignalType GetSignalType(UInt32 tracking) { NavigationSystem system = GetNavigationSystem(tracking); uint code = tracking >> 21 & 0x1f; return(GetSignalType(system, code)); }
protected void UpdateMove() { if (mPosDirty) { UpdateVisibleInfo(); mPosDirty = false; } if (!IsCannotFlag(CannotFlag.CannotMove) && Speed > 0.0f) { Position += mSpeed * Time.DeltaTime * Direction; float h; if (NavigationSystem.GetLayerHeight(Position, mNavLayer, out h)) { Vector3 pos = Position; pos.y = h; Position = pos; } else { mNavLayer = NavigationSystem.GetLayer(Position); } } UpdateSearchMove(); }
public static int Puzzle1(string input) { var data = Common.ParseIntArray(input, " "); var ns = new NavigationSystem(data); return(ns.SumMetadata()); }
public CombatDrone() //////public Program() { shipComponents = new ShipComponents(); LocateAllParts(); log = new Logger(Me.CubeGrid, shipComponents); communicationSystems = new CommunicationSystem(log, Me.CubeGrid, shipComponents); navigationSystems = new NavigationSystem(log, Me.CubeGrid, shipComponents); trackingSystems = new TrackingSystem(log, Me.CubeGrid, shipComponents, false); weaponSystems = new WeaponSystem(log, Me.CubeGrid, shipComponents); operatingOrder.AddLast(new TaskInfo(LocateAllParts)); operatingOrder.AddLast(new TaskInfo(InternalSystemCheck)); operatingOrder.AddLast(new TaskInfo(NavigationCheck)); operatingOrder.AddLast(new TaskInfo(RecieveFleetMessages)); operatingOrder.AddLast(new TaskInfo(SendPendingMessages)); operatingOrder.AddLast(new TaskInfo(FollowOrders)); operatingOrder.AddLast(new TaskInfo(ScanLocalArea)); operatingOrder.AddLast(new TaskInfo(UpdateTrackedTargets)); operatingOrder.AddLast(new TaskInfo(UpdateDisplays)); operatingOrder.AddLast(new TaskInfo(FollowOrders)); SetupFleetListener(); maxCameraRange = 5000; maxCameraAngle = 80; //set new defaults hoverHeight = 150; InitialBlockCount = shipComponents.AllBlocks.Count(); Runtime.UpdateFrequency = UpdateFrequency.Update1; }
public CombatDrone() //////public Program() { shipComponents = new ShipComponents(); LocateAllParts(); log = new Logger(Me.CubeGrid, shipComponents); communicationSystems = new CommunicationSystem(log, Me.CubeGrid, shipComponents); navigationSystems = new NavigationSystem(log, Me.CubeGrid, shipComponents); productionSystems = new ProductionSystem(log, Me.CubeGrid, shipComponents); storageSystem = new StorageSystem(log, Me.CubeGrid, shipComponents); trackingSystems = new TrackingSystem(log, Me.CubeGrid, shipComponents); weaponSystems = new WeaponSystem(log, Me.CubeGrid, shipComponents); operatingOrder.AddLast(new TaskInfo(LocateAllParts)); operatingOrder.AddLast(new TaskInfo(FollowOrders)); operatingOrder.AddLast(new TaskInfo(SensorScan)); operatingOrder.AddLast(new TaskInfo(AnalyzePlanetaryData)); operatingOrder.AddLast(new TaskInfo(InternalSystemScan)); //operatingOrder.AddLast(new TaskInfo(MaintainAltitude)); operatingOrder.AddLast(new TaskInfo(UpdateTrackedTargets)); operatingOrder.AddLast(new TaskInfo(FollowOrders)); operatingOrder.AddLast(new TaskInfo(UpdateDisplays)); maxCameraRange = 5000; maxCameraAngle = 80; //set new defaults hoverHeight = 100; }
static void ResetTargePos(Character cha, ChildObject childObject, SkillContext context, excel_skill_event e) { SkillSelectCharactorType selType = (SkillSelectCharactorType)e.evnetParam1; Character selTarget = context.SelectCharactorByType(selType); if (selTarget == null) { return; } float fAngle = (float)e.evnetParam2; if (e.evnetParam3 > 0) { float fAngleR = (float)e.evnetParam3 * 2.0f; float fPct = UnityEngine.Random.Range(0.0f, 1.0f); fAngle += fPct * fAngleR - fAngleR; } Quaternion q = Quaternion.AngleAxis(fAngle, Vector3.up); Vector3 dir = selTarget.Direction; if (e.evnetParam4 > 0 && context.mOwner != selTarget) { dir = selTarget.Position - context.mOwner.Position; dir.y = 0.0f; dir.Normalize(); } dir = q * dir; float dist = (float)e.evnetParam5 * 0.001f; Vector3 targetPos = selTarget.Position + dir * dist; TargetPosTestType testType = (TargetPosTestType)e.evnetParam6; switch (testType) { case TargetPosTestType.None: break; case TargetPosTestType.LineTest: { uint layer = NavigationSystem.GetLayer(context.mOwner.Position); if (NavigationSystem.LineCast(context.mOwner.Position, targetPos, layer, out targetPos)) { break; } break; } case TargetPosTestType.TargetInNav: { if (!NavigationSystem.IsInNavigation(targetPos)) { targetPos = selTarget.Position; } break; } } context.TargetPos = targetPos; }
public void UpdateMesh() { if (mMeshFilter == null) { return; } if (mMeshFilter.mesh == null) { return; } Vector3[] vs = new Vector3[mMeshFilter.mesh.vertexCount]; for (int i = 0; i < mMeshFilter.mesh.vertexCount; ++i) { Vector3 v = mMeshFilter.mesh.vertices[i]; v = transform.localToWorldMatrix.MultiplyPoint(v); float h = 0.0f; if (!NavigationSystem.GetLayerHeight(v, mNavLayer, out h)) { // mNavSys.GetLayer(v, out mNavLayer); h = transform.position.y; } v.y = h; v.y += offsetY; v = transform.worldToLocalMatrix.MultiplyPoint(v); vs[i] = v; } mMeshFilter.mesh.vertices = vs; }
// Start is called before the first frame update void Start() { NS = GetComponent <NavigationSystem>(); agent = GetComponent <NavMeshAgent>(); IS = GetComponent <InventorySystem>(); SeeItem = false; }
private static void Problem2() { var navSystem = new NavigationSystem(LoadInstructions(_sampleInput)); navSystem.Execute().Should().Be(286); navSystem = new NavigationSystem(LoadInstructions(_input)); Console.WriteLine($"Real Manhattan Distance: {navSystem.Execute()}"); }
static void Main(string[] args) { var navigationSystem = new NavigationSystem(File.ReadAllLines("../input.txt")); //Part One Console.WriteLine(navigationSystem.GetNavigationDistance()); //Part One Console.WriteLine(navigationSystem.GetNavigationDistanceWithWaypoint()); }
public void LocateAllBeacons() { var sut = new NavigationSystem(SAMPLE_COORDINATES); sut.CalculateDistances(); sut.FindPossibleIntersectingBeacons(); sut.ConsolidateBeacons(); Assert.Equal(79, sut.Beacons.Count); }
public void CalculateManhattanDistance() { var sut = new NavigationSystem(SAMPLE_COORDINATES); sut.CalculateDistances(); sut.FindPossibleIntersectingBeacons(); sut.ConsolidateBeacons(); Assert.Equal(3621, sut.GetLargestManhattanDistanceBetweenScanners()); }
public void SolveSecondPuzzle() { var sut = new NavigationSystem(REAL_COORDINATES); sut.CalculateDistances(); sut.FindPossibleIntersectingBeacons(); sut.ConsolidateBeacons(); Assert.Equal(9634, sut.GetLargestManhattanDistanceBetweenScanners()); }
public void SolveFirstPuzzle() { var sut = new NavigationSystem(REAL_COORDINATES); sut.CalculateDistances(); sut.FindPossibleIntersectingBeacons(); sut.ConsolidateBeacons(); Assert.NotEqual(402, sut.Beacons.Count); Assert.Equal(330, sut.Beacons.Count); }
private void Navigate() { if (originMarker == null || destinationMarker == null) { NavigationSystem.Clear(); } else { NavigationSystem.Navigate(originMarker.position, destinationMarker.position); } }
public void SearchMove(Vector3 pos, float destRadius = 0.3f, bool sync = true) { Vector3[] path; if (!NavigationSystem.Nav_CalcLayerPath(Position, pos, NavLayer, out path)) { return; } mPath = path; mCurrentNodeIndex = 0; MoveSpeed = 0.0f; mDestRadius = destRadius; }
public AISubstate(AIState parentState) { this.parentState = parentState; this.pilot = parentState.pilot; this.entity = parentState.pilot.entity; this.transform = entity.transform; this.sensorSystem = entity.sensorSystem; this.engineSystem = entity.engineSystem; this.weaponSystem = entity.weaponSystem; this.commSystem = entity.commSystem; this.navSystem = entity.navSystem; }
public AIState(string name, AIPilot pilot) { this.name = name; this.pilot = pilot; this.entity = pilot.entity; this.transform = entity.transform; this.sensorSystem = entity.sensorSystem; this.engineSystem = entity.engineSystem; this.weaponSystem = entity.weaponSystem; this.commSystem = entity.commSystem; this.navSystem = entity.navSystem; }
public override bool LogicTick() { if (mMoveData == null) { return(false); } float time = Time.realtimeSinceStartup - mStartTime; if (mMoveData.mMoveDataType == SkillMoveDataType.MoveType1) { SkillMoveData1 moveData = mMoveData as SkillMoveData1; float t = time / moveData.mTime; Vector3 dir = moveData.mDestPos - moveData.mSrcPos; Vector3 curPos = moveData.mSrcPos + dir * t; Vector3 curDir = dir.normalized; mOwner.Position = curPos; mOwner.Direction = curDir; if (time >= moveData.mTime) { return(false); } } if (mMoveData.mMoveDataType == SkillMoveDataType.MoveType2) { SkillMoveData2 moveData = mMoveData as SkillMoveData2; Vector3 curPos = moveData.mSrcPos + moveData.mTime * moveData.mSpeed * moveData.mDir; mOwner.Position = curPos; mOwner.Direction = moveData.mDir; if (time >= moveData.mTime) { return(false); } } Vector3 pos = mOwner.Position; pos.y += 10.0f; float h = 0.0f; if (NavigationSystem.GetLayerHeight(pos, mOwner.NavLayer, out h)) { pos.y = h; mOwner.Position = pos; } return(true); }
public void LocateAllScanners() { var sut = new NavigationSystem(SAMPLE_COORDINATES); sut.CalculateDistances(); sut.FindPossibleIntersectingBeacons(); Assert.Collection(sut.GetScannerPositions(), p0 => Assert.Equal((0, 0, 0), p0), p1 => Assert.Equal((68, -1246, -43), p1), p2 => Assert.Equal((1105, -1205, 1229), p2), p3 => Assert.Equal((-92, -2380, -20), p3), p4 => Assert.Equal((-20, -1133, 1061), p4)); }
public void LineMove(Vector3 pos, float destRadius = 0.3f, bool sync = true) { Vector3 destPos; if (!NavigationSystem.LineCast(Position, pos, NavLayer, out destPos)) { return; } mPath = new Vector3[1] { destPos }; mCurrentNodeIndex = 0; MoveSpeed = 0.0f; mDestRadius = destRadius; }
/// <summary> /// Возвращает тип сигнала навигационной системы /// </summary> /// <param name="system">Навигационная система</param> /// <param name="code">Код сигнала</param> /// <returns>Тип сигнала</returns> public static SignalType GetSignalType(NavigationSystem system, uint code) { switch (system) { case NavigationSystem.GPS: switch (code) { case GPS_SIGNAL_L1_CA: return(SignalType.L1CA); case GPS_SIGNAL_L2_C: return(SignalType.L2C); case GPS_SIGNAL_L2_P: return(SignalType.L2P); case GPS_SIGNAL_L2_P_CODELESS: return(SignalType.L2P_codeless); case GPS_SIGNAL_L5_Q: return(SignalType.L5Q); default: return(SignalType.Unknown); } case NavigationSystem.GLONASS: switch (code) { case GLONASS_SIGNAL_L1_CA: return(SignalType.L1CA); case GLONASS_SIGNAL_L2_CA: return(SignalType.L2CA); case GLONASS_SIGNAL_L2_P: return(SignalType.L2P); default: return(SignalType.Unknown); } default: return(SignalType.Unknown); } }
public void ShouldThrowWhenActionIsInvalid() { // Arrange var instructions = new List <string> { "S10", // valid "X100", // invalid }; // Act Action followInstructions = () => { _ = new NavigationSystem(CreateShip(), instructions); }; // Assert followInstructions.Should().Throw <InvalidActionException>(); }
protected virtual void Awake() { Planner = new AIPlanner(this); CurrentActions = new Queue <AIPlannerIAction>(); AvailableActions = new HashSet <AIPlannerIAction>(); WorldState = new State(); Backpack = new Backpack(WorldState); GoalState = new State(); foreach (var a in gameObject.GetComponents <AIActionBase>()) { AvailableActions.Add(a); } IdleState = new IdleState(this); MoveState = new MoveState(this); ActState = new ActState(this); StateMachine = new FSM(); StateMachine.PushState(IdleState); Navigation = gameObject.GetComponent <NavigationSystem>(); }
public void ShouldFollowWaypointInstructionsAndCalculateManhattanDistance() { // Arrange var instructions = new List <string> { "F10", "N3", "F7", "R90", "F11" }; var navigationSystem = new NavigationSystem(CreateFerry(), instructions); // Act var distance = navigationSystem.CalculateManhattanDistance(); // Assert distance.Should().Be(286); }
public override void Exit() { if (mMoveData.mMoveDataType == SkillMoveDataType.MoveType1) { SkillMoveData1 moveData = mMoveData as SkillMoveData1; mOwner.Position = moveData.mDestPos; } Vector3 pos = mOwner.Position; pos.y += 10.0f; float h = 0.0f; if (NavigationSystem.GetLayerHeight(pos, mOwner.NavLayer, out h)) { pos.y = h; mOwner.Position = pos; } }
public static void OnLoadScene() { Scene scn = SceneSystem.Instance.mCurrentScene; if (scn == null) { return; } if (scn.mScnLists == null) { return; } if (scn.mScnLists.temp == 0) { return; } RectTransform canvas = UIRoot2D.Instance.GetComponent <RectTransform>(); GameObject joystick = Resources.Load <GameObject>("GUI/UI_Joystick"); if (joystick != null) { joystick = GameObject.Instantiate(joystick); RectTransform jt = joystick.GetComponent <RectTransform>(); jt.parent = canvas; jt.localScale = new Vector3(2.2f, 2.2f, 2.2f); } NavigationSystem.OnEnterScene(); NetWork.SetSendHeartbeatCallback(OnHeartbeatSend); NetWork.RegisterNotify(STC.STC_PlayerMove, OnPlayerMove); NetWork.RegisterNotify(STC.STC_TargetChg, OnTargetChg); NetWork.RegisterNotify(STC.STC_SkillNotify, SkillNotify); NetWork.RegisterNotify(STC.STC_SkillBegin, SkillBeginFunc); NetWork.RegisterNotify(STC.STC_AtbNotify, AtbNotify); NetWork.RegisterNotify(STC.STC_HPChg, OnChgHp); NetWork.RegisterNotify(STC.STC_SetPos, OnSetPos); }
static void Main(string[] args) { //Without Facade var controlSystem = new ControlSystem(); var monitorSystem = new MonitorSystem(); var navigationSystem = new NavigationSystem(); //TurnOff controlSystem.ControlSystemOff(); monitorSystem.MonitorSystemOff(); navigationSystem.NavigationSystemOff(); //TurnOn controlSystem.ControlSystemOn(); monitorSystem.MonitorSystemOn(); navigationSystem.NavigationSystemOn(); //With Facade var mySystemFacade = new SystemFacade(); mySystemFacade.TurnSystemOff(); mySystemFacade.TurnSystemOn(); }
public void ShouldExecuteAllPossibleInstructionsAndCalculateManhattanDistance() { // Arrange var instructions = new List <string> { "N100", "S10", "E100", "W10", "F10", "R90", "F10", "L90", "F10" }; var navigationSystem = new NavigationSystem(CreateShip(), instructions); // Act var distance = navigationSystem.CalculateManhattanDistance(); // Assert distance.Should().Be(190); }
//todo -- probably takes a descriptor to read pilot stats out of public void Start() { this.entity = GetComponent<Entity>(); this.engines = GetComponentInChildren<EngineSystem>(); this.controls = engines.FlightControls; this.sensorSystem = entity.sensorSystem; this.weaponSystem = entity.weaponSystem; this.commSystem = entity.commSystem; this.navSystem = entity.navSystem; Assert.IsNotNull(this.entity, "AIPilot needs an entity " + transform.name); Assert.IsNotNull(this.engines, "AIPilot needs an engine system"); Assert.IsNotNull(this.sensorSystem, "AIPilot needs a sensor system"); goals = new List<AIGoal>(5); AddGoal(new AIGoal_Idle()); AIGoalDescriptor desc = new AIGoalDescriptor(0.5f); AddGoal(new AIGoal_GoTo(desc, new Vector3(0, 0, 42f), 5f)); aiStates = CreateAIStates(this); SetAIState(); }