Exemplo n.º 1
0
 void Start()
 {
     #region 当たり判定
     mainCamera       = GameObject.Find("Main Camera");
     mainCameraScript = mainCamera.GetComponent <Main_CameraScript>();
     #endregion
     #region 弾作成
     // 味方キャラクター のオブジェクトを取得
     GameObject friendChar = GameObject.FindWithTag(SceneCommon.Player_to_tag[friend]);
     // 弾のrigidbody2Dコンポーネントを取得
     Rigidbody2D rigidbody2D = GetComponent <Rigidbody2D>();
     // 味方キャラクター の向いている向きに弾を飛ばす
     rigidbody2D.velocity = new Vector2(speed * friendChar.transform.localScale.x, rigidbody2D.velocity.y);
     // 弾の画像の向きを 味方キャラクター に合わせる
     Vector2 temp = transform.localScale;
     temp.x = friendChar.transform.localScale.x / Common.SCALE;
     transform.localScale = temp;
     // 5秒後に消滅
     Destroy(gameObject, 5);
     #endregion
 }
        void Start()
        {
            mainCameraScript = GameObject.Find("Main Camera").GetComponent <Main_CameraScript>();
            #region 当たり判定
            opponent          = CommonScript.ReverseTeban((PlayerIndex)playerIndex);
            opponentHitboxTag = SceneCommon.PlayerAndHitbox_to_tag[(int)this.Opponent, (int)HitboxIndex.Hitbox];

            hitboxsSpriteRenderer = new SpriteRenderer[] {
                GameObject.Find(SceneCommon.PlayerAndHitbox_to_path[playerIndex, (int)HitboxIndex.Hitbox]).GetComponent <SpriteRenderer>(),
                GameObject.Find(SceneCommon.PlayerAndHitbox_to_path[playerIndex, (int)HitboxIndex.Weakbox]).GetComponent <SpriteRenderer>(),
                GameObject.Find(SceneCommon.PlayerAndHitbox_to_path[playerIndex, (int)HitboxIndex.Strongbox]).GetComponent <SpriteRenderer>(),
            };
            weakboxCollider2D = GameObject.Find(SceneCommon.PlayerAndHitbox_to_path[playerIndex, (int)HitboxIndex.Weakbox]).GetComponent <BoxCollider2D>();
            #endregion
            #region ジャンプ
            groundLayer = LayerMask.GetMask("Ground");
            Rigidbody2D = GetComponent <Rigidbody2D>();
            animator    = GetComponent <Animator>();
            #endregion

            // x位置を共有できるようにするぜ☆
            SceneCommon.Player_to_transform[playerIndex] = transform;
        }