示例#1
0
    public void OnMapZoneTouchMove(Vector2 pos)
    {
        var cell = localMap.GetPointedCell(pos);

        if (cell == null)
        {
            if (lastPointedCell != null)
            {
                lastPointedCell.SelectedOn(false);
                lastPointedCell = null;
            }
            return;
        }
        //if ( Mathf.Abs(cell.x - currentCell.x ) > 1 | Mathf.Abs(cell.z - currentCell.z) > 1 ) return;

        if (lastPointedCell != null & lastPointedCell != cell)
        {
            // turn off highlight last cell
            lastPointedCell.SelectedOn(false);
            if (lastPointedCell.tree != null)
            {
                lastPointedCell.tree.OnTouchExit();
            }
            if (cell.tree != null)
            {
                cell.tree.OnTouchEnter();
            }
        }
        lastPointedCell = cell;
        // turn on highlight
        lastPointedCell.SelectedOn(true);
    }
示例#2
0
    virtual protected void Update()
    {
        switch (state)
        {
        case TreeState.InSeed:
            break;

        case TreeState.Growing:
            _timer += Time.deltaTime;
            graphicalModel.localScale = Vector3.Lerp(startScale, originScale, _timer);
            if (graphicalModel.localScale == originScale)
            {
                state = TreeState.Grown;
            }
            break;

        case TreeState.Grown:
            break;

        case TreeState.WaitDomino:
            if (dominoDelayTime < 0)
            {
                _timer = 0;
                state  = TreeState.Falling;
            }
            else
            {
                dominoDelayTime -= Time.deltaTime;
            }
            break;

        case TreeState.Falling:
            if (Quaternion.Angle(graphicalModel.rotation, fallingQuat) < 1f)
            {
                gameObject.SetActive(false);
                graphicalModel.rotation = Quaternion.identity;
                p2Scene.Instance.treesInScene.Remove(this);
                cell.RemoveTree();
                cell.HighLightOn(false);
                cell.SelectedOn(false);
                ActivateOnFall(choper);

                if (dealDmg)
                {
                    var c = cell.Get(fx, fz);
                    if (c != null)
                    {
                        if (c.player != null)
                        {
                            c.player.OnBeingChoped(choper, 0);
                        }
                    }
                }
                break;
            }
            _timer += Time.deltaTime;
            graphicalModel.rotation = Quaternion.Lerp(Quaternion.identity, fallingQuat, _timer);

            break;
        }
    }