Exemplo n.º 1
0
 void Start()
 {
     controller      = GetComponent <UnityStandardAssets.Vehicles.Car.CarController> ();
     aiController    = GetComponent <UnityStandardAssets.Vehicles.Car.CarAIControl> ();
     progressTracker = GetComponent <UnityStandardAssets.Utility.WaypointProgressTracker> ();
     sceneManager    = GameObject.Find("Race Scene Manager").GetComponent <RG_SceneManager>();
 }
Exemplo n.º 2
0
        private void stopAllEnemy()
        {
            if (gameObject.tag == "Player")
            {
                GameObject[] allEnemyCar = GameObject.FindGameObjectsWithTag("Enemy");

                if (allEnemyCar.Length > 0)
                {
                    foreach (GameObject gameObjectEnemy in allEnemyCar)
                    {
                        if (gameObjectEnemy != null)
                        {
                            CarAIControl carAIControl = gameObjectEnemy.GetComponent <CarAIControl>();
                            EnemyGun     enemyGun     = gameObjectEnemy.GetComponent <EnemyGun>();

                            if ((carAIControl != null) && (enemyGun != null))
                            {
                                carAIControl.stopCarAi();
                                enemyGun.stopShooting();
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
    public void init(WaypointStrategy travelStrat)
    {
        controls = gameObject.GetComponent <UnityStandardAssets.Vehicles.Car.CarAIControl>();

        travelStrategy = travelStrat;

        controls.SetTarget(travelStrategy.pickNextWaypoint().getTransform());

        isDead = isDecoupled = false;

        hitPoints = 3;
    }
Exemplo n.º 4
0
 //ブレーキポイントに滞在中にm_limitsSpeedを速度が下回った場合ブレーキを離す
 private void OnTriggerStay(Collider other)
 {
     m_AiCon = other.gameObject.GetComponent <UnityStandardAssets.Vehicles.Car.CarAIControl>();
     if (m_AiCon == null)
     {
         return;
     }                               //もしotherがAiでなければ処理を行わない
     if (m_AiCon.CurrentAiSpeed() <= m_limitsSpeed && m_AiCon.m_Driving == false)
     {
         m_AiCon.m_Driving = true;
     }
 }
Exemplo n.º 5
0
    public void init(ChaseStrategy chaseStrat)
    {
        controls = gameObject.GetComponent <UnityStandardAssets.Vehicles.Car.CarAIControl>();

        chaseStrategy = chaseStrat;

        controls.SetTarget(chaseStrat.pickAttack().getTransform());

        isDead = isDecoupled = false;

        hitPoints = 5;
    }
Exemplo n.º 6
0
    private void OnTriggerEnter(Collider other)
    {
        m_AiCon = other.GetComponent <UnityStandardAssets.Vehicles.Car.CarAIControl>();

        if (m_AiCon == null)
        {
            return;
        }                               //もしotherがAiでなければ処理を行わない


        if (m_AiCon.CurrentAiSpeed() >= m_limitsSpeed && m_AiCon.m_Driving == true)//m_limitsSpeedより早ければスピードを下げる
        {
            m_AiCon.m_Driving = false;
        }
    }
        // Use this for initialization
        void Start()
        {
            waypointlist[0] = new Vector3(-20.6f, 0f, 126.2f);
            waypointlist[1] = new Vector3(35.6f, 0f, 138.8f);
            waypointlist[2] = new Vector3(78.7f, 0f, 105.3f);
            waypointlist[3] = new Vector3(98.4f, 0f, 43.9f);
            waypointlist[4] = new Vector3(75.8f , 0f, -13.3f);
            waypointlist[5] = new Vector3(28.4f, 0f, -18.4f);
            waypointlist[6] = new Vector3(-4.2f, 0f, -2.3f);
            waypointlist[7] = new Vector3(-18.7f, 0f, 26f);
            waypointlist[8] = new Vector3(-31.6f, 0f, 57.4f);
            waypointlist[9] = new Vector3(-30f, 0f, 95f);
            carai = GetComponent(typeof(CarAIControl)) as CarAIControl;
            car = carai.GetComponent(typeof(CarController)) as CarController;
            waypointholder.position = waypointlist[0];
            carai.SetTarget(waypointholder);
            for (int i = 0; i < 10; i++)
            {
                GameObject.Instantiate(marker);
                marker.transform.position = waypointlist[i];
            }
            lasttime = 0;

            //In start initialize both
            currentCameraIndex = 0;
            //Turn all cameras off, except the first default one
            for (int i=1; i<cameras.Length; i++)
            {
                cameras[i].gameObject.SetActive(false);
            }

            //If any cameras were added to the controller, enable the first one
            if (cameras.Length>0)
            {
                cameras [0].gameObject.SetActive (true);
            }
        }
Exemplo n.º 8
0
 void Start()
 {
     cac = GetComponent <UnityStandardAssets.Vehicles.Car.CarAIControl> ();
     cc  = GetComponent <UnityStandardAssets.Vehicles.Car.CarController> ();
 }
Exemplo n.º 9
0
 private void Awake()
 {
     // get the car controller
     m_Car = GetComponent <CarController>();
     ai    = GetComponent <CarAIControl>();
 }
Exemplo n.º 10
0
    //bool outOfSpace = false;

    void Start()
    {
        cac = gameObject.transform.parent.gameObject.GetComponent <UnityStandardAssets.Vehicles.Car.CarAIControl> ();
    }
Exemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     car = GameObject.FindGameObjectWithTag("Player").GetComponent <UnityStandardAssets.Vehicles.Car.CarAIControl>();
     Debug.Log("tar_f-Start");
 }
Exemplo n.º 12
0
        private void FixedUpdate()
        {
            if (drop1.transform.childCount > 0 && drop2.transform.childCount > 0)
            {
                Destroy(preventsRollingDown);
                m_Car.Move(TURN, 2, 0, 0);

                if (!timeDone2)
                {
                    TURN = 0;
                    move_forward.color      = new Color32(255, 128, 0, 255);
                    if_else.color           = new Color32(150, 20, 45, 45);
                    if_else_content.color   = new Color32(150, 20, 45, 45);
                    if_statement.color      = new Color32(150, 20, 45, 45);
                    if_content.color        = new Color32(150, 20, 45, 45);
                    last_move_forward.color = new Color32(150, 20, 45, 45);


                    StartCoroutine(Example2((float)17));
                }
                if (timeDone2)
                {
                    ////debug.log("TURN!!!!" + correct_input.ToString());
                    if (correct_input)
                    {
                        //TURN = -1;
                        gameObject.AddComponent <CarAIControl>();
                        gameObject.AddComponent <WaypointProgressTracker>();

                        CarAIControl aiControl = GetComponent <CarAIControl>();
                        aiControl.m_Driving = true;
                        aiControl.SetStopWhenTargetReached(false);

                        WaypointProgressTracker wpt = GetComponent <WaypointProgressTracker>();
                        wpt.circuit = correctcircuit;
                        wpt.target  = WaypointTargetObject.transform;
                    }
                    else
                    {
                        //TURN = 1;
                        gameObject.AddComponent <CarAIControl>();
                        gameObject.AddComponent <WaypointProgressTracker>();

                        CarAIControl aiControl = GetComponent <CarAIControl>();
                        aiControl.m_Driving = true;
                        aiControl.SetStopWhenTargetReached(false);

                        WaypointProgressTracker wpt = GetComponent <WaypointProgressTracker>();
                        wpt.circuit = wrongcircuit;
                        wpt.target  = WaypointTargetObject.transform;
                    }
                    move_forward.color = new Color32(150, 20, 45, 45);
                    if (!entered)
                    {
                        if_statement.color = new Color32(255, 128, 0, 255);
                        StartCoroutine(Example((float)0.2));
                        explainIfElse.SetActive(true);
                    }
                    else if (timeDone)
                    {
                        if_statement.color    = new Color32(150, 20, 45, 45);
                        if_content.color      = new Color32(150, 20, 45, 45);
                        if_else.color         = new Color32(255, 128, 0, 255);
                        if_else_content.color = new Color32(255, 128, 0, 255);
                        if_statement_done     = true;
                    }
                    if (timeDone3)
                    {
                        //TURN = 0;
                        if_else.color           = new Color32(150, 20, 45, 45);
                        if_else_content.color   = new Color32(150, 20, 45, 45);
                        if_statement.color      = new Color32(150, 20, 45, 45);
                        if_content.color        = new Color32(150, 20, 45, 45);
                        last_move_forward.color = new Color32(255, 128, 0, 255);
                        //m_Car.Move(0, 2, 0, 0);
                    }
                }

                if (!timeDone3)
                {
                    StartCoroutine(Example3((float)18));
                }



                // ENUMERATORS THAT ARE RUN THROUGH COROUTINES

                IEnumerator Example(float time)
                {
                    timeDone = false;
                    yield return(new WaitForSeconds((float)time));

                    timeDone = true;
                    entered  = true;
                }

                IEnumerator Example2(float time)
                {
                    ////debug.log("It reached here2");
                    timeDone2 = false;
                    yield return(new WaitForSeconds((float)time));

                    timeDone2 = true;
                    ////debug.log("It reached here3" + timeDone2.ToString());
                }

                IEnumerator Example3(float time)
                {
                    timeDone3 = false;
                    yield return(new WaitForSeconds((float)time));

                    timeDone3 = true;
                    ////debug.log("It reached here4" + timeDone2.ToString());
                }
            }
        }
Exemplo n.º 13
0
 // Start is called before the first frame update
 void Start()
 {
     selfAI = GetComponent <CarAIControl>();
     ManualTargetChange();
 }
Exemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     carAIControl = GetComponent <CarAIControl>();
     target       = GameObject.Find("Target").transform;
     //carAIControl.setDriving(true);
 }