character interactions are good yo
This commit is contained in:
parent
c2d8c78028
commit
21397a8ee4
23 changed files with 222 additions and 22 deletions
|
@ -0,0 +1,13 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3a68114b6ee7c444a90e241327d93bdc, type: 3}
|
||||
m_Name: NpcApproachingTarget
|
||||
m_EditorClassIdentifier:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9d5f7cb18596843449c520a3adde576a
|
||||
timeCreated: 1507654071
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,7 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: aed8389bb6c1d4d49ad5bf1d04d7be17
|
||||
folderAsset: yes
|
||||
timeCreated: 1506987054
|
||||
timeCreated: 1507593469
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5087e9722bba7ee478933f94f035b990, type: 3}
|
||||
m_Name: ObjectAlreadyHasInteractor
|
||||
m_EditorClassIdentifier:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4078502a092bd9a41be210395f51aef0
|
||||
timeCreated: 1507653787
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f3ee18a0ee4867f4980c76b7ceb7d74e, type: 3}
|
||||
m_Name: ObjectInRangeAndAvailable
|
||||
m_EditorClassIdentifier:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5b77ad8a89f818e47be8530f8148553b
|
||||
timeCreated: 1507653546
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,25 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5a6a367e35acd7e44a0a598eaa1d6700, type: 3}
|
||||
m_Name: NpcApproachingTarget
|
||||
m_EditorClassIdentifier:
|
||||
actions:
|
||||
- {fileID: 11400000, guid: 9d5f7cb18596843449c520a3adde576a, type: 2}
|
||||
transitions:
|
||||
- decision: {fileID: 11400000, guid: 5b77ad8a89f818e47be8530f8148553b, type: 2}
|
||||
trueState: {fileID: 11400000, guid: a70ae0bc5f16c9648ab8c7b1963547ac, type: 2}
|
||||
transitionValue: 1
|
||||
- decision: {fileID: 11400000, guid: 010846579b426744d84ebd4f5f2ce837, type: 2}
|
||||
trueState: {fileID: 11400000, guid: 963f4d74f828ef94d85740708e8ce1d0, type: 2}
|
||||
transitionValue: 1
|
||||
- decision: {fileID: 11400000, guid: 4078502a092bd9a41be210395f51aef0, type: 2}
|
||||
trueState: {fileID: 11400000, guid: 78ec31c429ad5074bb50d001b1a49a77, type: 2}
|
||||
transitionValue: 1
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 67adff9f9e4c58941b86d56c6faaade4
|
||||
timeCreated: 1507653176
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -18,5 +18,5 @@ MonoBehaviour:
|
|||
trueState: {fileID: 11400000, guid: 963f4d74f828ef94d85740708e8ce1d0, type: 2}
|
||||
transitionValue: 1
|
||||
- decision: {fileID: 11400000, guid: c14d2053399388247b9cfde51ce5f57c, type: 2}
|
||||
trueState: {fileID: 11400000, guid: a70ae0bc5f16c9648ab8c7b1963547ac, type: 2}
|
||||
trueState: {fileID: 11400000, guid: 67adff9f9e4c58941b86d56c6faaade4, type: 2}
|
||||
transitionValue: 1
|
||||
|
|
|
@ -1598,7 +1598,7 @@ MonoBehaviour:
|
|||
NPCPrefab: {fileID: 1249949894527080, guid: ea4aade53c5c4714b8b9c335e8100cf0, type: 2}
|
||||
cameraRigPrefab: {fileID: 1009033979625728, guid: 1764211b5690c164d82aa46fa4ec707d,
|
||||
type: 2}
|
||||
numNpcs: 5
|
||||
numNpcs: 10
|
||||
spyMissionsComplete: 0
|
||||
waitBetweenMissions: 5
|
||||
onMissionCooldown: 0
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(menuName = "CharacterStateMachine/Actions/NpcApproachingTarget")]
|
||||
public class NpcApproachingTargetAction : Action
|
||||
{
|
||||
public override void StartAct(StateController controller)
|
||||
{
|
||||
//Debug.Log("Approaching object");
|
||||
}
|
||||
|
||||
public override void Act(StateController controller)
|
||||
{
|
||||
controller.Destination = controller.SelectedObject.transform.position;
|
||||
}
|
||||
|
||||
public override void EndAct(StateController controller)
|
||||
{
|
||||
//Debug.Log("No longer approaching object");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3a68114b6ee7c444a90e241327d93bdc
|
||||
timeCreated: 1507654026
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(menuName = "CharacterStateMachine/Actions/NpcWaitForInteractionAcceptance")]
|
||||
|
@ -11,7 +8,6 @@ public class NpcWaitForInteractionAcceptanceAction : Action
|
|||
public override void StartAct(StateController controller)
|
||||
{
|
||||
controller.InitiateInteractionWithSelectedObject();
|
||||
//controller.Destination = controller.SelectedObject.transform.position;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,15 @@ public class RoamAction : Action
|
|||
{
|
||||
public override void StartAct(StateController controller)
|
||||
{
|
||||
// Debug.Log("Started Roaming");
|
||||
controller.StartRoaming();
|
||||
controller.characterAnimator.SetBool(CharacterAnimator.Params.Interacting, false);
|
||||
if (controller.SelectedObject)
|
||||
{
|
||||
controller.SelectedObject.IsInteracting = false;
|
||||
controller.SelectedObject = null;
|
||||
}
|
||||
if (controller.IsInteracting)
|
||||
controller.IsInteracting = false;
|
||||
}
|
||||
|
||||
public override void Act(StateController controller)
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(menuName = "CharacterStateMachine/Decisions/ObjectAlreadyHasInteractor")]
|
||||
public class ObjectAlreadyHasInteractorDecision : Decision
|
||||
{
|
||||
public override bool Decide(StateController controller)
|
||||
{
|
||||
if (controller.SelectedObject.Interactor != null)
|
||||
return controller.SelectedObject.Interactor != controller;
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5087e9722bba7ee478933f94f035b990
|
||||
timeCreated: 1507653758
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(menuName = "CharacterStateMachine/Decisions/ObjectInRangeAndAvailable")]
|
||||
public class ObjectInRangeAndAvailableDecision : Decision
|
||||
{
|
||||
public override bool Decide(StateController controller)
|
||||
{
|
||||
|
||||
return controller.InRangeOfSelectedObject() && controller.SelectedObject.Interactor == null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f3ee18a0ee4867f4980c76b7ceb7d74e
|
||||
timeCreated: 1507653505
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -18,11 +18,16 @@ public class Interaction : ScriptableObject
|
|||
{
|
||||
Nothing, SpyMissionComplete
|
||||
}
|
||||
/*
|
||||
public override int GetHashCode()
|
||||
|
||||
public int GetHash()
|
||||
{
|
||||
return interactionDescription.GetHashCode() ^ (int)characterInteraction;
|
||||
}*/
|
||||
return interactionDescription.Length + (int)initiatorAnimationTrigger + (int)objectAnimationTrigger;
|
||||
}
|
||||
|
||||
public bool CompareHash(int hash)
|
||||
{
|
||||
return hash == GetHash();
|
||||
}
|
||||
|
||||
public void ExecuteResult(StateController controller)
|
||||
{
|
||||
|
|
|
@ -180,7 +180,6 @@ public abstract class SelectableObject : Photon.PunBehaviour, IEquatable<Selecta
|
|||
|
||||
public void AcceptInteraction()
|
||||
{
|
||||
Debug.Log("Accepted Interaction");
|
||||
IsInteracting = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ public class StateController : SelectableObject
|
|||
Debug.LogError("Attempted to set interactor as self");
|
||||
|
||||
if (SelectedObject.IsInteracting)
|
||||
Debug.Log(SelectedObject.name + " is busy and cannot interact with " + name);
|
||||
return;
|
||||
|
||||
// Debug.Log("Sending interaction request...");
|
||||
IsInteracting = true;
|
||||
|
@ -174,7 +174,7 @@ public class StateController : SelectableObject
|
|||
{
|
||||
int hash = 0;
|
||||
if (value != null)
|
||||
hash = value.GetHashCode();
|
||||
hash = value.GetHash();
|
||||
photonView.RPC("SetSelectedInteractionRPC", PhotonTargets.All, hash);
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ public class StateController : SelectableObject
|
|||
Interaction[] foundInteractions = (Interaction[])Resources.FindObjectsOfTypeAll(typeof(Interaction));
|
||||
foreach (var interaction in foundInteractions)
|
||||
{
|
||||
if (interaction.GetHashCode() == hash)
|
||||
if (interaction.CompareHash(hash))
|
||||
{
|
||||
_selectedInteraction = interaction;
|
||||
return;
|
||||
|
@ -208,10 +208,10 @@ public class StateController : SelectableObject
|
|||
{
|
||||
while (true)
|
||||
{
|
||||
yield return new WaitForSeconds(UnityEngine.Random.value * 2.0f + 2.0f);
|
||||
yield return new WaitForSeconds(UnityEngine.Random.value * 10.0f + 0.5f);
|
||||
if (IsInteracting)
|
||||
Debug.LogError("Should have stopped this coroutine by now");
|
||||
if (UnityEngine.Random.value > 0.5f)
|
||||
if (UnityEngine.Random.value < 0.2f)
|
||||
{
|
||||
SelectableObject randomObject = GetRandomAvailableSelectableObject();
|
||||
if (randomObject != null)
|
||||
|
@ -220,7 +220,6 @@ public class StateController : SelectableObject
|
|||
IsInteracting = true;
|
||||
Interaction randomInteraction = SelectedObject.GetRandomNpcInteraction();
|
||||
SelectedInteraction = randomInteraction;
|
||||
Debug.Log(SelectedObject.name);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
@ -291,4 +290,9 @@ public class StateController : SelectableObject
|
|||
navMeshAgent.stoppingDistance = 0.0f;
|
||||
Destination = newPos;
|
||||
}
|
||||
|
||||
public bool InRangeOfSelectedObject()
|
||||
{
|
||||
return (SelectedObject.transform.position - transform.position).magnitude < INTERACT_RANGE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,17 +48,22 @@ public class InteractionPanelController : MonoBehaviour {
|
|||
if (mainPanel.activeInHierarchy)
|
||||
return;
|
||||
interactionsDropdown.ClearOptions();
|
||||
|
||||
var optionsList = new List<Dropdown.OptionData>();
|
||||
foreach (Interaction interaction in controller.SelectedObject.interactions)
|
||||
{
|
||||
var data = new InteractionData(interaction, false);
|
||||
optionsList.Add(data);
|
||||
}
|
||||
if (controller.SelectedObject.CompareTag("Spy"))
|
||||
{
|
||||
foreach (Interaction interaction in controller.SelectedObject.spyInteractions)
|
||||
{
|
||||
var data = new InteractionData(interaction, true);
|
||||
optionsList.Add(data);
|
||||
}
|
||||
}
|
||||
|
||||
interactionsDropdown.AddOptions(optionsList);
|
||||
_controller.SelectedInteraction = ((InteractionData)(interactionsDropdown.options[interactionsDropdown.value])).interaction;
|
||||
ActivePanel.mainPanel.SetActive(true);
|
||||
|
|
Reference in a new issue