void Attack() { if (updateAttack) { // Attack the player // For melee type if (!charType.isSpecial && charType.isMelee && !charType.isRanged) { if (Time.time % 10 > 5f) { charType.Secondary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); } else { charType.Tertiary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); } } // For ranged type else if (!charType.isSpecial && charType.isMelee && charType.isRanged) { charType.Secondary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); } // For teleport type else if (charType.isSpecial && charType.isMelee && charType.isRanged) { if (Time.time % 10 > 7f) { charType.Primary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); } else if (Time.time % 10 > 6f) { charType.Secondary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); } else { charType.Tertiary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); } } StartCoroutine(PauseAttack(attackWait)); } // If we're too far away from the player go back and chase them again if (Vector2.Distance(pathfinding.target.position, myTrans.position) > attackDistance) { print("I should chase."); state = 1; pathFollower.speed = 3 + GlobalMoveSpeed.GetSpeedDelta(); pathFollower.shouldMove = true; } }
// Update is called once per frame void Update() { cam = GameObject.FindGameObjectWithTag("MainCamera"); cam.transform.SetParent(transform); cam.transform.localPosition = new Vector3(0, 0, -10); if (Input.GetButtonDown("Fire1")) { characterType.Primary(); } else if (Input.GetButtonDown("Fire2")) { characterType.Secondary(); } else if (Input.GetButtonDown("Fire3")) { characterType.Tertiary(); } else if (Input.GetButtonDown("Hypno")) { if (characterType.name != "Hypno") { //StartCoroutine(NoNeutral(2f)); PlayerController np = og.GetComponent <PlayerController>(); np.enabled = true; characterType.rotationTrans.SetActive(false); np.characterType.rotationTrans.SetActive(true); GetComponent <Rigidbody2D>().isKinematic = true; GetComponent <BoxCollider2D>().enabled = false; np.name = name; np.name.text = np.GetComponent <CharacterType>().name; cam.transform.SetParent(og.transform); cam.transform.localPosition = new Vector3(0, 0, -10); characterType.dead = true;//it should kill itself characterType.Die(); // Destroy(this); } else { StartCoroutine(Hypno()); } } UpdateUI(); CheckState(); }