Commit f2b91f41 authored by 18류지석's avatar 18류지석

생명석 조각을 먹어서 채우는 것이 아닌 생명석 회복 구현(아이템 효과) 식탐 애드온 효과 구현, 활에 애드온 적용 안되던 버그 수정, 아이템풀 일부 수정

parent 2f7f0143
......@@ -19,6 +19,11 @@ public class AttackProperty : MonoBehaviour{
inventoryManager = InventoryManager.Instance;
}
public void Init(string combo)
{
attackCombo = combo;
}
private void OnTriggerEnter2D(Collider2D collision)
{
......
......@@ -54,7 +54,7 @@ public class PlayerAttack : MonoBehaviour {
if (playerController.playerState == PlayerState.GoingUp || playerController.playerState == PlayerState.GoingDown)
playerController.airAttack = false;
comboArray += (char)('A' + i);
attackProperty.attackCombo = comboArray;
attackProperty.Init(comboArray);
CheckCombo();
SetComboText();
break;
......
......@@ -7,6 +7,7 @@ using UnityEngine;
/// </summary>
public class Gluttony : Addon
{
LifeStoneManager lifeStoneManager;
public override void Declare()
{
id = 17; name = "식탐";
......@@ -15,12 +16,13 @@ public class Gluttony : Addon
sprite = Resources.Load<Sprite>("Sprites/Addons/parchment piece"); ;
highlight = Resources.Load<Sprite>("Sprites/Addons/parchment piece"); ;
sizeInventory = new Vector2(80, 80);
lifeStoneManager = GameObject.Find("LifeStoneUI").GetComponent<LifeStoneManager>();
}
public override void OtherEffect(PlayerAttackInfo attackInfo, Enemy enemyInfo, string combo)
{
if(attackInfo.damage > enemyInfo.currHealth)
if(attackInfo.damage >= enemyInfo.currHealth)
{
//생명석 2개 회복
lifeStoneManager.FillLifeStone(1, LifeStoneType.Normal);
}
}
}
\ No newline at end of file
......@@ -24,6 +24,7 @@ public class InventoryManager : Singleton<InventoryManager> {
SetPool();
ItemInstantiate("Dagger", player.transform.position, 0f);
AddonInstantiate("ParchmentPiece", player.transform.position, 0f);
AddonInstantiate("Gluttony", player.transform.position, 0f);
ItemInstantiate("Bow", player.transform.position, 0f);
StartCoroutine(TestCoroutine());
......@@ -57,13 +58,17 @@ public class InventoryManager : Singleton<InventoryManager> {
addonPool[0].Add("ParchmentPiece");
addonPool[0].Add("KnightsStirrup");
addonPool[0].Add("ApprenticesMark");
addonPool[1].Add("GlowingHerb");
addonPool[1].Add("BlacksmithsBrooch");
addonPool[1].Add("CoollyPride");
addonPool[1].Add("GlowingHerb");
addonPool[1].Add("Gluttony");
addonPool[1].Add("SmallLens");
//addonPool[2].Add("");
addonPool[2].Add("JanusCoin");
addonPool[2].Add("DesignofRagur");
addonPool[2].Add("Sandbag");
//addonPool[3].Add("");
......
......@@ -36,7 +36,8 @@ public class Bow : Item {
yield return new WaitForSeconds(0.3f);
GameObject tmpObj = Object.Instantiate(arrow, player.transform.position, Quaternion.identity);
tmpObj.transform.localScale = new Vector3(Mathf.Sign(player.transform.localScale.x), 1, 1);
tmpObj.GetComponent<Rigidbody2D>().velocity = new Vector2(-10f * Mathf.Sign(player.transform.localScale.x), 0f);
tmpObj.GetComponent<Rigidbody2D>().velocity = new Vector2(-15f * Mathf.Sign(player.transform.localScale.x), 0f);
tmpObj.GetComponent<AttackProperty>().Init(combo[0]);
}
protected override void PlaySkill2()
{
......@@ -46,6 +47,7 @@ public class Bow : Item {
{
yield return new WaitForSeconds(0.3f);
GameObject tmpObj = Object.Instantiate(arrow, player.transform.position, Quaternion.Euler(0, 0, -90f));
tmpObj.GetComponent<Rigidbody2D>().velocity = new Vector2(0f,10f);
tmpObj.GetComponent<Rigidbody2D>().velocity = new Vector2(0f,15f);
tmpObj.GetComponent<AttackProperty>().Init(combo[1]);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent (typeof(RectTransform))]
public class LifeStoneManager : MonoBehaviour {
/// <summary>
/// Location of lifeStoneFrame on Canvas
......@@ -67,14 +66,13 @@ public class LifeStoneManager : MonoBehaviour {
lifeStoneArray = new int[50, 3];
lifeStoneUnit = new GameObject[50, 3];
for (int i = 0; i < 50; i++) for (int j = 0; j < 3; j++) lifeStoneArray[i, j] = 0;
//StartCoroutine("TestEnumerator");
PushLifeStone(CreateLifeStoneInfo(new Vector2Int(3, 6), 0, 0));
StartCoroutine("TestEnumerator");
}
IEnumerator TestEnumerator()
{
yield return null;
}
/// <summary>
......@@ -118,6 +116,8 @@ public class LifeStoneManager : MonoBehaviour {
StartCoroutine(PopoutCoroutine(obj));
}
/// <summary>
/// Instantiate Dropped LifeStone
/// </summary>
......@@ -334,6 +334,7 @@ public class LifeStoneManager : MonoBehaviour {
new Vector2Int(xtmp, ytmp),
new Vector2Int(xtmp, lifeStoneRowNum + pj),
new Vector2(frameBorder * lifeStoneSize, frameBorder * lifeStoneSize),
true,
vibration);
vibration = 0;
}
......@@ -512,6 +513,57 @@ public class LifeStoneManager : MonoBehaviour {
}
}
public void FillLifeStone(int num, LifeStoneType type)
{
List<Vector2Int> fillCand;
List<KeyValuePair<Vector2Int, LifeStoneType>> fillArray = new List<KeyValuePair<Vector2Int, LifeStoneType>>();
Vector2Int selectedPos;
for (int n = 0; n < num; n++)
{
fillCand = new List<Vector2Int>();
for (int j = 0; j < lifeStoneRowNum; j++)
for (int i = 0; i < 3; i++)
if (
lifeStoneArray[j, i] == 0 &&
((i - 1 >= 0 && lifeStoneArray[j, i - 1] > 0) ||
(i + 1 < 3 && lifeStoneArray[j, i + 1] > 0) ||
(j - 1 >= 0 && lifeStoneArray[j - 1, i] > 0) ||
(j + 1 < lifeStoneRowNum && lifeStoneArray[j + 1, i] > 0)
))
fillCand.Add(new Vector2Int(i, j));
if (fillCand.Count == 0) break;
selectedPos = fillCand[Random.Range(0, fillCand.Count)];
fillArray.Add(new KeyValuePair<Vector2Int, LifeStoneType>(selectedPos, type));
lifeStoneArray[selectedPos.y, selectedPos.x] = (int)type;
lifeStoneUnit[selectedPos.y, selectedPos.x] = Instantiate(lifeUnitPrefab, stoneSuper.transform);
lifeStoneUnit[selectedPos.y, selectedPos.x].SetActive(false);
}
StartCoroutine(FillInPhase(fillArray));
}
IEnumerator FillInPhase(List<KeyValuePair<Vector2Int, LifeStoneType>> fillArray)
{
for(int i=0; i<fillArray.Count; i++)
{
lifeStoneUnit[fillArray[i].Key.y, fillArray[i].Key.x].SetActive(true);
lifeStoneUnit[fillArray[i].Key.y, fillArray[i].Key.x].GetComponent<LifeUnitInFrame>().Init(
(int)fillArray[i].Value,
lifeStoneSize,
new Vector2Int(fillArray[i].Key.x, fillArray[i].Key.y),
new Vector2Int(fillArray[i].Key.x, fillArray[i].Key.y),
new Vector2(frameBorder * lifeStoneSize, frameBorder * lifeStoneSize),
false,
0);
yield return new WaitForSeconds(0.1f);
}
}
/// <summary>
/// lifestoneframe vibration
/// </summary>
......
......@@ -11,11 +11,9 @@ public class LifeUnitInFrame : MonoBehaviour {
Vector2 zeroPos;
float size;
float v, accel;
bool isFall;
float vibration;
void Start()
{
}
/// <summary>
/// Create LifeStoneUnit from above. Starts to fall
/// </summary>
......@@ -24,10 +22,10 @@ public class LifeUnitInFrame : MonoBehaviour {
/// <param name="_pos"> destination point in lifestoneFrame</param>
/// <param name="_startPos"> starting point above the lifestoneFrame</param>
/// <param name="_zeroPos"> base position of (0,0) lifestoneFrame</param>
public void Init(int _type, float _size, Vector2Int _pos, Vector2Int _startPos, Vector2 _zeroPos, float _vibration)
public void Init(int _type, float _size, Vector2Int _pos, Vector2Int _startPos, Vector2 _zeroPos, bool _isFall , float _vibration)
{
animator = GetComponent<Animator>();
size = _size; type = _type; pos = _pos; startPos = _startPos; zeroPos = _zeroPos; vibration = _vibration;
size = _size; type = _type; pos = _pos; startPos = _startPos; zeroPos = _zeroPos; isFall = _isFall; vibration = _vibration;
GetComponent<RectTransform>().sizeDelta = new Vector2(size, size);
transform.localPosition = new Vector2(zeroPos.x + startPos.x * size, zeroPos.y + startPos.y * size);
v = 0;
......@@ -72,18 +70,18 @@ public class LifeUnitInFrame : MonoBehaviour {
}
IEnumerator FallEnumerator()
{
while (true)
while (isFall)
{
float vtmp = transform.localPosition.y - v;
if (vtmp <= zeroPos.y + pos.y * size)
{
transform.localPosition = new Vector2(transform.localPosition.x, zeroPos.y + pos.y * size);
break;
}
transform.localPosition = new Vector2(transform.localPosition.x, vtmp);
v += accel;
yield return null;
}
transform.localPosition = new Vector2(transform.localPosition.x, zeroPos.y + pos.y * size);
if (vibration != 0)
StartCoroutine(GameObject.Find("LifeStoneUI").GetComponent<LifeStoneManager>().VibrateEnumerator(vibration));
}
......
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