-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
public class Bag : MonoBehaviour { | ||
|
||
private Manager GM; | ||
private Image gridImage; | ||
private int mouseType = 0; | ||
|
||
public Sprite none; | ||
public Sprite weapon1; | ||
public Sprite weapon2; | ||
public Sprite weapon3; | ||
|
||
// Use this for initialization | ||
void Start () { | ||
GM = (Manager)FindObjectOfType(typeof(Manager)); | ||
gridImage = GetComponent<Image>(); | ||
weapon1 = GameObject.Find("Grid1").GetComponent<Image>().sprite; | ||
weapon2 = GameObject.Find("Grid2").GetComponent<Image>().sprite; | ||
weapon3 = GameObject.Find("Grid3").GetComponent<Image>().sprite; | ||
none = GameObject.Find("Grid4").GetComponent<Image>().sprite; | ||
Debug.Log(gridImage.sprite == weapon1); | ||
Debug.Log(weapon1); | ||
Debug.Log(weapon2); | ||
Debug.Log(weapon3); | ||
this.GetComponent<Button>().onClick.AddListener(OnBagButton); | ||
} | ||
|
||
// Update is called once per frame | ||
void Update () { | ||
|
||
} | ||
|
||
public void OnBagButton() | ||
{ | ||
//Debug.Log("grid click"); | ||
mouseType = GM.getMouse().getMouseType(); | ||
if (gridImage.sprite == none && mouseType != 0) | ||
{ | ||
switch (mouseType) | ||
{ | ||
case 1: | ||
gridImage.sprite = weapon1; | ||
break; | ||
case 2: | ||
gridImage.sprite = weapon2; | ||
break; | ||
case 3: | ||
gridImage.sprite = weapon3; | ||
break; | ||
default: | ||
gridImage.sprite = none; | ||
break; | ||
} | ||
GM.getMouse().setMouseType(0); | ||
} | ||
else | ||
{ | ||
//Debug.Log(gridImage.sprite); | ||
//Debug.Log(mouseType); | ||
if (gridImage.sprite == none) | ||
{ | ||
GM.getMouse().setMouseType(0); | ||
} | ||
else if (gridImage.sprite == weapon1) | ||
{ | ||
GM.getMouse().setMouseType(1); | ||
} | ||
else if (gridImage.sprite == weapon2) | ||
{ | ||
GM.getMouse().setMouseType(2); | ||
} | ||
else if (gridImage.sprite == weapon3) | ||
{ | ||
GM.getMouse().setMouseType(3); | ||
} | ||
|
||
switch (mouseType) | ||
{ | ||
case 0: | ||
gridImage.sprite = none; | ||
break; | ||
case 1: | ||
gridImage.sprite = weapon1; | ||
break; | ||
case 2: | ||
gridImage.sprite = weapon2; | ||
break; | ||
case 3: | ||
gridImage.sprite = weapon3; | ||
break; | ||
default: | ||
gridImage.sprite = none; | ||
break; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class BagTilt : MonoBehaviour { | ||
|
||
public Vector2 range = new Vector2(50f, 30f); | ||
|
||
Transform mTrans; | ||
Quaternion mStart; | ||
Vector2 mRot = Vector2.zero; | ||
|
||
// Use this for initialization | ||
void Start() | ||
{ | ||
mTrans = transform; | ||
mStart = mTrans.localRotation; | ||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
Vector3 pos = Input.mousePosition; | ||
//Debug.Log(pos); | ||
|
||
float halfWidth = Screen.width * 0.5f; | ||
float halfHeight = Screen.height * 0.5f; | ||
|
||
if (pos.x - halfWidth < 0) return; | ||
|
||
float x = Mathf.Clamp((pos.x - halfWidth) / halfWidth, -1f, 1f); | ||
float y = Mathf.Clamp((pos.y - halfHeight) / halfHeight, -1f, 1f); | ||
mRot = Vector2.Lerp(mRot, new Vector2(x, y), Time.deltaTime * 5f); | ||
|
||
mTrans.localRotation = mStart * Quaternion.Euler(-mRot.y * range.y, -mRot.x * range.x, 0f); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!21 &2100000 | ||
Material: | ||
serializedVersion: 6 | ||
m_ObjectHideFlags: 0 | ||
m_PrefabParentObject: {fileID: 0} | ||
m_PrefabInternal: {fileID: 0} | ||
m_Name: samuzai_animation_ok-13 - Default | ||
m_Shader: {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} | ||
m_ShaderKeywords: | ||
m_LightmapFlags: 4 | ||
m_EnableInstancingVariants: 0 | ||
m_DoubleSidedGI: 0 | ||
m_CustomRenderQueue: -1 | ||
stringTagMap: {} | ||
disabledShaderPasses: [] | ||
m_SavedProperties: | ||
serializedVersion: 3 | ||
m_TexEnvs: | ||
- _MainTex: | ||
m_Texture: {fileID: 2800000, guid: 1a61d3675f0d46b43a84ed25051ccf14, type: 3} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
m_Floats: [] | ||
m_Colors: | ||
- _Color: {r: 0.5882353, g: 0.5882353, b: 0.5882353, a: 1} | ||
--- !u!1002 &2100001 | ||
EditorExtensionImpl: | ||
serializedVersion: 6 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!21 &2100000 | ||
Material: | ||
serializedVersion: 6 | ||
m_ObjectHideFlags: 0 | ||
m_PrefabParentObject: {fileID: 0} | ||
m_PrefabInternal: {fileID: 0} | ||
m_Name: samuzai_animation_ok-19 - Default1 | ||
m_Shader: {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} | ||
m_ShaderKeywords: | ||
m_LightmapFlags: 4 | ||
m_EnableInstancingVariants: 0 | ||
m_DoubleSidedGI: 0 | ||
m_CustomRenderQueue: -1 | ||
stringTagMap: {} | ||
disabledShaderPasses: [] | ||
m_SavedProperties: | ||
serializedVersion: 3 | ||
m_TexEnvs: | ||
- _MainTex: | ||
m_Texture: {fileID: 2800000, guid: 5de33d0774b00fc419e636a27a74b40a, type: 3} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
m_Floats: [] | ||
m_Colors: | ||
- _Color: {r: 0.5882353, g: 0.5882353, b: 0.5882353, a: 1} | ||
--- !u!1002 &2100001 | ||
EditorExtensionImpl: | ||
serializedVersion: 6 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!21 &2100000 | ||
Material: | ||
serializedVersion: 6 | ||
m_ObjectHideFlags: 0 | ||
m_PrefabParentObject: {fileID: 0} | ||
m_PrefabInternal: {fileID: 0} | ||
m_Name: samuzai_animation_ok-20 - Default | ||
m_Shader: {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} | ||
m_ShaderKeywords: | ||
m_LightmapFlags: 4 | ||
m_EnableInstancingVariants: 0 | ||
m_DoubleSidedGI: 0 | ||
m_CustomRenderQueue: -1 | ||
stringTagMap: {} | ||
disabledShaderPasses: [] | ||
m_SavedProperties: | ||
serializedVersion: 3 | ||
m_TexEnvs: | ||
- _MainTex: | ||
m_Texture: {fileID: 2800000, guid: 1f026ad71b2bea549a827c910c6e632f, type: 3} | ||
m_Scale: {x: 1, y: 1} | ||
m_Offset: {x: 0, y: 0} | ||
m_Floats: [] | ||
m_Colors: | ||
- _Color: {r: 0.5882353, g: 0.5882353, b: 0.5882353, a: 1} | ||
--- !u!1002 &2100001 | ||
EditorExtensionImpl: | ||
serializedVersion: 6 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.