Commit 43f331db authored by 황호기's avatar 황호기

위쪽과 아래쪽이 카드를 뽑는 로직을 구현

parent b5634259
......@@ -276,7 +276,7 @@ MonoBehaviour:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: b238faa2b4a45574dbee41900f711daf, type: 3}
m_Sprite: {fileID: 21300000, guid: 699b04151029b3e4a98e9954dd8e89ec, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
......@@ -351,7 +351,7 @@ MonoBehaviour:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: b238faa2b4a45574dbee41900f711daf, type: 3}
m_Sprite: {fileID: 21300000, guid: 699b04151029b3e4a98e9954dd8e89ec, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
......@@ -378,7 +378,7 @@ MonoBehaviour:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: 65fc6ef35eca9d445a5ee600ff7b8dfb, type: 3}
m_Sprite: {fileID: 21300000, guid: 97a1c8f8dd1424141b1baf5194ac0e75, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
......@@ -394,9 +394,15 @@ MonoBehaviour:
m_GameObject: {fileID: 1692523429034490}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8dc705004716fbf4fa687ebcf24d275f, type: 3}
m_Script: {fileID: 11500000, guid: 83c2c5eeac489454e963a57b4708515e, type: 3}
m_Name:
m_EditorClassIdentifier:
image: {fileID: 114407155780053644}
hpBar: {fileID: 114101191979477576}
shieldBar: {fileID: 114146048921004652}
hpText: {fileID: 114673570930832878}
shieldText: {fileID: 114667973635924324}
cardPrefab: {fileID: 11441498, guid: 512204d60f1753c42af11e4e33c8ef5e, type: 2}
--- !u!114 &114667973635924324
MonoBehaviour:
m_ObjectHideFlags: 1
......@@ -482,7 +488,7 @@ MonoBehaviour:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: b238faa2b4a45574dbee41900f711daf, type: 3}
m_Sprite: {fileID: 21300000, guid: 699b04151029b3e4a98e9954dd8e89ec, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
......@@ -509,7 +515,7 @@ MonoBehaviour:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: b238faa2b4a45574dbee41900f711daf, type: 3}
m_Sprite: {fileID: 21300000, guid: 699b04151029b3e4a98e9954dd8e89ec, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
......
......@@ -494,7 +494,7 @@ Transform:
m_GameObject: {fileID: 165444}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.9, y: 0.9, z: 1}
m_LocalScale: {x: 70, y: 70, z: 1}
m_Children:
- {fileID: 425674}
- {fileID: 450614}
......@@ -606,20 +606,19 @@ MonoBehaviour:
m_GameObject: {fileID: 165444}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ef2d017a014f0394eaedecf7ad264c3c, type: 3}
m_Script: {fileID: 11500000, guid: e0d3187c3c7bef44587a7b8925b46cf5, type: 3}
m_Name:
m_EditorClassIdentifier:
number: 0
tColor: 0
color: {r: 0, g: 0, b: 0, a: 0}
cType: 0
nowPow: 0
actionElement: 0
TSprites:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 21300000, guid: 2963968e1987ead4eb7e099c69804953, type: 3}
- {fileID: 21300000, guid: 5dbd10cd445f3ac4a8f907704069156b, type: 3}
- {fileID: 21300000, guid: 7aa3ba111b8f60742907a391c9bca9c4, type: 3}
- {fileID: 21300000, guid: 462dbb6bd31a17a4fb5561437a39063c, type: 3}
- {fileID: 21300000, guid: e48f4881b9e48a14ea2f7d00752bf4b6, type: 3}
--- !u!114 &11488020
MonoBehaviour:
m_ObjectHideFlags: 1
......@@ -628,7 +627,7 @@ MonoBehaviour:
m_GameObject: {fileID: 179230}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1659c31ee9e53be4cb9fb983c8d6bb8d, type: 3}
m_Script: {fileID: 11500000, guid: 400e461c57fb69d48b3c89c00f2e37fb, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!212 &21208978
......@@ -1218,7 +1217,7 @@ SpriteRenderer:
m_SortingLayerID: -677567689
m_SortingLayer: 4
m_SortingOrder: 1
m_Sprite: {fileID: 21300000, guid: b238faa2b4a45574dbee41900f711daf, type: 3}
m_Sprite: {fileID: 21300000, guid: 699b04151029b3e4a98e9954dd8e89ec, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -23,6 +23,7 @@ public class GameLogic : MonoBehaviour {
private Text turnText;
private int turn;
private int firstTurnParty;
private int currentTurnParty;
// Use this for initialization
void Start () {
......@@ -51,51 +52,66 @@ public class GameLogic : MonoBehaviour {
characters[ p, i ].SetCharacter( dataLogic.Parties[ p ].Characters[ i ] );
}
}
partyUI1.SetParty( dataLogic.Parties[ 0 ], "아랫쪽" );
partyUI2.SetParty( dataLogic.Parties[ 1 ], "위쪽" );
yield return null;
turn = 0;
turnText.text = turn.ToString();
while (turn < 40)
{
int currentTurnParty = ( firstTurnParty + turn ) % 2;
yield return ShowNonLeaderCard( currentTurnParty );
turnText.text = ( turn / 2 + 1 ).ToString();
currentTurnParty = ( firstTurnParty + turn ) % 2;
dataLogic.SetCurrentTurnParty( currentTurnParty );
yield return ShowNonLeaderCard();
if ( dataLogic.Parties[ currentTurnParty ].LeaderAlive )
yield return SetLeaderCard( currentTurnParty );
yield return UseSkill( currentTurnParty );
dataLogic.CalcAndAssignBonus( currentTurnParty );
yield return Action( currentTurnParty );
yield return SetLeaderCard();
yield return UseSkill();
dataLogic.CalcAndAssignBonus();
yield return Action();
if ( CheckGameOver() )
break;
AssignDataAndResetCard();
turn++;
turnText.text = turn.ToString();
}
}
public IEnumerator ShowNonLeaderCard( int partyNum )
public IEnumerator ShowNonLeaderCard()
{
dataLogic.SetNonLeaderCard( partyNum );
yield return null;
dataLogic.SetNonLeaderCard();
for(int i=0;i<5;i++)
{
characters[ currentTurnParty, i].SetCard();
}
yield return new WaitForSeconds(0.5f);
}
public IEnumerator SetLeaderCard(int partyNum)
public IEnumerator SetLeaderCard()
{
yield return characters[ partyNum, dataLogic.Parties[ partyNum ].LeaderIndex ].SelectCard();
yield return characters[ currentTurnParty, dataLogic.Parties[ currentTurnParty ].LeaderIndex ].SelectCard();
}
public IEnumerator UseSkill( int partyNum )
public IEnumerator UseSkill()
{
dataLogic.UseSkill( partyNum );
dataLogic.UseSkill();
for ( int i = 0; i < 5; i++ )
{
yield return characters[ partyNum, i ].UseSkill();
yield return characters[ currentTurnParty, i ].UseSkill();
}
}
public IEnumerator Action( int partyNum )
public IEnumerator Action()
{
dataLogic.Action();
for ( int i = 0; i < 5; i++ )
{
yield return characters[ currentTurnParty, i ].Action();
}
}
public void AssignDataAndResetCard()
{
dataLogic.Action( partyNum );
for ( int i = 0; i < 5; i++ )
{
yield return characters[ partyNum, i ].Action();
characters[ currentTurnParty, i ].AssignDataAndResetCard();
}
}
......
......@@ -43,8 +43,10 @@ public class Card : MonoBehaviour {
return Color.black;
}
public void MakeCardSprite (int n, ActionElement e)
public void MakeCardSprite (CardData data)
{
var n = data.Number;
var e = data.Element;
number = n;
actionElement = e;
tColor = (TColor)((int)e);
......
......@@ -9,12 +9,25 @@ public class CharacterObj : MonoBehaviour
{
[SerializeField]
private SpriteRenderer characterImage;
[SerializeField]
private CharacterUI characterUI;
private Character character;
public void SetCharacter(Character character)
{
this.character = character;
characterImage.sprite = Resources.Load<Sprite>( "Characters/Game/" + character.BaseData.ImageId );
characterUI.SetCharacter( character );
}
public void SetCard()
{
characterUI.SetCard();
}
public void AssignDataAndResetCard()
{
characterUI.AssignDataAndResetCard();
}
public IEnumerator SelectCard()
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TBR.Game;
public class CharacterUI : MonoBehaviour {
public class CharacterUI : MonoBehaviour
{
[SerializeField]
private Image image;
[SerializeField]
private Slider hpBar;
[SerializeField]
private Slider shieldBar;
[SerializeField]
private Text hpText;
[SerializeField]
private Text shieldText;
private Character character;
[SerializeField]
private Card cardPrefab;
private Card curCard;
// Use this for initialization
void Start () {
public void SetCharacter( Character character )
{
this.character = character;
image.sprite = Resources.Load<Sprite>( "Characters/Icon/" + character.BaseData.ImageId );
hpBar.value = ( float )character.HP / character.MaxHP;
shieldBar.value = ( float )character.ShieldStack / character.MaxHP;
hpText.text = character.HP + "/" + character.MaxHP;
shieldText.text = character.ShieldStack.ToString();
}
// Update is called once per frame
void Update () {
public void SetCard()
{
if ( character.SelectedCard != null )
{
if ( curCard != null )
Destroy( curCard.gameObject );
curCard = Instantiate( cardPrefab, transform );
curCard.MakeCardSprite( character.SelectedCard );
}
}
public void AssignDataAndResetCard()
{
if ( curCard != null )
Destroy( curCard.gameObject );
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TBR.Game;
public class PartyUI : MonoBehaviour {
[SerializeField]
private Text playerName;
[SerializeField]
private Image leaderImage;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
public void SetParty(Party party, string playerName)
{
this.playerName.text = playerName;
leaderImage.sprite = Resources.Load<Sprite>( "Characters/Icon/" + party.Characters[ party.LeaderIndex ].BaseData.ImageId );
}
}
......@@ -29,7 +29,7 @@ namespace TBR.Data
foreach ( var c in cardData )
{
if ( c != null )
numberCounts[ c.Number ]++;
numberCounts[ c.Number - 1 ]++;
}
if ( numberCounts.Contains( 3 ) && numberCounts.Contains( 2 ) )
{
......@@ -50,7 +50,7 @@ namespace TBR.Data
{
if ( cardData[ i ] != null )
{
powerBonus[ i ] *= pairTable[ numberCounts[ cardData[ i ].Number ] ];
powerBonus[ i ] *= pairTable[ numberCounts[ cardData[ i ].Number -1 ] ];
}
}
......
......@@ -50,7 +50,7 @@ namespace TBR.Data
Element = ActionElement.Shield;
else if ( typeNum < 8 )
Element = ActionElement.Heal;
Number = Random.Range( 0, 10 );
Number = Random.Range( 1, 11 );
}
}
}
......@@ -56,7 +56,32 @@ namespace TBR.Game
public void Action()
{
var actionId = BaseData.ActionIds[ SelectedCard.Element ];
var action = BaseData.ActionIds[ SelectedCard.Element ];
DataLogic.CurDataLogic.DoAction( this, GetElementPower( SelectedCard.Element ), action );
}
public int GetElementPower(ActionElement element)
{
switch(element)
{
case ActionElement.Gun:
return Gun;
case ActionElement.Heal:
return Heal;
case ActionElement.Mana:
return Mana;
case ActionElement.Shield:
return Shield;
case ActionElement.Sword:
return Sword;
}
return 0;
}
public bool ReceiveDamage(int damage)
{
HP -= damage;
return HP < 0;
}
public static Character MakeRandomCharacter()
......
......@@ -2,16 +2,26 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TBR.TableData;
using TBR.Data;
namespace TBR.Game
{
public class DataLogic
{
public static DataLogic CurDataLogic;
public Party[] Parties { get; private set; }
private int currentTurnParty;
public DataLogic()
{
Parties = new Party[ 2 ];
CurDataLogic = this;
}
public void SetCurrentTurnParty( int partyNum )
{
currentTurnParty = partyNum;
}
public void MakeRandomData()
......@@ -21,24 +31,56 @@ namespace TBR.Game
Parties[ 1 ] = Party.MakeRandomParty();
}
public void SetNonLeaderCard(int partyNum)
public void SetNonLeaderCard()
{
Parties[ currentTurnParty ].SetNonLeaderCard();
}
public void UseSkill()
{
Parties[ currentTurnParty ].UseSkill();
}
public void CalcAndAssignBonus()
{
Parties[ partyNum ].SetNonLeaderCard();
Parties[ currentTurnParty ].CalcAndAssignBonus();
}
public void UseSkill( int partyNum )
public void Action()
{
Parties[ partyNum ].UseSkill();
Parties[ currentTurnParty ].Action();
}
public void CalcAndAssignBonus( int partyNum )
public void DoAction( Character actor, int elementPower, ActionDescriptor action )
{
Parties[ partyNum ].CalcAndAssignBonus();
List<bool> changeTarget = new List<bool>();
List<bool[]> target = new List<bool[]>();
for ( int i = 0; i < action.BehaviorList.Count; i++ )
{
changeTarget.Add( false );
target.Add( new bool[ 5 ] );
}
for ( int i = 0; i < action.BehaviorList.Count; i++ )
{
var behaivor = action.BehaviorList[ i ];
switch ( behaivor.Type )
{
case ActionType.Attack:
break;
case ActionType.Heal:
case ActionType.Shield:
case ActionType.Buff:
break;
}
}
}
public void Action( int partyNum )
// return 은 공격에 의해서 적이 죽었는지를 나타낸다.
public bool Attack( Character actor, int elementPower, Character target, int arg)
{
Parties[ partyNum ].Action();
if(target != null || target.HP<=0)
return false;
return target.ReceiveDamage( elementPower * arg / 100 );
}
}
}
......@@ -28,7 +28,7 @@ namespace TBR.Game
for ( int i = 0; i < 5; i++ )
{
if ( i != LeaderIndex || !LeaderAlive )
Characters[ LeaderIndex ].SetCard();
Characters[ i ].SetCard();
}
}
......
m_EditorVersion: 2018.2.12f1
m_EditorVersion: 2018.2.13f1
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