Beispiel #1
0
    private void Update()
    {
        float deltatime = Time.deltaTime;

        m_Ray.origin    = transform.position;
        m_Ray.direction = m_Direction;

        if (!m_Hit && Physics.SphereCast(m_Ray, 0.5f, out m_RayHit, m_Speed * deltatime, m_GroundLayer))
        {
            m_Hit = true;
            LifeTimerWithObjectPool life = ObjectPool.GetObject <LifeTimerWithObjectPool>(m_MiniMeteorImpactPrefab.name);
            life.Initialize();
            life.transform.position = m_RayHit.point;
            life.gameObject.SetActive(true);

            RaycastHit[] hits = Physics.SphereCastAll(m_Ray, m_DamageRadius, m_Speed * deltatime, m_Other.m_EnemyLayerMask);
            foreach (RaycastHit h in hits)
            {
                CharacterBase character = h.transform.GetComponentInParent <CharacterBase>();
                if (!character)
                {
                    continue;
                }
                if (character.m_Live == CharacterBase.E_Live.DEAD)
                {
                    continue;
                }
                if (character.m_Team == m_Other.m_Team)
                {
                    continue;
                }

                character.GiveToDamage(m_Other, m_Damage, true);
            }

            LifeTimerWithObjectPool mylife = GetComponent <LifeTimerWithObjectPool>();
            mylife.SetTimer(1.5f);
        }
        else
        {
            Vector3 nextpos = transform.position + m_Direction * m_Speed * deltatime;
            transform.position = nextpos;
        }
    }