Ejemplo n.º 1
0
    private void Update()
    {
        if (Vision.UnitOfInterest() != null)
        {
            CurrentTarget = Vision.UnitOfInterest();
        }
        else
        {
            CurrentTarget = Vision.SecondaryUnitOfInterest();
        }

        if (CurrentTarget != null && GameUnit.InReach(CurrentTarget))
        {
            Vector3    dir = CurrentTarget.transform.position - transform.position;
            Quaternion rot = Quaternion.LookRotation(dir);
            transform.rotation = Quaternion.Slerp(transform.rotation, rot, 2.5f * Time.deltaTime);
            Attack();
        }
    }
Ejemplo n.º 2
0
    private void Movement()
    {
        if (Vision.UnitOfInterest() != null)
        {
            CurrentTarget = Vision.UnitOfInterest();
        }
        else
        {
            CurrentTarget = Vision.SecondaryUnitOfInterest();
        }

        // DEBUG

        /*
         * try {
         *      float DistanceToTarget = Vector3.Distance(transform.position, CurrentTarget.transform.position);
         *      string DistanceToTargetMessage = "> Distance to target: " + DistanceToTarget;
         *      if (DistanceDebugLine == null) DistanceDebugLine = UnitDebug.AddLine(DistanceToTargetMessage);
         *      DistanceDebugLine.Message = DistanceToTargetMessage;
         *
         *      string TargetNameMessage = "> Target: " + CurrentTarget.name;
         *      if (TargetDebugLine == null) TargetDebugLine = UnitDebug.AddLine(TargetNameMessage);
         *      TargetDebugLine.Message = TargetNameMessage;
         *
         *      string StunnedMessage = "> Stunned: " + isStunned;
         *      if (StunnedDebugLine == null) StunnedDebugLine = UnitDebug.AddLine(StunnedMessage);
         *      StunnedDebugLine.Message = StunnedMessage;
         * } catch (System.NullReferenceException e) {
         *
         * }
         */
        //

        if (CurrentTarget != null)
        {
            GameUnit.AnimationState = UnitAnimationState.Running;
            SetDestination(CurrentTarget.transform.position);
        }
        else
        {
            GameUnit.AnimationState = UnitAnimationState.Idle;
        }
    }