Skip to content

Commit 89ef0c5

Browse files
committed
up
1 parent cda1918 commit 89ef0c5

File tree

5 files changed

+44
-32
lines changed

5 files changed

+44
-32
lines changed

Assets/Scripts/kbe_scripts/Avatar.cs

902 Bytes
Binary file not shown.

Assets/Scripts/u3d_scripts/UI.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,7 @@ void onWorldUI()
230230
{
231231
if(GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2, 200, 30), "Relive(复活)"))
232232
{
233-
if(KBEngineApp.app.entity_type == "Avatar")
234-
{
235-
KBEngine.Avatar avatar = (KBEngine.Avatar)KBEngineApp.app.player();
236-
if(avatar != null)
237-
avatar.relive(1);
238-
}
233+
KBEngine.Event.fireIn("relive", (Byte)1);
239234
}
240235
}
241236

Assets/Scripts/u3d_scripts/World.cs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,33 @@ void Update ()
6363
if (Input.GetKeyUp(KeyCode.Space))
6464
{
6565
Debug.Log("KeyCode.Space");
66-
67-
if(KBEngineApp.app.entity_type == "Avatar")
66+
KBEngine.Event.fireIn("jump");
67+
}
68+
else if (Input.GetMouseButton (0))
69+
{
70+
// 射线选择,攻击
71+
if(Camera.main)
6872
{
69-
KBEngine.Avatar avatar = (KBEngine.Avatar)KBEngineApp.app.player();
70-
if(avatar != null)
71-
avatar.jump();
73+
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
74+
RaycastHit hit;
75+
76+
if (Physics.Raycast(ray, out hit))
77+
{
78+
Debug.DrawLine (ray.origin, hit.point);
79+
UnityEngine.GameObject gameObj = hit.collider.gameObject;
80+
if(gameObj.name.IndexOf("terrain") == -1)
81+
{
82+
string[] s = gameObj.name.Split(new char[]{'_' });
83+
84+
if(s.Length > 0)
85+
{
86+
int targetEntityID = Convert.ToInt32(s[s.Length - 1]);
87+
KBEngine.Event.fireIn("useTargetSkill", (Int32)1, (Int32)targetEntityID);
88+
}
89+
}
90+
}
7291
}
73-
}
92+
}
7493
}
7594

7695
public void addSpaceGeometryMapping(string respath)
@@ -159,7 +178,7 @@ public void onEnterWorld(KBEngine.Entity entity)
159178
entity.renderObj = Instantiate(entityPerfab, new Vector3(entity.position.x, y, entity.position.z),
160179
Quaternion.Euler(new Vector3(entity.direction.y, entity.direction.z, entity.direction.x))) as UnityEngine.GameObject;
161180

162-
((UnityEngine.GameObject)entity.renderObj).name = entity.className + entity.id;
181+
((UnityEngine.GameObject)entity.renderObj).name = entity.className + "_" + entity.id;
163182

164183
object speed = entity.getDefinedPropterty("moveSpeed");
165184
if(speed != null)

Assets/Standard Assets/Character Controllers/Sources/Scripts/MouseLook.cs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,23 @@ public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
3232

3333
void Update ()
3434
{
35-
if (axes == RotationAxes.MouseXAndY)
35+
if (Input.GetMouseButton (1))
3636
{
37-
float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
38-
39-
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
40-
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
41-
42-
transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
43-
}
44-
else if (axes == RotationAxes.MouseX)
45-
{
46-
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
47-
}
48-
else
49-
{
50-
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
51-
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
52-
53-
transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
37+
if (axes == RotationAxes.MouseXAndY) {
38+
float rotationX = transform.localEulerAngles.y + Input.GetAxis ("Mouse X") * sensitivityX;
39+
40+
rotationY += Input.GetAxis ("Mouse Y") * sensitivityY;
41+
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
42+
43+
transform.localEulerAngles = new Vector3 (-rotationY, rotationX, 0);
44+
} else if (axes == RotationAxes.MouseX) {
45+
transform.Rotate (0, Input.GetAxis ("Mouse X") * sensitivityX, 0);
46+
} else {
47+
rotationY += Input.GetAxis ("Mouse Y") * sensitivityY;
48+
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
49+
50+
transform.localEulerAngles = new Vector3 (-rotationY, transform.localEulerAngles.y, 0);
51+
}
5452
}
5553
}
5654

0 commit comments

Comments
 (0)