Inheritance: MonoBehaviour
Exemplo n.º 1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Drone")
     {
         DronePatrol temp = other.GetComponent <DronePatrol>();
         if (temp.Target == transform.position)
         {
             temp.ReachedPoint();
         }
     }
 }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        myTarget = (DronePatrol)target;

        DrawDefaultInspector();
        //var waypoints = serializedObject.FindProperty("WaypointPatrolList");
        //EditorGUILayout.PropertyField(waypoints, new GUIContent("TEST EDITOR"), true);

        if (GUILayout.Button("ADD WAYPOINT"))
        {
            AddWaypoint();
        }

        if (GUILayout.Button("REMOVE WAYPOINT"))
        {
            RemoveWaypoint();
        }
    }
Exemplo n.º 3
0
    private void OnSceneGUI()
    {
        myTarget = (DronePatrol)target;



        if (myTarget.WaypointPatrolList != null)
        {
            for (int i = 0; i < myTarget.WaypointPatrolList.Count; i++)
            {
                if (myTarget.WaypointPatrolList[i] == null)
                {
                    myTarget.WaypointPatrolList.RemoveAt(i);
                    i--;
                }
            }

            Vector3[] newWaypointPosition = new Vector3[myTarget.WaypointPatrolList.Count];

            EditorGUI.BeginChangeCheck();
            for (int i = 0; i < newWaypointPosition.Length; i++)
            {
                newWaypointPosition[i] = Handles.PositionHandle(myTarget.WaypointPatrolList[i].transform.position, Quaternion.identity);
            }

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(myTarget, "Change Look At Target Position");

                for (int i = 0; i < newWaypointPosition.Length; i++)
                {
                    myTarget.WaypointPatrolList[i].transform.position = newWaypointPosition[i];
                }
                //myTarget.Update();
            }
        }
    }
Exemplo n.º 4
0
    /*
     * ===========================================================================================================
     * UNITY'S STUFF
     * ===========================================================================================================
     */
    /// <summary>
    /// When the script is initialized
    /// </summary>
    void Awake()
    {
        if(this.droneType == eDroneType.Patrol){
          patrolDroneScript  = this.gameObject.GetComponent<DronePatrol>();
          //patrolScript = this.gameObject.GetComponent<Patrol>();
        }
        else if(this.droneType == eDroneType.Saboteur) saboteurScript = this.gameObject.GetComponent<Saboteur>();

        // Check if it is a CPU controlled drone (or opponent drones, for that matter)
        if(this.gameObject.layer == MainScript.enemyLayer) {

        // Set a flag to make easier for us
           isThisAnEnemyDrone = true;

            // Check the type and get the component
            // AI hunter drone
            if(this.droneType == eDroneType.Hunter) {

                hunterAIScript = this.gameObject.GetComponent<DroneHunter>();

                captureSpot = GetCaptureSpot();
                captureRaySpot = GetCaptureRaySpot();

                if(!hunterAIScript) {

                    // DEBUG
                    Debug.LogError("DroneHunter component not found in " + this.transform);
                }
            }

          if(this.droneType == eDroneType.Patrol) {

        enemyPatrolScript = this.gameObject.GetComponent<EnemyPatrol>();
        // Set a flag to make easier for us
           //isThisAnEnemyDrone = true;

          }

        }

        sabotageTime = 2.0f;
        // Set the default settings for all the drones
        if(!isThisAnEnemyDrone)
            Selectable = true; // All drones are selectable

        Movable = true; // All drones are movable
        Type = eObjType.Drone;

        AIScript = gameObject.GetComponent<AstarAIFollow>();

        // FSM setup
        eFSMCurrentState = FSMState.STATE_IDLE;

        // Starts the object variables, like the sweet spot and the main mesh object
        GetSweetSpotAndMeshObject();

        // Get info about the collider
        GetColliderInfo();
    }