void Update() { gunTrans = playerCharacter.GetComponentInChildren <GunController>(); swordTrans = playerCharacter.GetComponentInChildren <SwordController>(); if (gunTrans != null && gunTrans.isActiveAndEnabled) { playerTransform = gunTrans.GetComponent <Transform>(); } else if (swordTrans != null && swordTrans.isActiveAndEnabled) { playerTransform = swordTrans.GetComponent <Transform>(); } enemyAgent.SetDestination(playerTransform.position); enemyPlayerDistance = Mathf.Abs(Vector3.Distance(playerTransform.position, transform.position)); if (enemyPlayerDistance <= thresholdVisiblityDistance) { bulletRenderer.enabled = true; } else { bulletRenderer.enabled = false; } if (enemyLife <= 0f) { // Debug.Log("enemy killed!"); gameManager.enemyKilled(); Destroy(gameObject); } }
void Update() { Jump(); if (mask6.GetComponent <BoxCollider2D>().enabled == false && crate2ready) { crate2.GetComponent <Rigidbody2D>().gravityScale = 0.5f; crate2.GetComponent <BoxCollider2D>().enabled = true; crate2.transform.position = new Vector2(2.5f, 1.5f); crate2ready = false; } if (Input.GetKeyDown(KeyCode.P)) { SwordController sword = GetComponentInChildren <SwordController>(); sword.SendMessage("SwingSword"); swordsound.Play(); } if (Input.GetKeyDown(KeyCode.E)) { if (hat.transform.parent == this) { hat.SendMessage("Escape"); } } if (winner) { winTime += Time.deltaTime; } }
// Start is called before the first frame update void Start() { anim = this.GetComponent <Animator>(); movement = this.GetComponent <MoveController>(); swordControl = this.GetComponent <SwordController>(); cutPlane.gameObject.SetActive(false); }
void Awake() { m_Animator = GetComponent <Animator>(); m_Rigidbody2D = GetComponent <Rigidbody2D>(); m_Shadow = GetComponentInChildren <ShadowController>(); m_Sword = GetComponentInChildren <SwordController>(); }
void OnTriggerEnter2D(Collider2D collider) { if ((collider.gameObject.tag == "lethalSword" || collider.gameObject.tag == "blockingSword") && !alternateSwordHitBox.Equals(collider.gameObject)) { Vector3 otherPlayerPosition = Vector3.zero; SwordController swordController = collider.gameObject.GetComponent <SwordController>(); if (swordController != null) { otherPlayerPosition = swordController.currentPlayer.transform.position; } else { otherPlayerPosition = collider.gameObject.transform.position; } currentPlayerController.setReeling(); Vector3 force = currentPlayer.transform.position - otherPlayerPosition; currentPlayer.GetComponent <Rigidbody2D>().AddForce(force * 250f); canHitPlayer = false; } else if (canHitPlayer && collider.gameObject.tag == "player" && !currentPlayer.Equals(collider.gameObject)) { collider.gameObject.GetComponent <PlayerController> ().takeDamage(currentPlayer.GetComponent <PlayerController>()); //GameObject swordClash = Instantiate<GameObject>(swordClashPrefab); //swordClash.transform.position = (collider.transform.position+transform.position)/2f; } }
public void Initialize() { if (CurrentCharacter != null) { Destroy(CurrentCharacter.gameObject); } CurrentCharacter = Instantiate(CharacterBase); }
void UpdateSword() { SwordController sc = gameObject.GetComponentInChildren <SwordController>(); sc.UpdateColour(attackPower / 100); attacking = sc.UpdateSword(attacking, charging); }
public virtual void PickUp(SwordController sword) { rb.bodyType = RigidbodyType2D.Kinematic; transform.DOKill(); transform.SetParent(sword.bladePos); transform.localPosition = Vector3.zero; transform.localRotation = sword.transform.rotation; state = PickUpState.PickedUp; }
private void Start() { player = GameObject.FindGameObjectWithTag("Player"); sc = gameObject.GetComponentInChildren <SwordController>(); r = GetComponent <MeshRenderer>(); r.material.color = Color.green; }
void Start() { _swordController = GetComponentInChildren <SwordController>(); _inputActions = new PlayerInputAction(); _inputActions.Enable(); // attack _inputActions.Player.Attack.performed += _ => _swordController.SwingSword(); }
void OnCollisionEnter2D(Collision2D collision) { GameObject other = collision.gameObject; if (other.CompareTag("Bad")) { SwordController sc = other.GetComponent <SwordController> (); health -= sc.damage; } }
void Start() { bulletRenderer = GetComponent <MeshRenderer>(); gameManager = gameManagerObject.GetComponent <GameMamager>(); playerCharacter = GameObject.FindGameObjectWithTag("Player"); gunTrans = playerCharacter.GetComponentInChildren <GunController>(); swordTrans = playerCharacter.GetComponentInChildren <SwordController>(); InvokeRepeating("hitPlayer", 3, 1); }
private void Awake() { if (Instance != null && Instance != this) { Destroy(gameObject); } else { Instance = this; } swordTrail.Stop(); }
void Awake() { /* Singleton */ if (instance == null) { instance = this; } else { DestroyImmediate(gameObject); } /* End of Singleton */ }
// Start is called before the first frame update void Start() { anim = this.GetComponent <Animator>(); input = this.GetComponent <MoveController>(); aimControl = this.GetComponent <AimController>(); swordControl = this.GetComponent <SwordController>(); skinMeshList = GetComponentsInChildren <SkinnedMeshRenderer>(); impulse = FindObjectOfType <CinemachineFreeLook>().GetComponent <CinemachineImpulseSource>(); Volume postVolume = FindObjectOfType <Volume>(); VolumeProfile postProfile = postVolume.profile; postProfile.TryGet <LensDistortion>(out distorsion); }
private void CheckCollider(Collider c, bool isStay) { if (c.tag == enemy) { SwordController sword = c.GetComponent <SwordController>(); if (sword) { if (sword.isAttacking && !sword.SetHit(this)) { TakeDamage(2); } } else if (!isStay) //Only sword attacks are valid for OnTriggerStay { TakeDamage(2); } } }
public override void Initialize(GameObject obj) { if (swordTriggerable == null) { //GameObject player = GameObject.FindGameObjectWithTag(playerTag).transform.root.gameObject; swordTriggerable = obj.GetComponent <SwordTriggerable>(); //No funciona pq esta disable la espada espadaGO = obj.transform.Find("Espada").gameObject; //espadaGO = GameObject.FindGameObjectsWithTag(espadaGameObjectTag)[0]; //posiblie solucion al disable swordTriggerable.swordGO = espadaGO; swordController = espadaGO.GetComponentInChildren <SwordController>(); swordTriggerable.swordController = swordController; Sword = swordController.SwordSc; swordTriggerable.sword = Sword; } }
void Update() { Jump(); if (Input.GetKeyDown(KeyCode.P)) { SwordController sword = GetComponentInChildren <SwordController>(); sword.SendMessage("SwingSword"); swordsound.Play(); } if (Input.GetKeyDown(KeyCode.E)) { if (hat.transform.parent == this) { hat.SendMessage("Escape"); } } if (winner) { winTime += Time.deltaTime; } }
private void hitPlayer() { gunTrans = playerCharacter.GetComponentInChildren <GunController>(); swordTrans = playerCharacter.GetComponentInChildren <SwordController>(); if (gunTrans != null && gunTrans.isActiveAndEnabled) { playerTransform = gunTrans.GetComponent <Transform>(); } else if (swordTrans != null && swordTrans.isActiveAndEnabled) { playerTransform = swordTrans.GetComponent <Transform>(); } float distance = Vector3.Distance(playerTransform.position, transform.position); distance = Mathf.Abs(distance); if (distance < enemyHitDistance) { // Debug.Log("player hit!"); playerCharacter.GetComponent <PlayerContoller>().playerLife -= enemyHitDamag; } }
// Start is called before the first frame update void Start() { body = transform.Find("Body").gameObject; bodyController = body.GetComponent <BodyController>(); pAnim = body.GetComponent <Animator>(); rbPlayer = GetComponent <Rigidbody>(); dirt = transform.Find("Dirt").gameObject; mainCamera = GameObject.Find("Main Camera"); swordObject = transform.Find("Sword").gameObject; swordController = swordObject.GetComponent <SwordController>(); swordController.pScript = this; sound = GetComponent <AudioSource>(); hpView = GameObject.Find("HP View").GetComponent <TextMeshProUGUI>(); killsView = GameObject.Find("Kills View").GetComponent <TextMeshProUGUI>(); Physics.gravity = Menu.gravity * gravityModifier; updateView(); //initialSpeed = speed; SetBounds(); }
public override void PickUp(SwordController sword) { base.PickUp(sword); transform.localEulerAngles = Vector3.zero; transform.DOKill(); }
void Start() { sc = SWROD.GetComponent<SwordController>(); SWROD.SetActive(false); }
public override void PickUp(SwordController sword) { base.PickUp(sword); }