public override void OnEnter() { base.OnEnter(); if (_stateManager.controller.role.Base.Type == DEngine.Common.GameLogic.RoleType.Hostage) { _waypoint = WayPointSet.Instance.FindWayPointRandom(_stateManager.controller); } else { _waypoint = WayPointSet.Instance.FindWayPointNoEnemy(_stateManager.controller); } if (_waypoint != null && _stateManager.controller != null) { _stateManager.controller.OnMove(_waypoint.transform.position); } else { Debug.Log(" RunAwayState OnEnter => Null"); } _stateManager.timerLastRun = Time.time; _timer = Time.time; }
public GameObject GetShortestDistanceWayPoint() { GameObject WayPoint = null; float ShortestDistance = Mathf.Infinity; foreach (GameObject obj in GameObject.FindGameObjectsWithTag("WayPoint")) { WayPointController waypointController = obj.GetComponent <WayPointController>(); if (m_WayPoints.Contains(waypointController.getIdNumber())) { continue; } else { float Distance = Vector3.Distance(m_Transform.position, obj.transform.position); if (Distance < ShortestDistance) { ShortestDistance = Distance; WayPoint = obj; } } } return(WayPoint); }
private void Awake() { WayPointController wayPointController = (WayPointController)target; wayPoints = wayPointController.wayPoints; parent = wayPointController.transform; }
public WayPointController FindWayPointRandom(Controller controller) { WayPointController waypoint = null; int index = Random.Range(0, _wayPointSet.Length); waypoint = _wayPointSet[index]; return(waypoint); }
public void PassedWayPoint(WayPointController Waypoint) { int IdNumber = Waypoint.getIdNumber(); if (!m_WayPoints.Contains(IdNumber) && m_GameController.getGameState() != "Final") { m_WayPoints.Add(IdNumber); m_CanvasPanel.Find("Waypoints").GetComponent <UnityEngine.UI.Text>().text = "Waypoints: " + m_WayPoints.Count; m_GameController.PlayerPassedThroughWaypoint(this, Waypoint); } }
void OnTriggerEnter2D(Collider2D cl) { if (cl.transform.tag == "Player") { Debug.Log("Colision With player"); WayPointController wpc = cl.gameObject.GetComponent <WayPointController>(); wpc.ActualWayPoint = this; wayPointDirectionChoosed = Vector3.zero; } }
private bool CheckWayPointsProximity(Vector3 NewWayPoint, float MinDistance) { foreach (GameObject obj in GameObject.FindGameObjectsWithTag("WayPoint")) { WayPointController wc = obj.GetComponent <WayPointController>(); float Distance = Vector3.Distance(NewWayPoint, wc.transform.position); if (Distance < MinDistance) { return(false); } } return(true); }
private void ClearCurrentTarget() { WayPointController oldWayPointController = Target; if (oldWayPointController != null) { oldWayPointController.TargetedUnits.Remove(this); oldWayPointController.TargetedImage.gameObject.SetActive(false); if (oldWayPointController.TargetedUnits.Count == 0 && oldWayPointController.GetComponent <UnitController>() == null) { Destroy(oldWayPointController.gameObject); } } }
public WayPointController FindWayPointNoEnemy(Controller controller) { WayPointController waypoint = null; HeroSet enemies = GameplayManager.Instance.getEnemySet(controller); float max = float.MinValue; foreach (WayPointController wp in _wayPointSet) { float distace = 0; foreach (Hero hero in enemies) { Controller c = hero.controller; if (c.gameObject != null) { if (c.typeCharacter != Controller.TypeChatacter.Healer) { float distanceToEnemy = 0; distanceToEnemy = Vector3.Distance(wp.transform.position, c.transform.position); if (c.typeCharacter == Controller.TypeChatacter.Range) { distanceToEnemy *= 2; } distace += distanceToEnemy; } } } if (distace > max) { max = distace; waypoint = wp; } } return(waypoint); }
public void PlayerPassedThroughWaypoint(PlayerController Player, WayPointController Waypoint) { Waypoint.PlayerPassed(); if (Player.getWayPoints().Count == m_WayPointQuantity && m_GameState == "Running") { m_GameState = "Final"; foreach (GameObject player in m_Players) { player.GetComponent <PlayerController>().EndMatch(); } } else { if (Waypoint.getPlayerCount() == 1 && m_WayPointActualQuantity < m_WayPointQuantity) { CreateRandomWayPoint(); } if (Waypoint.getPlayerCount() >= m_GlobalVariables.m_NumberOfPlayers) { Destroy(Waypoint.gameObject); } } }
private void Awake() { w = GetComponent <WayPointController>(); }
private void AddEnemyToDictionaries(GameObject enemy, WayPointController currentWayPointController) { currentEnemiesIndexes.Add(enemy, 1); currentEnemiesWayPointControllerIndexes.Add(enemy, currentWayPointController); }
public float waitTime; // 머물러야하는 대기시간 private void Awake() { w = GetComponent <WayPointController>(); //coroutine = Timer(); }