Ejemplo n.º 1
0
    public void HandleEvent(UIControl control, int command, float wparam, float lparam)
    {
        if (control == startButton)
        {
            string path = Application.dataPath + "/../../Documents/";
            if (File.Exists(path + "MySavedGame.game"))
            {
                gameDialog.Show();
            }
            else
            {
                Yes();
            }

            AudioPlayer.PlayAudio(GetComponent <AudioSource>());
        }
        else if (control == continueButton)
        {
            AudioPlayer.PlayAudio(GetComponent <AudioSource>());


            FadeAnimationScript.GetInstance().FadeInBlack();
            fadeTimer.Name = "Continue";
            fadeTimer.SetTimer(0.5f, false);
        }
    }
Ejemplo n.º 2
0
    public void Yes()
    {
        GameApp.GetInstance().GetGameState().ClearState();
        GameApp.GetInstance().GetGameState().InitWeapons();

        FadeAnimationScript.GetInstance().FadeInBlack();


        fadeTimer.Name = "Start";
        fadeTimer.SetTimer(0.5f, false);
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        /*
         * if (Camera.mainCamera != null)
         * {
         *  if (!Camera.mainCamera.audio.isPlaying)
         *  {
         *      Camera.mainCamera.audio.Play();
         *  }
         * }
         */



        if (FadeAnimationScript.GetInstance().FadeOutComplete())
        {
            foreach (UITouchInner touch in iPhoneInputMgr.MockTouches())
            {
                if (m_UIManager != null)
                {
                    if (m_UIManager.HandleInput(touch))
                    {
                        continue;
                    }
                }
            }
        }

        if (fadeTimer.Ready())
        {
            if (FadeAnimationScript.GetInstance().FadeInComplete())
            {
                if (fadeTimer.Name == "Start")
                {
                    UIResourceMgr.GetInstance().UnloadAllUIMaterials();
                    //GameApp.GetInstance().GetGameState().MenuMusicTime = Camera.mainCamera.audio.time;
                    //! Application.LoadLevel(SceneName.MAP);
                    SceneManager.LoadScene(SceneName.MAP);
                }
                else if (fadeTimer.Name == "Continue")
                {
                    if (!GameApp.GetInstance().Load())
                    {
                        GameApp.GetInstance().GetGameState().InitWeapons();  //! 初始化武器
                    }
                    UIResourceMgr.GetInstance().UnloadAllUIMaterials();
                    //GameApp.GetInstance().GetGameState().MenuMusicTime = Camera.mainCamera.audio.time;
                    //! Application.LoadLevel(SceneName.MAP);
                    SceneManager.LoadScene(SceneName.MAP);
                }
                fadeTimer.Do();
            }
        }
    }
Ejemplo n.º 4
0
    IEnumerator Init()
    {
        yield return(1);

        UIResourceMgr.GetInstance().LoadMapUIMaterials();
        //if (GameApp.GetInstance().GetGameState().FirstTimeGame)
        {
            if (Time.time - startTime < 3.0f && !GameApp.GetInstance().GetGameState().FromShopMenu)
            {
                yield return(new WaitForSeconds(3.0f - (Time.time - startTime)));
            }
        }
        FadeAnimationScript.GetInstance().FadeOutBlack();
        GameApp.GetInstance().GetGameState().FromShopMenu = false;

        mapPanel = new MapUIPanel();
        m_UIManager.Add(mapPanel);
        mapPanel.Start();
        mapPanel.Show();


        optionsUI = new OptionsMenuUI();
        m_UIManager.Add(optionsUI);
    }
Ejemplo n.º 5
0
    public void HandleEvent(UIControl control, int command, float wparam, float lparam)
    {
        if (buttonPressed)
        {
            return;
        }

        if (control == mapButtons[0])
        {
            GameObject.Destroy(GameObject.Find("Music"));
            MapUI.GetInstance().GetAudioPlayer().PlayAudio("Battle");
            FadeAnimationScript.GetInstance().FadeInBlack();
            fadeTimer.Name = "0";
            fadeTimer.SetTimer(2f, false);
            GameApp.GetInstance().Save();
            buttonPressed = true;
        }
        else if (control == mapButtons[1])
        {
            GameObject.Destroy(GameObject.Find("Music"));
            MapUI.GetInstance().GetAudioPlayer().PlayAudio("Battle");
            FadeAnimationScript.GetInstance().FadeInBlack();
            fadeTimer.Name = "1";
            fadeTimer.SetTimer(2f, false);
            GameApp.GetInstance().Save();
            buttonPressed = true;
        }
        else if (control == mapButtons[2])
        {
            GameObject.Destroy(GameObject.Find("Music"));
            MapUI.GetInstance().GetAudioPlayer().PlayAudio("Battle");
            FadeAnimationScript.GetInstance().FadeInBlack();
            fadeTimer.Name = "2";
            fadeTimer.SetTimer(2f, false);
            GameApp.GetInstance().Save();
            buttonPressed = true;
        }
        else if (control == mapButtons[3])
        {
            GameObject.Destroy(GameObject.Find("Music"));
            MapUI.GetInstance().GetAudioPlayer().PlayAudio("Battle");
            FadeAnimationScript.GetInstance().FadeInBlack();
            fadeTimer.Name = "3";
            fadeTimer.SetTimer(2f, false);
            GameApp.GetInstance().Save();
            buttonPressed = true;
        }
        else if (control == shopButton)
        {
            FadeAnimationScript.GetInstance().FadeInBlack(0.5f);
            fadeTimer.Name = "shop";
            fadeTimer.SetTimer(0.5f, false);
            buttonPressed = true;
        }
        else if (control == returnButton)
        {
            FadeAnimationScript.GetInstance().FadeInBlack(1);
            fadeTimer.Name = "return";
            fadeTimer.SetTimer(1f, false);
            buttonPressed = true;
        }
        else if (control == optionsButton)
        {
            this.Hide();
            MapUI.GetInstance().GetOptionsMenuUI().Show();
        }
    }
Ejemplo n.º 6
0
    public void HandleEvent(UIControl control, int command, float wparam, float lparam)
    {
        if (BattlePressed)
        {
            return;
        }
        if (control == upgradeButton)
        {
            ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button");
            //AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().audio);
            Hide();
            ui.GetPanel(MenuName.UPGRADE).Show();
        }
        else if (control == equipmentButton)
        {
            ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button");
            Hide();
            ui.GetPanel(MenuName.EQUIPMENT).Show();
        }
        else if (control == battleButton)
        {
            BattlePressed = true;
            //GameObject.Find("Music").audio.Stop();
            //GameObject.Destroy(GameObject.Find("Music"));
            //ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Battle");
            FadeAnimationScript.GetInstance().FadeInBlack(0.3f);
            fadeTimer.Name = "Continue";
            fadeTimer.SetTimer(0.3f, false);
            GameApp.GetInstance().Save();
        }
        else if (control == avatarButton)
        {
            ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button");
            Hide();
            ui.GetPanel(MenuName.AVATAR).Show();
        }
        else if (control == optionsButton)
        {
            //this.Hide();
            //ui.GetPanel(MenuName.OPTIONS).Show();

            //ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button");
        }
        else if (control == returnButton)
        {
            ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button");

            FadeAnimationScript.GetInstance().FadeInBlack();
            fadeTimer.Name = "StartMenu";
            fadeTimer.SetTimer(2f, false);
        }
        else if (control == leaderButton)
        {
            ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button");
            GameCenterInterface.OpenLeaderboard();

            /*
             * if (GameCenterInterface.IsLogin())
             * {
             *  GameCenterInterface.OpenLeaderboard();
             * }
             * else
             * {
             *  GameCenterInterface.Login();
             * }
             */
        }
        else if (control == achieveButton)
        {
            ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button");
            GameCenterInterface.OpenAchievement();

            /*
             * if (GameCenterInterface.IsLogin())
             * {
             *  GameCenterInterface.OpenAchievement();
             * }
             * else
             * {
             *  GameCenterInterface.Login();
             * }
             */
        }
    }
Ejemplo n.º 7
0
    //public GUISkin guiSkin;


    // Use this for initialization
    IEnumerator Start()
    {
        yield return(0);

        spawnSpeed       = 2 - waveNum * 0.1f;
        timeBetweenWaves = 1.0f;
        gameScene        = GameApp.GetInstance().GetGameScene();

        GameApp.GetInstance().GetGameScene().ArenaTrigger = this;
        doors     = GameObject.FindGameObjectsWithTag("Door");
        doorCount = doors.Length;

        waveStartTime = Time.time;
        player        = GameApp.GetInstance().GetGameScene().GetPlayer();

        paramXML = new GameParametersXML();



        if (Application.isEditor || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            spawnConfigInfo = paramXML.Load(null, GameApp.GetInstance().GetGameState().LevelNum);
        }
        else
        {
            spawnConfigInfo = paramXML.Load("/", GameApp.GetInstance().GetGameState().LevelNum);
        }

        int limit = GameApp.GetInstance().GetGameConfig().globalConf.enemyLimit;

        waveNum = 0;
        int startWaveNum = GameApp.GetInstance().GetGameState().LevelNum;
        int roundNum     = 0;

        gameScene.ArenaTrigger = this;
        Debug.Log("wave num:" + spawnConfigInfo.Waves.Count);
        foreach (Wave wave in spawnConfigInfo.Waves)
        {
            int enemyLeft = GameApp.GetInstance().GetGameScene().GetEnemies().Count;
            while (enemyLeft > 0 && Time.time - waveStartTime < Constant.MAX_WAVE_TIME)
            {
                yield return(0);

                enemyLeft = GameApp.GetInstance().GetGameScene().GetEnemies().Count;
            }

            waveNum++;

            waveStartTime = Time.time;
            gameScene.CalculateDifficultyFactor(GameApp.GetInstance().GetGameState().LevelNum);
            Debug.Log("Wave " + waveNum);
            GameApp.GetInstance().GetGameScene().BonusWeapon = null;
            GameApp.GetInstance().DebugInfo = "";
            //GameApp.GetInstance().GetGameScene().RefreshWoodBoxes();
            yield return(new WaitForSeconds(wave.intermission));

            foreach (Round round in wave.Rounds)
            {
                roundNum++;
                Debug.Log("Round " + roundNum);
                yield return(new WaitForSeconds(round.intermission));

                foreach (EnemyInfo enemyInfo in round.EnemyInfos)
                {
                    EnemyType enemyType = enemyInfo.EType;
                    //Debug.Log("Spawn " + enemyInfo.Count + " " + enemyType + " from " + enemyInfo.From);

                    int           spawnNum = enemyInfo.Count;
                    SpawnFromType from     = enemyInfo.From;

                    GameObject enemyPrefab = null;// GameApp.GetInstance().GetResourceConfig().enemy[(int)enemyType];
                    Transform  grave       = null;
                    if (from == SpawnFromType.Grave)
                    {
                        grave = CalculateGravePosition(player.GetTransform());
                    }

                    for (int i = 0; i < spawnNum; i++)
                    {
                        bool bElite = false;
                        bElite = EliteSpawn(enemyType, spawnNum, i);

                        if (bElite)
                        {
                            enemyPrefab = GameApp.GetInstance().GetResourceConfig().enemy_elite[(int)enemyType];
                        }
                        else
                        {
                            enemyPrefab = GameApp.GetInstance().GetResourceConfig().enemy[(int)enemyType];
                        }
                        enemyLeft = GameApp.GetInstance().GetGameScene().GetEnemies().Count;
                        while (enemyLeft >= limit)
                        {
                            yield return(0);

                            enemyLeft = GameApp.GetInstance().GetGameScene().GetEnemies().Count;
                        }


                        Vector3 spawnPosition = Vector3.zero;
                        if (from == SpawnFromType.Door)
                        {
                            spawnPosition = doors[currentDoorIndex].transform.position;
                            currentDoorIndex++;
                            if (currentDoorIndex == doorCount)
                            {
                                currentDoorIndex = 0;
                            }
                        }
                        else if (from == SpawnFromType.Grave)
                        {
                            float rndX = Random.Range(-grave.localScale.x / 2, grave.localScale.x / 2);
                            float rndZ = Random.Range(-grave.localScale.z / 2, grave.localScale.z / 2);
                            spawnPosition = grave.position + new Vector3(rndX, 0f, rndZ);

                            GameObject.Instantiate(GameApp.GetInstance().GetResourceConfig().graveRock, spawnPosition + Vector3.down * 0.3f, Quaternion.identity);
                        }

                        GameObject currentEnemy = null;
                        if (bElite)
                        {
                            currentEnemy = (GameObject)Instantiate(enemyPrefab, spawnPosition, Quaternion.Euler(0, 0, 0));
                        }
                        else
                        {
                            currentEnemy       = gameScene.GetEnemyPool(enemyType).CreateObject(spawnPosition, Quaternion.Euler(0, 0, 0));
                            currentEnemy.layer = PhysicsLayer.ENEMY;
                        }

                        int enemyID = GameApp.GetInstance().GetGameScene().GetNextEnemyID();
                        currentEnemy.name = ConstData.ENEMY_NAME + enemyID.ToString();

                        Enemy enemy = null;

                        switch ((int)enemyType)
                        {
                        case 0: enemy = new Zombie();
                            break;

                        case 1: enemy = new Nurse();
                            break;

                        case 2: enemy = new Tank();
                            currentEnemy.transform.Translate(Vector3.up * 2);
                            break;

                        case 3:
                            enemy = new Hunter();
                            break;

                        case 4:
                            enemy = new Boomer();
                            break;

                        case 5:
                            enemy = new Swat();
                            break;
                        }
                        enemy.IsElite = bElite;
                        enemy.Init(currentEnemy);
                        enemy.EnemyType = enemyType;
                        //enemy.Spawn = this;
                        enemy.Name = currentEnemy.name;

                        if (from == SpawnFromType.Grave)
                        {
                            enemy.SetInGrave(true);
                        }
                        GameApp.GetInstance().GetGameScene().GetEnemies().Add(currentEnemy.name, enemy);
                        yield return(new WaitForSeconds(0.3f));
                    }
                }
            }
        }


        int enemyCount = GameApp.GetInstance().GetGameScene().GetEnemies().Count;

        while (enemyCount > 0)
        {
            enemyCount = GameApp.GetInstance().GetGameScene().GetEnemies().Count;
            yield return(0);
        }

        //Scene Ends



        GameApp.GetInstance().GetGameScene().PlayingState = PlayingState.GameWin;
        List <Weapon> weaponList = GameApp.GetInstance().GetGameState().GetWeapons();
        GameConfig    gConfig    = GameApp.GetInstance().GetGameConfig();
        WeaponConfig  wConf      = gConfig.GetUnLockWeapon(GameApp.GetInstance().GetGameState().LevelNum);

        if (wConf != null)
        {
            foreach (Weapon w in weaponList)
            {
                //No duplicated weapons
                if (w.Name == wConf.name)
                {
                    if (w.Exist == WeaponExistState.Locked)
                    {
                        w.Exist = WeaponExistState.Unlocked;
                        GameApp.GetInstance().GetGameScene().BonusWeapon = w;
                        break;
                    }
                }
            }
        }
        else
        {
            GameApp.GetInstance().GetGameScene().BonusWeapon = null;
        }



        GameApp.GetInstance().GetGameState().Achievement.CheckAchievemnet_Survivior(GameApp.GetInstance().GetGameState().LevelNum);
        GameApp.GetInstance().GetGameState().Achievement.CheckAchievemnet_LastSurvivior(GameApp.GetInstance().GetGameState().LevelNum);

        GameApp.GetInstance().GetGameState().Achievement.SubmitScore(GameApp.GetInstance().GetGameState().LevelNum);

        GameApp.GetInstance().GetGameState().LevelNum++;

        /*
         * AvatarType aType = (AvatarType)Mathf.Clamp((GameApp.GetInstance().GetGameState().LevelNum - 1)/5, 0, GameApp.GetInstance().GetGameState().GetAvatarNum() - 1);
         *
         * if (GameApp.GetInstance().GetGameState().GetAvatarData(aType) == AvatarState.NotAvaliable)
         * {
         *  GameApp.GetInstance().GetGameState().EnableAvatar(aType);
         * }
         */


        //GameApp.GetInstance().GetGameState().AddScore(1000);

        GameApp.GetInstance().Save();

        yield return(new WaitForSeconds(4.0f));

        if (gameScene.BonusWeapon != null)
        {
            GameUIScript.GetGameUIScript().ClearLevelInfo();
            GameUIScript.GetGameUIScript().GetPanel(GameUIName.NEW_ITEM).Show();
            yield return(new WaitForSeconds(4.0f));
        }

        FadeAnimationScript.GetInstance().StartFade(new Color(0, 0, 0, 0.0f), new Color(0, 0, 0, 1), 1.0f);
        yield return(new WaitForSeconds(1.5f));

        UIResourceMgr.GetInstance().UnloadAllUIMaterials();
        Application.LoadLevel(SceneName.MAP);
    }
Ejemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        timeLeft -= Time.deltaTime;

        accum += Time.timeScale / Time.deltaTime;
        frames++;

        if (timeLeft <= 0)
        {
            fpsStr   = "FPS:" + (accum / frames).ToString();
            frames   = 0;
            accum    = 0;
            timeLeft = updateInterval;
        }

        if (uiInited)
        {
            fpsText.SetText(fpsStr);
            dayInfoPanel.UpdateAnimation();
            panels[GameUIName.GAME_OVER].UpdateLogic();

            if (FadeAnimationScript.GetInstance().FadeOutComplete())
            {
                foreach (UITouchInner touch in iPhoneInputMgr.MockTouches())
                {
                    if (m_UIManager.HandleInput(touch))
                    {
                        continue;
                    }
                }
            }


            if (gameScene.PlayingState == PlayingState.GameWin)
            {
                dayclear.Visible = true;
            }

            if (!GameApp.GetInstance().GetGameScene().GetPlayer().InputController.EnableShootingInput)
            {
                semiMask.Visible = true;
            }
            else
            {
                semiMask.Visible = false;
            }
        }

        if (Time.time - lastUpdateTime < 0.03f || !uiInited)
        {
            return;
        }

        lastUpdateTime = Time.time;


        if (player != null)
        {
            InputController inputController = player.InputController;

            float guihp      = player.GetGuiHp();
            float guihpWidth = uiPos.HPImage.width * guihp / player.GetMaxHp();


            int g = (int)guihpWidth;
            if (g % 2 != 0)
            {
                g += 1;
            }
            if (hpImage != null)
            {
                hpImage.Rect = AutoRect.AutoPos(new Rect(uiPos.HPImage.xMin, uiPos.HPImage.yMin, g, uiPos.HPImage.height));
                hpImage.SetTexture(gameuiMaterial, GameUITexturePosition.GetHPTextureRect(g), AutoRect.AutoSize(GameUITexturePosition.GetHPTextureRect(g)));
            }

            cashText.SetText("$" + GameApp.GetInstance().GetGameState().GetCash().ToString("N0"));

            Weapon weapon = player.GetWeapon();
            if (weapon.GetWeaponType() == WeaponType.Saw)
            {
                weaponInfoText.SetText("");
            }
            else
            {
                weaponInfoText.SetText(" x" + weapon.BulletCount);
            }

            PlayingState playingState = gameScene.PlayingState;
            Vector2      lastTouchPos = inputController.LastTouchPos;

            joystickThumb.Rect = new Rect(lastTouchPos.x - AutoRect.AutoValue(0.5f * GameUITexturePosition.MoveJoystickThumb.width), lastTouchPos.y - AutoRect.AutoValue(0.5f * GameUITexturePosition.MoveJoystickThumb.height), AutoRect.AutoValue(GameUITexturePosition.MoveJoystickThumb.width), AutoRect.AutoValue(GameUITexturePosition.MoveJoystickThumb.height));

            shootjoystickThumb.Rect = new Rect(inputController.LastShootTouch.x - AutoRect.AutoValue(0.5f * GameUITexturePosition.ShootJoystickThumb.width), inputController.LastShootTouch.y - AutoRect.AutoValue(0.5f * GameUITexturePosition.ShootJoystickThumb.height), AutoRect.AutoValue(GameUITexturePosition.ShootJoystickThumb.width), AutoRect.AutoValue(GameUITexturePosition.ShootJoystickThumb.height));

            /*
             *
             *
             *
             * Vector2 thumbCenter = inputController.ThumbCenter;
             * joystickImage.Rect = new Rect((thumbCenter.x - inputController.ThumbRadius), ((Screen.height - thumbCenter.y) - inputController.ThumbRadius), AutoRect.AutoValue(169), AutoRect.AutoValue(168));
             * thumbCenter = inputController.ShootThumbCenter;
             * shootjoystickImage.Rect = new Rect((thumbCenter.x - inputController.ThumbRadius), ((Screen.height - thumbCenter.y) - inputController.ThumbRadius), AutoRect.AutoValue(169), AutoRect.AutoValue(168));
             *
             *
             * if (inputController.GetMoveTouchFingerID() == -1)
             * {
             *  joystickImage.Visible = false;
             *  joystickThumb.Visible = false;
             * }
             * else
             * {
             *  joystickImage.Visible = true;
             *  joystickThumb.Visible = true;
             * }
             *
             * if (inputController.GetShootingTouchFingerID() == -1)
             * {
             *  shootjoystickImage.Visible = false;
             *  shootjoystickThumb.Visible = false;
             * }
             * else
             * {
             *  shootjoystickImage.Visible = true;
             *  shootjoystickThumb.Visible = true;
             * }
             */
        }
    }