Example #1
0
 IEnumerator Reset(bool fast)
 {
     if (fast)
     {
         yield return(new WaitForSecondsRealtime(0));
     }
     else
     {
         yield return(new WaitForSecondsRealtime(0.8f));
     }
     isActivate = initial;
     if (isActivate)
     {
         audioManager.PlayByName("Buzz");
     }
     else
     {
         audioManager.StopByName("Buzz");
     }
     if (isMove)
     {
         this.transform.position = Pos;
         dir = dirRecord;
     }
 }
Example #2
0
 Vector2 Dash(Vector2 velocity)
 {
     if (Input.GetKeyDown(input.dash) && canDash == true && isDashing == false)
     {
         audioManager.PlayByName("Dash");
         if (OnDash != null)
         {
             OnDash(this, EventArgs.Empty);
         }
         Camera.main.GetComponent <RippleEffect>().Emit(Camera.main.WorldToViewportPoint(transform.position));
         dashDirection = new Vector2((sr.flipX == false ? 1 : -1), 0);
         if (Input.GetKey(input.up))
         {
             dashDirection = new Vector2(0, 1);
         }
         if (Input.GetKey(input.down))
         {
             dashDirection = new Vector2(0, -1);
         }
         if (Input.GetKey(input.right))
         {
             dashDirection.x = 1;
         }
         if (Input.GetKey(input.left))
         {
             dashDirection.x = -1;
         }
         ParticleSystem dashParticle = Instantiate(dash, this.transform.position, Quaternion.Euler(0, 0, Vector2.SignedAngle(Vector2.up, dashDirection)), this.transform);
         canControlMove = true;
         canControlJump = false;
         canDash        = false;
         isDashing      = true;
         if (dashDirection.x != 0)
         {
             dashJump = true;
         }
         if (dashDirection.y > 0 && onGround && !Input.GetKeyDown(input.up) && jump != null)
         {
             Instantiate(jump, new Vector3(this.transform.position.x, this.transform.position.y - 1.2f, this.transform.position.z), Quaternion.identity, this.transform);
         }
         StartCoroutine(Dashing(dashParticle));
         StartCoroutine((Phantom(spawntime)));
     }
     if (isDashing)
     {
         velocity = dashDirection.normalized * 30;
     }
     return(velocity);
 }
Example #3
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         if (collision.gameObject.GetComponent <PlayerControl>().canDash == false)
         {
             collision.gameObject.GetComponent <PlayerControl>().canDash = true;
             sr.enabled    = false;
             cc.enabled    = false;
             point.enabled = false;
             eat.Play();
             ps.Clear();
             ps.Stop();
             anim.SetTrigger("Halt");
             audioManager.PlayByName("Touch");
             coroutine = StartCoroutine(Appear(false));
         }
     }
 }
Example #4
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (audioManager == null)
     {
         audioManager = animator.gameObject.GetComponent <ObjAudioManager>();
     }
     if (stateInfo.IsName("Player_Die"))
     {
         audioManager.PlayByName("Dead");
     }
 }
    void SpawnBrick()
    {
        int     x         = Mathf.FloorToInt(transform.position.x);
        int     y         = Mathf.RoundToInt(transform.position.y);
        float   catchFall = Fall.instance.transform.position.y - (int)Fall.instance.transform.position.y;
        Vector2 spawnPos  = new Vector2(x + 0.5f, y - 0.5f + catchFall);

        spawnPos = new Vector2(spawnPos.x, (transform.position.y - spawnPos.y) > 0.95f ? spawnPos.y : spawnPos.y - 1);

        RaycastHit2D hitInfo = Physics2D.Raycast(spawnPos, Vector2.zero, 0, scanLayer);

        bloomRect.gameObject.transform.position = spawnPos;
        bloomRect.color = (hitInfo.collider == null) ? Color.white : Color.red;

        if (Input.GetKeyDown(KeyCode.S) && hp > 10 && hitInfo.collider == null)
        {
            playerAudio.PlayByName("Place");
            GameObject go = Instantiate(brick, spawnPos, Quaternion.identity);
            go.transform.SetParent(Fall.instance.transform);
            go.GetComponent <Brick>().hp = hp / 3;
            hp         -= hp / 5;
            hpText.text = hp.ToString();
        }
    }
Example #6
0
 void Collect()
 {
     gain.Play();
     sr.enabled  = false;
     sr.material = haveBeenCollect;
     ParticleSystem.MainModule main = ps.main;
     main.startColor = Color.white;
     if (counter != null && collected == false)
     {
         counter.HardDiskAmount++;
     }
     collected = true;
     touched   = false;
     anim.SetTrigger("Collect");
     audioManager.PlayByName("Get");
     StartCoroutine(GoBack());
 }
Example #7
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         animator.SetBool("PlayerPress", true);
         Rigidbody2D   rb     = collision.gameObject.GetComponent <Rigidbody2D>();
         PlayerControl player = collision.gameObject.GetComponent <PlayerControl>();
         player.isDashing = false;
         player.onGround  = false;
         if (jumpX != 0)
         {
             player.canControlMove = false;
             player.springJump     = true;
             StartCoroutine(player.Spring());
         }
         StartCoroutine(DashReset(player));
         rb.velocity = new Vector2(jumpX, jumpY);
         audioManager.PlayByName("Twang");
     }
 }