상속: MonoBehaviour
예제 #1
0
    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;
    }
예제 #2
0
    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);
    }
예제 #3
0
    private void Awake()
    {
        WayPointController wayPointController = (WayPointController)target;

        wayPoints = wayPointController.wayPoints;
        parent    = wayPointController.transform;
    }
예제 #4
0
    public WayPointController FindWayPointRandom(Controller controller)
    {
        WayPointController waypoint = null;
        int index = Random.Range(0, _wayPointSet.Length);

        waypoint = _wayPointSet[index];
        return(waypoint);
    }
예제 #5
0
    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);
        }
    }
예제 #6
0
    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;
        }
    }
예제 #7
0
    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);
    }
예제 #8
0
        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);
                }
            }
        }
예제 #9
0
    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);
    }
예제 #10
0
    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);
            }
        }
    }
예제 #11
0
 private void Awake()
 {
     w = GetComponent <WayPointController>();
 }
예제 #12
0
 private void AddEnemyToDictionaries(GameObject enemy, WayPointController currentWayPointController)
 {
     currentEnemiesIndexes.Add(enemy, 1);
     currentEnemiesWayPointControllerIndexes.Add(enemy, currentWayPointController);
 }
예제 #13
0
    public float waitTime;      // 머물러야하는 대기시간

    private void Awake()
    {
        w = GetComponent <WayPointController>();

        //coroutine = Timer();
    }