Skip to content

Commit

Permalink
hw8 done
Browse files Browse the repository at this point in the history
  • Loading branch information
gitgiter committed Jun 5, 2018
1 parent 98ccd05 commit 9b23d38
Show file tree
Hide file tree
Showing 104 changed files with 17,782 additions and 2 deletions.
3 changes: 1 addition & 2 deletions homework7/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ void Update()

---
## 其他
- 以上多数为个人理解,可能有误,仅供参考。
- 本次项目觉得做得最好的模式是MVC,在之前几次的基础上渐渐改进,本次项目分离得比较彻底,耦合度低了许多。
- 以上为个人理解,可能有误,仅供参考。
- 如感兴趣,可访问笔者Gayhub博客地址---[传送门](https://gitgiter.github.io/2018/05/28/Unity3d-hw7-%E7%B2%92%E5%AD%90%E7%B3%BB%E7%BB%9F/)
- 视频演示地址---[传送门](https://www.bilibili.com/video/av24039975/)
- csdn博客地址---[传送门]()
Expand Down
Empty file.
Binary file not shown.
101 changes: 101 additions & 0 deletions homework8/BagSystem/Assets/Bag.cs
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;
}
}
}
}
13 changes: 13 additions & 0 deletions homework8/BagSystem/Assets/Bag.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions homework8/BagSystem/Assets/BagTilt.cs
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);
}
}
13 changes: 13 additions & 0 deletions homework8/BagSystem/Assets/BagTilt.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions homework8/BagSystem/Assets/Character Pack.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions homework8/BagSystem/Assets/Character Pack/Materials.meta

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.

10 changes: 10 additions & 0 deletions homework8/BagSystem/Assets/Character Pack/Texture.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9b23d38

Please sign in to comment.