Example #1
0
    public void ElimateMatchedElimates(HashSet <ElimateChain> chains, Action completion)
    {
        foreach (ElimateChain v in chains)
        {
            ElimateScoreForChain(v);

            foreach (ElimateUnit unit in v.GetElimateUnitList())
            {
                if (unit.View)
                {
                    ElimateView unitView = unit.View;
                    unitView.transform.DOScale(0.1f, 0.3f).SetEase(Ease.OutExpo).OnComplete(() => { unitView.Recycle(); unit.View = null; });
                }
            }
        }

        //todo sound

        // TODO: try to call completion in better way!
        transform.DOScale(Vector3.one, 0.3f).OnComplete(() => completion());
    }
Example #2
0
    public void ElimateNewElimates(List <List <ElimateUnit> > cols, Action completion)
    {
        float flongduration = 0f;

        foreach (List <ElimateUnit> unit in cols)
        {
            int startRow  = unit[0].Row + 1;
            int unitIndex = 0;

            foreach (ElimateUnit v in unit)
            {
                int         unitprefabindex = (int)v.GetUnitType();
                Vector2     pos             = PointForCell(v.Column, startRow);
                GameObject  obj             = ElimatePrefabs[unitprefabindex].Spawn(ElimateRootTransform, pos);
                ElimateView unitview        = obj.GetComponent <ElimateView>();

                unitview.transform.localScale = Vector3.one;
                v.View = unitview;

                float fdealy    = 0.1f + 0.2f * (unit.Count - unitIndex - 1);
                float fduration = (startRow - v.Row) * 0.1f;
                flongduration = Mathf.Max(flongduration, fduration + fdealy);

                Vector2 newpos = PointForCell(v.Column, v.Row);

                //todo unitview

                //动画
                Sequence sequence = DOTween.Sequence();
                sequence.Append(unitview.transform.DOLocalMove(newpos, fduration)).SetEase(Ease.OutExpo)
                .PrependInterval(fdealy);

                unitIndex++;
            }
        }

        // TODO: try to call completion in better way!
        transform.DOScale(Vector3.one, flongduration).OnComplete(() => completion());
    }
Example #3
0
    public void AddViewsForElimateUnits(ElimateUnit unit)
    {
        int        unitprefabindex = (int)unit.Type;
        Vector2    pos             = PointForCell(unit.Column, unit.Row);
        GameObject obj             = ElimatePrefabs[unitprefabindex].Spawn(ElimateRootTransform, pos);

        //设置新生成的单元信息
        ElimateView unitview = obj.GetComponent <ElimateView>();

        unitview.transform.localScale = new Vector2(0.5f, 0.5f);
        unit.View = unitview;

        //todo 可以对unitview做处理


        //动画
        Sequence sequence = DOTween.Sequence();

        sequence.Append(unitview.transform.DOScale(1f, 0.25f))
        .PrependInterval(UnityEngine.Random.Range(0f, 0.5f)
                         );
    }