|
|
|
@ -8,12 +8,14 @@ using UnityEngine.UI;
|
|
|
|
|
public class Main : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
#region var
|
|
|
|
|
private GameObject chara;
|
|
|
|
|
public GameObject chara;
|
|
|
|
|
private GameObject weapon;
|
|
|
|
|
private GameObject weaponL;
|
|
|
|
|
private GameObject weaponR;
|
|
|
|
|
private GameObject attachment;
|
|
|
|
|
private RuntimeAnimatorController originAnimator;
|
|
|
|
|
private SkinnedMeshRenderer charaFaceRender;
|
|
|
|
|
private int faceOverride = 0;
|
|
|
|
|
|
|
|
|
|
private string basePath = "F:/Ongeki_Unity/ab/";
|
|
|
|
|
public Dictionary<string, List<string>> charaAssetsNames = new Dictionary<string, List<string>>();
|
|
|
|
@ -21,6 +23,7 @@ public class Main : MonoBehaviour
|
|
|
|
|
public Dictionary<string, List<string>> attachmentAssetsNames = new Dictionary<string, List<string>>();
|
|
|
|
|
public Dictionary<string, string> charaWeapon = new Dictionary<string, string>();
|
|
|
|
|
public Dictionary<string, string> attachmentPosition = new Dictionary<string, string>();
|
|
|
|
|
public float speed;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
@ -29,6 +32,7 @@ public class Main : MonoBehaviour
|
|
|
|
|
loadCharaCSV();
|
|
|
|
|
loadWeaponCSV();
|
|
|
|
|
loadAttachmentCSV();
|
|
|
|
|
speed = 1.0f;
|
|
|
|
|
|
|
|
|
|
GameObject.Find("charaDropdown").GetComponent<Dropdown>().value = 14;
|
|
|
|
|
}
|
|
|
|
@ -122,6 +126,8 @@ public class Main : MonoBehaviour
|
|
|
|
|
charaAssetsNames.TryGetValue(charaName, out assetNames);
|
|
|
|
|
loadPrefab(charaName, assetNames, ref chara);
|
|
|
|
|
if (charaWeapon[charaName] != null) loadWeapon(charaWeapon[charaName]);
|
|
|
|
|
originAnimator = chara.GetComponent<Animator>().runtimeAnimatorController;
|
|
|
|
|
charaFaceRender = chara.GetComponentsInChildren<SkinnedMeshRenderer>()[1];
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -155,6 +161,7 @@ public class Main : MonoBehaviour
|
|
|
|
|
Destroy(parent.GetChild(i).gameObject);
|
|
|
|
|
Transform childL = Utils.findChildRecursive(weaponL.transform, "l_weapon");
|
|
|
|
|
Transform childR = Utils.findChildRecursive(weaponL.transform, "r_weapon");
|
|
|
|
|
removeWeaponButtonListener("L");
|
|
|
|
|
if (childL != null)
|
|
|
|
|
{
|
|
|
|
|
addWeaponButtonListener(childL.gameObject.AddComponent<RemoveAnimationTransfrom>(), "L");
|
|
|
|
@ -181,6 +188,7 @@ public class Main : MonoBehaviour
|
|
|
|
|
Destroy(parent.GetChild(i).gameObject);
|
|
|
|
|
Transform childL = Utils.findChildRecursive(weaponR.transform, "l_weapon");
|
|
|
|
|
Transform childR = Utils.findChildRecursive(weaponR.transform, "r_weapon");
|
|
|
|
|
removeWeaponButtonListener("R");
|
|
|
|
|
if (childL != null)
|
|
|
|
|
{
|
|
|
|
|
addWeaponButtonListener(childL.gameObject.AddComponent<RemoveAnimationTransfrom>(), "R");
|
|
|
|
@ -263,8 +271,6 @@ public class Main : MonoBehaviour
|
|
|
|
|
var animatorName = names[i];
|
|
|
|
|
var bundle = AssetBundle.LoadFromFile(basePath + animatorName);
|
|
|
|
|
var aoc = bundle.LoadAsset<AnimatorOverrideController>(animatorName);
|
|
|
|
|
if (originAnimator == null)
|
|
|
|
|
originAnimator = chara.GetComponent<Animator>().runtimeAnimatorController;
|
|
|
|
|
chara.GetComponent<Animator>().runtimeAnimatorController = aoc;
|
|
|
|
|
bundle.Unload(false);
|
|
|
|
|
}
|
|
|
|
@ -273,18 +279,31 @@ public class Main : MonoBehaviour
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Internal
|
|
|
|
|
void addWeaponButtonListener(RemoveAnimationTransfrom rat, string LR)
|
|
|
|
|
#region Face
|
|
|
|
|
public void setFace(int i)
|
|
|
|
|
{
|
|
|
|
|
GameObject.Find("faceDropdown").GetComponent<Dropdown>().value = i;
|
|
|
|
|
faceOverride = i;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Model Internal
|
|
|
|
|
void removeWeaponButtonListener(string LR)
|
|
|
|
|
{
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}x", LR)).GetComponent<Button>().onClick.RemoveAllListeners();
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}x", LR)).GetComponent<Button>().onClick.AddListener(rat.xReverse);
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}y", LR)).GetComponent<Button>().onClick.RemoveAllListeners();
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}y", LR)).GetComponent<Button>().onClick.AddListener(rat.yReverse);
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}z", LR)).GetComponent<Button>().onClick.RemoveAllListeners();
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}z", LR)).GetComponent<Button>().onClick.AddListener(rat.zReverse);
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}p", LR)).GetComponent<Button>().onClick.RemoveAllListeners();
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}p", LR)).GetComponent<Button>().onClick.AddListener(rat.zPlus);
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}m", LR)).GetComponent<Button>().onClick.RemoveAllListeners();
|
|
|
|
|
}
|
|
|
|
|
void addWeaponButtonListener(RemoveAnimationTransfrom rat, string LR)
|
|
|
|
|
{
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}x", LR)).GetComponent<Button>().onClick.AddListener(rat.xReverse);
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}y", LR)).GetComponent<Button>().onClick.AddListener(rat.yReverse);
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}z", LR)).GetComponent<Button>().onClick.AddListener(rat.zReverse);
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}p", LR)).GetComponent<Button>().onClick.AddListener(rat.zPlus);
|
|
|
|
|
GameObject.Find(string.Format("weapon{0}m", LR)).GetComponent<Button>().onClick.AddListener(rat.zMinus);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -322,35 +341,159 @@ public class Main : MonoBehaviour
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Action
|
|
|
|
|
public void setState(int i)
|
|
|
|
|
{
|
|
|
|
|
if (i != 1) removeWeapon();
|
|
|
|
|
if (i == 2 || i == 3) chara.transform.rotation = Quaternion.Euler(0, 180, 0);
|
|
|
|
|
else chara.transform.rotation = Quaternion.Euler(0, 0, 0);
|
|
|
|
|
if (chara.GetComponent<Animator>() != null)
|
|
|
|
|
chara.GetComponent<Animator>().SetInteger(Animator.StringToHash("State"), i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRoom(int i)
|
|
|
|
|
{
|
|
|
|
|
setState(6);
|
|
|
|
|
string[] names = {
|
|
|
|
|
"RoomAwake",
|
|
|
|
|
"RoomPresent", // not implement
|
|
|
|
|
"RoomFavorite",
|
|
|
|
|
"RoomJoy",
|
|
|
|
|
"RoomFaint"
|
|
|
|
|
};
|
|
|
|
|
setTrigger(names[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
public void setTurn(float i)
|
|
|
|
|
{
|
|
|
|
|
setState(1);
|
|
|
|
|
setFloat("Turn", i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDamageScale(float i)
|
|
|
|
|
{
|
|
|
|
|
setState(1);
|
|
|
|
|
setFloat("Damage_Scale", i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDamage()
|
|
|
|
|
{
|
|
|
|
|
setState(1);
|
|
|
|
|
setTrigger("Damage");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setHolding(bool i)
|
|
|
|
|
{
|
|
|
|
|
setState(1);
|
|
|
|
|
setBool("Holding", i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAttack(int i)
|
|
|
|
|
{
|
|
|
|
|
setState(1);
|
|
|
|
|
if (i == 1 || i == 2 || i == 3) setFace(1);
|
|
|
|
|
string[] names = {
|
|
|
|
|
"Attack_A",
|
|
|
|
|
"Attack_A_002",
|
|
|
|
|
"Attack_A_003",
|
|
|
|
|
"Attack_A_004",
|
|
|
|
|
"Attack_B"
|
|
|
|
|
};
|
|
|
|
|
setTrigger(names[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setSpeed(float value)
|
|
|
|
|
{
|
|
|
|
|
speed = value;
|
|
|
|
|
if (chara.GetComponent<Animator>() != null)
|
|
|
|
|
chara.GetComponent<Animator>().speed = value;
|
|
|
|
|
if (weapon && weapon.GetComponent<Animator>() != null)
|
|
|
|
|
weapon.GetComponent<Animator>().speed = value;
|
|
|
|
|
if (weaponL && weaponL.GetComponent<Animator>() != null)
|
|
|
|
|
weaponL.GetComponent<Animator>().speed = value;
|
|
|
|
|
if (weaponR && weaponR.GetComponent<Animator>() != null)
|
|
|
|
|
weaponR.GetComponent<Animator>().speed = value;
|
|
|
|
|
GameObject.Find("speedinput").GetComponent<InputField>().text = String.Format("{0:0.00}", value);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Action Internal
|
|
|
|
|
void setTrigger(string triggerName)
|
|
|
|
|
{
|
|
|
|
|
if (chara.GetComponent<Animator>() != null)
|
|
|
|
|
chara.GetComponent<Animator>().SetTrigger(Animator.StringToHash(triggerName));
|
|
|
|
|
if (weapon && weapon.GetComponent<Animator>() != null)
|
|
|
|
|
weapon.GetComponent<Animator>().SetTrigger(Animator.StringToHash(triggerName));
|
|
|
|
|
if (weaponL && weaponL.GetComponent<Animator>() != null)
|
|
|
|
|
weaponL.GetComponent<Animator>().SetTrigger(Animator.StringToHash(triggerName));
|
|
|
|
|
if (weaponR && weaponR.GetComponent<Animator>() != null)
|
|
|
|
|
weaponR.GetComponent<Animator>().SetTrigger(Animator.StringToHash(triggerName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setFloat(string triggerName, float value)
|
|
|
|
|
{
|
|
|
|
|
if (chara.GetComponent<Animator>() != null)
|
|
|
|
|
chara.GetComponent<Animator>().SetFloat(Animator.StringToHash(triggerName), value);
|
|
|
|
|
if (weapon && weapon.GetComponent<Animator>() != null)
|
|
|
|
|
weapon.GetComponent<Animator>().SetFloat(Animator.StringToHash(triggerName), value);
|
|
|
|
|
if (weaponL && weaponL.GetComponent<Animator>() != null)
|
|
|
|
|
weaponL.GetComponent<Animator>().SetFloat(Animator.StringToHash(triggerName), value);
|
|
|
|
|
if (weaponR && weaponR.GetComponent<Animator>() != null)
|
|
|
|
|
weaponR.GetComponent<Animator>().SetFloat(Animator.StringToHash(triggerName), value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setBool(string triggerName, bool value)
|
|
|
|
|
{
|
|
|
|
|
if (chara.GetComponent<Animator>() != null)
|
|
|
|
|
chara.GetComponent<Animator>().SetBool(Animator.StringToHash(triggerName), value);
|
|
|
|
|
if (weapon && weapon.GetComponent<Animator>() != null)
|
|
|
|
|
weapon.GetComponent<Animator>().SetBool(Animator.StringToHash(triggerName), value);
|
|
|
|
|
if (weaponL && weaponL.GetComponent<Animator>() != null)
|
|
|
|
|
weaponL.GetComponent<Animator>().SetBool(Animator.StringToHash(triggerName), value);
|
|
|
|
|
if (weaponR && weaponR.GetComponent<Animator>() != null)
|
|
|
|
|
weaponR.GetComponent<Animator>().SetBool(Animator.StringToHash(triggerName), value);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Input.GetMouseButtonDown(0))
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.Alpha1)) setState(1);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.Alpha2)) setState(2);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.Alpha3)) setState(3);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.Alpha4)) setState(4);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.Alpha5)) setState(5);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.Alpha6)) setState(6);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.V)) setRoom(0);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.B)) setRoom(2);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.N)) setRoom(3);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.M)) setRoom(4);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.A)) setAttack(0);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.S)) setAttack(1);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.D)) setAttack(2);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.F)) setAttack(3);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.G)) setAttack(4);
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.X)) setDamage();
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.Space))
|
|
|
|
|
GameObject.Find("stopbutton").GetComponent<Button>().onClick.Invoke();
|
|
|
|
|
else if (Input.GetKeyDown(KeyCode.Z))
|
|
|
|
|
{
|
|
|
|
|
Toggle t = GameObject.Find("holdingtoggle").GetComponent<Toggle>();
|
|
|
|
|
t.isOn = !t.isOn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Animator animator = model.GetComponent<Animator>();
|
|
|
|
|
//RuntimeAnimatorController rac = animator.runtimeAnimatorController;
|
|
|
|
|
//foreach (AnimationClip a in rac.animationClips)
|
|
|
|
|
//{
|
|
|
|
|
// //Debug.Log(a);
|
|
|
|
|
//}
|
|
|
|
|
////animator.Play(Animator.StringToHash("Extra_Attack_C_001_ref"), 0);
|
|
|
|
|
///
|
|
|
|
|
//chara.GetComponent<Animator>().SetTrigger(Animator.StringToHash("Attack_A"));
|
|
|
|
|
//weaponL.GetComponent<Animator>().SetTrigger(Animator.StringToHash("Attack_A"));
|
|
|
|
|
//weaponR.GetComponent<Animator>().SetTrigger(Animator.StringToHash("Attack_A"));
|
|
|
|
|
|
|
|
|
|
////animator.SetInteger(Animator.StringToHash("State"), 2);
|
|
|
|
|
////Animator animator2 = weapon.GetComponent<Animator>();
|
|
|
|
|
////animator2.SetInteger(Animator.StringToHash("State"), 2);
|
|
|
|
|
|
|
|
|
|
//chara.GetComponent<Animator>().SetBool(Animator.StringToHash("Holding"), true);
|
|
|
|
|
//weapon.GetComponent<Animator>().SetBool(Animator.StringToHash("Holding"), true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Input.GetMouseButtonDown(1))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//MotionEffectManager mem = chara.GetComponent<MotionEffectManager>();
|
|
|
|
|
//mem.isAttached = true;
|
|
|
|
@ -358,11 +501,20 @@ public class Main : MonoBehaviour
|
|
|
|
|
//mem.initialize();
|
|
|
|
|
//mem.TriggerEffect("StartEffect_attack_c_003");
|
|
|
|
|
|
|
|
|
|
//MotionEffectManager mem2 = weapon.GetComponent<MotionEffectManager>();
|
|
|
|
|
//mem2.isAttached = true;
|
|
|
|
|
//mem2.attachmentMotionIndex = 0;
|
|
|
|
|
//mem2.initialize();
|
|
|
|
|
//mem2.TriggerEffect("StartEffect_attack_c_002");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LateUpdate()
|
|
|
|
|
{
|
|
|
|
|
if (faceOverride != 0)
|
|
|
|
|
{
|
|
|
|
|
float u = (faceOverride == 1 || faceOverride == 3 ? 0f : 0.5f);
|
|
|
|
|
float v = (faceOverride == 1 || faceOverride == 2 ? 0f : 0.5f);
|
|
|
|
|
MaterialPropertyBlock block = new MaterialPropertyBlock();
|
|
|
|
|
charaFaceRender.GetPropertyBlock(block);
|
|
|
|
|
block.SetVector("_DecalTex_ST", new Vector4(1f, 1f, u, v));
|
|
|
|
|
charaFaceRender.SetPropertyBlock(block);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|