Example #1
0
    // Update is called once per frame
    void Update()
    {
        //Disable the time scale and set blocks when saving, loading or opening inventroy**************************************************************
        if (F1Trigger || F2Trigger || invTrigger)
        {
            Time.timeScale = 0;
            voxelChunk.CantSetBlocks();
        }
        else if (!F1Trigger || !F2Trigger || !invTrigger)
        {
            Time.timeScale = 1;
            voxelChunk.CanSetBlocks();
        }



        //Call open and close inventroy method when press "i" key**************************************************************************************
        if (Input.GetKeyDown("i"))
        {
            openAndCloseInv();
        }



//		if(Input.GetKeyDown("i")&&invOpen==false)
//		{
//
//			Canvas inv=canvasObject.GetComponent<Canvas>();
//			inv.enabled=true;
//			invOpen=true;
//
//		}



        //Destroy a block by clicking left mouse button and spawn that block as a collectable item by using delegate***********************************
        if (Input.GetButtonDown("Fire1"))
        {
            check = true;
            Vector3 v;
            if (PickThisBlock(out v, 4))
            {
                OnEventCheck(v, 0);
                //voxelChunk.SetBlock (v, 0);
                //SpawnCube(v,1);
            }
        }


        //create a block by clicking right mouse button based on the select block type*****************************************************************
        else if (Input.GetButtonDown("Fire2"))
        {
            check = false;
            Vector3 v;
            if (PickThisBlock(out v, 4))
            {
                OnEventCheck(v, selectBlockType);
                //voxelChunk.SetBlock(v,1);
            }
        }



//		if(voxelChunk.playerPosTrigger==true)
//		{
//			float PosX =this.gameObject.transform.position.x;
//			float PosY =this.gameObject.transform.position.y;
//			float PosZ =this.gameObject.transform.position.z;
//			float RotX =this.gameObject.transform.eulerAngles.x;
//			float RotY =this.gameObject.transform.eulerAngles.y;
//			float RotZ =this.gameObject.transform.eulerAngles.z;
//			XMLVoxelFileWriter.SaveChunkToXMLFile(voxelChunk.terrainArray, PosX,PosY,PosZ,RotX,RotY,RotZ,voxelChunk.inputName);
//			voxelChunk.playerPosTrigger=false;
//			//Debug.Log("save test");
//		}


//		if (Input.GetKeyDown (KeyCode.F2))
//		{
//			if (System.IO.File.Exists("PlayerPos.xml"))
//			{
//			//Debug.Log("abc");
//			this.gameObject.transform.position=XMLVoxelFileWriter.LoadPosFromXMLFile("PlayerPos");
//			this.gameObject.transform.rotation=XMLVoxelFileWriter.LoadRotFromXMLFile("PlayerPos");
//			}
//
//		}

//
//		if (Input.GetKeyDown ("r"))
//		{
//			keyDown = true;
//			PullInCubes();
//		}

        /*else if (Input.GetKeyUp ("r"))
         * {
         *      keyDown=false;
         * }*/
    }