示例#1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            gameOver.FadeIn();
            gameOver.MoveCenter();
            gameOverScore.FadeIn();
            gameOverScore.MoveCenter();
            if (car.score != 0)
            {
                if ((int)car.score > highscore)
                {
                    highscore = (int)car.score;
                }
                gameOverScore.GetComponent <Text>().text = "Score: " + (int)car.score + "\n Highscore: " + highscore;
                tapToStart.Activate();
                tapToStart.FadeIn();

                car.Restart();
                List <Hills> hills = new List <Hills>();

                hills.AddRange(FindObjectsOfType <Hills>());
                foreach (Hills hill in hills)
                {
                    hill.Restart();
                }
            }
        }
    }
示例#2
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            if (Main.gameMenu)
            {
                if (PlayerInput.UsingGamepad)
                {
                    outerLayer2.Remove();
                    if (!Elements.Contains(outerLayer1))
                    {
                        Append(outerLayer1);
                    }
                    outerLayer1.Activate();
                    outerLayer2.Deactivate();
                    Recalculate();
                    RecalculateChildren();
                    if (_labelHeight != 0f)
                    {
                        _textBox.Top.Pixels = _textBoxHeight;
                        _label.Top.Pixels   = _labelHeight;
                        _textBox.Recalculate();
                        _label.Recalculate();
                        _labelHeight = (_textBoxHeight = 0f);
                        UserInterface.ActiveInstance.ResetLasts();
                    }
                }
                else
                {
                    outerLayer1.Remove();
                    if (!Elements.Contains(outerLayer2))
                    {
                        Append(outerLayer2);
                    }
                    outerLayer2.Activate();
                    outerLayer1.Deactivate();
                    Recalculate();
                    RecalculateChildren();
                    if (_textBoxHeight == 0f)
                    {
                        _textBoxHeight       = _textBox.Top.Pixels;
                        _labelHeight         = _label.Top.Pixels;
                        _textBox.Top.Pixels += 50f;
                        _label.Top.Pixels   += 50f;
                        _textBox.Recalculate();
                        _label.Recalculate();
                        UserInterface.ActiveInstance.ResetLasts();
                    }
                }
            }
            if (!Main.editSign && _edittingSign)
            {
                IngameFancyUI.Close();
                return;
            }
            if (!Main.editChest && _edittingChest)
            {
                IngameFancyUI.Close();
                return;
            }
            base.DrawSelf(spriteBatch);
            UpdateOffsetDown();
            OffsetDown     = 0;
            ShouldHideText = false;
            SetupGamepadPoints(spriteBatch);
            PlayerInput.WritingText = true;
            Main.instance.HandleIME();
            Vector2 position = new Vector2(Main.screenWidth / 2, _textBox.GetDimensions().ToRectangle().Bottom + 32);

            Main.instance.DrawWindowsIMEPanel(position, 0.5f);
            string text = Main.GetInputText(Text, _edittingSign);

            if (_edittingSign && Main.inputTextEnter)
            {
                text += "\n";
            }
            else
            {
                if (_edittingChest && Main.inputTextEnter)
                {
                    ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]);
                    IngameFancyUI.Close();
                    return;
                }
                if (Main.inputTextEnter && CanSubmit)
                {
                    Submit();
                }
                else if (_edittingChest && Main.player[Main.myPlayer].chest < 0)
                {
                    ChestUI.RenameChestCancel();
                }
                else if (Main.inputTextEscape)
                {
                    if (_edittingSign)
                    {
                        Main.InputTextSignCancel();
                    }
                    if (_edittingChest)
                    {
                        ChestUI.RenameChestCancel();
                    }
                    IngameFancyUI.Close();
                    return;
                }
            }
            if (IngameFancyUI.CanShowVirtualKeyboard(_keyboardContext))
            {
                if (text != Text)
                {
                    Text = text;
                }
                if (_edittingSign)
                {
                    CopyTextToSign();
                }
                if (_edittingChest)
                {
                    CopyTextToChest();
                }
            }
            byte  b     = (byte)((255 + Main.tileColor.R * 2) / 3);
            Color value = new Color((int)b, (int)b, (int)b, 255);

            _textBox.TextColor = Color.Lerp(Color.White, value, 0.2f);
            _label.TextColor   = Color.Lerp(Color.White, value, 0.2f);
            position           = new Vector2(Main.screenWidth / 2, _textBox.GetDimensions().ToRectangle().Bottom + 32);
            Main.instance.DrawWindowsIMEPanel(position, 0.5f);
        }
示例#3
0
 /// <summary>
 /// Switch to a UIElement by using its object reference.
 /// </summary>
 /// <param name="nextUI">The UI Element to navigate to.</param>
 public void NavToUI(UIElement nextUI)
 {
     if (nextUI != activeUI)
     {
         previousUI = activeUI;
         activeUI = nextUI;
         Debug.Log("PreviousUI: " + previousUI);
         Debug.Log("ActiveUI: " + nextUI);
         previousUI.Deactivate();
         activeUI.Activate();
     }
 }