コード例 #1
0
    IEnumerator ResetGame(float waitTime)
    {
        float tempTime = 0;

        while (tempTime < waitTime)
        {
            tempTime += Time.deltaTime;
            yield return(null);
        }

        if (generateGravity != null)
        {
            generateGravity.SetIsGravity = false;
            generateGravity.ResetVelocity();
        }

        yield return(null);

        if (gameResetEvent != null)
        {
            gameResetEvent?.Invoke(null);
            isGameEnd = false;
        }

        GameStart();
    }
コード例 #2
0
 /// <summary>
 /// 游戏重置事件
 /// </summary>
 public virtual void GameReset()
 {
     if (gameResetEvent != null)
     {
         gameResetEvent?.Invoke(0);
     }
 }
コード例 #3
0
    /// <summary>
    /// 初始化
    /// </summary>
    public virtual void Init()
    {
        Time.timeScale = 1;
        gameState      = GameState.Play;
        GameDataController.GetInstance();

        Application.targetFrameRate = 60;

        if (gameData != null)
        {
            DiamantController[] diamants = FindObjectsOfType <DiamantController>();
            for (int i = 0; i < diamants.Length; i++)
            {
                if (diamants[i])
                {
                    diamants[i].SetGameData = gameData;
                    diamants[i].Init();
                }
            }
        }

        if (gameAwakeEvent != null)
        {
            gameAwakeEvent?.Invoke(0);
        }
    }
コード例 #4
0
 /// <summary>
 /// 游戏结束事件
 /// </summary>
 public virtual void GameEnd()
 {
     if (gameEndEvent != null)
     {
         gameEndEvent?.Invoke(0);
     }
 }
コード例 #5
0
 /// <summary>
 /// 继续游戏事件
 /// </summary>
 public override void GameContinue()
 {
     Time.timeScale = 1;
     if (gameContinueEvent != null)
     {
         gameContinueEvent?.Invoke(0);
     }
     gameState = GameState.Play;
 }
コード例 #6
0
    public override void HideUI()
    {
        if (mainUnAcitveEvent != null)
        {
            mainUnAcitveEvent?.Invoke(0);
        }

        isButton = true;
    }
コード例 #7
0
 public override void ShowUI()
 {
     isButton = false;
     if (mainAcitveEvent != null)
     {
         mainAcitveEvent?.Invoke(0);
         // Debug.Log("ShowUI");
     }
 }
コード例 #8
0
 /// <summary>
 /// 暂停游戏事件
 /// </summary>
 public override void GamePause()
 {
     if (gamePauseEvent != null)
     {
         gamePauseEvent?.Invoke(0);
     }
     Time.timeScale = 0;
     // Debug.Log("GamePause");
     gameState = GameState.Pause;
 }
コード例 #9
0
    /// <summary>
    /// 游戏开始事件
    /// </summary>
    public virtual void GameStart()
    {
        if (gameStartEvent != null)
        {
            gameStartEvent?.Invoke(0);
        }

        if (gameData != null)
        {
            gameData.startTime = System.DateTime.Now;
        }
    }
コード例 #10
0
    private void OnTriggerEnter(Collider other)
    {
        if (gameData != null)
        {
            sOpNum = gameData.tempOpNum;
        }

        if (sOpNum < 0)
        {
            return;
        }

        if (Physics.CheckBox(transform.position, Vector3.one / 2, transform.rotation, layer))
        {
            if (sOpNum > 0)
            {
                sOpNum--;
                if (gameData != null && gameData.tempOpNum != sOpNum)
                {
                    gameData.tempOpNum = sOpNum;
                }
            }
            else if (sOpNum == 0)
            {
                sOpNum--;
                if (gameData != null && gameData.tempOpNum != sOpNum)
                {
                    gameData.tempOpNum = sOpNum;
                }
                GameEnd();
            }


            if (gameEndEvent != null)
            {
                gameEndEvent?.Invoke(null);
            }

            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(6));
            }

            this.gameObject.SetActive(false);
        }
    }
コード例 #11
0
    void AnimEndEvent()
    {
        if (isEvent)
        {
            return;
        }

        //if (anim == null) return;
        if (!isPlaying)
        {
            if (gameStartEvent != null)
            {
                isEvent = true;
                //Debug.Log("GameStart");
                gameStartEvent?.Invoke(null);
                MonoMgr.GetInstance().RemoveLateUpdateListener(UpdatedIsPlaying);
                MonoMgr.GetInstance().RemoveLateUpdateListener(AnimEndEvent);
            }
        }
    }
コード例 #12
0
    public void BackButtonEvent()
    {
        if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
        {
            ButtonMusicEvent(GameDataController.GetInstance().musicData.GetSEClip(0), false);
        }

        if (isButton)
        {
            return;
        }

        if (backButtonEvent != null)
        {
            backButtonEvent.Invoke(0);
        }
        isButton = true;

        HideUI();
    }
コード例 #13
0
        public override void ToShootOff()
        {
            if (isToMoveCenter)
            {
                Collider[] colliders = OverlapColliders();
                if (colliders == null || colliders.Length <= 0)
                {
                    return;
                }

                for (int i = 0; i < colliders.Length; i++)
                {
                    if (colliders[i] == null || MyMathf.IsInLayerMask(colliders[i].attachedRigidbody.gameObject, colliderLayer) == false)
                    {
                        continue;
                    }

                    if ((triggerNum > 0 || triggerNum == -1) && !isMoveToCenter)
                    {
                        isMoveToCenter = true;

                        if (veiwModel != null)
                        {
                            veiwModel.gameObject.SetActive(false);
                        }

                        colliderRigidbody = colliders[i].attachedRigidbody;
                        colliderTrans     = colliderRigidbody.transform;
                        colliderGravity   = colliderTrans.GetComponent <GenerateGravity>();
                        if (colliderGravity)
                        {
                            colliderGravity.SetIsGravity = false;
                        }
                        colliderRigidbody.velocity = Vector3.zero;
                        isTrigger = true;
                        break;
                    }

                    break;
                }
            }
            else
            {
                Collider[] colliders = OverlapColliders();
                if (colliders == null || colliders.Length <= 0)
                {
                    return;
                }

                for (int i = 0; i < colliders.Length; i++)
                {
                    if (colliders[i] == null || MyMathf.IsInLayerMask(colliders[i].attachedRigidbody.gameObject, colliderLayer) == false)
                    {
                        continue;
                    }

                    if ((triggerNum > 0 || triggerNum == -1))
                    {
                        if (veiwModel != null)
                        {
                            veiwModel.gameObject.SetActive(false);
                        }

                        ToShootOff(colliders[i].attachedRigidbody);

                        if (SpringEvent != null)
                        {
                            SpringEvent?.Invoke(null);
                        }

                        if (triggerNum > 0)
                        {
                            triggerNum--;
                        }
                    }
                    break;
                }
            }
        }
コード例 #14
0
    private void MarkAnim(float targetRaidus = 0)
    {
        if (markMaterial != null)
        {
            if (Mathf.Abs(targetRaidus - raidus) > 0.05f)
            {
                float laststepInt = (isForward) ? maskShowAnim.Evaluate(tempTime) : maskHideAnim.Evaluate(tempTime);
                tempTime += (isUnscaleTime ? Time.unscaledDeltaTime : Time.deltaTime) * speed / 2;

                float animTime = (isForward) ? maskShowAnim.keys[maskShowAnim.length - 1].time : maskHideAnim.keys[maskHideAnim.length - 1].time;

                tempTime = (animTime <= tempTime) ? animTime : tempTime;

                float stepInt = (isForward) ? maskShowAnim.Evaluate(tempTime) : maskHideAnim.Evaluate(tempTime);

                raidus = Mathf.Max(0, raidus - dir * Mathf.Abs(stepInt - laststepInt));

                cicle.z = raidus;
                if (markMaterial.HasProperty("_Circle"))
                {
                    markMaterial.SetVector("_Circle", cicle);
                }
            }
            else
            {
                if (markEndEvent != null)
                {
                    markEndEvent?.Invoke(0);
                }
                raidus  = targetRaidus;
                cicle.z = targetRaidus;
                if (markMaterial.HasProperty("_Circle"))
                {
                    markMaterial.SetVector("_Circle", cicle);
                }
                RemoveListener();
            }


            //if (Mathf.Abs(targetRaidus - raidus) > 0.05f)
            //{
            //    if (Mathf.Abs(targetRaidus - raidus) > 0.2f)
            //    {
            //        raidus = Mathf.Lerp(raidus, targetRaidus, (isUnscaleTime ? Time.unscaledDeltaTime : Time.deltaTime) * speed);
            //        cicle.z = raidus;
            //        markMaterial.SetVector("_Circle", cicle);
            //    }
            //    else if (Mathf.Abs(targetRaidus - raidus) <= 0.2f && Mathf.Abs(targetRaidus - raidus) <= 0.1f)
            //    {
            //        raidus = Mathf.Lerp(raidus, targetRaidus, (isUnscaleTime ? Time.unscaledDeltaTime : Time.deltaTime) * speed);
            //        markMaterial.SetVector("_Circle", cicle);
            //    }
            //    else
            //    {
            //        raidus = Mathf.Lerp(cicle.z > raidus ? cicle.z : raidus, targetRaidus, (isUnscaleTime ? Time.unscaledDeltaTime : Time.deltaTime) * speed);
            //        cicle.z = raidus;
            //        markMaterial.SetVector("_Circle", cicle);
            //    }
            //}
            //else
            //{

            //    if (markEndEvent != null)
            //    {
            //        markEndEvent?.Invoke(0);
            //    }

            //    cicle.z = targetRaidus;
            //    markMaterial.SetVector("_Circle", cicle);
            //    RemoveListener();
            //}
        }
    }