Commit 4c99fd4d authored by 황호기's avatar 황호기

로직 상 카드 뽑기 구현

parent 06bd7319
This diff is collapsed.
......@@ -113,6 +113,40 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &7368867
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7368868}
m_Layer: 5
m_Name: Characters
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7368868
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 7368867}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1143583902}
m_Father: {fileID: 1902028737}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 800, y: 0}
m_Pivot: {x: 1, y: 0.5}
--- !u!1 &201200011
GameObject:
m_ObjectHideFlags: 0
......@@ -315,8 +349,8 @@ Canvas:
m_GameObject: {fileID: 540539224}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_RenderMode: 1
m_Camera: {fileID: 364967097}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
......@@ -324,7 +358,7 @@ Canvas:
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingLayerID: -1122741741
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &540539228
......@@ -337,8 +371,7 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 1902028737}
- {fileID: 603751245}
- {fileID: 739413543}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -347,80 +380,132 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &603751244
--- !u!1 &739413542
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 603751245}
- component: {fileID: 603751247}
- component: {fileID: 603751246}
- component: {fileID: 739413543}
- component: {fileID: 739413544}
m_Layer: 5
m_Name: Text
m_Name: P1UI
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &603751245
--- !u!224 &739413543
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 603751244}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_GameObject: {fileID: 739413542}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Children:
- {fileID: 1902028737}
m_Father: {fileID: 540539228}
m_RootOrder: 1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0.239}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 160, y: 30}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &603751246
--- !u!114 &739413544
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 603751244}
m_GameObject: {fileID: 739413542}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: 11500000, guid: 92dbb8638d959164cbb52606b6fb372b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1143583901
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1143583902}
- component: {fileID: 1143583905}
- component: {fileID: 1143583904}
- component: {fileID: 1143583903}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1143583902
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1143583901}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 7368868}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0.2, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1143583903
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1143583901}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7526772403305aa488633bd221a921a3, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1143583904
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1143583901}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_Color: {r: 0, g: 0.78431374, b: 0.78431374, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 1000
--- !u!222 &603751247
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &1143583905
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 603751244}
m_GameObject: {fileID: 1143583901}
m_CullTransparentMesh: 0
--- !u!1 &1175682419
GameObject:
......@@ -446,9 +531,11 @@ MonoBehaviour:
m_GameObject: {fileID: 1175682419}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fca38767f3b8eb94982aeea5a43a9e58, type: 3}
m_Script: {fileID: 11500000, guid: 8bcc89f34e5e7484a8886b1fea1800c2, type: 3}
m_Name:
m_EditorClassIdentifier:
partyUI1: {fileID: 739413544}
partyUI2: {fileID: 0}
--- !u!4 &1175682421
Transform:
m_ObjectHideFlags: 0
......@@ -485,11 +572,12 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1902028736}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 540539228}
m_Children:
- {fileID: 7368868}
m_Father: {fileID: 739413543}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TBR.Data
{
public enum ActionType
{
Sword,
Gun,
Mana,
Shield,
Heal
}
public class ActionData
{
ActionType actionType;
string ActionId;
}
}
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TBR.Data
{
public class CardData
{
public ActionType Type { 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;
}
public static bool operator !=( CardData a, CardData b )
{
return a.Type != b.Type || a.number != b.number;
}
public override bool Equals( object obj )
{
if ( !( obj is CardData ) )
return false;
else return (CardData)obj == this;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
//임시 코드(HSymbol)
public void Randomize()
{
var typeNum = Random.Range( 0, 8 );
if ( typeNum < 2 )
Type = ActionType.Sword;
else if (typeNum <4 )
Type = ActionType.Gun;
else if ( typeNum < 6 )
Type = ActionType.Mana;
else if ( typeNum < 7 )
Type = ActionType.Shield;
else if ( typeNum < 8 )
Type = ActionType.Heal;
number = Random.Range( 0, 10 );
}
}
}
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TBR.Data
{
public class CharacterData
{
public string LeaderSkillId { get; private set; }
public int Grade { get; private set; }
public int Level { get; private set; }
public int HP { get; private set; }
public int Sword { get; private set; }
public int Gun { get; private set; }
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 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" );
}
//임시 코드(HSymbol)
public void Randomize()
{
HP = Random.Range( 10000, 20000 );
Sword = Random.Range( 100, 200 );
Gun = Random.Range( 100, 200 );
Mana = Random.Range( 100, 200 );
Shield = Random.Range( 100, 200 );
CardCases = new CardCase[ 10 ];
List<CardData> selectedCards = new List<CardData>();
foreach(var c in CardCases)
{
var card = new CardData();
card.Randomize();
while( selectedCards.Contains( card ) )
{
card.Randomize();
}
selectedCards.Add( card );
c.SetCard( card );
}
}
}
public class CardCase
{
public CardData Card { get; private set; }
public string SkillId { get; private set; }
public bool[] ActionCondition { get; private set; }
public bool[] NumberCondition { get; private set; }
public void SetCard( CardData card )
{
Card = card;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TBR.Data
{
public class PartyData
{
public CharacterData[] Characters { get; private set; }
public int LeaderIndex { get; private set; }
public bool Useable { get; private set; }
public PartyData()
{
Characters = new CharacterData[ 5 ];
LeaderIndex = 0;
Useable = false;
}
public void SetChatacter(CharacterData character, int index)
{
Characters[ index ] = character;
CheckUseAble();
}
public void SetLeader( int index )
{
LeaderIndex = index;
CheckUseAble();
}
public void CheckUseAble()
{
Useable = true;
foreach (CharacterData c in Characters )
{
if ( c == null )
{
Useable = false;
return;
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public enum BuffType
{
SwordUp
}
public class Buff
{
public BuffType Type { get; private set; }
public int Arg1 { get; private set; }
public int Arg2 { get; private set; }
public int BuffValue { get; private set; }
}
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TBR.Data;
public class Character
{
private CharacterData baseData;
public int HP { get; private set; }
public int MaxHP { get; private set; }
public int ShieldStack { get; private set; }
public List<Buff> buffs { get; private set; }
public int Sword { get; private set; }
public int Gun { get; private set; }
public int Mana { get; private set; }
public int Shield { get; private set; }
public int Heal { get; private set; }
public CardData SelectedCard { get; private set; }
public string SelectedSkill { get; private set; }
private int powerBonus;
private int countBonus;
public Character( CharacterData data )
{
baseData = data;
HP = data.HP;
MaxHP = HP * 2;
buffs = new List<Buff>();
Sword = data.Sword;
Gun = data.Gun;
Mana = data.Mana;
Shield = data.Shield;
Heal = data.Heal;
}
public void SetCard()
{
var selectedIndex = Random.Range( 0, 10 );
SelectedCard = baseData.CardCases[ selectedIndex ].Card;
SelectedSkill = baseData.CardCases[ selectedIndex ].SkillId;
}
public IEnumerator SelectCard()
{
yield return null;
}
public IEnumerator UseSkill()
{
yield return null;
}
public IEnumerator Action()
{
var actionId = baseData.ActionIds[ SelectedCard.Type ];
yield return null;
}
public static Character MakeRandomCharacter()
{
var data = new CharacterData();
data.Randomize();
var character = new Character( data );
return character;
}
}
using System;
using System.Collections;
using System.Linq;
using System.Text;
using TBR.Data;
public class Party
{
public Character[] Characters { get; private set; }
public string LeaderSkillId { get; private set; }
public int LeaderIndex { get; private set; }
public bool LeaderAlive { get; private set; }
public Party()
{
Characters = new Character[ 5 ];
}
public void SetPartyData(PartyData partyData)
{
}
public void SetNonLeaderCard()
{
for(int i=0;i<5;i++ )
{
if ( i != LeaderIndex || !LeaderAlive )
Characters[ LeaderIndex ].SetCard();
}
}
public IEnumerator SetLeaderCard()
{
yield return Characters[ LeaderIndex ].SelectCard();
}
public IEnumerator UseSkill()
{
for ( int i = 0; i < 5; i++ )
{
if ( string.IsNullOrEmpty( Characters[ i ].SelectedSkill ) )
yield return Characters[ i ].UseSkill();
}
}
public void CalcBonus()
{
}
public IEnumerator Action()
{
for ( int i = 0; i < 5; i++ )
{
if ( string.IsNullOrEmpty( Characters[ i ].SelectedSkill ) )
yield return Characters[ i ].Action();
}
}
public static Party MakeRandomParty()
{
var party = new Party();
party.Characters[ 0 ] = Character.MakeRandomCharacter();
party.Characters[ 1 ] = Character.MakeRandomCharacter();
party.Characters[ 2 ] = Character.MakeRandomCharacter();
party.Characters[ 3 ] = Character.MakeRandomCharacter();
party.Characters[ 4 ] = Character.MakeRandomCharacter();
return party;
}
}
using UnityEngine;
using TBR.Data;
public class Card : MonoBehaviour {
int[,] visible = new int[10, 16]{
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0},
{0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0},
{0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0},
{0,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0},
{1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0},
{1,0,1,0,1,0,1,0,1,0,0,0,1,0,1,0},
{1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0},
{1,0,1,1,0,1,0,1,0,1,0,1,1,0,1,0},
{1,0,1,1,1,1,0,0,0,1,1,1,1,0,1,0}
};
public int number;
public enum TColor { grey, green, blue, black, red };
public TColor tColor;
public Color color;
public ActionType actionType;
public Sprite[] TSprites = new Sprite[5];
// Use this for initialization
void Awake()
{
}
// Update is called once per frame
void Update () {
}
Color ToColor(TColor tColor)
{
if (tColor == TColor.grey)
return Color.grey;
if (tColor == TColor.red)
return Color.red;
if (tColor == TColor.blue)
return Color.blue;
if (tColor == TColor.green)
return Color.green;
return Color.black;
}
public void MakeCardSprite (int n, ActionType aType)
{
number = n;
actionType = aType;
tColor = (TColor)((int)aType);
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.color = color;
nowSprite.gameObject.SetActive(visible[number - 1, i - 1] > 0);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterUI : MonoBehaviour {
// Use this for initialization
void Start () {