Example #1
0
    void doGameOverBoom(Entity entity)
    {
        AudioManager.Instance.PlayBoom();
        string effName = "";

        if (entity.Id < 10)
        {
            effName = "Effects/effect_hecheng_0" + entity.Id;
        }
        else
        {
            effName = "Effects/effect_hecheng_" + entity.Id;
        }
        GameObject effObj = ResHelper.Instance.LoadModel(effName);

        effObj.transform.position   = entity.obj.transform.position;
        effObj.transform.localScale = Vector3.one * scaleRatio;
        TimerTween.Delay(1.2f, () =>
        {
            GameObject.DestroyImmediate(effObj);
        }).Start();


        TimerTween.Delay(0.2f, () =>
        {
            int score = entity.Id;
            if (entity.Id == 11)
            {
                score = 500;
            }

            EventDispatcher.Instance.DispatchEvent(EventID.OnScoreChange, singleScore, score);
            entity.Destroy();
        }).Start();
    }
Example #2
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.G))
     {
         Debug.LogError("now---->time:" + Time.time + ",real:" + Time.realtimeSinceStartup);
         TimerTween.Delay(5, () =>
         {
             Debug.LogError("delay---->time:" + Time.time + ",real:" + Time.realtimeSinceStartup);
         }).SetUseRealTime(true).Start();
     }
 }
Example #3
0
    public Entity(int id, float size, string name, GameObject obj)
    {
        this.Id   = id;
        this.Size = size;
        this.name = name;
        this.obj  = obj;

        checkTimer = TimerTween.Delay(1.5f, () =>
        {
            checkRedLine = true;
        });
        checkTimer.Start();
    }
Example #4
0
    public void Show()
    {
        Time.timeScale = 0;
        root.gameObject.SetActive(true);
        effTongGuan.localPosition = Vector3.zero;
        effTongGuan.gameObject.SetActive(true);
        effCaiDai.localPosition = Vector3.zero;
        effCaiDai.gameObject.SetActive(true);


        TimerTween.Delay(2f, () =>
        {
            this.Hide();
        }).SetUseRealTime(true).Start();
    }
Example #5
0
    public void PlayEffectOnce(Transform holder, string effectName, int effectSize, float time, Action onPlayFinished)
    {
        this.playEffect(holder, effectName, effectSize);

        TimerTween.Delay(time, () =>
        {
            //有可能在Delay期间,holder因为各种原因被清除
            if (holder != null)
            {
                if (holder.childCount > 0)
                {
                    onPlayFinished?.Invoke();
                    this.ClearEffect(holder);
                }
            }
        }).Start();
    }
Example #6
0
    private void onGameOver(string evtId, object[] paras)
    {
        Debug.LogError("game over!!!");
        isGameOver = true;
        Entity targetEntity = paras[0] as Entity;

        targetEntity.obj.GetComponent <SpriteRenderer>().color = new Color(120 / 255f, 120 / 255f, 120 / 255f, 1);

        entities.Remove(targetEntity);
        entities.Sort((a, b) =>
        {
            if (a.obj.transform.position.y > b.obj.transform.position.y)
            {
                return(-1);
            }
            else
            {
                return(1);
            }
        });
        entities.Insert(0, targetEntity);

        for (int i = 0; i < entities.Count; i++)
        {
            int   tmpI      = i;
            int   x         = i + 1;
            float y         = Mathf.Log(x, 3);
            float delayTime = y + 0.2f;
            //Debug.LogError("delayTime:" + delayTime);
            TimerTween.Delay(delayTime, () =>
            {
                doGameOverBoom(entities[tmpI]);
                if (tmpI == entities.Count - 1)
                {
                    entities.Clear();


                    GameCenter.Instance.gameOverWindow.Show(singleScore);
                    GameCenter.Instance.mainWindow.Hide();
                }
            }).Start();
        }
    }
Example #7
0
    void doSingleBoom(BoomPair boomPair)
    {
        var candidateObj = boomPair.candidate.obj;
        var targetObj    = boomPair.target.obj;

        int pairId = boomPair.candidate.Id;

        Vector3 fromPos = candidateObj.transform.position;
        Vector3 toPos   = targetObj.transform.position;
        bool    flag    = false;

        TimerTween.Value(0, 1, 0.2f, (v) =>
        {
            if (v > 0.3f)
            {
                targetObj.GetComponent <Rigidbody2D>().simulated = false;//不再受影响
            }
            if (v > 0.6f && !flag)
            {
                flag = true;
                if (pairId == 10)
                {
                    AudioManager.Instance.PlayAudioMaxMerge();
                }
                else
                {
                    AudioManager.Instance.PlayAudioMerge();
                }


                AudioManager.Instance.PlayBoom();
                string effName = "";
                if (pairId < 9)
                {
                    effName = "Effects/effect_hecheng_0" + (pairId + 1);
                }
                else
                {
                    effName = "Effects/effect_hecheng_" + (pairId + 1);
                }
                GameObject effObj           = ResHelper.Instance.LoadModel(effName);
                effObj.transform.position   = boomPair.target.obj.transform.position;
                effObj.transform.localScale = Vector3.one * scaleRatio;
                TimerTween.Delay(1.2f, () =>
                {
                    GameObject.DestroyImmediate(effObj);
                    if (pairId == 10)
                    {
                        GameCenter.Instance.maxMergeEffect.Show();
                    }
                }).Start();
            }
            candidateObj.transform.position = fromPos + (toPos - fromPos) * v;
        }, () =>
        {
            //在targetObj的位置生成新的合成的球
            if (boomPair.candidate.Id < 11)
            {
                int score = boomPair.candidate.Id;
                if (boomPair.candidate.Id == 10)
                {
                    score = 500;
                }
                EventDispatcher.Instance.DispatchEvent(EventID.OnScoreChange, singleScore, score);


                //Debug.LogError("score:" + singleScore);
                this.genEntityBy2DPos(boomPair.candidate.Id + 1, targetObj.transform.position, true);
            }
            boomPair.candidate.Destroy();
            boomPair.target.Destroy();
        }).Start();
    }
Example #8
0
    public void Update()
    {
        if (isGameOver)
        {
            return;
        }
        if (nextShow.sprite == null || scaleFinished == false)
        {
        }
        else
        {
            if (Input.GetMouseButtonDown(0))
            {
                interaction = true;

                targetXPos = restrictXPos(ScreenXPosTo2DPos(Input.mousePosition.x));

                nextShow.gameObject.RunTween(new MoveTo(0.1f, new Vector3(targetXPos, nextShowYPos, 0), Space.World).OnComplete(
                                                 (a) =>
                {
                    this.moveFinished = true;
                }
                                                 ));
            }
            if (interaction && Input.GetMouseButtonUp(0))
            {
                this.moveFinished = false;
                this.interaction  = false;
                if (isWelcome)
                {
                    GameCenter.Instance.welcomeArea.Hide();
                    isWelcome = false;
                }
                this.genEntityBy2DPos(nextId, new Vector3(targetXPos, nextShowYPos, 0), false);
                nextShow.sprite             = null;
                nextShow.transform.position = new Vector3(0, nextShowYPos, 0);

                TimerTween.Delay(0.8f, () =>
                {
                    nextShow.transform.position = new Vector3(0, nextShowYPos, 0);

                    this.genNextBall();
                }).Start();
            }

            if (interaction && Input.GetMouseButton(0))
            {
                if (this.moveFinished)
                {
                    float tmpXPos = ScreenXPosTo2DPos(Input.mousePosition.x);
                    targetXPos = restrictXPos(tmpXPos);
                    nextShow.transform.position = new Vector3(targetXPos, nextShowYPos, 0);
                }
            }
        }


        //checkDropFloor();
        //checkCollision();
        //doBoom();
        //checkRedLine();
    }