Exemple #1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.C))
     {
         Block_Pos.destroy_piece(pos[0], pos[1]);
     }
 }
Exemple #2
0
 void landing(int x, int y, GameObject gameobj)
 {
     Block_Pos.make_occupy(pos[0], pos[1], gameobj);
     Block_Pos.check_line_up(pos[0], pos[1]);
     if (control_enable)
     {
         Central.signal = true;
         control_enable = false;
     }
 }
Exemple #3
0
 public bool is_grounded()
 {
     if (pos[1] == 0)
     {
         return(true);
     }
     else if (Block_Pos.is_occupy(pos[0], pos[1] - 1))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #4
0
    /* public static void starting(int x, int y)
     * {
     *   //Random 2 number which will be the position
     *   pos[0] = x;
     *   pos[1] = y;
     *
     * }*/

    void Start()
    {
        if (color == 0)
        {
            gameObject.renderer.material.color = Color.yellow;
            gameObject.tag = "Yellow";
        }
        if (color == 1)
        {
            gameObject.renderer.material.color = Color.red;
            gameObject.tag = "Red";
        }
        if (color == 2)
        {
            gameObject.renderer.material.color = Color.green;
            gameObject.tag = "Green";
        }
        transform.position = Vector3.Lerp(transform.position, Block_Pos.get_pos(pos[0], pos[1]), 1);
        Block_Pos.make_occupy(pos[0], pos[1], gameObject);
    }
Exemple #5
0
    void Generate_virus()
    {
        //Set random and send to virus
        GameObject hmm = (GameObject)Instantiate(virus);

        hmm.name = "BasicVirus";
        int x, y, z;

        x = Random.Range(0, 8);
        y = Random.Range(0, 8);
        while (Block_Pos.is_occupy(x, y))
        {
            x = Random.Range(0, 8);
            y = Random.Range(0, 8);
        }
        hmm.SendMessage("Set_x", x);
        hmm.SendMessage("Set_y", y);
        z = Random.Range(0, 3);
        hmm.SendMessage("Set_type", z);
        Block_Pos.make_occupy(x, y, hmm);
    }
Exemple #6
0
 void do_work()
 {
     //Debug.Log(pos[0]);
     //Debug.Log(pos[1]);
     if (is_grounded())
     {
         landing(pos[0], pos[1], gameObject);
     }
     else
     {
         Block_Pos.make_available(pos[0], pos[1]);
         pos[1]             = pos[1] - 1;
         transform.position = Vector3.Lerp(transform.position, Block_Pos.get_pos(pos[0], pos[1]), 1);
         //check for is grounded here
         //if grounded, do check lining up
         if (is_grounded())
         {
             landing(pos[0], pos[1], gameObject);
         }
     }
 }
Exemple #7
0
 void control()
 {
     if (Input.GetKeyDown(KeyCode.LeftArrow))
     {
         //Need to check for avaible
         if (!Block_Pos.is_occupy(pos[0] - 1, pos[1]))
         {
             pos[0]             = pos[0] - 1;
             transform.position = Vector3.Lerp(transform.position, Block_Pos.get_pos(pos[0], pos[1]), 1);
         }
     }
     if (Input.GetKeyDown(KeyCode.RightArrow))
     {
         //Need to check for avaible
         if (!Block_Pos.is_occupy(pos[0] + 1, pos[1]))
         {
             pos[0]             = pos[0] + 1;
             transform.position = Vector3.Lerp(transform.position, Block_Pos.get_pos(pos[0], pos[1]), 1);
         }
     }
     if (Input.GetKeyDown(KeyCode.Space))
     {
         pos[1]             = Block_Pos.check_down(pos[0], pos[1]);
         transform.position = Vector3.Lerp(transform.position, Block_Pos.get_pos(pos[0], pos[1]), 2f);
         landing(pos[0], pos[1], gameObject);
     }
     if (Input.GetKeyDown(KeyCode.DownArrow))
     {
         if (!Block_Pos.is_occupy(pos[0], pos[1] - 1))
         {
             pos[1]             = pos[1] - 1;
             transform.position = Vector3.Lerp(transform.position, Block_Pos.get_pos(pos[0], pos[1]), 1);
         }
         if (Block_Pos.is_occupy(pos[0], pos[1] - 1))
         {
             landing(pos[0], pos[1], gameObject);
         }
     }
 }