//prefab那邊有問題 小心 http://stackoverflow.com/questions/36095870/how-to-keep-references-to-ui-elements-in-a-prefab-instantiated-at-runtime void OnTriggerEnter2D(Collider2D other) { npcclass = GetComponentInParent <npcClass>(); triggerBullet(other); triggerNpc(other); //problem maybe? }
// Use this for initialization void Start() { npcclass = GetComponentInParent <npcClass>(); if (GameObject.FindGameObjectsWithTag("megumin_player").Length != 0) { selectEnemySystem = GameObject.FindGameObjectsWithTag("megumin_player")[0].GetComponent <selectEnemySystemScript>(); // } }
// Use this for initialization void Start() { rigid2d = GetComponentInParent <Rigidbody2D>(); npcclass = GetComponentInParent <npcClass>(); if (GameObject.FindGameObjectsWithTag("megumin_player").Length != 0) { selectEnemySystem = GameObject.FindGameObjectsWithTag("megumin_player")[0].GetComponent <selectEnemySystemScript>(); // } npcSkeletonAnimation.state.Complete += State_Complete; }
// Update is called once per frame void Update() { if (playerContorl != null) { inContorlObjectnpcClass = playerContorl.incontorlObj.GetComponent <npcClass>(); } soulsPart(); HPBARPart(); ShieldPart(); controlNpcTypeShow(); }
// Use this for initialization void Start() { playerData = GameObject.FindGameObjectsWithTag("backgroundScipt")[0].GetComponent <playerDataClass>(); // rigidbody2d = GetComponent <Rigidbody2D>(); npcclass = GetComponent <npcClass>(); playermove = GetComponent <playerMove>(); npcmove = GetComponent <npcMove>(); npcclass.npcClassSetUp(); ignoreCollisionSetUp();//無視其他enemy碰撞 thisAnimation.state.Complete += MyCompleteListener; DelegateSetUp(); }
void ShieldPart() { if (playerContorl != null) { inContorlObjectnpcClass = playerContorl.incontorlObj.GetComponent <npcClass>(); if (inContorlObjectnpcClass.HP > 0.0f) { shieldPart.enabled = true; } else { shieldPart.enabled = false; } } }
// Use this for initialization void Start() { rb2d = GetComponent <Rigidbody2D>(); npcscript = GetComponent <npcScript>(); npcclass = GetComponent <npcClass>(); patrolLeftPointSave = patrolLeftPoint.position; patrolRightPointSave = patrolRightPoint.position; if (transform.localScale.x < 0) { localScaleX = -1 * transform.localScale.x; } else { localScaleX = transform.localScale.x; } }
// Use this for initialization void Awake() { if (transform.localScale.x < 0) { localScaleX = -1 * transform.localScale.x; } else { localScaleX = transform.localScale.x; } npcclass = GetComponent <npcClass>(); npcScript = GetComponent <npcScript>(); rb2d = GetComponent <Rigidbody2D>(); GroundCheckWall1 = npcScript.GroundCheckWall1; GroundCheckWall2 = npcScript.GroundCheckWall2; }
// Use this for initialization void Start() { if (transform.localScale.x < 0) { localScaleX = -1 * transform.localScale.x; } else { localScaleX = transform.localScale.x; } SR = GetComponent <SpriteRenderer>(); npcclass = GetComponent <npcClass>(); npcScript = GetComponent <npcScript>(); GroundCheckWall1 = npcScript.GroundCheckWall1; GroundCheckWall2 = npcScript.GroundCheckWall2; }
// Use this for initialization void Awake() { rb2d = GetComponent <Rigidbody2D>(); npcscript = GetComponent <npcScript>(); GroundCheckWall1 = npcscript.GroundCheckWall1; GroundCheckWall2 = npcscript.GroundCheckWall2; npcclass = GetComponent <npcClass>(); patrolLeftPointSave = patrolLeftPoint.position; patrolRightPointSave = patrolRightPoint.position; if (transform.localScale.x < 0) { localScaleX = -1 * transform.localScale.x; } else { localScaleX = transform.localScale.x; } setPatrolDirection(); }
// Use this for initialization void Start() { playerData = GameObject.FindGameObjectsWithTag("backgroundScipt")[0].GetComponent <playerDataClass>(); // rigidbody2d = GetComponent <Rigidbody2D>(); npcclass = GetComponent <npcClass>(); npcclass.npcClassSetUp(); GameObject[] gameObj = GameObject.FindGameObjectsWithTag("enemy"); //無視其他enemy碰撞 foreach (GameObject each in gameObj) { Physics2D.IgnoreCollision(each.GetComponent <BoxCollider2D>(), GetComponent <BoxCollider2D>()); Physics2D.IgnoreCollision(each.GetComponent <BoxCollider2D>(), GetComponent <CircleCollider2D>()); Physics2D.IgnoreCollision(each.GetComponent <CircleCollider2D>(), GetComponent <BoxCollider2D>()); Physics2D.IgnoreCollision(each.GetComponent <CircleCollider2D>(), GetComponent <CircleCollider2D>()); } GameObject[] HPpartaclegameObj = GameObject.FindGameObjectsWithTag("HPpartacle"); //無視其他enemy碰撞 foreach (GameObject each in HPpartaclegameObj) { Physics2D.IgnoreCollision(each.GetComponent <Collider2D>(), GetComponent <BoxCollider2D>()); Physics2D.IgnoreCollision(each.GetComponent <Collider2D>(), GetComponent <CircleCollider2D>()); } }
public void Shot() { npcclass = GetComponentInParent <Transform>().GetComponentInParent <npcClass>(); Debug.Log(npcclass.HP); if (shootByNpc && npcclass != null) { if (npcclass.TypeP == npcClass.Type.contorl) { float Angle = ImageLookAt2D(transform.position, getCameraToV3(mouseInCameraPosition)).eulerAngles.z; spawnBulletSpecial1((int)Angle, endZRotation, everyAngleShotOnce); } else { float Angle = ImageLookAt2D(transform.position, Player.transform.position).eulerAngles.z; spawnBulletSpecial1((int)Angle, endZRotation, everyAngleShotOnce); } } else { float Angle = ImageLookAt2D(transform.position, Player.transform.position).eulerAngles.z; spawnBulletSpecial1((int)Angle, endZRotation, everyAngleShotOnce); } }
void Awake() { npcclass = GetComponentInParent <npcClass>(); audio = GetComponent <AudioSource>(); }