示例#1
0
        void OnCollisionEnter2D(Collision2D collision)
        {
            if (radius == 0)
            {
                GameObject go = TransformUtility.GetTopParent(collision.gameObject);

                Gridlike.Grid grid = go.GetComponent <Gridlike.Grid> ();
                if (grid != null)
                {
                    int x;
                    int y;

                    Gridlike.GridUtility.GetClosestNonEmptyTile(grid, transform.position, out x, out y);
                    if (grid != null)
                    {
                        GSGrid gsGrid = grid.GetComponent <GSGrid> ();

                        gsGrid.Damage(character, x, y, damage, transform.position);
                    }
                }
            }
            else
            {
                GridUtility.ExplodeInAllGrid(character, transform.position, radius, damage);
            }

            StartCoroutine(DestroyAnimation());
        }
示例#2
0
    void Update()
    {
        // The player is grounded if a linecast to the groundcheck position hits anything on the ground layer.
        RaycastHit2D hit = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));

        grounded = hit;

        // If the jump button is pressed and the player is grounded then the player should jump.
        if (Input.GetButtonDown("Jump") && grounded)
        {
            jump = true;
        }

        Gridlike.Grid grid = Gridlike.Grid.GetFirstGrid();

        if (grid != null)
        {
            int x;
            int y;

            grid.WorldToGrid(Camera.main.ScreenToWorldPoint(Input.mousePosition), out x, out y);

            if (Input.GetMouseButton(0))
            {
                grid.showOnSet = true;
                grid.SetId(x, y, 1);
            }
            else if (Input.GetMouseButton(1))
            {
                grid.Clear(x, y);
            }
        }
    }
示例#3
0
 void Start()
 {
     grid = GetComponent <Gridlike.Grid>();
 }