コード例 #1
0
    void CheckLand()
    {
        float     distance = Vector3.Distance(transform.position, lastPosition);
        Transform tr       = CheckGroundType();

        if (tr != null)
        {
            if (distance <= .1f)
            {
                if (tr.gameObject.tag == "Log")
                {
                    lastPosition.x = tr.position.x;
                    if (isAlive)
                    {
                        CameraFollow.CameraMoveOnRiver();
                        if (tr.GetComponentInParent <LogSpawner>().isFromRight)
                        {
                            if (lastPosition.x < BoardManager.instance.xMinEffectiveBoard)
                            {
                                GameOver();
                            }
                        }
                        else
                        {
                            if (lastPosition.x > BoardManager.instance.xMaxEffectiveBoard)
                            {
                                GameOver();
                            }
                        }
                    }
                }
                else if (tr.gameObject.tag == "River")
                {
                    //DIe
                    lastPosition.y -= 2;
                    SoundManager.instance.PlaySplash();
                    GameOver();
                }
                else if (tr.tag.Equals("Coin"))
                {
                    SaveLoad.coins = SaveLoad.coins + 1;
                    List <GameObject> updateList = new List <GameObject>();
                    PoolingSystem.instance.poolingDict.TryGetValue(tr.tag, out updateList);
                    updateList.Add(tr.gameObject);
                    PoolingSystem.instance.poolingDict[tr.tag] = updateList;
                    tr.gameObject.SetActive(false);
                    CanvasMainGame.instance.UpdateCoin(SaveLoad.coins);
                    //if(SoundManager.instance != null)
                    SoundManager.instance.PlayCoin();
                }
            }
            else if (tr.tag.Equals("Coin"))
            {
                SaveLoad.coins = SaveLoad.coins + 1;
                List <GameObject> updateList = new List <GameObject>();
                PoolingSystem.instance.poolingDict.TryGetValue(tr.tag, out updateList);
                updateList.Add(tr.gameObject);
                PoolingSystem.instance.poolingDict[tr.tag] = updateList;
                tr.gameObject.SetActive(false);
                CanvasMainGame.instance.UpdateCoin(SaveLoad.coins);
                //if(SoundManager.instance != null)
                SoundManager.instance.PlayCoin();
            }
            else if (tr == null)
            {
            }
            else if (tr.gameObject.tag == "Log")
            {
                lastPosition.x = tr.position.x;
                CameraFollow.CameraMoveOnRiver();
            }
            else if (tr.gameObject.tag.Equals("SolidRoad") || tr.gameObject.tag.Equals("Rail") || tr.gameObject.tag.Equals("Grass"))
            {
            }
        }
    }