コード例 #1
0
ファイル: Rigidbody2D_ex.cs プロジェクト: scythae/Shmup
    public static void SetPaused(Rigidbody2D rb, bool paused)
    {
        Rigidbody2D_ex ex = rb.gameObject.GetComponent <Rigidbody2D_ex>();

        if (!ex)
        {
            ex = rb.gameObject.AddComponent <Rigidbody2D_ex>();
        }

        ex.SetPaused(paused);
    }
コード例 #2
0
    public static void SetEnabled(GameObject go, bool enabled)
    {
        foreach (PausableRepetition script in go.GetComponentsInChildren <PausableRepetition>())
        {
            script.enabled = enabled;
        }

        foreach (Pausable script in go.GetComponentsInChildren <Pausable>())
        {
            script.enabled = enabled;
        }

        foreach (Rigidbody2D rigidbody in go.GetComponentsInChildren <Rigidbody2D>())
        {
            Rigidbody2D_ex.SetPaused(rigidbody, !enabled);
        }
    }
コード例 #3
0
ファイル: Equipment.cs プロジェクト: scythae/Shmup
    protected virtual void Shot()
    {
        if (bulletTemplate == null)
        {
            return;
        }

        GameObject newBullet = (GameObject)Instantiate(bulletTemplate);

        Utils.AssignTransformFromTo(this.gameObject.transform, newBullet.transform);

        Rigidbody2D rb2D = newBullet.GetComponent <Rigidbody2D> ();
        Vector2     newBulletVelocity = this.gameObject.transform.up * bulletSpeed;

        Rigidbody2D_ex.SetScaledVelocity(rb2D, newBulletVelocity);

        AddComponentsToBullet(newBullet);
    }
コード例 #4
0
    protected void Move(Vector2 movement)
    {
        Rigidbody2D rb2D = this.gameObject.GetComponent <Rigidbody2D> ();

        if (rb2D == null)
        {
            return;
        }

        float movementMultiplifier = Speed * GetModifierValue(ShipModifierType.smtMoveSpeed);

        Rigidbody2D_ex.SetScaledVelocity(rb2D, movement * movementMultiplifier);

        rb2D.position = new Vector2(
            Mathf.Clamp(rb2D.position.x, zone.xMin, zone.xMax),
            Mathf.Clamp(rb2D.position.y, zone.yMin, zone.yMax)
            );
    }