Esempio n. 1
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Mouse0))
     {
         Ray ray       = new Ray(transform.position, transform.forward);
         int layerMask = LayerMask.GetMask("Player");
         if (Physics.Raycast(ray, out RaycastHit hitInfo, 20.0f, ~layerMask))
         {
             Debug.Log($"Hit objects name = {hitInfo.transform.name}");
             TargetMgrBase target = hitInfo.transform.GetComponentInParent <TargetMgrBase>();
             if (target != null)
             {
                 target.TakeDamage(200);
             }
         }
         Debug.DrawRay(transform.position, transform.forward.normalized * 20.0f, Color.red, 2.0f);
     }
 }
Esempio n. 2
0
        private void SpawnTarget_F()
        {
            SpawnLocatorBase spawner = m_Spawners[Random.Range(0, m_Spawners.Length)];

            TargetMgrBase target = Instantiate(m_TargetPrefab.gameObject, Vector3.zero, Quaternion.identity)
                                   .GetComponent <TargetMgrBase>();

            spawner.SetTargetPosAndRot_F(target);
            target.OnSpawn_F();

            void onTargetKilledE(TargetMgrBase caller)
            {
                caller.m_OnKilledE -= onTargetKilledE;
                SpawnTarget_F(0.1f);
            }

            target.m_OnKilledE += onTargetKilledE;
        }
Esempio n. 3
0
    public virtual void SetTargetPosAndRot_F(TargetMgrBase target)
    {
        Vector3 spawnPoint;

        do
        {
            spawnPoint = CalcRandomSpawnPoint_F();
            target.transform.position = spawnPoint;
            target.transform.rotation = transform.rotation;
        } while (target.GetShapeComponent_F().CheckForOverlaps_F());

#if UNITY_EDITOR
        if (m_SpawnPoints.Count > 5)
        {
            m_SpawnPoints.RemoveAt(0);
        }
        m_SpawnPoints.Add(spawnPoint);
#endif
    }
Esempio n. 4
0
 protected virtual void Awake()
 {
     m_Target    = GetComponent <TargetMgrBase>();
     m_Rigidbody = GetComponent <Rigidbody>();
 }