初期コミット
This commit is contained in:
71
Assets/Yurowm/Demo/Scripts/Actions.cs
Normal file
71
Assets/Yurowm/Demo/Scripts/Actions.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
[RequireComponent (typeof (Animator))]
|
||||
public class Actions : MonoBehaviour {
|
||||
|
||||
private Animator animator;
|
||||
|
||||
const int countOfDamageAnimations = 3;
|
||||
int lastDamageAnimation = -1;
|
||||
|
||||
void Awake () {
|
||||
animator = GetComponent<Animator> ();
|
||||
}
|
||||
|
||||
public void Stay () {
|
||||
animator.SetBool("Aiming", false);
|
||||
animator.SetFloat ("Speed", 0f);
|
||||
}
|
||||
|
||||
public void Walk () {
|
||||
animator.SetBool("Aiming", false);
|
||||
animator.SetFloat ("Speed", 0.5f);
|
||||
}
|
||||
|
||||
public void Run () {
|
||||
animator.SetBool("Aiming", false);
|
||||
animator.SetFloat ("Speed", 1f);
|
||||
}
|
||||
|
||||
public void Attack () {
|
||||
Aiming ();
|
||||
animator.SetTrigger ("Attack");
|
||||
}
|
||||
|
||||
public void Death () {
|
||||
if (animator.GetCurrentAnimatorStateInfo (0).IsName ("Death"))
|
||||
animator.Play("Idle", 0);
|
||||
else
|
||||
animator.SetTrigger ("Death");
|
||||
}
|
||||
|
||||
public void Damage () {
|
||||
if (animator.GetCurrentAnimatorStateInfo (0).IsName ("Death")) return;
|
||||
int id = Random.Range(0, countOfDamageAnimations);
|
||||
if (countOfDamageAnimations > 1)
|
||||
while (id == lastDamageAnimation)
|
||||
id = Random.Range(0, countOfDamageAnimations);
|
||||
lastDamageAnimation = id;
|
||||
animator.SetInteger ("DamageID", id);
|
||||
animator.SetTrigger ("Damage");
|
||||
}
|
||||
|
||||
public void Jump () {
|
||||
animator.SetBool ("Squat", false);
|
||||
animator.SetFloat ("Speed", 0f);
|
||||
animator.SetBool("Aiming", false);
|
||||
animator.SetTrigger ("Jump");
|
||||
}
|
||||
|
||||
public void Aiming () {
|
||||
animator.SetBool ("Squat", false);
|
||||
animator.SetFloat ("Speed", 0f);
|
||||
animator.SetBool("Aiming", true);
|
||||
}
|
||||
|
||||
public void Sitting () {
|
||||
animator.SetBool ("Squat", !animator.GetBool("Squat"));
|
||||
animator.SetBool("Aiming", false);
|
||||
}
|
||||
}
|
||||
18
Assets/Yurowm/Demo/Scripts/Actions.cs.meta
Normal file
18
Assets/Yurowm/Demo/Scripts/Actions.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a85c5e349cb17df4b85883ea088c2f95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 29235
|
||||
packageName: Contract Killer
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Yurowm/Demo/Scripts/Actions.cs
|
||||
uploadId: 62633
|
||||
93
Assets/Yurowm/Demo/Scripts/CharacterPanel.cs
Normal file
93
Assets/Yurowm/Demo/Scripts/CharacterPanel.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public class CharacterPanel : MonoBehaviour {
|
||||
|
||||
public GameObject character;
|
||||
public Transform weaponsPanel;
|
||||
public Transform actionsPanel;
|
||||
public Transform camerasPanel;
|
||||
public Button buttonPrefab;
|
||||
public Slider motionSpeed;
|
||||
|
||||
Actions actions;
|
||||
PlayerController controller;
|
||||
Camera[] cameras;
|
||||
|
||||
void Start () {
|
||||
Initialize ();
|
||||
}
|
||||
|
||||
void Initialize () {
|
||||
actions = character.GetComponent<Actions> ();
|
||||
controller = character.GetComponent<PlayerController> ();
|
||||
|
||||
foreach (PlayerController.Arsenal a in controller.arsenal)
|
||||
CreateWeaponButton(a.name);
|
||||
|
||||
CreateActionButton("Stay");
|
||||
CreateActionButton("Walk");
|
||||
CreateActionButton("Run");
|
||||
CreateActionButton("Sitting");
|
||||
CreateActionButton("Jump");
|
||||
CreateActionButton("Aiming");
|
||||
CreateActionButton("Attack");
|
||||
CreateActionButton("Damage");
|
||||
CreateActionButton("Death Reset", "Death");
|
||||
|
||||
cameras = GameObject.FindObjectsOfType<Camera> ();
|
||||
var sort = from s in cameras orderby s.name select s;
|
||||
|
||||
foreach (Camera c in sort)
|
||||
CreateCameraButton(c);
|
||||
|
||||
camerasPanel.GetChild (0).GetComponent<Button>().onClick.Invoke();
|
||||
}
|
||||
|
||||
void CreateWeaponButton(string name) {
|
||||
Button button = CreateButton (name, weaponsPanel);
|
||||
button.onClick.AddListener(() => controller.SetArsenal(name));
|
||||
}
|
||||
|
||||
void CreateActionButton(string name) {
|
||||
CreateActionButton(name, name);
|
||||
}
|
||||
|
||||
void CreateActionButton(string name, string message) {
|
||||
Button button = CreateButton (name, actionsPanel);
|
||||
button.onClick.AddListener(() => actions.SendMessage(message, SendMessageOptions.DontRequireReceiver));
|
||||
}
|
||||
|
||||
void CreateCameraButton (Camera c) {
|
||||
Button button = CreateButton (c.name, camerasPanel);
|
||||
button.onClick.AddListener(() => {
|
||||
ShowCamera(c);
|
||||
});
|
||||
}
|
||||
|
||||
Button CreateButton(string name, Transform group) {
|
||||
GameObject obj = (GameObject) Instantiate (buttonPrefab.gameObject);
|
||||
obj.name = name;
|
||||
obj.transform.SetParent(group);
|
||||
obj.transform.localScale = Vector3.one;
|
||||
Text text = obj.transform.GetChild (0).GetComponent<Text> ();
|
||||
text.text = name;
|
||||
return obj.GetComponent<Button> ();
|
||||
}
|
||||
|
||||
void ShowCamera (Camera cam) {
|
||||
foreach (Camera c in cameras)
|
||||
c.gameObject.SetActive(c == cam);
|
||||
}
|
||||
|
||||
void Update() {
|
||||
Time.timeScale = motionSpeed.value;
|
||||
}
|
||||
|
||||
public void OpenPublisherPage() {
|
||||
Application.OpenURL ("https://www.assetstore.unity3d.com/en/#!/publisher/11008");
|
||||
}
|
||||
}
|
||||
18
Assets/Yurowm/Demo/Scripts/CharacterPanel.cs.meta
Normal file
18
Assets/Yurowm/Demo/Scripts/CharacterPanel.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faff4e71621cfa64582e837b57a15288
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 29235
|
||||
packageName: Contract Killer
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Yurowm/Demo/Scripts/CharacterPanel.cs
|
||||
uploadId: 62633
|
||||
37
Assets/Yurowm/Demo/Scripts/CharacterViewer.cs
Normal file
37
Assets/Yurowm/Demo/Scripts/CharacterViewer.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CharacterViewer : MonoBehaviour {
|
||||
|
||||
public Transform cameras;
|
||||
|
||||
Transform targetForCamera;
|
||||
Vector3 deltaPosition;
|
||||
Vector3 lastPosition = Vector3.zero;
|
||||
bool rotating = false;
|
||||
|
||||
void Awake () {
|
||||
targetForCamera = GameObject.Find ("RigSpine3").transform;
|
||||
deltaPosition = cameras.position - targetForCamera.position;
|
||||
}
|
||||
|
||||
void Update () {
|
||||
if (Input.GetMouseButtonDown (0) && Input.mousePosition.x < Screen.width * 0.6f) {
|
||||
lastPosition = Input.mousePosition;
|
||||
rotating = true;
|
||||
}
|
||||
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
rotating = false;
|
||||
|
||||
if (rotating && Input.GetMouseButton(0))
|
||||
transform.Rotate(0, -300f * (Input.mousePosition - lastPosition).x / Screen.width, 0);
|
||||
|
||||
lastPosition = Input.mousePosition;
|
||||
}
|
||||
|
||||
void LateUpdate () {
|
||||
cameras.position += (targetForCamera.position + deltaPosition - cameras.position) * Time.unscaledDeltaTime * 5;
|
||||
}
|
||||
}
|
||||
18
Assets/Yurowm/Demo/Scripts/CharacterViewer.cs.meta
Normal file
18
Assets/Yurowm/Demo/Scripts/CharacterViewer.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b68f89f0558dba64592fe494ff82683c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 29235
|
||||
packageName: Contract Killer
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Yurowm/Demo/Scripts/CharacterViewer.cs
|
||||
uploadId: 62633
|
||||
51
Assets/Yurowm/Demo/Scripts/PlayerController.cs
Normal file
51
Assets/Yurowm/Demo/Scripts/PlayerController.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
[RequireComponent (typeof (Animator))]
|
||||
public class PlayerController : MonoBehaviour {
|
||||
|
||||
public Transform rightGunBone;
|
||||
public Transform leftGunBone;
|
||||
public Arsenal[] arsenal;
|
||||
|
||||
private Animator animator;
|
||||
|
||||
void Awake() {
|
||||
animator = GetComponent<Animator> ();
|
||||
if (arsenal.Length > 0)
|
||||
SetArsenal (arsenal[0].name);
|
||||
}
|
||||
|
||||
public void SetArsenal(string name) {
|
||||
foreach (Arsenal hand in arsenal) {
|
||||
if (hand.name == name) {
|
||||
if (rightGunBone.childCount > 0)
|
||||
Destroy(rightGunBone.GetChild(0).gameObject);
|
||||
if (leftGunBone.childCount > 0)
|
||||
Destroy(leftGunBone.GetChild(0).gameObject);
|
||||
if (hand.rightGun != null) {
|
||||
GameObject newRightGun = (GameObject) Instantiate(hand.rightGun);
|
||||
newRightGun.transform.parent = rightGunBone;
|
||||
newRightGun.transform.localPosition = Vector3.zero;
|
||||
newRightGun.transform.localRotation = Quaternion.Euler(90, 0, 0);
|
||||
}
|
||||
if (hand.leftGun != null) {
|
||||
GameObject newLeftGun = (GameObject) Instantiate(hand.leftGun);
|
||||
newLeftGun.transform.parent = leftGunBone;
|
||||
newLeftGun.transform.localPosition = Vector3.zero;
|
||||
newLeftGun.transform.localRotation = Quaternion.Euler(90, 0, 0);
|
||||
}
|
||||
animator.runtimeAnimatorController = hand.controller;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct Arsenal {
|
||||
public string name;
|
||||
public GameObject rightGun;
|
||||
public GameObject leftGun;
|
||||
public RuntimeAnimatorController controller;
|
||||
}
|
||||
}
|
||||
18
Assets/Yurowm/Demo/Scripts/PlayerController.cs.meta
Normal file
18
Assets/Yurowm/Demo/Scripts/PlayerController.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9aa840a3854ebd47b920d1a5c7d693f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 29235
|
||||
packageName: Contract Killer
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Yurowm/Demo/Scripts/PlayerController.cs
|
||||
uploadId: 62633
|
||||
Reference in New Issue
Block a user