Example #1
0
    private void HitTarget(Collider2D collision)
    {
        sfxCreator.Create(hit, 0.8f, 1f);
        GameObject thisEffect = Instantiate(hitEffectPrefabs, collision.transform.localPosition, hitEffectPrefabs.transform.rotation);
        GameObject player     = GameObject.Find(collision.transform.name);

        thisEffect.transform.parent        = player.transform;
        thisEffect.transform.localPosition = new Vector3(0, 0, -0.1f);
        thisEffect.transform.localScale    = new Vector3(7f, 7f, 7f);
    }
Example #2
0
    private void checkInput()
    {
        FlipAddingScoreText();
        var move = new Vector3(joystick.Horizontal(), 0);

        if (waitTimeForEffector >= 0)
        {
            waitTimeForEffector -= Time.deltaTime;
        }
        if (curTimeCDSkill > 0 && !isSkillActive)
        {
            curTimeCDSkill -= Time.deltaTime;
            if (curTimeDurationSkill > 0)
            {
                curTimeDurationSkill -= Time.deltaTime;
                buffMoveSpeed        *= 1.0003f;
                buffjumpForce        *= 1.0003f;
            }
            else
            {
                buffMoveSpeed = 1f;
                buffjumpForce = 1f;
            }
            countDownText_BuffUI.text     = curTimeCDSkill.ToString(curTimeCDSkill < 10f ? "#" : "##");
            rollerCoverBuffImg.fillAmount = curTimeCDSkill / cooldownSkill;
            if (curTimeCDSkill <= 0)
            {
                countDownObj_BuffUI.SetActive(false);
            }
        }
        else if (curTimeCDSkill > 0 && isSkillActive)
        {
            isSkillActive = false;
        }

        if (((Input.GetKeyDown(KeyCode.Space) || jumpBtn.pressed) && !anim.GetBool("IsJump") && isGrounded) && curJumpCount <= 0)
        {
            curJumpCount++;
            sfxCreator.Create(jump, 0.3f, 1f);
            PerformJumpPlus();
        }

        if ((!jumpBtn.pressed && curJumpCount > 0) && isGrounded)
        {
            curJumpCount = 0;
        }

        if ((Input.GetKeyDown(KeyCode.E) || pickupBtn.pressed) && !isPickup)
        {
            anim.SetTrigger("Pickup");
            photonView.RPC("PickUpAnimationTrigger", PhotonTargets.Others);
        }

        WaitForDestroyTrashInHand();

        if ((Input.GetKeyDown(KeyCode.Mouse0) || throwBtn.pressed) && !isPickup)
        {
            anim.SetTrigger("Throw");
            sfxCreator.Create(throwTrash, 1f, 1f);
            photonView.RPC("ThrowAnimationTrigger", PhotonTargets.Others);
        }
        else if ((Input.GetKeyDown(KeyCode.Mouse0) || throwBtn.pressed) && isPickup)
        {
            anim.SetTrigger("Throw");
            sfxCreator.Create(throwTrash, 1f, 1f);
            for (int i = 0; i < trashImg.Length; i++)
            {
                if (trashImg[i].activeSelf)
                {
                    trashImg[i].SetActive(false);
                    photonView.RPC("ShowTrash", PhotonTargets.OthersBuffered, i, trashImg[i].activeSelf);
                }
            }
            photonView.RPC("ThrowAnimationTrigger", PhotonTargets.Others);
            ThrowTrash();
            isPickup = false;
        }

        if (anim.GetBool("IsWalk") && (move.x >= -0.15f || move.x <= 0.15f))
        {
            anim.SetBool("IsWalk", false);
            photonView.RPC("WalkAnimationFalse", PhotonTargets.Others);
        }

        if (Input.GetKey(KeyCode.D) || joystick.Horizontal() > 0)
        {
            transform.position += move * (moveSpeed * buffMoveSpeed) * Time.deltaTime;
            if (!anim.GetBool("IsWalk") && move.x > 0)
            {
                anim.SetBool("IsWalk", true);
                photonView.RPC("WalkAnimationTrue", PhotonTargets.Others);
            }

            if (transform.localScale.x < 0)
            {
                isFacingRight                = !isFacingRight;
                scale.x                     *= -1;
                textObjScale.x              *= -1;
                transform.localScale         = scale;
                textObj.transform.localScale = textObjScale;
                photonView.RPC("OnSpriteFlip", PhotonTargets.Others);
            }
        }
        else if (Input.GetKey(KeyCode.A) || joystick.Horizontal() < 0)
        {
            transform.position += move * (moveSpeed * buffMoveSpeed) * Time.deltaTime;
            if (!anim.GetBool("IsWalk") && move.x < 0)
            {
                anim.SetBool("IsWalk", true);
                photonView.RPC("WalkAnimationTrue", PhotonTargets.Others);
            }

            if (transform.localScale.x > 0)
            {
                isFacingRight                = !isFacingRight;
                scale.x                     *= -1;
                textObjScale.x              *= -1;
                transform.localScale         = scale;
                textObj.transform.localScale = textObjScale;
                photonView.RPC("OnSpriteFlip", PhotonTargets.Others);
            }
        }
    }