/* * AnimStates * 0 = idle * 1 = Walk * 2 = Attack * 3= Jump * 4 = GetHurt * 5= Death */ void Update() { if (altBuild) { tankMat.color = Color.HSVToRGB(.613f, .537f, .4f); } else if (!altBuild) { tankMat.color = Color.HSVToRGB(.613f, .537f, .82f); } anim.SetInteger("AnimState", 0); // colliders is for grounding the player, for jumping purposes. colliders = Physics.OverlapCapsule(transform.position, transform.position - (Vector3.up * .1f), .25f, groundMask, QueryTriggerInteraction.Ignore); h1 = health.health; #region Controls if (walkspeed >= 0 && CTRLID != 0 && !health.isDead) { playermovement = new Vector3(Input.GetAxis("J" + CTRLID + "Horizontal"), 0, Input.GetAxis("J" + CTRLID + "Vertical")); //Vector3 relpos = playermovement - transform.position; if (playermovement != Vector3.zero) { if (Input.GetKey("joystick " + CTRLID + " button 1") && cooldowns.activeCooldowns[0] <= 0 && !altBuild) { transform.rotation = transform.rotation; } else { transform.rotation = Quaternion.LookRotation(playermovement); } transform.Translate(playermovement * walkspeed * Time.deltaTime, Space.World); anim.SetInteger("AnimState", 1); } else { } } if (CTRLID != 0 && colliders.Length > 0 && Input.GetKeyDown("joystick " + CTRLID + " button 0")) { abilities.Jump(CTRLID, gameObject, jumpHeight); anim.SetInteger("AnimState", 3); } else { } if (CTRLID != 0 && Input.GetKey("joystick " + CTRLID + " button 3") && !health.isDead) { timer1 += Time.deltaTime; if (timer1 > reviveCastTime) { abilities.Revive(1, gameObject, reviveRadius); } } if (CTRLID != 0 && Input.GetKeyUp("joystick " + CTRLID + " button 3") && !health.isDead) { reviveCastTime = 0; } if (CTRLID != 0 && Input.GetKey("joystick " + CTRLID + " button 1") && cooldowns.activeCooldowns[0] <= 0 && !altBuild && !health.isDead) { GameObject cap = GameObject.CreatePrimitive(PrimitiveType.Capsule); Destroy(cap.GetComponent <CapsuleCollider>()); cap.transform.position = transform.position + transform.forward * 10; cap.transform.rotation = transform.rotation * Quaternion.Euler(90, 0, 0); cap.transform.localScale = new Vector3(1, 10, 1); cap.transform.parent = transform; Destroy(cap, Time.deltaTime + .002f); abilities.TankMagnet(magnetThreat, 0, gameObject, magnetCooldown, magnetMask, magnetDistance, pullSpeed); anim.SetInteger("AnimState", 2); tankMat.SetColor("_EmissionColor", Color.HSVToRGB(.7f, 1, 1)); } else { tankMat.SetColor("_EmissionColor", Color.HSVToRGB(.7f, 1, 0)); } if (CTRLID != 0 && Input.GetKeyUp("joystick " + CTRLID + " button 1") && !altBuild && !health.isDead) { cooldowns.triggerCooldown(0, magnetCooldown); } if (CTRLID != 0 && Input.GetKeyDown("joystick " + CTRLID + " button 2") && cooldowns.activeCooldowns[1] <= 0 && altBuild && !health.isDead) { abilities.TankPerfectShield(shieldHealth, 0, gameObject, perfectShieldCooldown, perfectShieldDuration, dodgeRadius); anim.SetInteger("AnimState", 2); } if (CTRLID != 0 && Input.GetKeyDown("joystick " + CTRLID + " button 2") && cooldowns.activeCooldowns[1] <= 0 && !altBuild && !health.isDead) { abilities.TankShield(shieldHealth, 0, gameObject, shieldCooldown, shieldDuration, InfiniteShield, shieldSize); anim.SetInteger("AnimState", 2); } if (CTRLID != 0 && Input.GetKey("joystick " + CTRLID + " button 1") && cooldowns.activeCooldowns[0] <= 0 && altBuild && !health.isDead) { //timer += Time.deltaTime; //reflectDamage += (h2 - h1) * 2; abilities.TankReflect(reflectDamage, 0, gameObject, reflectCooldown, true, h1, h2, timer, reflectDistance, beamWidth, damageMultiplier); tankMat.SetColor("_EmissionColor", Color.HSVToRGB(.5f, 1, 1)); //if (timer > 2) //{ // timer = 0; // reflectDamage = 0; //} } if (CTRLID != 0 && Input.GetKeyUp("joystick " + CTRLID + " button 1") && cooldowns.activeCooldowns[0] <= 0 && altBuild && !health.isDead) { tankMat.SetColor("_EmissionColor", Color.HSVToRGB(.5f, 1, 0)); cooldowns.triggerCooldown(0, reflectCooldown); //timer = 0; //reflectDamage = 0; } if (CTRLID != 0 && Input.GetKeyDown("joystick " + CTRLID + " button 5")) { altBuild = !altBuild; } #endregion #region Health and Death if (h1 < h2) { tankMat.SetColor("_EmissionColor", Color.HSVToRGB(1, 1, 1)); anim.SetInteger("AnimState", 4); h2 = h1; } else if (tankMat.GetColor("_EmissionColor") != Color.HSVToRGB(1, 1, 0) && !Input.GetKey("joystick " + CTRLID + " button 1")) { tankMat.SetColor("_EmissionColor", Color.HSVToRGB(1, 1, 0)); } if (health.isDead) { anim.SetInteger("AnimState", 5); walkspeed = 0; playermovement *= 0; } else { walkspeed = 10; } #endregion }
public void TankShield(float damage, int playerID, GameObject me, float CD, float duration, bool infiniteshield, float shieldsize) { GameObject clone; clone = Instantiate(Resources.Load("Shield_Magnetable"), me.transform.position, me.transform.rotation) as GameObject; clone.transform.localScale = new Vector3(shieldsize, shieldsize, shieldsize); if (!infiniteshield) { Destroy(clone, duration + 1); } cooldown.abilityCooldowns[1] = CD; cooldown.triggerCooldown(1, CD); }