Ejemplo n.º 1
0
    public static void SendChatMessage(Entity sender, string message, Sprite avatar)
    {
        Game.PauseGame();

        // Set current talking Entity
        CurrentTalkingEntity = sender;

        // Enable the chat message
        ChatMessagePanel.SetActive(true);

        // Set the text
        ChatMessageText.text = message;

        // Set the avatar
        ChatMessageAvatar.sprite = avatar;

        // Player is currently talking
        PlayerController.SetCurrentlyTalking(true);
    }
Ejemplo n.º 2
0
    public static void RemoveCurrentChatMessage()
    {
        if (!PlayerController.IsCurrentlyTalking())
        {
            return;
        }

        // Disable the chat panel
        ChatMessagePanel.SetActive(false);

        // Player is no longer talking
        PlayerController.SetCurrentlyTalking(false);

        // Unpause the game
        Game.UnpauseGame();

        if (CurrentTalkingEntity)
        {
            CurrentTalkingEntity.OnMessageRead();
            CurrentTalkingEntity = null;
        }
    }
Ejemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("PlayerUI started");

        // Try to access Player
        player = GetComponentInParent <Player>();
        if (!player)
        {
            Debug.LogError("Could not access Player");
            return;
        }

        // Setup the Game Timer
        GameObject UITimer = GameObject.Find("UI_Timer");

        if (!UITimer)
        {
            Debug.LogError("Could not access UI_Timer");
        }
        TimerText = UITimer.GetComponent <Text>();

        // Setup score counter
        GameObject UIScore = GameObject.Find("UI_Score");

        if (!UIScore)
        {
            Debug.LogError("Could not access UI_Score");
        }
        ScoreText = UIScore.GetComponent <Text>();

        // Setup player lives
        LivesContainer = GameObject.Find("UI_Lives");
        if (!LivesContainer)
        {
            Debug.LogError("Could not access UI_Lives");
        }
        LivesCount = 0;

        // Setup chat message avatar
        GameObject UIChatAvatar = GameObject.Find("UI_ChatAvatar");

        if (!UIChatAvatar)
        {
            Debug.LogError("Could not access UI_ChatAvatar");
        }
        ChatMessageAvatar = UIChatAvatar.GetComponent <Image>();

        // Setup chat message text
        GameObject UIChatText = GameObject.Find("UI_ChatText");

        if (!UIChatText)
        {
            Debug.LogError("Could not access UI_ChatText");
        }
        ChatMessageText = UIChatText.GetComponent <Text>();

        // Setup chat message panel
        ChatMessagePanel = GameObject.Find("UI_Chat");
        if (!ChatMessagePanel)
        {
            Debug.LogError("Could not access UI_Chat");
        }
        ChatMessagePanel.SetActive(false);

        // Setup spells
        GameObject UISpellPanel = GameObject.Find("UI_Spells");

        if (!UISpellPanel)
        {
            Debug.LogError("Could not access UI_Spells");
        }

        int MaxSpells = player.GetMaxSpells();

        Spells = new Image[MaxSpells];
        for (int i = 0; i < MaxSpells; ++i)
        {
            Image img = UISpellPanel.transform.GetChild(i).GetComponent <Image>();
            if (img)
            {
                Spells[i] = img;
            }
        }
    }