Ejemplo n.º 1
0
 private void DragEvent()
 {
     GameAudios.PlaySfx(gameObject, GameAudios.dragPlatformSfx);
     if (pc)
     {
         pc.bJoystick = true;
     }
 }
Ejemplo n.º 2
0
    IEnumerator Fire()
    {
        while (true)
        {
            yield return(new WaitForSeconds(internalTime));

            if (weapon != null && firePoint != null)
            {
                Transform obj = Instantiate(weapon, transform);
                obj.position = firePoint.position;

                GameAudios.PlaySfx(gameObject, GameAudios.fireSfx);
            }
        }
    }
Ejemplo n.º 3
0
    private void SpawnPlatform(Vector3 direction)
    {
        GameAudios.StopSfx(gameObject);

        if (pc)
        {
            pc.bJoystick = false;
        }
        else
        {
            return;
        }
        if (!pc.CanSpawnPlatform())
        {
            return;
        }

        if (objToSpawn != null)
        {
            GameAudios.PlaySfx(gameObject, GameAudios.releasePlatformSfx);

            Transform platform = Instantiate(objToSpawn);
            platform.position = transform.position - direction.normalized * spawnDist;

            /*SlowdownByResistance slowdown = platform.GetComponent<SlowdownByResistance>();
             * if (slowdown)
             * {
             *  slowdown.SetInitVelocity(-spawnSpeedRate * direction);
             * }*/
            Rigidbody2D platformRigidbody = platform.GetComponent <Rigidbody2D>();
            if (platformRigidbody == null)
            {
                platformRigidbody                = platform.gameObject.AddComponent <Rigidbody2D>();
                platformRigidbody.mass           = mass;
                platformRigidbody.gravityScale   = 0.0f;
                platformRigidbody.drag           = 0.0f;
                platformRigidbody.angularDrag    = 0.0f;
                platformRigidbody.freezeRotation = true;
            }

            platformRigidbody.velocity = -spawnSpeedRate * direction;

            pc.AddPlatformNum(-1);
        }
    }
Ejemplo n.º 4
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.tag != "Player")
        {
            return;
        }
        Debug.Log("Enter ShowJoystick!");
        GameAudios.PlaySfx(collision.collider.gameObject, GameAudios.landSfx);

        SpawnByReleaseJoystic joystick = collision.gameObject.GetComponent <SpawnByReleaseJoystic>();

        if (joystick && collision.contacts[0].normal.y < 0.0f)
        {
            joystick.SetJoystickState(true);
            bShowJoystick = true;

            PlayerController pc = collision.collider.GetComponent <PlayerController>();
            if (pc && gameObject.tag == "Platform")
            {
                pc.SetLastPlatform(collision.collider.transform.position);
            }
        }
    }