Esempio n. 1
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     agent            = animator.GetComponent <NavMeshAgent>();
     waypointsManager = animator.GetComponent <WaypointsManager>();
     nextWaypoint     = waypointsManager.GetClosestWaypoint();
     nextDest         = nextWaypoint.transform.position;
     agent.SetDestination(nextDest);
 }
Esempio n. 2
0
    private void Awake()
    {
        waypointsManager = FindObjectOfType <WaypointsManager>();        // Not optimal, but it works :)
        agent            = GetComponent <NavMeshAgent>();
        animator         = GetComponentInChildren <Animator>();
        fov = GetComponent <FieldOfView>();

        agent.speed = walkSpeed.Value;
        StartCoroutine(fov.FindTargetsWithDelay(0.2f));
    }
 public void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
     else if (_instance != this)
     {
         Destroy(gameObject);
     }
 }
Esempio n. 4
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
    // Use this for initialization
    void Awake()
    {
        if (!instance)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        GetWaypoints();
    }
Esempio n. 6
0
    // Inspector 操作邏輯
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        WaypointsManager _w_m = target as WaypointsManager;

        if (_w_m._Mode == WaypointsManager.Mode.EnableEdit)
        {
            if (GUILayout.Button("關閉編輯"))
            {
                _w_m._Mode = WaypointsManager.Mode.DisableEdit;
                return;
            }
            _w_m._NamePrefix    = EditorGUILayout.TextField("物件標題名稱", _w_m._NamePrefix);
            _w_m._PositionAdder = EditorGUILayout.Vector3Field("位置偏移", _w_m._PositionAdder);
            _w_m._DrawPointType = (WaypointsManager.DrawPointType)EditorGUILayout.EnumPopup("圖示類型", _w_m._DrawPointType);
            if (_w_m._DrawPointType == WaypointsManager.DrawPointType.Icon)
            {
                _w_m._SelectedIcon = (IconManager.Icon)EditorGUILayout.EnumPopup("圖標", _w_m._SelectedIcon);
            }
            else if (_w_m._DrawPointType == WaypointsManager.DrawPointType.LabelIcon)
            {
                _w_m._SelectedLabelIcon = (IconManager.LabelIcon)EditorGUILayout.EnumPopup("標籤", _w_m._SelectedLabelIcon);
            }
            _w_m._PointLineColor = EditorGUILayout.ColorField("路線色彩", _w_m._PointLineColor);
            EditorGUILayout.IntField("路徑點總數", _w_m._Waypoints.Count);
            EditorGUILayout.IntField("路徑點計數器", _w_m._Count);
            if (GUILayout.Button("返回上一步"))
            {
                _w_m.Return();
            }
            if (GUILayout.Button("重置路徑點計數器"))
            {
                _w_m._Count = 0;
            }
            if (GUILayout.Button("刪除全部路徑點"))
            {
                _w_m.ClearAllPoints();
            }
            EditorGUILayout.LabelField("說明:在編輯場景中,滑鼠中鍵新增路徑點。");
            return;
        }
        if (_w_m._Mode == WaypointsManager.Mode.DisableEdit)
        {
            if (GUILayout.Button("啟用編輯"))
            {
                _w_m._Mode = WaypointsManager.Mode.EnableEdit;
                return;
            }
        }
    }
Esempio n. 7
0
    // 增加路徑點功能
    private void AddWaypoint()
    {
        WaypointsManager _w_m             = target as WaypointsManager;
        GameObject       _waypoint_object = new GameObject();

        _waypoint_object.transform.position = _HitInfo.point + _w_m._PositionAdder;
        _waypoint_object.transform.parent   = Selection.activeGameObject.transform;
        _waypoint_object.name = _w_m._NamePrefix + "_" + _w_m._Count;
        if (_w_m._DrawPointType == WaypointsManager.DrawPointType.Icon)
        {
            IconManager.SetIcon(_waypoint_object, _w_m._SelectedIcon);
        }
        else if (_w_m._DrawPointType == WaypointsManager.DrawPointType.LabelIcon)
        {
            IconManager.SetLabelIcon(_waypoint_object, _w_m._SelectedLabelIcon);
        }
        _w_m._Count++;
    }
    private void Awake()
    {
        // Get the 3D rigid body for the robot game object this script is assigned to
        robot_body = GetComponent <Rigidbody2D>();

        // Initialize the Trajectory DLL
        pClassObj = MotionProfiling_Init();

        // Set initial constants for the generator
        setTrajectoryConstants(pClassObj, 10f, 168f, -72f, 120f);
        setPathGenerationConstants(pClassObj, 2f, 0.25f, 0.1f, 15f);
        setRobotConstants(pClassObj, 12.5f, 25f);

        robotTrailScript = GetComponent <RobotTrailRenderer>();
        waypointsManager = GameObject.Find("AddWaypointButton").GetComponent <WaypointsManager>();

        isEnded = true;
    }
Esempio n. 9
0
    public void Awake()
    {
        navMeshAgent = GetComponent <NavMeshAgent>();
        Debug.Log("manager = " + WaypointsManager.GetWaypointsManager());

        humanScript  = GetComponent <NPCHuman>();
        zombieScript = GetComponent <NPCZombie>();

        if (isZombie)
        {
            humanScript.enabled  = false;
            zombieScript.enabled = true;
        }

        else
        {
            humanScript.enabled  = true;
            zombieScript.enabled = false;
        }
    }
Esempio n. 10
0
    // 增加路徑點邏輯
    private void OnSceneGUI()
    {
        WaypointsManager _w_m = target as WaypointsManager;

        if (_w_m._Mode == WaypointsManager.Mode.EnableEdit)
        {
            // 紀錄當前的事件
            Event _e = Event.current;
            // 若當前事件為按下滑鼠右鍵並放開鍵鼠時則執行
            if (_e.type == EventType.MouseUp && _e.button == 2)
            {
                // 取得當前編輯場景畫面鼠標座標位置
                Ray _world_ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
                if (Physics.Raycast(_world_ray, out _HitInfo))
                {
                    AddWaypoint();
                }
            }
        }
    }
Esempio n. 11
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     base.OnStateEnter(animator, stateInfo, layerIndex);
     waypointsManager = animator.GetComponent <WaypointsManager>();
     timeUntilWander  = Random.Range(randomTimeRangeUntilWander.x, randomTimeRangeUntilWander.y);
 }
Esempio n. 12
0
 private void Start()
 {
     waypointsManager = this;
 }
Esempio n. 13
0
 void Awake()
 {
     instance = this;
 }
Esempio n. 14
0
 private void Awake()
 {
     _Instance = this;
 }
Esempio n. 15
0
 public Node_Patrol(WaypointsManager waypointsManager, NavMeshAgent navAgent)
 {
     this.waypointsManager = waypointsManager;
     this.navAgent         = navAgent;
     waypointTarget        = null;
 }
Esempio n. 16
0
 // Start is called before the first frame update
 void Awake()
 {
     wp = this;
 }