예제 #1
0
    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>();
    }
예제 #2
0
    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);
                    }
                }
            }
        }
    }
예제 #3
0
 // 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);
            }
        }
    }
예제 #6
0
 public MovingCarSate(CharacterNavigationController characterNavigationController) : base(characterNavigationController)
 {
 }
예제 #7
0
 public override void TransitionToState(CarState newState, CharacterNavigationController otherCarController)
 {
     newState.SetOtherCarController(otherCarController);
     base.TransitionToState(newState);
 }
예제 #8
0
 public CarStoppedCarState(CharacterNavigationController characterNavigationController, float toleranceTime) : base(characterNavigationController)
 {
     this.otherCarController = null;
     this.sinceStopped       = 0;
     this.toleranceTime      = toleranceTime;
 }
예제 #9
0
 public override void SetOtherCarController(CharacterNavigationController otherCarController)
 {
     this.otherCarController = otherCarController;
 }
예제 #10
0
 private void Awake()
 {
     controller = GetComponent <CharacterNavigationController>();
 }
예제 #11
0
 private void Awake()
 {
     direction  = Mathf.RoundToInt(Random.Range(0f, 1f));
     controller = GetComponent <CharacterNavigationController>();
 }
예제 #12
0
 public CarState(CharacterNavigationController characterNavigatonController)
 {
     this.characterNavigatonController = characterNavigatonController;
 }
예제 #13
0
 public virtual void TransitionToState(CarState newState, CharacterNavigationController otherCarController)
 {
 }
예제 #14
0
 public virtual void SetOtherCarController(CharacterNavigationController otherCarController)
 {
 }
 public PotholeStoppedCarState(CharacterNavigationController characterNavigationController) : base(characterNavigationController)
 {
     this.pothole      = null;
     this.sinceStopped = 0;
 }