void AttackUpdate() { if (anim != null && atkTimer > atkDelay && !dead) { if (dSCollection != null) { switch (curAMode) { case eAttackMode.NORMAL: if ((int)atkTimer % 5 == 0) { if (dSCollection.skills [1].isActive) { dSCollection.skills [1].target = targeter.SelectTarget(dSCollection.skills [1].effectRange); // disable the button dSCollection.skills [1].isActive = false; dSCollection.skills [1].activate(); } anim.SetTrigger("Attack"); } else if ((int)atkTimer % 2 == 0) { if (dSCollection.skills [0].isActive) { dSCollection.skills [0].target = targeter.SelectTarget(dSCollection.skills [0].effectRange); // disable the button dSCollection.skills [0].isActive = false; dSCollection.skills [0].activate(); } anim.SetTrigger("Attack"); } break; case eAttackMode.FRENZY: if ((int)atkTimer % 3 == 0) { if (dSCollection.skills [1].isActive) { dSCollection.skills [1].target = targeter.SelectTarget(dSCollection.skills [1].effectRange); // disable the button dSCollection.skills [1].isActive = false; dSCollection.skills [1].activate(); } anim.SetTrigger("Attack"); } else if ((int)atkTimer % 1 == 0) { if (dSCollection.skills [0].isActive) { dSCollection.skills [0].target = targeter.SelectTarget(dSCollection.skills [0].effectRange); // disable the button dSCollection.skills [0].isActive = false; dSCollection.skills [0].activate(); } anim.SetTrigger("Attack"); } break; } } atkDelay = atkTimer + 1; } atkTimer += Time.deltaTime; foreach (IsASkill skill in dSCollection.skills) { skill.isActive = true; } }
// read axis input from controller and make player walk fwd/back or turn l/r public void PlayerLogicUpdate() { h = Input.GetAxis("Horizontal"); v = Input.GetAxis("Vertical"); this.transform.Rotate(new Vector3(0.0f, h * rotSpeed * Time.deltaTime, 0.0f)); if (v < 0) { this.transform.forward = -forwardTargetObj.transform.forward; //this.transform.Translate(new Vector3(0.0f, 0.0f, v * walkBckSpeed * Time.deltaTime)); this.transform.position += this.transform.forward * -v * walkSpeed * Time.deltaTime; } else if (v > 0) { this.transform.forward = forwardTargetObj.transform.forward; //this.transform.Translate(new Vector3(0.0f, 0.0f, v * walkSpeed * Time.deltaTime)); this.transform.position += this.transform.forward * v * walkSpeed * Time.deltaTime; } anim.SetFloat("Horizontal", h); anim.SetFloat("Vertical", v); if (Input.GetKeyUp(KeyCode.Space)) { anim.SetTrigger("Jump"); } //AnimatorStateInfo currAnimationState = anim.GetCurrentAnimatorStateInfo(0); if (pSCollection != null) { // if (targeter != null) // { // GameObject targetedObj = targeter.SelectTarget(5f); // foreach (IsASkill skill in pSCollection.skills) // { // skill.target = targetedObj; // } // } //if (currAnimationState.IsName("Idle") || // currAnimationState.IsName("Run") || // currAnimationState.IsName("Run 0")) //{ // normal attack if (Input.GetKeyUp(KeyCode.Alpha1)) { if (pSCollection.skills[0].isActive) { pSCollection.skills[0].target = targeter.SelectTarget(pSCollection.skills[0].effectRange); // disable the button pSCollection.skills[0].isActive = false; pSCollection.skills[0].activate(); anim.SetTrigger("Attack1"); } } // fire medium attack if (Input.GetKeyUp(KeyCode.Alpha2)) { if (pSCollection.skills[1].isActive) { pSCollection.skills[1].target = targeter.SelectTarget(pSCollection.skills[1].effectRange); // disable the button pSCollection.skills[1].isActive = false; pSCollection.skills[1].activate(); anim.SetTrigger("Attack2"); } } // fire strong attack if (Input.GetKeyUp(KeyCode.Alpha3)) { if (pSCollection.skills[2].isActive) { pSCollection.skills[2].target = targeter.SelectTarget(pSCollection.skills[2].effectRange); // disable the button pSCollection.skills[2].isActive = false; pSCollection.skills[2].activate(); anim.SetTrigger("Attack3"); } } // ice medium attack if (Input.GetKeyUp(KeyCode.Alpha4)) { if (pSCollection.skills[3].isActive) { pSCollection.skills[3].target = targeter.SelectTarget(pSCollection.skills[3].effectRange); // disable the button pSCollection.skills[3].isActive = false; pSCollection.skills[3].activate(); anim.SetTrigger("Attack2"); } } // ice strong attack if (Input.GetKeyUp(KeyCode.Alpha5)) { if (pSCollection.skills[4].isActive) { pSCollection.skills[4].target = targeter.SelectTarget(pSCollection.skills[4].effectRange); // disable the button pSCollection.skills[4].isActive = false; pSCollection.skills[4].activate(); anim.SetTrigger("Attack3"); } } // do damage if (Input.GetKeyUp(KeyCode.Return)) { this.GetComponent <IsDamager>().DoDamage(targetEnemy); } // ACTIVATE SKILLS AGAIN // normal attack animation has ended //if (currAnimationState.IsName("Attack01")) //{ // // normal attack done playing; activate // pSCollection.skills[0].isActive = true; //} if (!pSCollection.skills[0].isActive && normalAtkTimer < 1.0f) // 1 second cooldown { Debug.Log(this.gameObject.name); normalAtkTimer += Time.deltaTime; } else { // reset timer back to 0 and activate skill again normalAtkTimer = 0.0f; pSCollection.skills[0].isActive = true; } // fire arrow timer has ended if (!pSCollection.skills[1].isActive && fireArrowTimer < 3.0f) // 3 second cooldown { fireArrowTimer += Time.deltaTime; } else { // reset timer back to 0 and activate skill again fireArrowTimer = 0.0f; pSCollection.skills[1].isActive = true; } // fireball timer has ended if (!pSCollection.skills[2].isActive && fireballAtkTimer < 7.0f) // 7 second cooldown { fireballAtkTimer += Time.deltaTime; } else { // reset timer back to 0 and activate skill again fireballAtkTimer = 0.0f; pSCollection.skills[2].isActive = true; } // ice attack timer has ended if (!pSCollection.skills[3].isActive && iceAtkTimer < 3.0f) // 3 second cooldown { iceAtkTimer += Time.deltaTime; } else { // reset timer back to 0 and activate skill again iceAtkTimer = 0.0f; pSCollection.skills[3].isActive = true; } // ice dragon timer has ended if (!pSCollection.skills[4].isActive && iceDragonTimer < 7.0f) // 7 second cooldown { iceDragonTimer += Time.deltaTime; } else { // reset timer back to 0 and activate skill again iceDragonTimer = 0.0f; pSCollection.skills[4].isActive = true; } } // check if HP is 0 IntData[] attributes = GetComponents <IntData>(); if (attributes != null) { //iterate through IntData attributes foreach (IntData attribute in attributes) { if (attribute.key == "HP") { if (attribute.val <= 0) { // dead; call the Dead trigger this.GetComponent <Animator>().SetTrigger("Dead"); } } } } }