示例#1
0
    private float groundLevel   = 6f;   // the ground level for landing action



    // Start is called before the first frame update
    void Start()
    {
        // initialize the variable fields
        rb            = this.GetComponent <Rigidbody>();
        psManager     = GameObject.Find("ParkingSystem").GetComponent <ParkingSpotManager>(); // Find instance of ParkingSpotManager script
        taskScheduler = GameObject.Find("TaskScheduler").GetComponent <TaskScheduler>();
        planeTask     = this.gameObject.GetComponent <PlaneTask>();

        currentState   = PlaneState.START;  // initial state
        gas_limit_time = planeTask.gasTime; // get the gas time from the task script
    }
    void Update()
    {
        //try creating a task event every time interval
        timeElapsed += Time.deltaTime;
        planeSpawningTimeElapsed += Time.deltaTime;

        if (timeElapsed > timeInterval)
        {
            //if there are no available tasks, try again at next interval
            Task tempTask = FindAvailableTask();
            if (tempTask != null)
            {
                taskEventList.Add(InstantiateTaskEvent(tempTask));
                UpdateTaskListText();
            }
            timeElapsed = 0;
        }

        // Spawn planes every time interval (use a different timer)
        if (planeSpawningTimeElapsed > spawnPlanesTimeInterval)
        {
            // generate a plane at the spawning point
            GameObject plane     = Instantiate(planePrefab, spawningPoint.transform.position, spawningPoint.transform.rotation);
            PlaneTask  planeTask = plane.GetComponent <PlaneTask>();
            taskEventList.Add(InstantiateTaskEvent(planeTask));  // add this landing task to the task event list
            UpdateTaskListText();
            planeSpawningTimeElapsed = 0;
        }

        UpdateTaskListText();

        /* check for game over state
         * if(planeCrashCounter > maxPlaneCrashes)
         * {
         *  // trigger game over
         *  //gameOverScript.gameObject.SetActive(true);
         *  Game_state.isGameOver = true;
         *  planeCrashCounter = 0;
         * }
         */
    }