protected override void Awake()
    {
        base.Awake();

        SetGizmoColor(Color.blue);
        _cc   = GetComponent <CharacterController>();
        _stat = GetComponent <SlimeStat>();
        _anim = GetComponentInChildren <Animator>();

        _playercc        = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterController>();
        _playerTransform = _playercc.transform;

        SlimeState[] stateValues = (SlimeState[])System.Enum.GetValues(typeof(SlimeState));
        foreach (SlimeState s in stateValues)
        {
            System.Type   FSMType = System.Type.GetType("Slime" + s.ToString());
            SlimeFSMState state   = (SlimeFSMState)GetComponent(FSMType);
            if (null == state)
            {
                state = (SlimeFSMState)gameObject.AddComponent(FSMType);
            }

            _states.Add(s, state);
            state.enabled = false;
        }
    }
Exemple #2
0
    public void AttackCheck()
    {
        if (target == null)
        {
            return;
        }
        SlimeStat targetStat = target.GetComponent <SlimeStat>();

        targetStat.ApplyDamage(stat);
    }
Exemple #3
0
 public void ApplyDamage(SlimeStat from)
 {
     hp -= from.attackRate;
     if (hp <= 0)
     {
         manager.SetDead();
         if (lastHitBy == null)
         {
             lastHitBy = from;
         }
         from.NotifyDead();
     }
 }
Exemple #4
0
 private void Awake()
 {
     slani = GetComponentInChildren <Animator>();
     stat  = GetComponent <SlimeStat>();
     states.Add(SlimeState.IDLE, GetComponent <SlimeIDLE>());
     states.Add(SlimeState.PATROL, GetComponent <SlimePATROL>());
     states.Add(SlimeState.CHASE, GetComponent <SlimeCHASE>());
     states.Add(SlimeState.ATTACK, GetComponent <SlimeATTACK>());
     states.Add(SlimeState.DEAD, GetComponent <SlimeDEAD>());
     scc      = GetComponent <CharacterController>();
     sight    = GetComponentInChildren <Camera>();
     PlayerCc = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterController>();
 }
Exemple #5
0
    public static void JJMove(CharacterController scc, Vector3 destination, SlimeStat stat)
    {
        Transform transform = scc.transform;

        JJRotate(transform, destination, stat);

        Vector3 deltaMove = Vector3.MoveTowards(
            transform.position,
            destination,
            stat.slimeSpeed * Time.deltaTime) - transform.position;

        deltaMove.y = -stat.slimeFall * Time.deltaTime;

        scc.Move(deltaMove);
    }
Exemple #6
0
    public static void JJRotate(Transform transform, Vector3 destination, SlimeStat stat)
    {
        // B-A는 A에서 B로 향하는 벡터.
        Vector3 dir = destination - transform.position;

        dir.y = 0.0f;
        if (dir != Vector3.zero)
        {
            transform.rotation = Quaternion.RotateTowards(
                transform.rotation,
                Quaternion.LookRotation(dir),
                stat.slimeRotat * Time.deltaTime
                );
        }
    }
Exemple #7
0
    public static void JJMove(CharacterController scc, Transform target, SlimeStat stat)
    {
        Transform transform = scc.transform;

        JJMove(scc, target.position, stat);
    }