public void Init(Bezier2D path, Player player) { Path = path; _player = player; var g = GetComponentsInChildren <GimmickBase>(); _gimmicks = new GimmickInfo[g.Length]; for (var i = 0; i < g.Length; i++) { _gimmicks[i] = new GimmickInfo(g[i]); g[i].Init(); } //昇順にソート _gimmicks = _gimmicks .OrderBy((item) => item.Gimmick.StartPoint) .ToArray(); SetStartTime(); SetLine(); for (var i = g.Length - 1; i >= 0; i--) { _gimmicks[i].Gimmick.SpawnModel(player); } GameMaster.Instance.OnGameStart += () => _startTime = Time.time; }
void Start() { mInfo = transform.root.GetComponent <MapInfo>(); gInfo = GetComponent <GimmickInfo>(); //if (gInfo.type == GimmickInfo.GimmickType.WATER) { // sController.Waters.Add(gameObject); //} if (FindObjectOfType <BossController>()) { bossCon = FindObjectOfType <BossController>(); } }
/// <summary> /// ジャンプ判定 /// </summary> /// <param name="col">足元のObject</param> /// <returns></returns> bool JumpCheck(GameObject col) { if (col.GetComponent <ItemManager>()) { return(false); } // Item if (col.gameObject.layer == 2) { return(false); } // 背景 if (col.gameObject.layer == LayerMask.NameToLayer("BackGround")) { return(true); } if (col.GetComponent <KeyBlockCol>()) { return(false); } // 鍵ActiveCollider if (col.GetComponent <GimmickInfo>()) { GimmickInfo info = col.GetComponent <GimmickInfo>(); if (info.type == GimmickInfo.GimmickType.LADDER) { return(false); } // はしご if (info.type == GimmickInfo.GimmickType.FIREFIELD) { return(false); } // 敵攻撃範囲 if (info.type == GimmickInfo.GimmickType.THUNDERFIELD) { return(false); } // 敵攻撃範囲 } return(true); }
private void OnTriggerExit2D(Collider2D col) { //スイッチから降りた時 if (SwitchCheck(col.gameObject)) { move_ctr.switchGimmick = null; col.GetComponent <GimmickController>().OnPlayerFlag = false; } if (col.gameObject.layer != 2 && JumpCheck(col.gameObject)) { onGroundCount--; } if (col.gameObject.name == "FallCol") { _onFallBlock = false; } if (col.GetComponent <GimmickInfo>()) { if (col.GetComponent <GimmickInfo>().type == GimmickInfo.GimmickType.FIREFIELD && onGroundCount <= 0) { return; } if (col.GetComponent <GimmickInfo>().type == GimmickInfo.GimmickType.THUNDERFIELD && onGroundCount <= 0) { return; } if (col.GetComponent <MagicBalletController>() && onGroundCount <= 0) { return; } } if (onGroundCount <= 0) { onGroundCount = 0; isLanding = false; } if (col.gameObject.layer == 2 && !col.GetComponent <MapChange>()) { move_ctr.InLadderCount--; move_ctr.ladderDownFlag = false; } if (!col.GetComponent <GimmickInfo>()) { return; } player_ctr.OnGimmick = null; GimmickInfo info = col.GetComponent <GimmickInfo>(); switch (col.GetComponent <GimmickInfo>().type) { case GimmickInfo.GimmickType.GROWTREE: _onLandding = false; player_ctr.rideTreeFlag = false; break; case GimmickInfo.GimmickType.LADDER: move_ctr.ladderDownFlag = false; move_ctr.InLadderCount--; if (move_ctr.InLadderCount <= 0) { move_ctr.InLadderCount = 0; } break; } }
private void OnTriggerEnter2D(Collider2D col) { // switchの上にいるか判定 if (SwitchCheck(col.gameObject)) { move_ctr.switchGimmick = col.gameObject; col.GetComponent <GimmickController>().OnPlayerFlag = true; } //動く雲と背景、敵の攻撃コライダー以外のブロックに当たった時 if (!col.gameObject.GetComponent <CloudCol>() || col.gameObject.layer != 2 || col.gameObject.layer != LayerMask.NameToLayer("AttackField")) { //Debug.Log("col.gameObject.name = " + col.gameObject.name); if (_onLandding || _onMoveCloud) { _onMoveCloud = false; _onLandding = false; } } if (col.gameObject.GetComponent <CloudCol>()) { Debug.Log("getLandingCloud = " + col.gameObject.GetComponent <CloudCol>().getLandingCloud); if (col.gameObject.GetComponent <CloudCol>().getLandingCloud) { _onMoveCloud = true; _onLandding = true; } } //ちくわブロックに乗っかった時 if (col.gameObject.name == "FallCol") { _onFallBlock = false; } if (col.gameObject.layer != 2 && JumpCheck(col.gameObject) && !col.GetComponent <MagicBalletController>()) { move_ctr.setJumping = false; onGroundCount++; } if (onGroundCount > 0) { isLanding = true; } if (col.gameObject.layer == LayerMask.NameToLayer("Block")) { Rigidbody2D rb = transform.parent.GetComponent <Rigidbody2D>(); rb.velocity = new Vector2(rb.velocity.x, 0); player_ctr.OnBlock = col.gameObject; if (gameObject.layer == LayerMask.NameToLayer("LadderPlayer")) { player_ctr.ChangeLayer(); move_ctr.ladderDownFlag = true; move_ctr.InLadderCount = 1; return; } } // 壁ブロックなら if (col.gameObject.layer == 2 && !col.GetComponent <MapChange>()) { move_ctr.InLadderCount++; move_ctr.ladderDownFlag = true; } if (!col.GetComponent <GimmickInfo>()) { return; } GimmickInfo info = col.GetComponent <GimmickInfo>(); player_ctr.OnGimmick = col.gameObject; switch (info.type) { case GimmickInfo.GimmickType.GROWTREE: player_ctr.rideTreeFlag = true; _onLandding = true; break; case GimmickInfo.GimmickType.LADDER: move_ctr.InLadderCount++; break; } player_ctr.OnBlock = null; }