コード例 #1
0
ファイル: Virus.cs プロジェクト: vietanh1441/Mansion
    /* 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);
    }
コード例 #2
0
ファイル: Mole.cs プロジェクト: vietanh1441/Mansion
 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);
         }
     }
 }
コード例 #3
0
ファイル: Mole.cs プロジェクト: vietanh1441/Mansion
 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);
         }
     }
 }