資源簡介
武士2可能4~5年前已經(jīng)在網(wǎng)絡上流傳開來,這是一捷克大神出品的神作
新手可能苦于有源碼缺好像無從入門(其實這游戲一開始要打包到Android真機測試,但無論是模擬器或者真機,對于Unity高級程序都是很難進行調(diào)
試)
這項目就是為了解決這個問題,是一個使武士2源碼能支持PC鼠標和鍵盤操作的擴展源碼
這只是擴展非完整項目

代碼片段和文件信息
using?UnityEngine;
using?System.Collections;
using?System.Collections.Generic;
public?class?PlayerControls
{
????public?enum??E_ButtonStatus
????{
????????UpFirst
????????Up
????????DownFirst
????????Down
????????Cancel
????}
????public?enum?E_ButtonsName
????{
????????None?=?-1
????????AttackX
????????AttackO
????????Roll
????????Use
????????Shop
????????InGameMenu
????????ShopOk
????????ShopCancel
????????ShopHealth
????????ShopSword
????????ShopCombo1
????????ShopCombo2
????????ShopCombo3
????????ShopCombo4
????????ShopCombo5
????????ShopCombo6
????????ShopInfoBuy
????????ShopInfoBack
????????Max
????}
????public?class?Button
????{
????????public?int?FingerId?=?-1;
????????public?E_ButtonStatus?Status?=?E_ButtonStatus.Up;
????????public?bool?On?=?true;
????????public?float?PressTime?=?-1;
????????
????????bool?useRadius;
????????public?Vector2?Center;
????????float?Left?Bottom?Width?Height;
????????public?Button(Vector2?center)?{
????????????Center?=?center;?useRadius?=?true;?
????????}
????????
????????public?Button(float?left?float?bottom?float?witdth?float?height)?{?Left?=?left;?Bottom?=?bottom;?Width?=?witdth;?Height?=?height;?useRadius?=?false;?}
????????public?void?SetCenter(Vector2?center)?{?Center?=?center;?}
????????//public?bool?IsInsideButton(Touch?touch)
public?bool?IsInsideButton(Vector2?touchPos)
????????{
????????????if?(useRadius)
????????????{
if?((touchPos?-?Center).magnitude?0.07f?*?Screen.width)
????????????????????return?true;
????????????}
????????????else
????????????{
if?(touchPos.x?>?Left?&&?touchPos.x? ????touchPos.y?>?Bottom&&?touchPos.y?????????????????{
????????????????????return?true;
????????????????}
????????????}
????????????return?false;
????????}
????}
????public?class?JoystickControl
????{
????????public?int?FingerID?=?-1;
????????public?float?DeadZone?{?get?{?return?0.01f?*?Screen.width;?}?}
????????public?float?Radius?{get?{?return?0.075f?*?Screen.width;}}
????????public?bool?On?=?true;
????????public?Vector3?Direction?=?new?Vector2();
????????public?float?Force;
????????public?Vector2?Center;
????????public?JoystickControl(Vector2?center)?{?Center?=?center;?}
????????public?void?SetCenter(Vector2?center)?{?Center?=?center;?}
????}
????Transform?_Temp;
????public?Button[]?Buttons;
????public?JoystickControl?Joystick?=?null;
????Transform?MainCameraTransfom;
????public?void?Start()
????{
????????Gameobject?t?=?new?Gameobject();
????????_Temp?=?t.transform;
????????MainCameraTransfom?=?Camera.main.transform;
???????Buttons?=?new?Button[]?{
????????????new?Button(Game.Instance.ButtonXPositon?+?new?Vector2(GuiButtonX.Instance.ScreenWidth?*?0.5f?GuiButtonX.Instance.ScreenHeight?*0.5f))?
????????????new?Button(Game.Instance.ButtonOPositon?+?new?Vector2(GuiButtonY.Instance.ScreenWidth?*?0.5f?GuiBu
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-04-23?02:06??wushi——Pc鍵盤操作腳本備份\
?????目錄???????????0??2018-04-23?00:38??wushi——Pc鍵盤操作腳本備份\Assets\
?????目錄???????????0??2018-04-23?00:40??wushi——Pc鍵盤操作腳本備份\Assets\sc
?????目錄???????????0??2018-04-23?00:38??wushi——Pc鍵盤操作腳本備份\Assets\sc
?????目錄???????????0??2018-04-23?00:38??wushi——Pc鍵盤操作腳本備份\Assets\sc
?????文件???????20016??2018-04-23?02:04??wushi——Pc鍵盤操作腳本備份\Assets\sc
?????目錄???????????0??2018-04-23?00:41??wushi——Pc鍵盤操作腳本備份\Assets\sc
?????文件????????9799??2018-04-18?15:54??wushi——Pc鍵盤操作腳本備份\Assets\sc
?????文件???????14376??2018-04-18?15:53??wushi——Pc鍵盤操作腳本備份\Assets\sc
?????文件???????26068??2018-04-18?19:17??wushi——Pc鍵盤操作腳本備份\Assets\sc
?????文件?????????674??2018-04-23?02:14??wushi——Pc鍵盤操作腳本備份\readme.txt
評論
共有 條評論