void Awake()
 {
     movementCheck = GetComponentInChildren <MovementCheck>();
     myJump        = GetComponentInChildren <EnemyJump>();
     collisionMask = LayerMask.GetMask("Ground");
     calculateRays();
 }
Пример #2
0
    private void Start()
    {
        aS = GetComponent <AudioSource>();

        eJ         = GetComponentInChildren <EnemyJump>();
        rb2D       = GetComponent <Rigidbody2D>();
        enemyStats = GetComponent <EnemyStats>();
        enemyType  = GetComponent <IEnemyType>();
        attackZone = transform.GetComponentInChildren <EnemyAttack>();
    }
Пример #3
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag == "Ground")
        {
            //プレイヤー死亡
            isDeadFlag = true;
        }

        if (other.gameObject.tag == "DGround")
        {
            OnDamegeEffect();
            Hp--;
            HPtext.text = string.Format("HP: {0}", Hp);
        }

        if (other.collider.tag == "Enemy")
        {
            //踏みつけ判定になる高さ
            float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));
            //踏みつけ判定のワールド座標
            float judgePos = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;
            Debug.Log("接触したよ");
            foreach (ContactPoint2D p in other.contacts)
            {
                if (p.point.y < judgePos)
                {
                    EnemyJump o = other.gameObject.GetComponent <EnemyJump>();
                    if (o != null)
                    {
                        otherJumpHeight = o.boundHeight;        //踏んづけたものから跳ねる高さを取得する
                        o.playerjump    = true;                 //踏んづけたものに対して踏んづけた事を通知する
                        jumpPos         = transform.position.y; //ジャンプした位置を記録する
                        isOtherJump     = true;
                        isJump          = false;
                        jumpTime        = 0.0f;
                        Debug.Log("ジャンプしたよ");
                        Camera.main.gameObject.GetComponent <CameraScritpt>().Shake();
                    }
                    else
                    {
                        Debug.Log("ObjectCollisionが付いてないよ!");
                    }
                }
                else
                {
                    isDown = true;
                    break;
                }
            }
        }
    }
Пример #4
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag == "Ground")
        {
            if (CS == 0)
            {
                Camera.main.gameObject.GetComponent <CameraScritpt>().Shake();
                Instantiate(playerDeathObj, transform.position, Quaternion.identity);

                //プレイヤー死亡
                isDeadFlag = true;
            }
            else
            {
                audioSource.PlayOneShot(JumpSE);
                otherJumpHeight = Recovery;             //踏んづけたものから跳ねる高さを取得する
                jumpPos         = transform.position.y; //ジャンプした位置を記録する
                isOtherJump     = true;
                Rcv             = true;
                isJump          = false;
                hip             = false;
                jumpTime        = 0.0f;
                on_ground       = true;
                StartCoroutine("WaitForit");
                //着地時のエフェクト
                switch (CS)
                {
                case ColorState.Blue:
                    Instantiate(BlueEffect, transform.position, Quaternion.identity);
                    break;

                case ColorState.Green:
                    Instantiate(GreenEffect, transform.position, Quaternion.identity);
                    break;

                case ColorState.Red:
                    Instantiate(RedEffect, transform.position, Quaternion.identity);
                    break;
                }
                CS = ColorState.White;
                return;
            }
        }
        if (other.gameObject.tag == "Rain")
        {
            Camera.main.gameObject.GetComponent <CameraScritpt>().Shake();
            Instantiate(playerDeathObj, transform.position, Quaternion.identity);
            isDeadFlag = true;
        }

        if (other.collider.tag == "Enemy" || other.collider.tag == "HighEnemy")
        {
            //踏みつけ判定になる高さ
            float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));
            //踏みつけ判定のワールド座標
            float judgePos = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;
            //Debug.Log("接触したよ");
            foreach (ContactPoint2D p in other.contacts)
            {
                if (p.point.y < judgePos)
                {
                    EnemyJump o = other.gameObject.GetComponent <EnemyJump>();
                    if (o != null)
                    {
                        anim1 = true;//animのtrue
                        audioSource.PlayOneShot(EnemyDeadSE);
                        audioSource.PlayOneShot(JumpSE);
                        otherJumpHeight = o.boundHeight;    //踏んづけたものから跳ねる高さを取得する
                        o.playerjump    = true;             //踏んづけたものに対して踏んづけた事を通知する
                        CS          = (ColorState)Enum.ToObject(typeof(ColorState), o.GetColor());
                        jumpPos     = transform.position.y; //ジャンプした位置を記録する
                        isOtherJump = true;
                        isJump      = false;
                        jumpTime    = 0.0f;
                        //Debug.Log("ジャンプしたよ");
                        Camera.main.gameObject.GetComponent <CameraScritpt>().Shake();
                        if (other.collider.tag == "Enemy")
                        {
                            score    += AddPoint / 2;//スコアを足す(4/17)
                            numScore += AddPoint / 2;
                        }
                        else
                        {
                            score    += HighPoint / 2;
                            numScore += HighPoint / 2;
                        }
                    }
                    else
                    {
                        Debug.Log("ObjectCollisionが付いてないよ!");
                    }
                }
                else
                {
                    isDown = true;
                    break;
                }
            }
        }
        //300点取る度にジャンプを一回増やす
        if (numScore >= 300)
        {
            IJumpC       += 1;
            numScore      = 0;
            IJump         = true;
            jumpText.text = string.Format("ジャンプ残り {0} 回", IJumpC);
        }
    }
	void Start () {
		jumpScript = jumpObject.GetComponent<EnemyJump> ();
	}
 void Begin()
 {
     enemyStates = GetComponent <EnemyStates>();
     enemyJump   = GetComponent <EnemyJump>();
 }