Пример #1
0
 public GiantMudCrabModel(GameObject prefab, GiantMudCrabData giantMudCrabData)
 {
     GiantMudCrabData      = giantMudCrabData;
     GiantMudCrabStruct    = giantMudCrabData.GiantMudCrabStruct;
     GiantMudCrabTransform = prefab.transform;
     Player        = GameObject.FindGameObjectWithTag("Player");
     Crab          = prefab;
     CrabMouth     = prefab.transform.GetChild(0);
     CurrentHealth = GiantMudCrabData.GiantMudCrabStruct.CurrentHealth;
 }
Пример #2
0
        public void Attack(GiantMudCrabStruct giantMudCrabStruct, NavMeshAgent CrabAgent, GameObject Target, GameObject Prefab)
        {
            float DistanceBetweenTargetAndPrefab = Vector3.Distance(Target.transform.position, Prefab.transform.position);

            if (giantMudCrabStruct.CanAttack && !giantMudCrabStruct.IsDigIn)
            {
                if (DistanceBetweenTargetAndPrefab <= giantMudCrabStruct.AttackRange)
                {
                    CrabAgent.isStopped = true;
                    CrabAgent.ResetPath();
                    RotateTowards(Target.transform, Prefab.transform);
                    if (Time.time >= NextAttackRate)
                    {
                        Debug.Log("Attacking");
                        new GiantMudCrabProjectile(giantMudCrabStruct.AttackDamage, giantMudCrabStruct.Stats, Target.transform, Prefab.transform.GetChild(0), giantMudCrabStruct.CrabProjectile);
                        NextAttackRate = giantMudCrabStruct.AttackSpeed + Time.time;
                    }
                }
                else if (DistanceBetweenTargetAndPrefab > giantMudCrabStruct.AttackRange)
                {
                    CrabAgent.destination = Target.transform.position;
                }
            }
        }