void Awake() { initialPosition = transform.position; initialRotation = transform.rotation; if (lastTargetPosition == null) { lastTargetPosition = new GameObject().transform; lastTargetPosition.hideFlags = HideFlags.HideInHierarchy & HideFlags.HideInInspector; } eyeController = GetComponent <EnemyEyeController>(); character = GetComponent <Character>(); navAgent = GetComponent <CharacterNavigationController>(); audioSource = GetComponent <AudioSource>(); if (patrolNodeParent != null) { patrolNodeParent.transform.SetParent(transform.parent); } patrolPost = new GameObject().transform; patrolPost.position = transform.position; //aiSight = GetComponentInChildren<AISight>(); }
private void OnTriggerStay(Collider other) { HP hp = other.GetComponent <HP>(); if (hp) { if (other.tag == "Player") { if (characterStatus.isInCar == false) { float damage = (modul(rigidbody.velocity) - smallestSpeed) * kDamage; if (damage > 0) { hp.Change(damage); } } } else { CharacterNavigationController characterNavigationController = other.GetComponent <CharacterNavigationController>(); if (characterNavigationController.isInCar == false) { float damage = (modul(rigidbody.velocity) - smallestSpeed) * kDamage; if (damage > 0) { hp.Change(damage); } } } } }
// Start is called before the first frame update void Start() { if (GetComponent <CharacterNavigationController>()) { characterNavigationController = GetComponent <CharacterNavigationController>(); } hp = 100; if (characterStatus) { characterStatus.isAlive = true; } }
void OnTriggerEnter(Collider other) { CharacterNavigationController npc = other.GetComponent <CharacterNavigationController>(); if (npc != null) { npc.animator.enabled = false; npc.isRagdoll = true; //should pass variable based on hit velocity Collider[] hitColliders = Physics.OverlapSphere(other.transform.position, 0.5f, 18, QueryTriggerInteraction.Ignore); foreach (Collider c in hitColliders) { c.GetComponent <Rigidbody>().AddExplosionForce(520f, transform.position - new Vector3(0f, 0.15f, 0f), 1f); } } }
// Update is called once per frame void Update() { Pothole pothole = CheckForPotholes(); if (pothole != null) { carState.TransitionToState(stoppedByPotholeState, pothole, PotholeDone); } CharacterNavigationController otherCar = CheckForOtherCars(); if (otherCar != null) { if (otherCar.carState.StoppedByPothole()) { carState.TransitionToState(stoppedByPotholeState, otherCar.carState.GetPothole(), PotholeDone); } else { carState.TransitionToState(stoppedByCarState, otherCar); } } if (pothole == null && otherCar == null && !carState.IsMoving()) { carState.TransitionToState(movingState); } if (carState.IsMoving()) { MoveTowardsDestination(); } else { carState.TimeGoesBy(Time.deltaTime); if (carState.NeedToKillCar()) { Destroy(this.gameObject); } } }
public MovingCarSate(CharacterNavigationController characterNavigationController) : base(characterNavigationController) { }
public override void TransitionToState(CarState newState, CharacterNavigationController otherCarController) { newState.SetOtherCarController(otherCarController); base.TransitionToState(newState); }
public CarStoppedCarState(CharacterNavigationController characterNavigationController, float toleranceTime) : base(characterNavigationController) { this.otherCarController = null; this.sinceStopped = 0; this.toleranceTime = toleranceTime; }
public override void SetOtherCarController(CharacterNavigationController otherCarController) { this.otherCarController = otherCarController; }
private void Awake() { controller = GetComponent <CharacterNavigationController>(); }
private void Awake() { direction = Mathf.RoundToInt(Random.Range(0f, 1f)); controller = GetComponent <CharacterNavigationController>(); }
public CarState(CharacterNavigationController characterNavigatonController) { this.characterNavigatonController = characterNavigatonController; }
public virtual void TransitionToState(CarState newState, CharacterNavigationController otherCarController) { }
public virtual void SetOtherCarController(CharacterNavigationController otherCarController) { }
public PotholeStoppedCarState(CharacterNavigationController characterNavigationController) : base(characterNavigationController) { this.pothole = null; this.sinceStopped = 0; }