Ejemplo n.º 1
0
 //APply gear/component on gridspot
 public void OnEndDrag(PointerEventData data)
 {
     if (_previewPiece != null)
     {
         Destroy(_previewPiece);
     }
     ConstantHandler.Instance.ComponentDragged = false;
     if (ConstantHandler.Instance.ComponentAdded)
     {
         IVector3 pos = ConstantHandler.Instance.PositionAdded;
         _grid.SetTileToType(pos.x, pos.y, _itemType);
         _sHandler.SetGearTeethValue(pos.x, pos.y, _itemType);
         _sHandler.CalculateSpeed();
         _grid.AttachItem(pos.x, pos.y);
     }
 }
Ejemplo n.º 2
0
    //Change position of sender
    void OnMouseUp()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            if (hit.transform.gameObject.tag == "Grid")
            {
                IVector3 posNew = new IVector3((int)(hit.transform.position.x * 2), (int)(hit.transform.position.y * 2), 0);
                if (_grid.GetTileType(posNew.x, posNew.y) != GridHandler.Gear.ORANGE_CHECK &&
                    _grid.GetTileType(posNew.x, posNew.y) != GridHandler.Gear.GREEN_CHECK &&
                    _grid.GetTileType(posNew.x, posNew.y) != GridHandler.Gear.BLUE_CHECK)
                {
                    _grid.SetTileToType(posNew.x, posNew.y, _type);
                    _sHandler.SetGearTeethValue(posNew.x, posNew.y, _type);
                    _grid.AttachItem(posNew.x, posNew.y);

                    _grid.SetTileToType(_position.x, _position.y, GridHandler.Gear.EMPTY);
                    _sHandler.SetGearTeethValue(_position.x, _position.y, GridHandler.Gear.EMPTY);
                    _sHandler.CalculateSpeed();
                    //_sHandler.CalculateSenderSpeeds ();
                    _grid.AttachItem(_position.x, _position.y);
                }
                else
                {
                    gameObject.GetComponent <Renderer> ().enabled     = true;
                    gameObject.GetComponent <LineRenderer> ().enabled = true;
                }
            }
            else
            {
                gameObject.GetComponent <Renderer> ().enabled     = true;
                gameObject.GetComponent <LineRenderer> ().enabled = true;
            }
        }
        gameObject.GetComponent <Renderer> ().enabled     = true;
        gameObject.GetComponent <LineRenderer> ().enabled = true;
    }