Esempio n. 1
0
        // GUIとして描画する部分(Debug)
        //private void OnGUI()
        //{
        //    Vector2 pos = new Vector2(
        //        transform.position.x - CameraManager.Instance.BottomLeft.x,
        //        (-1) * transform.position.y - CameraManager.Instance.BottomLeft.y
        //    );

        //    GUI.Label(new Rect(
        //        pos.x * 40,
        //        pos.y * 40,
        //        30,
        //        30), _Hp.ToString(), GUI.skin.box);

        //    GUI.Label(new Rect(
        //        pos.x * 40,
        //        pos.y * 40 + 30,
        //        150,
        //        30), _StateMachine._CurrentState.ToString(), GUI.skin.box);
        //}

        #endregion // 基本

        #region 衝突

        private void OnCollisionEnter2D(Collision2D collision)
        {
            // PLに当たった場合
            if (collision.gameObject.GetComponent <PLBehaviour>() != null)
            {
                PLBehaviour pl = collision.gameObject.GetComponent <PLBehaviour>();

                SEManager.Instance.playSE(SEManager.SEName.Hit);
                _Speed = collision.gameObject.GetComponent <PLBehaviour>()._Speed;
                damage(pl._CollAttackPower);

                // パーティクル
                ParticleManager.Instance.initiateParticle(ParticleManager.ParticleName.Hit, collision.contacts[0].point);

                collision.gameObject.GetComponent <PLBehaviour>().hit(true);
            }
            // 他の敵に当たった場合
            else if (_StateMachine._CurrentState is Em1StateBlowOut &&
                     collision.gameObject.GetComponent <EnemyBehaviour>() != null)
            {
                Em1Behaviour otherEm = collision.gameObject.GetComponent <Em1Behaviour>();

                SEManager.Instance.playSE(SEManager.SEName.Hit);
                damage(otherEm._CollAttackPower);
                ParticleManager.Instance.initiateParticle(ParticleManager.ParticleName.Hit, collision.contacts[0].point);

                Vector3 currentSpeed = _Speed;
                _Speed = otherEm._Speed;

                // 当たった敵にも影響を与える
                otherEm._Speed = currentSpeed;
                otherEm.damage(_CollAttackPower);
            }
        }
 public void registerPLBehaviour(PLBehaviour pLBehaviour)
 {
     _plBehaviour = pLBehaviour;
 }