Commit 46229780 authored by 황호기's avatar 황호기

Action제작 가능, 기본 족보 보너스 계산식 추가

parent 4c99fd4d
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="System">
<type fullname="System.ComponentModel.TypeConverter" preserve="all" />
<!-- <namespace fullname="System.ComponentModel" preserve="all" /> -->
</assembly>
</linker>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
[{"BehaviorList":[{"Type":0,"Target":0,"TargetArg":1,"Arg1":100}],"Id":"A00000","Desc":"가장 앞에 있는 적에게 {element}수치의 {arg11}%의 데미지를 입힌다."},{"BehaviorList":[{"Type":1,"Target":0,"TargetArg":1,"Arg1":100}],"Id":"A00001","Desc":"가장 앞에 있는 아군에게 {element}수치의 {arg11}%만큼의 방패를 쌓는다."},{"BehaviorList":[{"Type":2,"Target":0,"TargetArg":1,"Arg1":100}],"Id":"A00002","Desc":"가장 앞에 있는 아군의 {element}수치의 {arg11}%만큼의 체력을 회복한다."}]
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
using TBR.TableData;
using Newtonsoft.Json;
public class ActionEditor : MonoBehaviour
{
public InputField Id;
public Dropdown ActionTypeSelect;
public Dropdown TargetTypeSelect;
public InputField TargetArg;
public InputField Arg1;
public InputField Desc;
public Transform BehaviorParent;
public BehaivorSeer BehaviorSeerPrefab;
public Transform ActionParent;
public ActionSeer ActionSeerPrefab;
private List<BehaviorDescriptor> behaviors = new List<BehaviorDescriptor>();
private List<ActionDescriptor> actions = new List<ActionDescriptor>();
private void Start()
{
List<Dropdown.OptionData> ActionOptions = new List<Dropdown.OptionData>();
for ( int i = 0; i < ( int )ActionType.Count; i++ )
{
ActionOptions.Add( new Dropdown.OptionData( ( ( ActionType )i ).ToString() ) );
}
ActionTypeSelect.options = ActionOptions;
List<Dropdown.OptionData> TargetOptions = new List<Dropdown.OptionData>();
for ( int i = 0; i < ( int )TargetType.Count; i++ )
{
TargetOptions.Add( new Dropdown.OptionData( ( ( TargetType )i ).ToString() ) );
}
TargetTypeSelect.options = TargetOptions;
LoadActions();
}
public void AddBehavior()
{
behaviors.Add( new BehaviorDescriptor( ActionTypeSelect.value, TargetTypeSelect.value, int.Parse( TargetArg.text ), int.Parse( Arg1.text ) ) );
RefreshBehavior();
}
public void RemoveBehavior(int index)
{
behaviors.RemoveAt( index );
RefreshBehavior();
}
public void RefreshBehavior()
{
for ( int i = BehaviorParent.childCount - 1; i >= 0; i-- )
{
Destroy( BehaviorParent.GetChild( i ).gameObject );
}
for ( int i = 0;i<behaviors.Count;i++ )
{
var behaivorSeek = Instantiate( BehaviorSeerPrefab, BehaviorParent );
behaivorSeek.SetBehaivorDesc( behaviors[ i ], true );
behaivorSeek.SetActionEditor( this, i );
}
}
public void AddAction()
{
actions.Add( new ActionDescriptor( Id.text, behaviors, Desc.text));
actions = actions.OrderBy( a => a.Id ).ToList();
RefreshAction();
behaviors.Clear();
RefreshBehavior();
}
public void RefreshAction()
{
for ( int i = ActionParent.childCount - 1; i >= 0; i-- )
{
Destroy( ActionParent.GetChild( i ).gameObject );
}
for ( int i = 0; i < actions.Count; i++ )
{
var actionSeer = Instantiate( ActionSeerPrefab, ActionParent );
actionSeer.SetActionDesctiptor( actions[ i ] );
actionSeer.SetActionEditor( this, i );
}
}
public void SaveActions()
{
var data = JsonConvert.SerializeObject( actions );
StreamWriter stream = new StreamWriter( "Assets/Resources/Table/ActionTable.json" );
stream.WriteLine( data );
stream.Close();
Table.Instance.LoadTable();
}
public void LoadActions()
{
actions = Table.Instance.ActionTable.Values.ToList();
RefreshAction();
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TBR.TableData;
public class ActionSeer : MonoBehaviour {
private ActionDescriptor actionDescriptor;
public Text Id;
public Button OpenBehaivor;
public BehaivorSeer Behaivor1;
public Transform BehaivorTransform;
public BehaivorSeer BehaivorPrefab;
public Text ShortDesc;
public Text LongDesc;
private bool IsDescLong;
private bool ShowAllBehaivor;
private ActionEditor actionEditor;
private int index;
public void SetActionDesctiptor( ActionDescriptor actionDescriptor)
{
this.actionDescriptor = actionDescriptor;
Id.text = actionDescriptor.Id;
if(actionDescriptor.BehaviorList.Count!=0)
{
Behaivor1.SetBehaivorDesc( actionDescriptor.BehaviorList[ 0 ], false );
if ( actionDescriptor.BehaviorList.Count == 1 )
OpenBehaivor.gameObject.SetActive( false );
}
ShortDesc.text = actionDescriptor.Desc;
RefreshSize();
}
public void RefreshSize()
{
var size = 20;
if ( IsDescLong )
size = 60;
if ( ShowAllBehaivor )
size = Mathf.Max( size, actionDescriptor.BehaviorList.Count );
GetComponent<RectTransform>().sizeDelta = new Vector2( GetComponent<RectTransform>().sizeDelta.x, size );
}
public void SetActionEditor( ActionEditor actionEditor, int index )
{
this.actionEditor = actionEditor;
this.index = index;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TBR.TableData;
public class BehaivorSeer : MonoBehaviour {
public Text ActionTypeSelect;
public Text TargetTypeSelect;
public Text TargetArg;
public Text Arg1;
public Button RemoveButton;
private BehaviorDescriptor desc;
private ActionEditor actionEditor;
private int index;
public void SetBehaivorDesc( BehaviorDescriptor desc, bool showRemoveButton )
{
ActionTypeSelect.text = desc.Type.ToString();
TargetTypeSelect.text = desc.Target.ToString();
TargetArg.text = desc.TargetArg.ToString();
Arg1.text = desc.Arg1.ToString();
RemoveButton.gameObject.SetActive( showRemoveButton );
}
public void SetActionEditor( ActionEditor actionEditor, int index)
{
this.actionEditor = actionEditor;
this.index = index;
}
public void Remove()
{
if( actionEditor !=null)
actionEditor.RemoveBehavior( index );
}
}
......@@ -18,7 +18,7 @@ public class Card : MonoBehaviour {
public enum TColor { grey, green, blue, black, red };
public TColor tColor;
public Color color;
public ActionType actionType;
public ActionElement actionElement;
public Sprite[] TSprites = new Sprite[5];
// Use this for initialization
void Awake()
......@@ -43,18 +43,18 @@ public class Card : MonoBehaviour {
return Color.black;
}
public void MakeCardSprite (int n, ActionType aType)
public void MakeCardSprite (int n, ActionElement e)
{
number = n;
actionType = aType;
tColor = (TColor)((int)aType);
actionElement = e;
tColor = (TColor)((int)e);
color = ToColor(tColor);
transform.GetChild(0).GetComponent<TextMesh>().color = color;
transform.GetChild(0).GetComponent<TextMesh>().text = number.ToString();
for (int i = 1; i < 17; i++)
{
SpriteRenderer nowSprite = transform.GetChild(i).GetComponent<SpriteRenderer>();
nowSprite.sprite = TSprites[(int)aType];
nowSprite.sprite = TSprites[(int)e];
nowSprite.color = color;
nowSprite.gameObject.SetActive(visible[number - 1, i - 1] > 0);
}
......
using System.Collections.Generic;
using System.Linq;
namespace TBR.Data
{
public static class Calculator
{
private static int[] pairBonus = { 1, 3, 20, 80, 100 };
private const int fullhouseBonus = 50;
private const int straightBonus = 30;
private const int twopairBonus = 5;
public static int[] GetPowerBonus(CardData[] cardDatas)
{
var bonus = new int[ 5 ] { 1, 1, 1, 1, 1 };
if ( cardDatas[ 0 ] != null && cardDatas[ 1 ] != null && cardDatas[ 2 ] != null && cardDatas[ 3 ] != null && cardDatas[ 4 ] != null )
if ( cardDatas[ 0 ].Element == cardDatas[ 1 ].Element && cardDatas[ 1 ].Element == cardDatas[ 2 ].Element
&& cardDatas[ 2 ].Element == cardDatas[ 3 ].Element && cardDatas[ 3 ].Element == cardDatas[ 4 ].Element )
bonus = new int[ 5 ] { 2, 2, 2, 2, 2 };
List<int> counts = new List<int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
List<int> pairTable = new List<int>( pairBonus );
foreach ( var c in cardDatas )
{
if ( c != null )
counts[ c.Number ]++;
}
if ( counts.Contains( 3 ) && counts.Contains( 2 ) )
{
pairTable[ 1 ] = fullhouseBonus;
pairTable[ 2 ] = fullhouseBonus;
}
else if ( counts.Count(c=>c==1)==5 )
{
var firstNum = counts.IndexOf( 1 );
if ( counts[ firstNum ] == 1 && counts[ firstNum + 1 ] == 1 && counts[ firstNum + 2 ] == 1 && counts[ firstNum + 3 ] == 1 && counts[ firstNum + 4 ] == 1 )
pairTable[ 0 ] = straightBonus;
}
else if ( counts.Count( c => c == 2 ) == 2 )
{
pairTable[ 1 ] = twopairBonus;
}
for ( int i = 0; i < 5; i++ )
{
if ( cardDatas[ i ] != null )
{
bonus[ i ] *= pairTable[ counts[ cardDatas[ i ].Number ] ];
}
}
return bonus;
}
public static int[] GetCountBonus( CardData[] cardDatas )
{
var bonus = new int[ 5 ] { -2, -2, -2, -2, -2 };
int[] counts = new int[ 5 ];
foreach(var c in cardDatas)
{
if ( c != null )
counts[ ( int )c.Element ]++;
}
for(int i=0; i<5; i++ )
{
if ( cardDatas[ i ] != null )
{
int matchBonus = 1;
for ( int j = 0; j < counts[ ( int )cardDatas[ i ].Element ]; j++ )
matchBonus *= 2;
bonus[ i ] += matchBonus;
}
}
return bonus;
}
}
}
......@@ -2,10 +2,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TBR.TableData;
namespace TBR.Data
{
public enum ActionType
public enum ActionElement
{
Sword,
Gun,
......@@ -16,7 +17,13 @@ namespace TBR.Data
public class ActionData
{
ActionType actionType;
string ActionId;
public ActionElement ActionElement { get; private set; }
public ActionDescriptor ActionDesc { get; private set; }
public ActionData( ActionElement element, ActionDescriptor actionDesc)
{
ActionElement = element;
ActionDesc = actionDesc;
}
}
}
......@@ -7,16 +7,16 @@ namespace TBR.Data
{
public class CardData
{
public ActionType Type { get; private set; }
public int number { get; private set; }
public ActionElement Element { get; private set; }
public int Number { get; private set; }
public static bool operator ==( CardData a, CardData b )
{
return a.Type == b.Type && a.number == b.number;
return a.Element == b.Element && a.Number == b.Number;
}
public static bool operator !=( CardData a, CardData b )
{
return a.Type != b.Type || a.number != b.number;
return a.Element != b.Element || a.Number != b.Number;
}
public override bool Equals( object obj )
......@@ -36,16 +36,16 @@ namespace TBR.Data
{
var typeNum = Random.Range( 0, 8 );
if ( typeNum < 2 )
Type = ActionType.Sword;
Element = ActionElement.Sword;
else if (typeNum <4 )
Type = ActionType.Gun;
Element = ActionElement.Gun;
else if ( typeNum < 6 )
Type = ActionType.Mana;
Element = ActionElement.Mana;
else if ( typeNum < 7 )
Type = ActionType.Shield;
Element = ActionElement.Shield;
else if ( typeNum < 8 )
Type = ActionType.Heal;
number = Random.Range( 0, 10 );
Element = ActionElement.Heal;
Number = Random.Range( 0, 10 );
}
}
}
......@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TBR.TableData;
namespace TBR.Data
{
......@@ -16,19 +17,19 @@ namespace TBR.Data
public int Mana { get; private set; }
public int Shield { get; private set; }
public int Heal { get; private set; }
public Dictionary<ActionType, string> ActionIds { get; private set; }
public Dictionary<ActionElement, ActionDescriptor> ActionIds { get; private set; }
public List<ActionData> actionPool;
public List<CardData> CardPool;
public CardCase[] CardCases;
public CharacterData()
{
ActionIds = new Dictionary<ActionType, string>();
ActionIds.Add( ActionType.Sword, "act00000" );
ActionIds.Add( ActionType.Gun, "act00000" );
ActionIds.Add( ActionType.Mana, "act00000" );
ActionIds.Add( ActionType.Shield, "act00000" );
ActionIds.Add( ActionType.Heal, "act00000" );
ActionIds = new Dictionary<ActionElement, ActionDescriptor>();
ActionIds.Add( ActionElement.Sword, Table.Instance.ActionTable["A00000"] );
ActionIds.Add( ActionElement.Gun, Table.Instance.ActionTable[ "A00000" ] );
ActionIds.Add( ActionElement.Mana, Table.Instance.ActionTable[ "A00000" ] );
ActionIds.Add( ActionElement.Shield, Table.Instance.ActionTable[ "A00001" ] );
ActionIds.Add( ActionElement.Heal, Table.Instance.ActionTable[ "A00002" ] );
}
//임시 코드(HSymbol)
......
......@@ -52,9 +52,15 @@ public class Character
yield return null;
}
public void SetBonus(int powerBonus, int countBonus)
{
this.powerBonus = powerBonus;
this.countBonus = countBonus;
}
public IEnumerator Action()
{
var actionId = baseData.ActionIds[ SelectedCard.Type ];
var actionId = baseData.ActionIds[ SelectedCard.Element ];
yield return null;
}
......
......@@ -46,7 +46,19 @@ public class Party
public void CalcBonus()
{
CardData[] cards = new CardData[ 5 ];
for(int i=0;i<5;i++ )
{
if ( Characters[ i ] != null )
cards[ i ] = Characters[ i ].SelectedCard;
}
int[] powerBonus = Calculator.GetPowerBonus( cards );
int[] countBonus = Calculator.GetCountBonus( cards );
for ( int i = 0; i < 5; i++ )
{
if ( Characters[ i ] != null )
Characters[ i ].SetBonus( powerBonus[ i ], countBonus[ i ] );
}
}
public IEnumerator Action()
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
namespace TBR.TableData
{
public enum ActionType
{
Attack=0,
Shield,
Heal,
Buff,
Count,
}
public enum TargetType
{
Select=0,
Random,
All,
Lazor,
Count,
}
public class ActionDescriptor
{
[JsonProperty]
public string Id { get; private set; }
[JsonProperty]
public List<BehaviorDescriptor> BehaviorList;
[JsonProperty]
public string Desc { get; private set; }
public ActionDescriptor()
{
}
public ActionDescriptor(string id, List<BehaviorDescriptor> behaviors, string desc)
{
Id = id;
BehaviorList = new List<BehaviorDescriptor>( behaviors );
Desc = desc;
}
}
public class BehaviorDescriptor
{
[JsonProperty]
public ActionType Type { get; private set; }
[JsonProperty]
public TargetType Target { get; private set; }
[JsonProperty]
public int TargetArg { get; private set; }
[JsonProperty]
public int Arg1 { get; private set; }
public BehaviorDescriptor()
{
}
public BehaviorDescriptor(int type, int target, int targetArg, int arg1)
{
Type = ( ActionType)type;
Target = ( TargetType )target;
TargetArg = targetArg;
Arg1 = arg1;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using Newtonsoft.Json;
namespace TBR.TableData
{
public class Table
{
private static Table instance;
public static Table Instance
{
get {
if ( instance == null )
{
instance = new Table();
instance.LoadTable();
}
return instance;
}
}
public Dictionary<string, ActionDescriptor> ActionTable;
public void LoadTable()
{
ActionTable = new Dictionary<string, ActionDescriptor>();
var actions = JsonConvert.DeserializeObject<List< ActionDescriptor >>(Resources.Load<TextAsset>( "Table/ActionTable" ).text);
foreach(var a in actions)
{
ActionTable.Add( a.Id, a );
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment