// Use this for initialization void Start() { step = stepObj.GetComponent <Step>(); point = new Vector3(7, 2); ph = new PathController(gameObject); gameObject.transform.GetComponentInParent <CheckPath>().OnTriggerObjects += delegate() { Vector2 pos; IEnumerable <GameObject> boots; ph.GetOverlap(out pos, out boots); ph.GetValue(boots, pos); }; //При поступлении шага step.StepDone += delegate() { CheckPath.stop = false; Astar star = new Astar(transform.position, point); path = star.GetPath(); gameObject.GetComponent <Path>().path = path; }; }
private void Start() { _path = GetComponent <PathController>(); MCurrentGeneCount = 0; CreateStartPopulation(); Run(); }
public override void OnInspectorGUI() { instance = target as PathController; EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add new Path")) { var newPath = instance.gameObject.AddComponent <PathInMaze>(); newPath.ID = GetNextID(); } if (GUILayout.Button("Re-Numerate Path IDs")) { var paths = instance.gameObject.GetComponents <PathInMaze>(); var count = paths.Count(); for (int i = 0; i < count; i++) { paths.ElementAt(i).ID = i; } } EditorGUILayout.EndHorizontal(); }
public void Initialize(int health, float speed, PathController pathController) { this.health = health; this.speed = speed; _pathController = pathController; destination = pathController.nextMapNode(index); }
void PathfindingUpdateAndGetMoveVector(float delta, double distanceToReach, Vector3 from, Vector3 target, out Vector3 moveVector) { moveVector = Vector3.Zero; var pathfinding = GetPathfinding(); if (pathfinding != null) { //update if (pathController == null) { pathController = new PathController(); } pathController.Update(pathfinding, delta, distanceToReach, from, target); //get move vector if (pathController.GetNextPointPosition(out var nextPointPosition)) { var vector = nextPointPosition - from; if (vector.X != 0 || vector.Y != 0) { moveVector = new Vector3(vector.ToVector2().GetNormalize(), vector.Z); } } } }
//导入资源 public void LoadResources() { //人物初始化 roleControllers = new RoleModelController[6]; for (int i = 0; i < 6; i++) { roleControllers[i] = new RoleModelController(); roleControllers[i].CreateRole(PositionModel.roles[i], i < 3 ? true : false, i); } //左右岸初始化 leftLandController = new LandModelController(); leftLandController.CreateLand("left_land", PositionModel.left_land); rightLandController = new LandModelController(); rightLandController.CreateLand("right_land", PositionModel.right_land); //将人物添加并定位至左岸 foreach (RoleModelController roleModelController in roleControllers) { roleModelController.GetRoleModel().role.transform.localPosition = leftLandController.AddRole(roleModelController.GetRoleModel()); } //河流Model实例化 riverModel = new RiverModel(PositionModel.river); //船初始化 boatController = new BoatModelController(); boatController.CreateBoat(PositionModel.left_boat); pathController = new PathController(); //数据初始化 isRuning = true; time = 60; }
// Start is called before the first frame update void Start() { enemiesKilled = 0; levelPath = GameObject.Find("Path").GetComponent <PathController>(); pathWaypoints = levelPath.GetWaypoints(); Invoke("LevelOne", 4.0f); }
void Awake() { PathController = GetComponentInChildren <AbstractPathMind>(); PathController.SetCharacter(this); LocomotionController = GetComponent <Locomotion>(); LocomotionController.SetCharacter(this); }
public override void OnInspectorGUI() { DrawDefaultInspector(); PathController controllerScript = (PathController)target; if (GUILayout.Button("Create path point")) { GameObject newPoint = controllerScript.AddPoint(); Selection.activeGameObject = newPoint; } //Check if path point or controller is selected if (controllerScript.gameObject == Selection.activeGameObject || controllerScript.gameObject == Selection.activeGameObject.transform.parent.gameObject) { //set active to true so gizmos will render controllerScript.activePath = true; } else { //set active to false so gizmos will not render controllerScript.activePath = false; } }
static void Update() { //search for path controllers in scene PathController[] controllers = GameObject.FindObjectsOfType <PathController>(); activeController = null; //find the selected path controller or path point if (controllers.Length > 0 && Selection.activeGameObject) { foreach (PathController controller in controllers) { if (Selection.activeGameObject == controller.gameObject) { activeController = controller; break; } else if (Selection.activeGameObject.transform.parent != null && Selection.activeGameObject.transform.parent == controller.transform) { activeController = controller; break; } } } }
void Start() { rb = GetComponent<Rigidbody>(); rb.centerOfMass += new Vector3(0, 0, 1); autopilot = false; pathcontroller = GetComponent<PathController>(); }
void Start() { if (path_controller == null) { path_controller = GetComponent <PathController>(); } }
private static void SolveTheProblem(int problemNr) { Console.WriteLine($"Solving Euler problem: {problemNr}"); var watch = System.Diagnostics.Stopwatch.StartNew(); IPyramideController pyramid = new PyramidController(GetInputValues(problemNr)); IPathController pathController = new PathController(pyramid); var path = pathController.GetSuitablePath(); watch.Stop(); Console.WriteLine("Result: " + path.Sum); var output = "Path -> "; for (var i = 0; i < path.PathNodes.Count; i++) { output += path.PathNodes[i].Value; if (i < path.PathNodes.Count - 1) { output += " + "; } } output += $" = {path.Sum}"; Console.WriteLine(output); Console.WriteLine($"It tooked: {watch.ElapsedMilliseconds}ms"); Console.WriteLine("-----------------------------------------\n"); }
void OnEnable() { _pathController = target as PathController; _begin = serializedObject.FindProperty(nameof(PathController.BeginOnAwake)); _path = serializedObject.FindProperty(nameof(PathController.Path)); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); PathController pathController = (PathController)target; EditorGUILayout.LabelField("Number of waypoints", pathController.path.Length.ToString()); }
private void Start() { //set components navigator = GetComponent <NavMeshAgent>(); if (GetComponent <DetectionMeter>()) { detection = GetComponent <DetectionMeter>(); } if (pathParent && pathParent.GetComponent <PathController>()) { pathController = pathParent.GetComponent <PathController>(); } //set search pos lastKnownPlayerPosition = Vector3.zero; SearchPosition = Vector3.zero; //set FOV CurrentFOV = patrolFOV; //set current point to first point if (pathController && pathController.listPoints.Count > 0) { currentPathPoint = pathController.listPoints[0]; } currentListIndex = 0; //find the player if (player == null) { player = GameObject.FindGameObjectWithTag("Player"); if (player == null) { player = GameObject.FindGameObjectWithTag("Player"); if (player.transform.root.gameObject.tag == "Player") { player = player.transform.root.gameObject; } } } //check if player has detection component if (player.GetComponent <PlayerDetection>()) { playerDetection = player.GetComponent <PlayerDetection>(); playerComponents = playerDetection.components; } if (headTransform == null) { headTransform = transform; } //set state currentState = StealthState.PATROL; EnterPatrol(); }
void Start() { pathController = new PathController(jsonFile.text, transform); pathController.OnFinish += onFinish; line = gameObject.GetComponent <LineRenderer>(); Reset(); }
void Awake() { PC = GameObject.FindGameObjectWithTag("Ground").GetComponent <PathController>(); sphere = GetComponent <Rigidbody>(); toPosition = transform.position; height = transform.localScale.x * 0.5f; threshold = transform.localScale.x * 0.1f; sphere.freezeRotation = true; }
public PathAnimators(PathController path, float speed, float size, bool wrap = false) { animators = new List <PathAnimator>(); PathController = path; Speed = speed; Size = size; Wrap = wrap; Initialize(); }
public void PathController_CalculateBestPath_MatchesExpectedSum(string input, int expected) { IPyramideController matrix = new FakeMatrixController(CreateNodeValues(input)); var path = new PathController(matrix); var pathTaken = path.GetSuitablePath(); Assert.AreEqual(expected, pathTaken.Sum); }
public WanderingState(Enemy2Controller enemy) : base(enemy) { animatorBoolParameterName = "IsWandering"; _transform = enemy.transform; _rigidbody = enemy.Rigidbody; _parameters = enemy.Parameters; _spriteRenderer = enemy.SpriteRenderer; _pathController = enemy.PathController; }
void Update() { if (BoardManager == null) { return; } if (LocomotionController.MoveNeed) { LocomotionController.SetNewDirection(PathController.GetNextMove(BoardManager.boardInfo, LocomotionController.CurrentEndPosition(), null)); } }
public void StartEnemy(PathController path, Transform enemyPool) { Debug.Log("Enemy - " + Data.name + " started."); this.path = path; pool = enemyPool; currentHealth = Data.Health; currentWayPointIndex = 0; positionOffsetZ = Vector3.up * 0.1f; startPosition = path.Data.WayPoints[currentWayPointIndex] + positionOffsetZ; endPosition = path.Data.WayPoints[path.Data.WayPoints.Length - 1] + positionOffsetZ; StartFollowPath(); }
// Update is called once per frame void Update() { Debug.Log("Whose Turn " + whosTurn); PathController pc = pathControls[whosTurn - 1]; if (pc.moveAllowed && (pc.moveForwardCount == 0) && pc.jumpIndex == 0) { pc.moveAllowed = false; if (GameStates.MatchType == 2) { whosTurn = whosTurn == GameStates.PlayerCount ? 1 : ++whosTurn; } else if (GameStates.MatchType == 1) { if (GameStates.MatchState.matchIndex == whosTurn) { whosTurn = whosTurn == GameStates.MatchState.type ? 1 : ++whosTurn; } else { whosTurn = GameStates.MatchState.whosTurn; } } DiceController.instance.shouldRollDice = true; UIController.instance.switchTurn(); if (GameStates.MatchState.matchIndex == whosTurn) { Invoke("startCountdown", 5f); } } if (pc.currentPathIndex == pc.totalWayPoint) { gameOver(whosTurn); } if (shouldIncrementTimer) { timeLeft -= Time.deltaTime; UIController.instance.updateTimerText(timeLeft); if (timeLeft <= 0) { autoTrigger = true; } } }
//Get the inactive path object private PathController GetPathControl() { foreach (PathController o in listPathControl) { if (!o.gameObject.activeInHierarchy) { return(o); } } PathController pathControl = Instantiate(groundPrefab, Vector3.zero, Quaternion.identity).GetComponent <PathController>(); listPathControl.Add(pathControl); pathControl.gameObject.SetActive(false); return(pathControl); }
//Создание волны врагов public void CreateWave(Transform enemyPool, Transform wavePool, PathController path) { this.enemyPool = enemyPool; this.wavePool = wavePool; int i = 0; while (i++ != Data.EnemyCount) { Transform enemy = enemyPool.GetChild(0); enemy.SetParent(wavePool); enemy.gameObject.SetActive(false); } StartEnemies(path); }
void Awake() { _rb2D = GetComponent <Rigidbody2D>(); if (_rb2D == null) { Debug.LogError("Rigid body could not be found"); } if (pathControllerPrefab == null) { Debug.Log("Path controller is not set"); } _pathController = pathControllerPrefab.GetComponent <PathController>(); if (_pathController == null) { Debug.Log("Path controller couldn't be found"); } }
public void Init(ushort id, byte type, float scl, float time, float actionSpeed, bool actionUnite, float speed, PathLinearInterpolator interp) { ResFishData fd = FishResManager.Instance.GetFishData(type); if (fd == null) { Debug.Log("不存在的鱼模型:" + type.ToString()); return; } m_CatchSeat = 0xff; m_bCatched = false; m_Delay = false; m_Scaling = scl; m_FishID = id; m_FishType = type; m_PathCtrl = new PathController(); m_PathCtrl.ResetController(interp, speed, time, fd.ClipLength[(byte)FishClipType.CLIP_CHAOFENG]); m_Model = (GameObject)GameObject.Instantiate(FishResManager.Instance.GetFishObj(type)); m_ModelTransform = m_Model.GetComponent <Transform>(); m_ModelTransform.position = FishInitPos; m_Anim = m_Model.GetComponent <Animator>(); m_OrgRot = m_ModelTransform.localRotation; m_Model.name = m_FishID.ToString(); SetScaling(scl); m_Renderer = m_ModelTransform.GetChild(0).gameObject.GetComponent <Renderer>(); if (m_Renderer == null) { m_Renderer = m_ModelTransform.GetChild(1).gameObject.GetComponent <Renderer>(); } m_Anim.speed = actionSpeed; if (!actionUnite) { m_Anim.Play(YouYongHashName, 0, Utility.Range(0.0f, 1.0f)); } if (IsBossFish()) { m_bgsoundDelay = 2; AudioManager.Instance.StopBgMusic(); //AudioManager.Instance.PlayOrdianryMusic(Audio.OrdianryMusic.m_bosscoming); //KonnoTool.ShowBossComingWindow(); } }
void Start() { textMode.text = (isBfs) ? "Current Mode: BFS" : "Current Mode: DFS"; ySize = tilemap.cellBounds.size.y; xSize = tilemap.cellBounds.size.x; yMin = tilemap.cellBounds.yMin; xMin = tilemap.cellBounds.xMin; InitializeGrid(); var sourcePosition = SetupSourceAndTarget(); if (isBfs) { controller = new BFS(grid, sourcePosition); } else { controller = new DFS(grid, sourcePosition); } }
// Use this for initialization void Start() { Application.targetFrameRate = 60; ScoreManager.Instance.Reset(); //Fire event GameState = GameState.Prepare; gameState = GameState.Prepare; //Add another actions here //Set variables GroundBottomPosition = firstGround.transform.position.y; GroundLargeScale = groundLargeScale; ObjectFadingTime = objectFadingTime; ReviveWaitTime = reviveWaitTime; currentZPos = firstGround.transform.position.z; xPathDistance = originalXPathDistance; IsRevived = false; //Add first path to the list listPathControl.Add(firstGround.GetComponent <PathController>()); //Create some path first for (int i = 0; i < groundNumber; i++) { float zPos = currentZPos + pathSpace; float xPos = 0; Vector3 pathPos = new Vector3(xPos, GroundBottomPosition, zPos); PathController pathControl = GetPathControl(); pathControl.gameObject.transform.position = pathPos; pathControl.gameObject.SetActive(true); currentZPos = pathControl.transform.position.z; } if (isRestart) { PlayGame(); } }
//Get the arranged list of path control private List <PathController> ArrangedList() { List <PathController> finalList = new List <PathController>(); List <PathController> pathsControl = FindObjectsOfType <PathController>().ToList(); int pathNumber = pathsControl.Count; while (finalList.Count < pathNumber) { float min = 1000; PathController minZPathControl = null; foreach (PathController o in pathsControl) { if (o.transform.position.z < min) { min = o.transform.position.z; minZPathControl = o; } } finalList.Add(minZPathControl); pathsControl.Remove(minZPathControl); } return(finalList); }
public void GetRange() { path_controller = GetComponent<PathController>(); path_controller.SetRange(myChar.movementRange); }
public static Easing[] easeController( PathController pc, float time ) { return easeController( pc, time, "default" ); }
public static Easing[] easeController( PathController pc, float time, string easingGroup ) { int i = 0; Easing[] easings = new Easing[ pc.paths.Length ]; foreach( PathScript scr in pc.paths ) { Easing es = Easing.easePath( scr.easingTarget, scr, time, easingGroup ); es.alignPathWithSpeed( scr.alignWithSpeed ); easings[ i++ ] = es; } return easings; }
void Start() { if (path_controller == null) path_controller = GetComponent<PathController>(); }