コード例 #1
0
    void Awake()
    {
        int currentPoint = 0;

        List <Vector3> roadVertices = new List <Vector3>
        {
            new Vector3(-5f, 0f, -1f),
            new Vector3(5f, 0f, -10f),
            new Vector3(13f, 0f, 3f),
            new Vector3(8f, 0f, 0f),
            new Vector3(3f, 0f, -2f),
        };

        GameObject spherePoint1 = Instantiate(spherePrefab);

        spherePoint1.transform.position = roadVertices[currentPoint];
        _sphere1 = spherePoint1.GetComponent <SphereMovement>();
        _sphere1.PositionChanged += OnSpherePositionChanged;
        _sphere1.GetComponent <MeshRenderer>().material = materialSphere1;

        GameObject spherePoint2 = Instantiate(spherePrefab);

        spherePoint2.transform.position = roadVertices[++currentPoint];
        _sphere2 = spherePoint2.GetComponent <SphereMovement>();
        _sphere2.PositionChanged += OnSpherePositionChanged;

        GameObject spherePoint3 = Instantiate(spherePrefab);

        spherePoint3.transform.position = roadVertices[++currentPoint];
        _sphere3 = spherePoint3.GetComponent <SphereMovement>();
        _sphere3.PositionChanged += OnSpherePositionChanged;

        GameObject spherePoint4 = Instantiate(spherePrefab);

        spherePoint4.transform.position = roadVertices[++currentPoint];
        _sphere4 = spherePoint4.GetComponent <SphereMovement>();
        _sphere4.PositionChanged += OnSpherePositionChanged;

        GameObject spherePoint5 = Instantiate(spherePrefab);

        spherePoint5.transform.position = roadVertices[++currentPoint];
        _sphere5 = spherePoint5.GetComponent <SphereMovement>();
        _sphere5.PositionChanged += OnSpherePositionChanged;
        _sphere5.GetComponent <MeshRenderer>().material = materialSphere2;

        // mesh
        GameObject road = new GameObject("MyRoad");

        roadMeshFilter = road.AddComponent <MeshFilter>();

        mesh = RoadMeshGenerator2.GenerateRoadMesh(roadVertices, roadWidth, radius);

        //RoadMeshGenerator2 roadGenerator = new RoadMeshGenerator2();
        //mesh = roadGenerator.GenerateRoadMesh(roadVertices, roadWidth, radius);
        roadMeshFilter.sharedMesh = mesh;

        var meshRenderer = road.AddComponent <MeshRenderer>();

        meshRenderer.material = material;
    }
コード例 #2
0
ファイル: SceneScript.cs プロジェクト: jurhs2000/Lab3Juegos
    public void restoreNewInstance()
    {
        newObj = Instantiate(prefab, sphereMovementScript.getStartPos(), Quaternion.identity);
        int oldPoints = sphereMovementScript.getPoints();

        sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement;
        sphereMovementScript.setPoints(oldPoints);
    }
コード例 #3
0
    // Start is called before the first frame update
    protected override void Start()
    {
        base.Start();
        input      = GetComponent <SphereMovement>();
        renderer   = GetComponent <Renderer>();
        audio      = GetComponent <AudioSource>();
        rb         = GetComponent <Rigidbody>();
        pc         = GameObject.Find("PipeSystem").GetComponent <PipeColor>();
        playedOnce = true;

        renderer.material.color = pc._scoreColor;
        input.enabled           = false;
        rb.Sleep();
    }
コード例 #4
0
ファイル: WallDown.cs プロジェクト: jurhs2000/Lab2Juegos
 private void FixedUpdate()
 {
     sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement;
 }
コード例 #5
0
ファイル: WallDown.cs プロジェクト: jurhs2000/Lab2Juegos
 // Start is called before the first frame update
 void Start()
 {
     startPos             = transform.localPosition;
     sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement;
 }
コード例 #6
0
ファイル: SceneScript.cs プロジェクト: jurhs2000/Lab3Juegos
 // Start is called before the first frame update
 void Start()
 {
     sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement;
     prefab = Resources.Load("Prefabs/Sphere", typeof(GameObject)) as GameObject;
     newObj = GameObject.Find("Sphere");
 }
コード例 #7
0
ファイル: ConeEnemy.cs プロジェクト: jurhs2000/Lab2Juegos
 // Start is called before the first frame update
 void Start()
 {
     sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement;
 }
コード例 #8
0
ファイル: CrystalController.cs プロジェクト: Alorexos/P3
 private void Awake()
 {
     CrystalRenderer = Crystal.GetComponent <Renderer>();
     Sphere          = GameObject.FindGameObjectWithTag("Player");
     SphereMovement  = Sphere.GetComponent <SphereMovement>();
 }
コード例 #9
0
 // Start is called before the first frame update
 void Start()
 {
     CollisionControl = FindObjectOfType <CollisionControl>();
     sphere           = FindObjectOfType <SphereMovement>();
 }
コード例 #10
0
ファイル: UI.cs プロジェクト: jurhs2000/Lab3Juegos
 private void FixedUpdate()
 {
     sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement;
     coins_text.text      = "COINS: " + sphereMovementScript.getPoints();
 }
コード例 #11
0
ファイル: UI.cs プロジェクト: jurhs2000/Lab3Juegos
 // Start is called before the first frame update
 void Start()
 {
     sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement;
     coins_text           = GetComponentInChildren <TMP_Text>();
 }
コード例 #12
0
 // Start is called before the first frame update
 void Start()
 {
     sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement;
     prefab = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Sphere.prefab", typeof(GameObject));
     newObj = GameObject.Find("Sphere");
 }