Exemplo n.º 1
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;
             * }
             */
        }
    }