// Update is called once per frame void Update() { if (mCooldown > 0f) { mCooldown -= Time.deltaTime; return; } // See if the player is in range and in a straight line, and if so, cast! if (Vector3.Distance(transform.position, Game.instance.avatar.transform.position) < 3f) { // Cast toward the player ... Vector3 direction = Game.instance.avatar.transform.position - spellCaster.transform.position; direction.y = 0f; direction.Normalize(); SimpleMovement.OrientToDirection(spellCaster.gameObject, direction); spellCaster.gameObject.transform.Rotate(0f, -90f, 0f); castingFX.gameObject.SetActive(true); castingFX.enableEmission = true; castingFX.transform.localScale = castingFXScale; spellCaster.CastSpell(12); mCooldown = 6f; StartCoroutine(DisableVFX()); } }
private void OnSkillDraw(List <Point> points) { Gesture candidate = new Gesture(points.ToArray()); Result gestureResult = PointCloudRecognizer.Classify(candidate, trainingSet.ToArray()); Debug.Log(gestureResult.GestureClass + " " + System.Math.Round(gestureResult.Score, 2)); spellCaster.CastSpell(gestureResult.GestureClass); }
private void CastSpell() { Vector3 playerPosition = Game.instance.avatar.transform.position; Vector3 direction = playerPosition - transform.position; direction.y = 0f; direction.Normalize(); SimpleMovement.OrientToDirection(mSimpleMovement.subMesh, direction); int magic = GetComponent <CharacterStatistics>().ModifiedStatValue(CharacterStatType.Magic, gameObject); mSpellCaster.CastSpell(magic); mCastCounter = 3; }
// Update is called once per frame void Update() { // Update health if (HealthBar != null) { HealthBar.fillAmount = health; } // If time is moving if (Time.timeScale > 0) { // Moving left and right if (Input.GetKey(KeyCode.A)) { rigidbody2D.AddForce(new Vector2(-MovementForce, 0)); animator.SetBool("Move", true); animator.SetBool("Left", true); } else if (Input.GetKey(KeyCode.D)) { rigidbody2D.AddForce(new Vector2(MovementForce, 0)); animator.SetBool("Move", true); animator.SetBool("Left", false); } else { animator.SetBool("Move", false); } // Jumping if (Input.GetKeyDown(KeyCode.W)) { rigidbody2D.AddForce(new Vector2(0, JumpingForce)); } // Animates jumping if (System.Math.Abs(rigidbody2D.velocity.y) <= 0.5f) { animator.SetBool("Jump", false); } else { animator.SetBool("Jump", true); } // Casting if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)) { animator.SetTrigger("Cast"); spellCaster.CastSpell(); } } // Pausing if (Input.GetKeyDown(KeyCode.Return) || Input.GetMouseButtonDown(1)) { if (PauseAnimator != null) { if (PauseAnimator.GetBool("Pause")) { PauseAnimator.SetBool("Pause", false); Time.timeScale = 1; } else { PauseAnimator.SetBool("Pause", true); Time.timeScale = 0; } } } }
public override void UpdateAI() { if (mCurrentState == AIState.Stun) { if (mStunTimer > 2f) { SwitchState(); } } else if (!mTeleportedIntoPlaceForState) { mTeleport.Teleport(true); mTeleportedIntoPlaceForState = true; // If we're going into the charging state, get ready to head toward the player ... mChargeDirection = TowardPlayer(); if (mCurrentState == AIState.Charging) { Game.instance.soundManager.PlaySound("boss2_charge"); } } else if (mCurrentState == AIState.Teleporting) { if (mTeleport.CanTeleport()) { ++mNumTeleports; int maxTeleports = 5 + mCurrentPhase; mTeleport.Teleport(); SimpleMovement.OrientToDirection(mSimpleMovement.subMesh, TowardPlayer()); if (mNumTeleports >= maxTeleports) { SwitchState(); } } } else if (mCurrentState == AIState.Charging) { if (mSimpleAttack.CanAttack(mChargeDirection)) { mSimpleAttack.Attack(mChargeDirection); FollowCamera.main.SimpleShake(); SwitchState(); } else if (mSimpleMovement.CanMove(mChargeDirection)) { mSimpleMovement.Move(mChargeDirection); } else { mStunTimer = 0f; mCurrentState = AIState.Stun; Game.instance.soundManager.PlaySound("boss2_smash"); FollowCamera.main.SimpleShake(); } } else if (mCurrentState == AIState.ForwardCast) { SimpleMovement.OrientToDirection(mSimpleMovement.subMesh, TowardPlayer()); mSpell2.CastSpell(20); SwitchState(); } else if (mCurrentState == AIState.ScreenCast) { SimpleMovement.OrientToDirection(mSimpleMovement.subMesh, TowardPlayer()); mSpell1.CastSpell(20); SwitchState(); } }