private void skillSelected(CharacterSkill skill, int selectedIndex)
    {
        CharacterAttribute attribute = NeverdawnDatabase.GetAttribute(skill.baseAttribute);

        UIQuickMenuSkillUp skillUp = Instantiate(skillUpPrefab);

        int level = avatarController.character.GetSkillLevel(skill.type);

        skillUp.label          = skill.label;
        skillUp.description    = skill.description;
        skillUp.baseValue      = level;
        skillUp.attributeValue = avatarController.character.GetAttributeLevel(attribute.type);
        skillUp.equipmentValue = avatarController.character.mannequin ? avatarController.character.mannequin.GetSkillBonus(skill.type) : 0;
        skillUp.foodValue      = avatarController.character.GetFoodBonus(skill.type);
        skillUp.cost           = NeverdawnDatabase.GetUpgradeCost(skill.type, level);
        skillUp.learningPoints = avatarController.character.skillable.learningPoints;
        skillUp.showAttributes = true;
        skillUp.attributeColor = attribute.color;
        skillUp.attributeLabel = attribute.label;

        skillUp.confirm.interactable = avatarController.character.skillable.learningPoints >= NeverdawnDatabase.GetUpgradeCost(skill.type, level);
        skillUp.confirm.onClick.AddListener(() => skillUpSkill(skillUp, skill.type));

        this.selectedIndex = selectedIndex;
        menu.NavigateInto(skillUp);
    }
Exemple #2
0
    public override void UpdateEvent()
    {
        if (chatMessage == null)
        {
            foreach (string discoveryId in discoveries)
            {
                Discovery discovery = NeverdawnDatabase.GetDisovery(discoveryId);

                PlayerJournal.CreateEntry(discovery, target);
            }

            chatMessage = new ChatMessage(null, updatedMessage, ChatMessageIconMode.None);
            UIChatMenu.SendChatMessage(chatMessage);
            return;
        }


        if (controllers == null || controllers.Count == 0)
        {
            controllers = GameController.activeControllers;
        }

        foreach (AvatarController controller in controllers)
        {
            if (controller.inputModule.GetButtonDown(NeverdawnInputButton.Confirm))
            {
                close();
            }

            if (controller.inputModule.GetButtonDown(NeverdawnInputButton.Cancel))
            {
                close();
            }
        }
    }
    private void attributeSelected(CharacterAttribute attribute, int selectedIndex)
    {
        int level = avatarController.character.GetAttributeLevel(attribute.type);

        UIQuickMenuSkillUp skillUp = Instantiate(skillUpPrefab);

        skillUp.label          = attribute.label;
        skillUp.description    = attribute.description;
        skillUp.baseValue      = level;
        skillUp.equipmentValue = avatarController.character.mannequin ? avatarController.character.mannequin.GetAttributeBonus(attribute.type) : 0;
        skillUp.foodValue      = avatarController.character.GetFoodBonus(attribute.type);
        skillUp.attributeValue = 0;
        skillUp.cost           = NeverdawnDatabase.GetUpgradeCost(attribute.type, level);
        skillUp.learningPoints = avatarController.character.skillable.learningPoints;
        skillUp.showAttributes = false;
        skillUp.baseColor      = attribute.color;
        //skillUp.currentLabel = "Current level";
        //skillUp.currentValue = avatarController.character.GetAttributeLevel(attribute.type).ToString();
        //skillUp.pointsLabel = "Remaining attribute points";
        //skillUp.pointsValue = avatarController.character.learningPoints.ToString();
        //skillUp.color = attribute.color;

        skillUp.confirm.interactable = avatarController.character.skillable.learningPoints >= NeverdawnDatabase.GetUpgradeCost(attribute.type, level);
        skillUp.confirm.onClick.AddListener(() => skillUpAttribute(skillUp, attribute.type));

        this.selectedIndex = selectedIndex;
        menu.NavigateInto(skillUp);
    }
Exemple #4
0
    internal void ImproveSkill(SkillType skillType)
    {
        int level = _skills[(int)skillType];
        int cost  = NeverdawnDatabase.GetUpgradeCost(skillType, level);

        if (learningPoints >= cost)
        {
            learningPoints -= cost;
            _skills[(int)skillType]++;
        }
    }
Exemple #5
0
    public void ImproveAttribute(AttributeType attributeType)
    {
        int level = _attributes[(int)attributeType];
        int cost  = NeverdawnDatabase.GetUpgradeCost(attributeType, level);

        if (learningPoints >= cost)
        {
            learningPoints -= cost;
            _attributes[(int)attributeType]++;
        }
    }
Exemple #6
0
    internal int GetSkillLevel(SkillType skillType, bool includeSkillBonus = false)
    {
        int skillLevel = skillable ? skillable[skillType] : 0;

        if (includeSkillBonus && mannequin != null)
        {
            skillLevel += GetAttributeLevel(NeverdawnDatabase.GetBaseAttributeType(skillType));
            skillLevel += mannequin.GetSkillBonus(skillType);
            skillLevel += GetFoodBonus(skillType);
        }

        return(skillLevel);
    }
    private void skillUpAttribute(UIQuickMenuSkillUp sender, AttributeType attributeType)
    {
        int level = avatarController.character.GetAttributeLevel(attributeType);
        int cost  = NeverdawnDatabase.GetUpgradeCost(attributeType, level);

        avatarController.character.skillable.ImproveAttribute(attributeType);

        int newCost = NeverdawnDatabase.GetUpgradeCost(attributeType, level + 1);

        sender.confirm.interactable = avatarController.character.skillable.learningPoints >= newCost;
        sender.baseValue            = level + 1;
        sender.cost           = newCost;
        sender.learningPoints = avatarController.character.skillable.learningPoints;
    }
Exemple #8
0
    internal string GetRequirementString(Character character)
    {
        List <string> requires = new List <string>();

        foreach (CharacterSkillLevel condition in requirements)
        {
            if (!character.HasSkill(condition))
            {
                CharacterSkill skill = NeverdawnDatabase.GetSkill(condition.type);
                requires.Add(string.Format("{0} {1}", skill.label, condition.value));
            }
        }

        return("Requires: " + string.Join(", ", requires.ToArray()));
    }
Exemple #9
0
    public override void UpdateEvent()
    {
        if (selectedEvent != null && !selectedEvent.IsEventComplete())
        {
            selectedEvent.UpdateEvent();
            return;
        }

        if (chatMessage == null)
        {
            if (target != null)
            {
                Talker talker = target.GetComponent <Talker>();

                if (talker != null)
                {
                    Topic[]         talkerTopics = NeverdawnDatabase.GetTopics(talker.topicIds, true);
                    Topic[]         talkTopics   = PlayerJournal.GetCommonTopics(talkerTopics);
                    TopicQuestion[] questions    = new TopicQuestion[talkTopics.Length + 1];

                    for (int i = 0; i < talkTopics.Length; i++)
                    {
                        questions[i] = TopicQuestion.Create(talker, talkTopics[i]);
                    }

                    questions[questions.Length - 1] = new TopicQuestion()
                    {
                        message = "That'll be all.",
                        trigger = null
                    };


                    chatMessage = new QuestionMessage(getTargetSelf(0).identity.icon, string.Empty, questions);
                    UIChatMenu.SendQuestionMessage(chatMessage, questionSelected);
                }
            }
        }
    }
Exemple #10
0
    private void questionSelected(TopicQuestion question)
    {
        if (question.trigger == null)
        {
            chatMessage.Discard();
        }
        else
        {
            chatMessage = null;

            if (question.trigger.Equals(string.Empty))
            {
                Topic topic = NeverdawnDatabase.GetTopic(question.topicId);
                selectedEvent = topic.defaultEvent;
            }
            else
            {
                selectedEvent = EventController.FindEvent(question.trigger);
            }

            selectedEvent.ResetEvent();
        }
    }
Exemple #11
0
    /// <summary>
    /// Deserializes a set of serialized frames into the scene
    /// </summary>
    /// <param name="frames"></param>
    internal static void DeserializeFrames(SerializableGame gameData, int sceneBuildIndex)
    {
        SerializableGame data = GameController.instance.currentGame;

        // Create a dictionarry with ALL saved frames
        foreach (SerializedFrame serializedFrame in gameData.frames)
        {
            data[serializedFrame.id] = serializedFrame;
        }

        _frames = new List <Frame>();
        _frames.AddRange(FindObjectsOfType <Frame>());

        // Check the current scene of all stationary frames
        foreach (Frame frame in _frames)
        {
            if (data.ContainsKey(frame.id))
            {
                SerializedFrame serializedFrame = data[frame.id];

                // stationary is not in the scene..
                if (serializedFrame.scene != sceneBuildIndex)
                {
                    Destroy(frame.gameObject);
                }
            }
        }

        SerializedFrame[] sceneFrames = gameData.GetFramesBySceneBuildIndex(sceneBuildIndex);

        // Create all the frames needed in the scene
        foreach (SerializedFrame serializedFrame in sceneFrames)
        {
            Frame frame = FindFrameById(serializedFrame.id);

            // If the frame doesn't exist in the level yet, create it!
            if (frame == null)
            {
                // If the frame has been destroyed in the last session, we won't need it ever again!
                if (serializedFrame.destroyed)
                {
                    data.Remove(serializedFrame.id);
                    continue;
                }

                frame = Instantiate(NeverdawnDatabase.GetPrefab(serializedFrame.prefab));
            }

            if (serializedFrame.destroyed)
            {
                Destroy(frame.gameObject);
                continue;
            }

            frame.id                    = serializedFrame.id;
            frame.prefab                = serializedFrame.prefab;
            frame.transform.position    = serializedFrame.position.ToVector3();
            frame.transform.eulerAngles = serializedFrame.rotation.ToVector3();

            frame.Init();
        }

        // Load the frame components
        foreach (SerializedFrame serializedFrame in sceneFrames)
        {
            Frame frame = FindFrameById(serializedFrame.id);
            frame.DeserializeComponents(serializedFrame.componentData);
        }
    }
    // Use this for initialization
    void Start()
    {
        buttons          = new List <UIButton>();
        attributeViewMap = new Dictionary <AttributeType, UISkillView>();
        skillViewMap     = new Dictionary <SkillType, UISkillView>();

        Character character = avatarController.character;

        listController.inputModule = avatarController.inputModule;

        int k = 0;

        foreach (CharacterAttribute attribute in NeverdawnDatabase.attributes)
        {
            if (attribute != null)
            {
                UISkillView attributeView = Instantiate(skillViewPrefab);
                int         i             = k++;

                attributeView.transform.SetParent(skillViewParent);
                attributeView.totalValue = string.Empty;
                attributeView.label      = attribute.label;
                attributeView.value      = character.GetAttributeLevel(attribute.type, true).ToString();
                attributeView.labelColor = attribute.color;

                attributeView.button.onClick.AddListener(() => attributeSelected(attribute, i));
                attributeViewMap.Add(attribute.type, attributeView);

                buttons.Add(attributeView.button);
            }
        }

        GameObject go = new GameObject("gap");

        go.AddComponent <RectTransform>();
        LayoutElement layout = go.AddComponent <LayoutElement>();

        layout.preferredHeight = 10;

        go.transform.SetParent(skillViewParent);

        foreach (CharacterSkill skill in NeverdawnDatabase.skills)
        {
            if (skill != null)
            {
                int i = k++;

                CharacterAttribute baseAttribute = NeverdawnDatabase.GetAttribute(skill.baseAttribute);

                UISkillView skillView = Instantiate(skillViewPrefab);
                skillView.transform.SetParent(skillViewParent);
                skillView.label           = skill.label;
                skillView.totalValue      = string.Empty;
                skillView.value           = character.GetSkillLevel(skill.type, true).ToString();
                skillView.totalValueColor = baseAttribute.color;
                skillView.button.onClick.AddListener(() => skillSelected(skill, i));
                skillViewMap.Add(skill.type, skillView);

                buttons.Add(skillView.button);
            }
        }

        selectedIndex = 0;
    }