コード例 #1
0
 void SpawnVan()
 {
     if (inkLevel.getInkLevel() <= spawnThreshold && GameObject.FindGameObjectsWithTag("Van").Length == 0)
     {
         float maxDist = -1.0f;
         currentPoint = null;
         Transform spawnPoint = spawnPoints[0].transform;
         Transform player     = GameObject.FindGameObjectWithTag("Player").transform;
         foreach (GameObject o in spawnPoints)
         {
             Transform t        = o.transform;
             float     distance = Vector3.Distance(t.position, player.position);
             if (distance > maxDist)
             {
                 currentPoint = o;
                 maxDist      = distance;
                 spawnPoint   = t;
             }
         }
         vanIsHereText.SetActive(true);
         VanPointController comp = currentPoint.GetComponent(typeof(VanPointController)) as VanPointController;
         hornFX.Play();
         GameObject vanInst = Instantiate(van, spawnPoint.position, Quaternion.identity);
         if (comp.Vertical())
         {
             vanInst.transform.rotation = Quaternion.Euler(0, 0, 270.0f);
         }
     }
 }
コード例 #2
0
    public void MoveVan()
    {
        GameObject v = GameObject.FindGameObjectWithTag("Van");

        if (v == null)
        {
            CancelInvoke("MoveVan");
        }
        Vector2            move = new Vector2();
        VanPointController comp = currentPoint.GetComponent(typeof(VanPointController)) as VanPointController;

        move.x = 1.0f;
        move.y = 0.0f;
        if (comp.GoesForward())
        {
            move.x = -move.x;
            move.y = -move.y;
        }

        float moveSpeed = 3.0f;

        v.transform.Translate(move * Time.deltaTime * moveSpeed);
    }