This commit is contained in:
2023-04-18 00:29:51 -04:00
parent 3b31797ce4
commit 6d2d0e4c4d
16 changed files with 6449 additions and 154 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9cad50f842393434fa2dc09cc614fd93
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,64 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor.Rendering;
using UnityEngine;
public class SkinlessMonsterAnimator : MonoBehaviour
{
[SerializeField]
private Animator animator;
private float speed = 0f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
animator.SetFloat("speed", speed);
}
public void StartMoving()
{
speed = 1;
}
public void StopMoving()
{
speed = 0;
}
public void Attack()
{
animator.SetTrigger("Attack");
}
/// <summary>
/// 0,1,2,3
/// </summary>
/// <param name="attackType"></param>
public void SetAttackType(int attackType)
{
animator.SetInteger("AttackIndex", attackType);
}
public void InLight()
{
animator.SetBool("InLight", true);
}
public void NotInLight()
{
animator.SetBool("InLight", false);
}
public void AttackScream()
{
animator.SetTrigger("AttackScream");
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 25b1ea1a67bb5ac46ab647a1cd794807
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,100 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class SkinlessMonsterComponent : MonoBehaviour
{
[SerializeField]
private NavMeshAgent agent;
[SerializeField]
private SkinlessMonsterAnimator animator;
private bool inRangeOfTarget = false;
private bool atTarget = false;
[SerializeField]
private float atTargetDistance = 3;
private TargetInformation target;
private void Update()
{
if (target != null)
{
//Update booleans for movement
float distToTarget = Vector3.Distance(target.target.transform.position, agent.transform.position);
atTarget = atTargetDistance >= distToTarget;
if (target.hasDamageRange)
{
inRangeOfTarget = target.damageRange <= distToTarget;
}
else
{
inRangeOfTarget = false;
}
//Perform actions.
}
}
/*
STANDARD BEHAVIOR:
- OnSeeing/Hearing Player:
- Run towards Player
- OnHearing Bolt:
- Run towards bolt
- OnSeeing Flare:
- Run towards flare if not within (flareRange + flareMargin).
- This acts like if you are far enough away that you don't feel the pain of the flare
- OnSeeing FlareBeacon:
- Run away if within (flareBeaconRange + flareBeaconMargin).
*/
//Runs towards target. If its meant to be hostile, it will melee attack once in range.
public void Target(GameObject obj,bool hostile=false)
{
if(target.target!= obj)
{
//target = new TargetInformation(obj,hostile,false,runTowards:true);
}
}
//Runs towards flare such that it stops randomly within margin before range.
public void TargetFlare(GameObject obj,float range,float margin)
{
if(target.target != obj)
{
//target = new TargetInformation(obj, false, true, range, margin,runTowards:true);
}
}
/// <summary>
/// Runs away from object. A minimum range is specified where it no longer takes damage, and a minimum margin is
/// speicifed where it can stop running.
/// </summary>
/// <param name="obj"></param>
/// <param name="minRange"></param>
/// <param name="minMargin"></param>
public void RunAwayFrom(GameObject obj,float minRange,float minMargin) {
if(target.target != obj)
{
//target = new TargetInformation(obj, false, true, minRange, minMargin, false);
}
}
}
class TargetInformation
{
public GameObject target;
public bool isHostile;
public bool hasDamageRange;
public float damageRange;
public float damageMargin;
public bool runTowards;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5ef96d673cf373444b2ae89ea9588ee1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: