예제 #1
0
    public void SpawnBl()
    {
        if (Scale >= 0.01f || cylindersNum > 1)                                                                                                                //If the size is more than 0.01 or more than one cylinder, you can spawn
        {
            SpawnBlock newSpawnBlock = Instantiate(SpawnBlock);                                                                                                //Spawn the road block
            offset = new Vector3(0, -cylinders[cylinders.Count - 1].transform.localScale.z / 2 - 0.05f, 0);                                                    //We calculate its mixing relative to the last cylinder

            newSpawnBlock.transform.localPosition = new Vector3(transform.position.x, cylinders[cylinders.Count - 1].transform.position.y, posStart) + offset; //Set coordinates
            spawnedBlocks.Add(newSpawnBlock);

            zScale = spawnedBlocks[spawnedBlocks.Count - 1].transform.localScale.z; //zScale - road length

            Spawn   = false;
            Stretch = true;

            xPosOfSpawn = transform.position.x;
            xPosM       = xPosOfSpawn - xPosChange;
            xPosA       = xPosOfSpawn + xPosChange; //We calculate the extreme points of the road to the right and left

            posWill = posStart + distance;          //Finish point

            zDistance = 0;                          //All distance

            hasDistance = 0;                        //Distance now
        }
    }
    private void CreateNewBlock(SpawnBlock sb)
    {
        if (sb.SpawnedBlock != null)
            GameObject.DestroyImmediate(sb.SpawnedBlock);

        sb.SpawnedBlock = LevelGenerator.CreateSimpleLevelBlock(sb.TileSet, sb.transform.position, sb.BlockHeight, sb.BlockWidth, sb.Seed);
        sb.SpawnedBlock.transform.parent = sb.transform;
    }
예제 #3
0
 private void Start()
 {
     // If we didn't set a spawn block
     if (spawn == null)
     {
         // set the spawn variable to the spawn block
         spawn = GameObject.FindGameObjectWithTag("Respawn").GetComponent <SpawnBlock>();
     }
 }
예제 #4
0
    private void EndGame()
    {
        GameObject camera = GameObject.Find("Main Camera");

        Debug.Log("END");
        SpawnBlock _mainScript = camera.GetComponent <SpawnBlock>();

        //scr_Enemy enemyScript = enemy.GetComponent<scr_Enemy>();
        _mainScript.GameOver = true;
    }
예제 #5
0
 public static bool Prefix(SpawnBlock __instance)
 {
     if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
     {
         if (InstanceTracker.GameScript.gameObject.GetComponent <RPCHooks>() == null)
         {
             InstanceTracker.GameScript.gameObject.AddComponent <RPCHooks>();
         }
         __instance.StartCoroutine(WaitAndTryAgain(__instance));
         return(false);
     }
     else
     {
         return(true);
     }
 }
예제 #6
0
    // Use this for initialization
    void Start()
    {
        gameScoreDisplay = GameObject.Find("Score").GetComponent <ScoreText> ();
        spawner          = GameObject.Find("Spawner").GetComponent <SpawnBlock> ();
        // Verify the current active scene, usage for speed factor manipulation
        UnityEngine.SceneManagement.Scene currentScene = SceneManager.GetActiveScene();
        sceneName   = currentScene.name;
        speedFactor = 1;

        if (!isValidGridPos())
        {
            Debug.Log("GAME OVER");
            Destroy(gameObject);
        }
        m_Controller = GameObject.Find("Controller").GetComponent <Controller> ();
    }
예제 #7
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.transform.tag == "HitFromBelow" && rb.velocity.y > -0.2f)
     {
         float distanceY = transform.position.y - collision.transform.position.y;
         if (distanceY < -0.9f)
         {
             SpawnBlock spawnBlock = collision.gameObject.GetComponent <SpawnBlock>();
             if (!spawnBlock.isUsed)
             {
                 spawnBlock.HitFromBelow(state);
             }
         }
     }
     else if (collision.transform.tag == "FlagPole")
     {
         rb.constraints = RigidbodyConstraints2D.FreezeAll;
         GameObject.Find("EndFlag").GetComponent <EndFlag>().goUp = true;
     }
 }
예제 #8
0
    private void SpawnSpawner()
    {
        while (numBlocks < maxBlocks)
        {
            if (debugMode)
            {
                Debug.Log("SpawnSpawner");
            }

            int row = Random.Range(1, boardSize + 1);
            int col = Random.Range(1, boardSize + 1);

            if (board [row, col].block == null)
            {
                spawnBlock = ((GameObject)Instantiate(spawnBlockRes, Vector2.zero, Quaternion.identity)).GetComponent <SpawnBlock> ();
                spawnBlock.SetBlockProperties(nextBlock.color, nextBlock.shape);
                spawnBlock.SetBoardPosition(row, col);
                break;
            }
        }
    }
예제 #9
0
        private static IEnumerator WaitAndTryAgain(SpawnBlock __instance)
        {
            yield return(new WaitUntil(() => GadgetNetwork.MatrixReady || GadgetNetwork.GetTimeSinceConnect() > GadgetNetwork.MatrixTimeout));

            OnConnectedToServer.Invoke(__instance, new object[] { });
        }
예제 #10
0
 // Use this for initialization
 void Start()
 {
     m_Spawn      = GameObject.Find("Spawner").GetComponent <SpawnBlock> ();
     CurrentPiece = m_Spawn.nextPiece;
     go           = Instantiate(groups[m_Spawn.nextPiece], transform.position, Quaternion.identity) as GameObject;
 }
예제 #11
0
 // Use this for initialization
 void Start()
 {
     setMaterial ();
     numBlocks = GameObject.Find("SpawnBlock").GetComponent<SpawnBlock>();
     transform.position = new Vector2(Random.Range(-1.5f, 2.0f), transform.position.y);
 }
예제 #12
0
 void Start()
 {
     sr      = gameObject.GetComponent <Image>();
     spawner = GameObject.Find("Spawner").GetComponent <SpawnBlock> ();
 }
예제 #13
0
	private void SpawnSpawner ()
	{
		while (numBlocks < maxBlocks) {
			if (debugMode) {
				Debug.Log ("SpawnSpawner");
			}
			
			int row = Random.Range (1, boardSize + 1);
			int col = Random.Range (1, boardSize + 1);

			if (board [row, col].block == null) {
				spawnBlock = ((GameObject)Instantiate (spawnBlockRes, Vector2.zero, Quaternion.identity)).GetComponent<SpawnBlock> ();
				spawnBlock.SetBlockProperties (nextBlock.color, nextBlock.shape);
				spawnBlock.SetBoardPosition (row, col);
				break;
			}
		}
	}
예제 #14
0
    // Update is called once per frame
    void Update()
    {
        if (Stick.GetComponent <DetectCliks> ())
        {
            if (!IsReady && DetectsClick.GetComponent <DetectCliks> ().GetStickReadyToCheck())
            {
                DetectsClick.GetComponent <DetectCliks> ().SetStickReadyToCheck(false);
                if ((Stick.GetComponent <DetectCliks> ().GetStickInst().transform.localScale.y / 2 < SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.position.x
                     - SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.localScale.x / 2 - Stick.GetComponent <DetectCliks> ().GetStickInst().transform.position.x) ||
                    (Stick.GetComponent <DetectCliks> ().GetStickInst().transform.localScale.y / 2 > SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.position.x
                     + SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.localScale.x / 2 - Stick.GetComponent <DetectCliks> ().GetStickInst().transform.position.x))
                {
                    IsWin = false;
                    AudioSource.PlayClipAtPoint(Clip_Lose, new Vector3(0f, 0f, 0f));
                }
                else
                {
                    IsWin = true;
                    AudioSource.PlayClipAtPoint(Clip_done, new Vector3(0f, 0f, 0f));
                    DetectsClick.GetComponent <SpawnBlock> ().SetIsSpawn(false);
                }
            }
        }

        if (Player.transform.position.y < -6f)
        {
            Destroy(Player);
        }
        if (IsWin && Player)
        {
            if (SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.position.x != Player.transform.position.x)
            {
                if (DetectsClick.GetComponent <DetectCliks> ().GetPlayerIsReady() == true)
                {
                    Player.transform.position = Vector3.MoveTowards(Player.transform.position,
                                                                    new Vector3(SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.position.x, -0.25f, -8f), Time.deltaTime * 3);
                }
            }

            if (SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.position.x <= Player.transform.position.x)
            {
                IsReady = true;
                Player.transform.position = (new Vector3(SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.position.x, -0.25f, -8f));
                Allblock.GetComponent <MoveBlocks> ().SetOnPlace(false);
                enabled = false;
            }
        }
        else
        {
            if (IsReadyToDown == false && (Player.transform.position != new Vector3(Stick.GetComponent <DetectCliks> ().GetStickInst().transform.position.x
                                                                                    + Stick.GetComponent <DetectCliks> ().GetStickInst().transform.localScale.y / 2, -0.25f, -8f) && IsReadyToDown == false))
            {
                Player.transform.position = Vector3.MoveTowards(Player.transform.position,
                                                                new Vector3(Stick.GetComponent <DetectCliks> ().GetStickInst().transform.position.x
                                                                            + Stick.GetComponent <DetectCliks> ().GetStickInst().transform.localScale.y / 2, -0.25f, -8f), Time.deltaTime * 3);
            }
            else
            {
                // audio proigr
                IsReadyToDown = true;
                IsReady       = true;
                Player.GetComponent <MovePlayer> ().SetIsWin(false);
                Player.transform.Translate(new Vector3(0f, -8f, 0f) * Time.deltaTime);
            }
        }
    }
예제 #15
0
	// Use this for initialization
	void Start () {
		BlockSpawn ();
		BlockSpawn ();
		if (instance) Destroy(this);
		else instance = this;
	}
예제 #16
0
 public static void MagneticPressure( )
 {
     spwn = GameObject.Find("Spawner").GetComponent <SpawnBlock> ();
     spwn.MagneticPressure = true;
     spwn.magneticTime0    = Time.time;
 }