예제 #1
0
 // Use this for initialization
 void Start()
 {
     timer = GetComponentInParent <EnemyTimer> ();
     timer.generateAnEnemy     = GenerateEnemy;
     playerHitScript           = Player.GetComponent <PlayerHitDetection> ();
     playerHitScript.killEnemy = KillEnemy;
     playerControlScript       = Player.GetComponent <PlayerControlScript> ();
     gameOverCanvas.enabled    = false;
     sound   = GetComponentInParent <SoundScript> ();
     spawner = GetComponent <EnemySpawner> ();
     Floor2.SetActive(false);
 }
예제 #2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            PlayerHitDetection phd = GameManager.instance.phd;
            phd.GetHit(collision.collider);
        }
        else if (collision.gameObject.CompareTag("Floor") == false)
        {
            Destroy(collision.gameObject);
            speed += speedAdd;

            if (speed >= MaxSpeed)
            {
                speed = MaxSpeed;
            }
        }
    }
예제 #3
0
    public void Update()
    {
        if (!m_bIsOn)
        {
            return;
        }

        float   fDir, fRatio;
        Vector3 vDir = Vector3.zero;


        // Process the Lerp
        {
            fRatio = Mathf.Abs((TimerManager.fGameTime - m_fEventTime) / m_fArcTrackingDuration);

            // Handle ping pong
            if (!m_bIsForward)
            {
                fDir = 1.0f - fRatio;
            }
            else
            {
                fDir = fRatio;
            }

            if (fRatio >= 1.0f)
            {
                m_fEventTime = TimerManager.fGameTime;
                if (m_bPingPong)
                {
                    m_bIsForward = !m_bIsForward;
                }
            }
        }


        // Calc the tracking angle
        {
            m_fTrackingAngle = -(m_fRotationArcDegrees / 2.0f) + (m_fRotationArcDegrees * Easing.EaseInOut(fDir, m_iEasingType));

            switch (m_iDir)
            {
            case Types.EDirection._VERTICAL_U2D: vDir = Quaternion.AngleAxis(m_fTrackingAngle, transform.forward) * Vector2.down; break;

            case Types.EDirection._VERTICAL_D2U: vDir = Quaternion.AngleAxis(m_fTrackingAngle, transform.forward) * Vector2.up; break;

            case Types.EDirection._HORIZONTAL_L2R: vDir = Quaternion.AngleAxis(m_fTrackingAngle, transform.forward) * Vector2.right; break;

            case Types.EDirection._HORIZONTAL_R2L: vDir = Quaternion.AngleAxis(m_fTrackingAngle, transform.forward) * Vector2.left; break;
            }
        }


        // Find the end point for the laser
        RaycastHit2D Hit = Physics2D.Raycast(transform.position + (vDir * m_fColliderRayCastOffset), vDir * Types.s_fRoomWidth);

        Debug.DrawRay(transform.position + (vDir * m_fColliderRayCastOffset), vDir * Types.s_fRoomWidth);


        // Set the positions of the line renderer... (Start point is pushed behind the gun's sprite)
        {
            m_aPositions[0] = transform.position + new Vector3(0.0f, 0.0f, 0.1f);

            if (null != Hit.collider)
            {
                m_aPositions[1] = Hit.point;
            }
            else
            {
                m_aPositions[1] = transform.position + (vDir * Types.s_fRoomWidth);
            }

            m_gcLineRenderer.SetPositions(m_aPositions);
        }


        // Did we hit the player?
        {
            if (null != Hit.collider && Hit.collider.gameObject.CompareTag(Types.s_sTag_Player))
            {
                PlayerHitDetection gc = Hit.transform.gameObject.GetComponent <PlayerHitDetection>();
                if (null != gc)
                {
                    gc.DoImpact();
                }
            }
        }


        // Place the particle system...
        if (null != m_goEndPointParticles)
        {
            m_goEndPointParticles.transform.position = m_aPositions[1];
        }
    }