public override void Update() { if (Summoned) { CurrentState.Execute(); if (!spellPrefabs [HEAL].OnCooldown()) { spellCaster.Cast(HEAL, Targets [0]); } } }
/// <summary> /// Handles leystrokes regarding magic attacks. /// </summary> void handleMagicAttack() { if (Input.GetButtonDown("Spell1")) { caster.Cast(0, target); } else if (Input.GetButtonDown("Spell2")) { caster.Cast(1, target); } else if (Input.GetButtonDown("Spell3")) { caster.Cast(2, target); } else if (Input.GetButtonDown("Spell4")) { caster.Cast(3, target); } if (Input.GetButtonUp("Spell1")) { caster.StopCast(0); } else if (Input.GetButtonUp("Spell2")) { caster.StopCast(1); } else if (Input.GetButtonUp("Spell3")) { caster.StopCast(1); } else if (Input.GetButtonUp("Spell4")) { caster.StopCast(2); } }
// Update is called once per frame void Update() { input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); playerToMouse = GetMousePos() - rb.position; if (Input.GetAxisRaw("Fast Speed") == 1) { character.currentSpeed = CharacterSpeed.FAST; } else { character.currentSpeed = CharacterSpeed.NORMAL; } if (character.currentSpeed == CharacterSpeed.FAST) { if ((lastNoisePosition - transform.position).magnitude > fastWalkingNoiseDistance) { lastNoisePosition = transform.position; character.noiseEmitter.EmitNoise(fastWalkingSpeedNoiseRadius); } } // change radius for area spells if (spellCaster.spellRadius + Input.GetAxis("Mouse ScrollWheel") * 5 != spellCaster.spellRadius) { // update effect radiuses spellCaster.spellRadius = spellCaster.spellRadius + Input.GetAxis("Mouse ScrollWheel") * 5; } // cast spell on click; if (Input.GetMouseButtonUp(0)) { spellCaster.Cast(true); } if (Input.GetAxisRaw("Cast Spell") == 1 && !specialCastKeydown) { specialCastKeydown = true; spellCaster.Cast(false); } if (Input.GetAxisRaw("Cast Spell") == 0) { specialCastKeydown = false; } if (Input.GetButtonDown("Pause")) { pause = !pause; camAnimator.SetBool("paused", pause); //Time.timeScale = 0.05f; } if (Input.GetButtonDown("Menu") && !menuPause) { //Time.timeScale = 0; menuPause = true; SharedSceneController.Instance.OpenFortressMenu(); } if (Input.GetButtonDown("CurrentMission")) { showCurrentMissionElement.Value = !showCurrentMissionElement.Value; } if (Input.GetButtonDown("Minimap")) { showMinimap.Value = !showMinimap.Value; } if (pause) { Time.timeScale = Mathf.Max(pauseSpeed, Time.timeScale - pauseTimeIncrement); } else { Time.timeScale = Mathf.Min(1, Time.timeScale + unpauseTimeIncrement); } if (spellCaster.selectedSpell.Value != null && spellCaster.selectedSpell.Value.spellTarget == SpellTarget.MISSILE) { if (Input.GetMouseButtonDown(0)) { selectingTargetsStartPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); } selectingTargets = Input.GetMouseButton(0); if (selectingTargets) { var mousePosWorld = Camera.main.ScreenToWorldPoint(Input.mousePosition); var width = mousePosWorld.x - selectingTargetsStartPos.x; var height = mousePosWorld.y - selectingTargetsStartPos.y; var pos = new Vector3(width > 0 ? selectingTargetsStartPos.x : mousePosWorld.x, height > 0 ? selectingTargetsStartPos.y : mousePosWorld.y); spellCaster.spellTarget.GetComponent <MagicTargetMissileController>().SelectRect(pos + new Vector3(Mathf.Abs(width) / 2, Mathf.Abs(height) / 2), new Vector2(Mathf.Abs(width), Mathf.Abs(height)) ); } } }