created MissionObject
This commit is contained in:
parent
4d9f59e3c4
commit
ff0652636d
6 changed files with 51 additions and 10 deletions
|
@ -645,9 +645,9 @@ GameObject:
|
|||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 1145874549}
|
||||
- component: {fileID: 1145874548}
|
||||
- component: {fileID: 1145874547}
|
||||
- component: {fileID: 1145874550}
|
||||
- component: {fileID: 1145874548}
|
||||
m_Layer: 10
|
||||
m_Name: Statue
|
||||
m_TagString: Untagged
|
||||
|
@ -675,7 +675,7 @@ MonoBehaviour:
|
|||
onSerializeRigidBodyOption: 2
|
||||
ownershipTransfer: 0
|
||||
ObservedComponents:
|
||||
- {fileID: 1145874548}
|
||||
- {fileID: 0}
|
||||
ObservedComponentsFoldoutOpen: 1
|
||||
viewIdField: 5
|
||||
instantiationId: 5
|
||||
|
@ -689,14 +689,14 @@ MonoBehaviour:
|
|||
m_GameObject: {fileID: 1145874546}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9b3f3e01c4d73ca439fd8977a38cf5b4, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: a2e14842720228c49bf03c30440cbcbf, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_queuedInteractorId: -1
|
||||
_isInteracting: 0
|
||||
interactions:
|
||||
interactions: []
|
||||
spyInteractions:
|
||||
- {fileID: 11400000, guid: 80ca1bec2c07531428cf5a84624e44a4, type: 2}
|
||||
spyInteractions: []
|
||||
--- !u!4 &1145874549
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -20,8 +20,10 @@ public class IdleClickAction : Action
|
|||
|
||||
public override void Act(StateController controller)
|
||||
{
|
||||
// If the user clicks, but not on a UI object ...
|
||||
if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
|
||||
{
|
||||
// If the player was receiving an interaction, this click we've detected is them declining the interaction
|
||||
if (controller.Interactor)
|
||||
{
|
||||
controller.Interactor = null;
|
||||
|
@ -29,8 +31,8 @@ public class IdleClickAction : Action
|
|||
}
|
||||
else
|
||||
{
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
// Check first if the player clicked on a selectable object
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
SelectableObject selectableObject;
|
||||
if (RaycastForSelectableObject(controller, ray, out selectableObject))
|
||||
{
|
||||
|
@ -47,7 +49,7 @@ public class IdleClickAction : Action
|
|||
|
||||
// If the player has selected an object, move the player toward that object
|
||||
if (controller.SelectedObject && !controller.IsInteracting)
|
||||
controller.Destination = controller.SelectedObject.transform.position;
|
||||
controller.MoveToSelectedObject();
|
||||
}
|
||||
|
||||
// Check if StateController clicked on a Selectable Object
|
||||
|
@ -58,9 +60,12 @@ public class IdleClickAction : Action
|
|||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit, 100.0f, mask))
|
||||
{
|
||||
Debug.Log("Found SelectableObject");
|
||||
SelectableObject selectable = hit.collider.gameObject.GetComponentInParent<SelectableObject>();
|
||||
if (selectable != null && selectable != controller && selectable.HasInteractions())
|
||||
if (!selectable.HasInteractions())
|
||||
{
|
||||
Debug.LogError("\"" + selectable.name + "\", a SelectableObject, has no pre-defined interactions.");
|
||||
}
|
||||
else if (selectable != null && !selectable.Equals(controller))
|
||||
{
|
||||
selectableObject = selectable;
|
||||
return true;
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MissionObject : SelectableObject {
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (Interactor != null && !IsInteracting)
|
||||
{
|
||||
AcceptInteraction();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a2e14842720228c49bf03c30440cbcbf
|
||||
timeCreated: 1510178050
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -3,7 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SelectableObject : Photon.PunBehaviour, IEquatable<SelectableObject>
|
||||
public abstract class SelectableObject : Photon.PunBehaviour, IEquatable<SelectableObject>
|
||||
{
|
||||
// PhotonView Id of interacting character
|
||||
[SerializeField]
|
||||
|
|
|
@ -121,6 +121,7 @@ public class StateController : SelectableObject
|
|||
}
|
||||
else
|
||||
{
|
||||
// If _selectedObject is set to null, stop in place
|
||||
navMeshAgent.stoppingDistance = 0.0f;
|
||||
Destination = transform.position;
|
||||
}
|
||||
|
@ -271,6 +272,14 @@ public class StateController : SelectableObject
|
|||
}
|
||||
}
|
||||
|
||||
public void MoveToSelectedObject()
|
||||
{
|
||||
Vector3 awayDirection = (transform.position - SelectedObject.transform.position).normalized;
|
||||
Vector3 newPos = SelectedObject.transform.position + awayDirection * INTERACT_RANGE * 0.8f;
|
||||
navMeshAgent.stoppingDistance = 0.0f;
|
||||
Destination = newPos;
|
||||
}
|
||||
|
||||
public void MoveForSelectedObjectInteraction()
|
||||
{
|
||||
Vector3 awayDirection = (transform.position - SelectedObject.transform.position).normalized;
|
||||
|
|
Reference in a new issue