Merge remote-tracking branch 'origin/player-object-interactions'
This commit is contained in:
commit
aea5f6382c
12 changed files with 1437 additions and 22 deletions
76
Project Undercover/Assets/Materials/Statue.mat
Normal file
76
Project Undercover/Assets/Materials/Statue.mat
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
%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: Statue
|
||||||
|
m_Shader: {fileID: 4800000, guid: 138071fa1e289e345881d6208d5c5573, type: 3}
|
||||||
|
m_ShaderKeywords:
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BumpMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailMask:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNormalMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _EmissionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MetallicGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _OcclusionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ParallaxMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Floats:
|
||||||
|
- _BumpScale: 1
|
||||||
|
- _Cutoff: 0.5
|
||||||
|
- _DetailNormalMapScale: 1
|
||||||
|
- _DstBlend: 0
|
||||||
|
- _GlossMapScale: 1
|
||||||
|
- _Glossiness: 0.5
|
||||||
|
- _GlossyReflections: 1
|
||||||
|
- _Metallic: 0
|
||||||
|
- _Mode: 0
|
||||||
|
- _OcclusionStrength: 1
|
||||||
|
- _Parallax: 0.02
|
||||||
|
- _SmoothnessTextureChannel: 0
|
||||||
|
- _SpecularHighlights: 1
|
||||||
|
- _SrcBlend: 1
|
||||||
|
- _UVSec: 0
|
||||||
|
- _ZWrite: 1
|
||||||
|
m_Colors:
|
||||||
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
9
Project Undercover/Assets/Materials/Statue.mat.meta
Normal file
9
Project Undercover/Assets/Materials/Statue.mat.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 36f8514d2d781234ba875e9155399049
|
||||||
|
timeCreated: 1509474085
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e496172999d202948be110cc90eba6e2
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1509473891
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
1292
Project Undercover/Assets/Scenes/Player-Object-Interactions.unity
Normal file
1292
Project Undercover/Assets/Scenes/Player-Object-Interactions.unity
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f1d38ea6f4a30c14e826037e86106cfb
|
||||||
|
timeCreated: 1509473003
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3b44e343791674a4692df18a304a5e9d
|
||||||
|
timeCreated: 1509473920
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
mainObjectFileID: 23800000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -1,16 +0,0 @@
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class HighlightInteractableAction : MonoBehaviour {
|
|
||||||
|
|
||||||
// Use this for initialization
|
|
||||||
void Start () {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update () {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,9 +20,9 @@ public class IdleClickAction : Action
|
||||||
|
|
||||||
public override void Act(StateController controller)
|
public override void Act(StateController controller)
|
||||||
{
|
{
|
||||||
|
// If the user clicks, but not on a UI object ...
|
||||||
if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
|
if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
|
||||||
{
|
{
|
||||||
|
|
||||||
if (controller.Interactor)
|
if (controller.Interactor)
|
||||||
{
|
{
|
||||||
controller.Interactor = null;
|
controller.Interactor = null;
|
||||||
|
@ -30,8 +30,8 @@ public class IdleClickAction : Action
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
||||||
// Check first if the player clicked on a selectable object
|
// Check first if the player clicked on a selectable object
|
||||||
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||||
SelectableObject selectableObject;
|
SelectableObject selectableObject;
|
||||||
if (RaycastForSelectableObject(controller, ray, out selectableObject))
|
if (RaycastForSelectableObject(controller, ray, out selectableObject))
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ public class IdleClickAction : Action
|
||||||
|
|
||||||
// If the player has selected an object, move the player toward that object
|
// If the player has selected an object, move the player toward that object
|
||||||
if (controller.SelectedObject && !controller.IsInteracting)
|
if (controller.SelectedObject && !controller.IsInteracting)
|
||||||
controller.Destination = controller.SelectedObject.transform.position;
|
controller.MoveToSelectedObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if StateController clicked on a Selectable Object
|
// Check if StateController clicked on a Selectable Object
|
||||||
|
@ -60,7 +60,11 @@ public class IdleClickAction : Action
|
||||||
if (Physics.Raycast(ray, out hit, 100.0f, mask))
|
if (Physics.Raycast(ray, out hit, 100.0f, mask))
|
||||||
{
|
{
|
||||||
SelectableObject selectable = hit.collider.gameObject.GetComponentInParent<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;
|
selectableObject = selectable;
|
||||||
return true;
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 9fbeeedae6595654db10065b82213fc0
|
guid: a2e14842720228c49bf03c30440cbcbf
|
||||||
timeCreated: 1506994655
|
timeCreated: 1510178050
|
||||||
licenseType: Free
|
licenseType: Free
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -121,6 +121,7 @@ public class StateController : SelectableObject
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// If _selectedObject is set to null, stop in place
|
||||||
navMeshAgent.stoppingDistance = 0.0f;
|
navMeshAgent.stoppingDistance = 0.0f;
|
||||||
Destination = transform.position;
|
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()
|
public void MoveForSelectedObjectInteraction()
|
||||||
{
|
{
|
||||||
Vector3 awayDirection = (transform.position - SelectedObject.transform.position).normalized;
|
Vector3 awayDirection = (transform.position - SelectedObject.transform.position).normalized;
|
||||||
|
|
Reference in a new issue