Commit 1569e03d authored by abpo11's avatar abpo11

콤보 시스템 만듬

parent f67cf105
......@@ -265,6 +265,23 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 1623439448163086, guid: 3d077a5f727dd1e4780e9265ed26e036,
type: 2}
m_PrefabInternal: {fileID: 1618052740}
--- !u!114 &489222434
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 489222433}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4ab58a64164eb984d8683df370ddce96, type: 3}
m_Name:
m_EditorClassIdentifier:
state: 0
attackA: 0
attackB: 0
attackC: 0
comboArray:
StartTime: 0
--- !u!1001 &677608594
Prefab:
m_ObjectHideFlags: 0
......

public class AttackCombo
{
float time;
//시전시간 1.5초
string name;
//화염발사!
string combo;
//"ABCACBAC"
public AttackCombo(string name, string combo, float time)
{
this.time = time;
this.name = name;
this.combo = combo;
}
public override string ToString()
{
return name;
}
public override bool Equals(object obj)
{
return combo.Equals(obj);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public float getTime()
{
return time;
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: edea51a314af27047a14dcdc911cf7ab
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAttack : MonoBehaviour {
public ComboState state;
public float attackA,attackB,attackC;
public float cancel;
public string comboArray;
public float StartTime;
public bool keyCoolDown=true;
public AttackCombo[] AttackArr= { new AttackCombo("화염발사", "ABC", 1.5f),
new AttackCombo("공격A", "A", 0.5f),
new AttackCombo("공격B", "B", 0.5f),
new AttackCombo("공격C", "C", 0.5f),
new AttackCombo("콩", "AC", 1f),
new AttackCombo("콩콩콩", "ACB", 2f),
};
public Queue comboQueue = new Queue();
// Use this for initialization
void Start () {
StartTime = Time.time;
state = ComboState.Idle;
}
// Update is called once per frame
void Update()
{
attackA = Input.GetAxisRaw("Fire1");
attackB = Input.GetAxisRaw("Fire2");
attackC = Input.GetAxisRaw("Fire3");
cancel = Input.GetAxisRaw("stop");
if (attackA + attackB + attackC == 0)
{
keyCoolDown = true;
}
if (state == ComboState.Idle)
{
if (attackA + attackB + attackC > 0 && keyCoolDown)
{
state = ComboState.Attack;
StartTime = Time.time;
ComboCheck();
}
}
else if (state == ComboState.Attack)
{
ComboCheck();
//공격중일때
if (Time.time > StartTime)
{
state = ComboState.Combo;
}
}
else if (state == ComboState.Combo)
{
ComboCheck();
if (comboQueue.Count > 0) //콤보가 남아있다면
{
AttackCombo cur = (AttackCombo)comboQueue.Dequeue();
print(cur);
state = ComboState.Attack;
StartTime = Time.time + cur.getTime();
}
else if (Time.time > StartTime + 1f || cancel==1)
{
//현재 시간이 마지막 콤보 끝나는 시점보다 1초 지났다면
state = ComboState.Idle;
comboArray = "";
}
}
if (attackA + attackB + attackC > 0)
{
keyCoolDown = false;
}
}
void ComboCheck()
{
//들어갈 콤보가 있는지 확인함
if (attackA + attackB + attackC > 0 && keyCoolDown)
{
if (attackA == 1)
{
comboArray += "A";
}
else if (attackB == 1)
{
comboArray += "B";
}
else if (attackC == 1)
{
comboArray += "C";
}
bool success = false;
foreach (AttackCombo com in AttackArr)
{
if (com.Equals(comboArray))
{
comboQueue.Enqueue(com);
success = true;
}
}
if (success==false) //콤보 실행에 실패했다면
{
string temp = comboArray[comboArray.Length - 1]+"";
foreach (AttackCombo com2 in AttackArr) //기본 글자 콤보 실행
{
if (com2.Equals(temp))
{
comboQueue.Enqueue(com2);
}
}
}
}
}
}
fileFormatVersion: 2
guid: 4ab58a64164eb984d8683df370ddce96
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -30,12 +30,13 @@ public enum ItemType
}
public enum PlayerState { Idle, Walk, Run, GoingUp, GoingDown, Rope }
public enum ComboState {Idle, Combo, Attack}
/// <summary>
/// Enum for game's state.
/// </summary>
public enum GameState { MainMenu, Ingame, Tetris, Pause, Inventory, GameOver }
/// <summary>
/// Enum for room types.
/// </summary>
......
......@@ -42,9 +42,9 @@ InputManager:
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left ctrl
positiveButton: z
altNegativeButton:
altPositiveButton: mouse 0
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
......@@ -58,9 +58,9 @@ InputManager:
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left alt
positiveButton: x
altNegativeButton:
altPositiveButton: mouse 1
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
......@@ -74,9 +74,25 @@ InputManager:
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left shift
positiveButton: c
altNegativeButton:
altPositiveButton: mouse 2
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: stop
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: v
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
......
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