コード例 #1
0
ファイル: PlatformMove.cs プロジェクト: REALDaGong/Projection
 private void OnTriggerEnter(Collider other)
 {
     if (other.name == "Player" && entered == false)
     {
         entered = true;
         Vector3 distance = new Vector3(0, 3, 0);
         var     group    = RotateController.getInstance().getRotatingGroup(1);
         foreach (Rotating r in group)
         {
             Vector3 target = r.transform.localPosition + distance;
             StartCoroutine(MoveToPosition(r, target));
         }
     }
 }
コード例 #2
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.E))
     {
         if (!(Input.GetKey(KeyCode.Q) || Input.GetKey(KeyCode.W)))
         {
             RotateController.getInstance().selectNext();
         }
     }
     if (Input.GetKeyDown(KeyCode.R))
     {
         if (!(Input.GetKey(KeyCode.Q) || Input.GetKey(KeyCode.W)))
         {
             RotateController.getInstance().selectPre();
         }
     }
 }
コード例 #3
0
ファイル: MapManager.cs プロジェクト: REALDaGong/Projection
    private void MakeMap(IMapData mapData)
    {
        RotateController.getInstance().clearRotatings();

        GameObject[] floor = GameObject.FindGameObjectsWithTag("Floor");
        foreach (GameObject obj in floor)
        {
            GameObject.Destroy(obj);
        }
        GameObject[] end = GameObject.FindGameObjectsWithTag("Endpoint");
        foreach (GameObject obj in end)
        {
            GameObject.Destroy(obj);
        }


        foreach (Vector3 pos in mapData.CubePos)
        {
            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.tag  = "Floor";
            cube.name = "C" + pos.x + pos.y + pos.z;    // 'C'ube
            cube.transform.position = pos;
        }
        for (int i = 0; i < mapData.SlopePos.Length; i++)
        {
            GameObject slope = makeSlope();
            Vector3    pos   = mapData.SlopePos[i];
            slope.tag  = "Floor";
            slope.name = "S" + pos.x + pos.y + pos.z;   // 'S'lope
            slope.transform.position = pos;
            slope.transform.rotation = mapData.SlopeRot[i];
        }
        foreach (RotatingObject data in mapData.RotObj)
        {
            GameObject obj = GameObject.Find(data.name);
            if (obj == null)
            {
                continue;
            }
            Rotating script = obj.AddComponent <Rotating>() as Rotating;
            script.point     = data.point;
            script.axis      = data.axis;
            script.PlayerRot = data.playerRot;
            RotateController.getInstance().addRotating(script, data.groupId);
        }
        {
            GameObject player = GameObject.Find("Player");
            player.transform.position = new Vector3(mapData.PlayerStart.x, mapData.PlayerStart.y + 1, mapData.PlayerStart.z); //
            player.GetComponent <MoveCharacter>().Init();
        }
        //关卡终点
        {
            GameObject endpoint = (GameObject)Resources.Load("Prefabs/endpoint");
            endpoint.tag = "Endpoint";
            endpoint.transform.position = mapData.GameEnd;
            Object.Instantiate(endpoint);
        }
        //升降
        {
            //************************
            //ImapData的底层数据结构设计比较糟糕,修改会影响到其他地图,因此可升降平台在此写死
            //************************
            if (id == 3)
            {
                Map03      mapData03 = (Map03)mapData;
                GameObject movePoint = (GameObject)Resources.Load("Prefabs/movepoint");
                movePoint.transform.position = mapData03.MovePoint;
                Object.Instantiate(movePoint);
            }
        }
        RotateController.getInstance().select();
    }