Skip to content
This repository was archived by the owner on Sep 18, 2023. It is now read-only.

Commit ce0d7da

Browse files
committed
Merge branch 'dev'
2 parents fe659ea + 9f50909 commit ce0d7da

File tree

126 files changed

+9420
-6730
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+9420
-6730
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = crlf
7+
charset = utf-8
8+
trim_trailing_whitespace = false
9+
insert_final_newline = false

.gitignore

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
/AssetStoreTools*
2-
*.meta
32
*.unitypackage
3+
4+
# Unity metas
5+
Demo.meta
6+
Diplomata.meta
7+
Textures.meta
8+
LICENSE.md.meta
9+
README.md.meta
10+
/[Dd]iplomata/**/*.meta
11+
!/[Dd]iplomata/Lib/MonoBehaviours/*.meta
12+
13+
# IDE's
14+
.vs/
15+
.vscode/
16+
.idea/

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

Demo/.gitkeep

Whitespace-only changes.

Diplomata Canvas.prefab

-48.4 KB
Binary file not shown.

Diplomata Canvas.prefab.meta

Lines changed: 0 additions & 9 deletions
This file was deleted.

Diplomata.meta

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
3+
namespace Diplomata.Dictionaries
4+
{
5+
[Serializable]
6+
public class AttributeDictionary
7+
{
8+
public string key;
9+
public byte value;
10+
11+
public AttributeDictionary() {}
12+
public AttributeDictionary(string key)
13+
{
14+
this.key = key;
15+
}
16+
}
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
3+
namespace Diplomata.Dictionaries
4+
{
5+
[Serializable]
6+
public class LanguageDictionary
7+
{
8+
public string key;
9+
public string value;
10+
11+
public LanguageDictionary() {}
12+
public LanguageDictionary(string key, string value)
13+
{
14+
this.key = key;
15+
this.value = value;
16+
}
17+
}
18+
}

Diplomata/DiplomataCharacter.cs

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
using System.Collections.Generic;
2+
using Diplomata.Dictionaries;
3+
using Diplomata.Helpers;
4+
using Diplomata.Models;
5+
using UnityEngine;
6+
7+
namespace Diplomata
8+
{
9+
/// <summary>
10+
/// The Diplomata Character component.
11+
/// </summary>
12+
public class DiplomataCharacter : DiplomataTalkable
13+
{
14+
/// <summary>
15+
/// Set the main talkable fields.
16+
/// </summary>
17+
private void Start()
18+
{
19+
choices = new List<Message>();
20+
controlIndexes = new Dictionary<string, int>();
21+
22+
controlIndexes.Add("context", 0);
23+
controlIndexes.Add("column", 0);
24+
controlIndexes.Add("message", 0);
25+
26+
if (talkable != null && Application.isPlaying)
27+
{
28+
talkable = Character.Find(DiplomataData.characters, talkable.name);
29+
}
30+
}
31+
32+
/// <summary>
33+
/// To set a choice by the player.
34+
/// </summary>
35+
/// <param name="content">The choice text.</param>
36+
public void ChooseMessage(string content)
37+
{
38+
Character character = (Character) talkable;
39+
40+
if (currentColumn != null)
41+
{
42+
foreach (Message msg in choices)
43+
{
44+
var localContent = DictionariesHelper.ContainsKey(msg.content, DiplomataData.options.currentLanguage).value;
45+
46+
if (localContent == content)
47+
{
48+
currentMessage = msg;
49+
OnStartCallbacks();
50+
break;
51+
}
52+
}
53+
54+
if (currentMessage != null)
55+
{
56+
choiceMenu = false;
57+
choices = new List<Message>();
58+
character.influence = SetInfluence();
59+
}
60+
61+
else
62+
{
63+
Debug.LogError("Unable to found the message with the content \"" + content + "\".");
64+
EndTalk();
65+
}
66+
}
67+
68+
else
69+
{
70+
Debug.LogError("No column setted.");
71+
EndTalk();
72+
}
73+
}
74+
75+
/// <summary>
76+
/// Set the influence over the character using the message and player attributes.
77+
/// </summary>
78+
/// <returns>The influence value.</returns>
79+
public byte SetInfluence()
80+
{
81+
Character character = (Character) talkable;
82+
83+
if (currentMessage != null)
84+
{
85+
byte max = 0;
86+
List<byte> min = new List<byte>();
87+
88+
foreach (AttributeDictionary attrMsg in currentMessage.attributes)
89+
{
90+
foreach (AttributeDictionary attrChar in character.attributes)
91+
{
92+
if (attrMsg.key == attrChar.key)
93+
{
94+
if (attrMsg.value < attrChar.value)
95+
{
96+
min.Add(attrMsg.value);
97+
break;
98+
}
99+
else if (attrMsg.value >= attrChar.value)
100+
{
101+
min.Add(attrChar.value);
102+
break;
103+
}
104+
}
105+
}
106+
}
107+
108+
foreach (byte val in min)
109+
{
110+
if (val > max)
111+
{
112+
max = val;
113+
}
114+
}
115+
116+
int tempInfluence = (max + character.influence) / 2;
117+
return (byte) tempInfluence;
118+
}
119+
120+
else
121+
{
122+
Debug.Log("Cannot set influence, no character attached or message selected.");
123+
return 50;
124+
}
125+
}
126+
}
127+
}

0 commit comments

Comments
 (0)