Esempio n. 1
0
 void HandleCandyBlockCollision(Collision2D col)
 {
     // no bouncing back n forth
     if (Mathf.Abs(Vector3.Dot(col.GetContact(0).normal, new Vector3(1, 0))) > 0.8391f)
     {
         rb.velocity = Vector3.Reflect(last_frame_vel, col.contacts[0].normal);
     }
     else
     {
         rb.velocity = RestrictVelocityToCeilingHeight(col.GetContact(0).normal);
         if (slam_state != SlamState.NOT_SLAMMING)
         {
             bool is_super_slam = slam_state == SlamState.SUPER_SLAMMING;
             if (is_super_slam)
             {
                 GameObject ghost = Instantiate(ghostPlayerPrefab);
                 ghost.transform.position = transform.position;
                 slam_state = SlamState.SLAMMING; // prevent multiple flashy animations from happening
             }
             bool will_destroy = colour == col.collider.gameObject.GetComponent <CandyScript>().colour || is_super_slam;
             if (will_destroy)
             {
                 SetColour(colour);
                 int INF       = 1000; // 10 * 10 = 100; 1000 is more than safe to be considered inf
                 int destroyed = candyDestructor.DestructTile(col.collider.gameObject.GetComponent <CandyScript>(), INF, is_super_slam);
                 if (!is_super_slam)
                 {
                     slamBarCounter += destroyed;
                 }
             }
         }
     }
 }
 private void OnHMDLostTracking()
 {
     NRDebugger.Log("[SlamStateNotification] OnHMDLostTracking.");
     if (m_CurrentState != SlamState.LostTracking)
     {
         this.OnStateChanged(Level.Middle);
         m_CurrentState = SlamState.LostTracking;
     }
 }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (Time.timeScale == 0)
        {
            return;
        }
        if (currently_frozen)
        {
            rb.velocity = new Vector2();
            return;
        }

        Vector2 cur_vel = rb.velocity;

        if (cur_vel.y > 0)
        {
            slam_state = SlamState.NOT_SLAMMING;
            pac.Slam(false);
        }

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            cur_vel.x -= accel * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.RightArrow))
        {
            cur_vel.x += accel * Time.deltaTime;
        }

        cur_vel.x = Mathf.Clamp(cur_vel.x, -maxVelx, maxVelx);

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            SetColour((CandyScript.Colour)(((int)colour + 1) % 3));
        }

        if (Input.GetKeyDown(KeyCode.DownArrow) && slam_state == SlamState.NOT_SLAMMING)
        {
            audioSource.PlayOneShot(slamClip, 1.0f);
            pac.Slam(true);
            slam_state = SlamState.SLAMMING;
            cur_vel.y  = -slam_vel;
            cur_vel.x  = 0;
        }
        else if ((Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.Space)) && slam_state == SlamState.NOT_SLAMMING && slamBarCounter >= slamBarMaxCounter)
        {
            audioSource.PlayOneShot(superSlamClip, 1.0f);
            pac.Slam(true);
            pac.SetColour((int)CandyScript.Colour.WHITE + 1);
            slam_state     = SlamState.SUPER_SLAMMING;
            cur_vel.y      = -slam_vel * 2;
            cur_vel.x      = 0;
            slamBarCounter = 0;
        }


        cur_vel.y  -= gAccel * Time.deltaTime;
        cur_vel.y   = Mathf.Clamp(cur_vel.y, -maxVely, maxVely);
        rb.velocity = cur_vel;

        last_frame_vel = rb.velocity;

        // update slam bar
        slamBar.SetBarLevel(((float)slamBarCounter) / slamBarMaxCounter);
    }
 private void OnHMDPoseReady()
 {
     NRDebugger.Log("[SlamStateNotification] OnHMDPoseReady.");
     m_CurrentState = SlamState.TrackingReady;
 }