Exemplo n.º 1
0
 public void UnbindFromCell()
 {
     if (cellBinded != null)
     {
         cellBinded.RemoveOverride();
         cellBinded = null;
     }
     middle.SetActive(true);
 }
Exemplo n.º 2
0
 public void BindToCell(OverrideCell cell)
 {
     cellBinded = cell;
     cell.AddOverride(this);
     LeanTween.cancel(tweenId);
     tweenId = LeanTween.move(gameObject, cell.transform.position, 0.3f).setEaseOutCubic().id;
     //if (cell.isOnTile)
     //    middle.SetActive(false);
 }
Exemplo n.º 3
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 100, holdersLayer))
            {
                holderInHand = hit.transform.gameObject.GetComponent <OverrideHolder>();
                if (holderInHand != null)
                {
                    SetHintForAllCells(true);
                    holderInHand.UnbindFromCell();
                }
            }
        }

        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            if (holderInHand != null)
            {
                SetHintForAllCells(false);
                Ray          ray = cam.ScreenPointToRay(Input.mousePosition);
                RaycastHit   hit;
                OverrideCell cell = null;
                if (Physics.Raycast(ray, out hit, 100, cellsLayer))
                {
                    cell = hit.transform.gameObject.GetComponent <OverrideCell>();
                }

                if (cell != null)
                {
                    holderInHand.BindToCell(cell);
                    //CameraShaker.Shake(new BounceShake(shakeParams));
                    holderInHand = null;
                }
                else
                {
                    holderInHand.ResetToInitals();
                    holderInHand = null;
                }
            }
        }

        if (holderInHand != null)
        {
            Vector3 pos = cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10));
            holderInHand.transform.position = Vector3.SmoothDamp(holderInHand.transform.position, pos, ref vel, 0.05f);
        }
    }
Exemplo n.º 4
0
 private void OnEnable()
 {
     cell = GetComponentInChildren <OverrideCell>();
 }
Exemplo n.º 5
0
 private void Start()
 {
     cell          = GetComponentInChildren <OverrideCell>();
     cell.isOnTile = true;
     cell.index    = Index;
 }