Пример #1
0
    void PollEntitySelection()
    {
        if (Input.GetMouseButtonUp(0) && !system.IsPointerOverGameObject())
        {
            var item = GetItemUnderCursor();
            if (item != null)
            {
                Item underCursor = new Item();
                underCursor = item;

                Debug.Log("under cursor: " + item);
                Debug.Log("under cursor name: " + item.name);
                Debug.Log("under cursor ID: " + item.ID);
                Debug.Log("under cursor assetID: " + item.assetID);

                if (underCursor.type == ItemType.Other)
                {
                    taskInterface.Activate();
                    SetMode(originalCursorMode);
                    selectEntity.Invoke(underCursor.ID);
                }
            }
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            taskInterface.Activate();
            SetMode(originalCursorMode);
            selectEntity.Invoke("");
        }
    }
Пример #2
0
    private void showBattleResults(bool victory)
    {
        if (window)
        {
            endDialogue(0);
        }

        speakerPos = null;

        //create window
        window = Instantiate(battleResultsBoxPrefab).GetComponentInChildren <GUIWindowScripts>();
        window.DestroyOnClose = true;
        window.Activate();
        window.transform.SetSiblingIndex(0);

        if (victory)
        {
            window.transform.Find("Victory").GetComponent <Text>().text = "<color=lime>VICTORY!</color>";
        }
        else
        {
            window.transform.Find("Victory").GetComponent <Text>().text = "<color=red>DEFEAT</color>";
        }

        battleZoneManager = FindObjectOfType <BattleZoneManager>();
        if (!battleZoneManager)
        {
            return;
        }

        string[]      stats      = battleZoneManager.GetStats();
        RectTransform scrollArea = window.transform.Find("Background/ViewBorder/Scroll View/Viewport/Content").GetComponent <RectTransform>();
        GameObject    prefab     = scrollArea.Find("Stats").gameObject;

        for (int i = 0; i < stats.Length; i++)
        {
            var obj = Instantiate(prefab);
            obj.name = "Faction_" + i;
            RectTransform rt   = obj.GetComponent <RectTransform>();
            Text          text = obj.GetComponent <Text>();

            rt.SetParent(scrollArea);
            rt.anchorMin = new Vector2(0f, 0f);
            rt.anchorMax = new Vector2(0f, 1f);
            rt.pivot     = new Vector2(0f, 0.5f);
            rt.offsetMin = new Vector2(120f + 80f * i, 10f);
            rt.offsetMax = new Vector2(128f + 80f * (i + 1), -10f);

            text.text = stats[i];
        }

        scrollArea.sizeDelta = new Vector2(120f + 80f * stats.Length, scrollArea.sizeDelta.y);
    }
Пример #3
0
    private void showReward(RewardWrapper wrapper)
    {
        if (window)
        {
            endDialogue(0, false);
        }

        //create window
        window = Instantiate(rewardBoxPrefab).GetComponentInChildren <GUIWindowScripts>();
        window.Activate();
        window.transform.SetSiblingIndex(0);

        SetupRewards(window.gameObject, wrapper);
    }
Пример #4
0
    private void startDialogue(Dialogue dialogue, Entity speaker)
    {
        if (window)
        {
            endDialogue();
        }
        speakerPos = speaker.transform.position;
        //create window
        window = Instantiate(dialogueBoxPrefab).GetComponentInChildren <GUIWindowScripts>();
        window.Activate();

        DialogueViewTransitionIn(speaker);

        background = window.transform.Find("Background").GetComponent <RectTransform>();
        background.transform.Find("Exit").GetComponent <Button>().onClick.AddListener(() => { endDialogue(); });
        window.OnCancelled.AddListener(() => { endDialogue(); });
        textRenderer      = background.transform.Find("Text").GetComponent <Text>();
        textRenderer.font = shellcorefont;

        next(dialogue, 0, speaker);
    }
Пример #5
0
    private void showMissionComplete(Mission mission, string rewardsText)
    {
        // if(window) endDialogue(0);
        speakerPos = null;

        //create window
        window = Instantiate(missionCompleteBoxPrefab).GetComponentInChildren <GUIWindowScripts>();
        window.Activate();
        window.transform.SetSiblingIndex(0);

        if (mission.name.Length <= 33)
        {
            window.transform.Find("Holder").Find("Mission Name").GetComponent <Text>().text = mission.name.ToUpper();
        }
        else
        {
            window.transform.Find("Holder").Find("Mission Name").GetComponent <Text>().text = mission.name.ToUpper().Substring(0, 30) + "...";
        }
        window.transform.Find("Rank").GetComponent <Text>().text  = mission.rank.ToUpper();
        window.transform.Find("Rank").GetComponent <Text>().color = TaskDisplayScript.rankColorsByString[mission.rank];
        window.transform.Find("Holder").Find("Rewards").GetComponent <Text>().text = rewardsText;
    }
Пример #6
0
    ///
    /// Instantiates the given prefab and sets it up as a window.
    ///
    private void CreateWindow(GameObject prefab, string text, Color color, Entity speaker)
    {
        if (window)
        {
            Destroy(window.transform.parent.gameObject);
        }
        //create window
        speakerPos = null;

        if (speaker)
        {
            speakerPos = speaker.transform.position;
        }

        window = Instantiate(prefab).GetComponentInChildren <GUIWindowScripts>();


        window.Activate();
        window.transform.SetSiblingIndex(0);
        background = window.transform.Find("Background").GetComponent <RectTransform>();
        var exit = background.transform.Find("Exit");

        exit.GetComponent <Button>().onClick.AddListener(() => {
            endDialogue();
        });
        if (isInCutscene)
        {
            exit.gameObject.SetActive(false);
        }
        window.OnCancelled.AddListener(() => { endDialogue(); });
        textRenderer      = background.transform.Find("Text").GetComponent <Text>();
        textRenderer.font = shellcorefont;

        // radio image
        if (window.GetComponentInChildren <SelectionDisplayHandler>())
        {
            if (speaker)
            {
                DialogueViewTransitionIn(speaker);
                window.GetComponentInChildren <SelectionDisplayHandler>().AssignDisplay(speaker.blueprint, null, speaker.faction);
                window.transform.Find("Name").GetComponent <Text>().text = speaker.blueprint.entityName;
            }
            else
            {
                window.GetComponentInChildren <SelectionDisplayHandler>().gameObject.SetActive(false);
                window.transform.Find("Name").GetComponent <Text>().text = "Unknown Speaker";
            }
        }

        // change text
        this.text         = text.Replace("<br>", "\n");
        characterCount    = 0;
        nextCharacterTime = (float)(Time.time + timeBetweenCharacters);

        characterCount    = 0;
        nextCharacterTime = (float)(Time.time + timeBetweenCharacters);

        textRenderer.color = color;

        if (speaker)
        {
            AudioManager.PlayClipByID("clip_typing");
        }
    }