예제 #1
0
    public IEnumerator PopulateCharactersWithSkins()
    {
        while (!SkinDatabase.loaded)
        {
            yield return(null);
        }

        if (!m_IsLoadingCharacter)
        {
            m_IsLoadingCharacter = true;

            Destroy(c1);
            Destroy(c3);

            for (int i = 0; i <= SkinDatabase.charNameList.Count - 1; i++)
            {
                string c = SkinDatabase.charNameList[i];

                if (c != null)
                {
                    if (charNum - 1 >= 0)
                    {
                        if (charNum - 1 == i)
                        {
                            GameObject newChar = null;
                            Skin       s       = SkinDatabase.GetSkin(c + "_basic");

                            newChar = Instantiate(s.gameObject);
                            newChar.transform.SetParent(charPosition, false);
                            newChar.transform.rotation   = k_FlippedYAxisRotation;
                            newChar.transform.localScale = new Vector3(2.2f, 2.2f, 2.2f);

                            c1 = newChar;

                            c1.transform.localPosition = Vector3.right * 1 * charInterval;
                        }
                    }

                    if (charNum == i)
                    {
                        //GameObject newChar = null;

                        //Skin s = SkinDatabase.GetSkin(SkinDatabase.skinNameList[i]);
                        //newChar = Instantiate(s.gameObject);

                        if (m_CharacterName != null)
                        {
                            m_CharacterName = null;
                        }

                        m_CharacterName = c;

                        StartCoroutine(PopulateSkins());
                    }

                    if ((SkinDatabase.charNameList.Count - 1) - charNum >= 1)
                    {
                        if (charNum + 1 == i)
                        {
                            GameObject newChar = null;

                            Skin s = SkinDatabase.GetSkin(c + "_basic");

                            newChar = Instantiate(s.gameObject);
                            newChar.transform.SetParent(charPosition, false);
                            newChar.transform.rotation   = k_FlippedYAxisRotation;
                            newChar.transform.localScale = new Vector3(2.2f, 2.2f, 2.2f);

                            c3 = newChar;

                            c3.transform.localPosition = Vector3.left * 1 * charInterval;
                        }
                    }
                }
                //else
                //yield return new WaitForSeconds(1.0f);
            }
            //CharacterSelectUIUpdate();
            SkinSelectUIUpdate();
            m_IsLoadingCharacter = false;
        }
    }
예제 #2
0
    public IEnumerator PopulateSkins()
    {
        SkinSelectUIUpdate();

        //Destroy(s1);
        //Destroy(s3);

        List <string> charSkinList = new List <string>();

        charSkinList.Clear();

        for (int i = 0; i <= SkinDatabase.skinNameList.Count - 1; i++)
        {
            Skin s = SkinDatabase.GetSkin(SkinDatabase.skinNameList[i]);
            if (s.characterName == m_CharacterName)
            {
                charSkinList.Add(s.skinName);
            }
        }

        Skin sk = SkinDatabase.GetSkin(SkinDatabase.skinNameList[skinNum]);

        if (!charSkinList.Contains(sk.skinName))
        {
            string result = charSkinList.Find(item => item == (m_CharacterName + "_basic"));
            basicIndex = SkinDatabase.skinNameList.IndexOf(result);
            skinNum    = basicIndex;
        }

        for (int i = 0; i <= SkinDatabase.skinNameList.Count - 1; i++)
        {
            Skin s = SkinDatabase.GetSkin(SkinDatabase.skinNameList[i]);

            if (s.characterName == m_CharacterName)
            {
                if (s != null)
                {
                    /*
                     * if (skinNum - 1 >= 0)
                     * {
                     *  if (skinNum - 1 == i)
                     *  {
                     *      GameObject newSkin = null;
                     *
                     *      newSkin = Instantiate(s.gameObject);
                     *      newSkin.transform.SetParent(skinPosition);
                     *      newSkin.transform.rotation = k_FlippedYAxisRotation;
                     *      newSkin.transform.localScale = new Vector3(2f, 2f, 2f);
                     *
                     *      s1 = newSkin;
                     *
                     *      s1.transform.localPosition = Vector3.right * skinInterval;
                     *  }
                     * }
                     */

                    if (skinNum == i)
                    {
                        /*
                         * GameObject newSkin = null;
                         *
                         * newSkin = Instantiate(s.gameObject);
                         * newSkin.transform.SetParent(skinPosition);
                         * newSkin.transform.rotation = k_FlippedYAxisRotation;
                         * newSkin.transform.localScale = new Vector3(2f, 2f, 2f);
                         *
                         * if (m_Skin != null)
                         *  Destroy(m_Skin);
                         *
                         * m_Skin = newSkin;
                         *
                         * m_Skin.transform.localPosition = Vector3.zero;
                         */

                        m_Skin = s;

                        /*
                         * if(s.skinName != s.characterName + "_basic")
                         *  skinNameDisplay.text = s.skinName;
                         * else
                         *  skinNameDisplay.text = null;
                         */
                        //skinStarText.text = s.skinStar.ToString();
                        //skinCoinText.text = s.skinCoin.ToString();


                        //---character populate---
                        GameObject newChar = null;
                        while (newChar == null)
                        {
                            newChar = Instantiate(s.gameObject);
                            newChar.transform.SetParent(charPosition, false);
                            newChar.transform.rotation = k_FlippedYAxisRotation;

                            if (m_Character != null)
                            {
                                Destroy(m_Character);
                            }

                            m_Character = newChar;

                            if (!PlayerData.instance.koreanCheck)
                            {
                                charNameDisplay.text = s.displayName;
                            }
                            else
                            {
                                charNameDisplay.text = s.korDisplayName;
                            }

                            skinStarText.text = s.skinStar.ToString();
                            skinCoinText.text = s.skinCoin.ToString();

                            m_Character.transform.localPosition = Vector3.right * 1000;

                            yield return(new WaitForEndOfFrame());

                            m_Character.transform.localPosition = Vector3.zero;
                        }
                    }

                    /*
                     * if ((SkinDatabase.skinNameList.Count - 1) - skinNum >= 1)
                     * {
                     *  if (skinNum + 1 == i)
                     *  {
                     *      GameObject newSkin = null;
                     *
                     *      newSkin = Instantiate(s.gameObject);
                     *      newSkin.transform.SetParent(skinPosition);
                     *      newSkin.transform.rotation = k_FlippedYAxisRotation;
                     *      newSkin.transform.localScale = new Vector3(2f, 2f, 2f);
                     *
                     *      s3 = newSkin;
                     *
                     *      s3.transform.localPosition = Vector3.left * 1 * skinInterval;
                     *  }
                     * }
                     */
                }
            }
        }
    }
예제 #3
0
    /*
     * private void Awake()
     * {
     *  GameState.OnEndGame += ClearStage;
     * }
     */
    /*
     * void Start ()
     * {
     *  currentTipIndex = startTipIndex - 1;
     *  UpdateStage(preInstantiate);
     * }
     */

    public void Begin()
    {
        // (이어하기가 아닌) 시작 시 씬 전체를 초기화(캐릭터, 스테이지, 장애물, 몬스터, 배경등)
        if (!m_Rerun)
        {
            inGame = true;

            //backGroundGenerator.Begin();
            KeepPosition keepPosition = sideTrigger.GetComponent <KeepPosition>();
            keepPosition.IsGame(true);

            playerController.gameObject.SetActive(true);
            //playerController = Instantiate(playerController);
            //characterSlot = playerController.characterSlot;

            // Spawn the player
            Skin player = Instantiate(SkinDatabase.GetSkin(SkinDatabase.skinNameList[PlayerData.instance.usedSkin]), Vector3.zero, Quaternion.identity);
            player.transform.SetParent(characterSlot, false);
            //Camera.main.transform.SetParent(characterController.transform, true);


            //player.SetupAccesory(PlayerData.instance.usedAccessory);

            if (playerController.character == null)
            {
                playerController.character = player;
            }
            playerController.stageManager = this;
            playerController.Init();
            cameraController.Begin();

            //characterController.Init();
            //characterController.CheatInvincible(invincible);

            //m_CurrentThemeData = ThemeDatabase.GetThemeData(PlayerData.instance.themes[PlayerData.instance.usedTheme]);
            //m_CurrentZone = 0;
            //m_CurrentZoneDistance = 0;

            //skyMeshFilter.sharedMesh = m_CurrentThemeData.skyMesh;
            //RenderSettings.fogColor = m_CurrentThemeData.fogColor;
            //RenderSettings.fog = true;

            gameObject.SetActive(true);

            playerController.gameObject.SetActive(true);

            playerController.Star = 0;
            playerController.Coin = 0;
            //characterController.coins = 0;
            //characterController.premium = 0;

            //m_Score = 0;
            //m_ScoreAccum = 0;

            //m_SafeSegementLeft = k_StartingSafeSegments;

            //Coin.coinPool = new Pooler(currentTheme.collectiblePrefab, k_StartingCoinPoolSize);

            PlayerData.instance.StartRunMissions(this);
            currentTipIndex      = startTipIndex - 1;
            backGCurrentTipIndex = backGStartTipIndex - 1;

#if UNITY_ANALYTICS
            AnalyticsEvent.GameStart(new Dictionary <string, object>
            {
                //{ "theme", m_CurrentThemeData.themeName},
                { "character", player.characterName }
                //{ "accessory",  PlayerData.instance.usedAccessory >= 0 ? player.accessories[PlayerData.instance.usedAccessory].accessoryName : "none"}
            });
#endif
        }

        playerController.Begin();
        //gameObject.SetActive(true);
        UpdateStage(preInstantiate);
        UpdateBackGStage(backGPreInstantiate);
    }