Esempio n. 1
0
    private void PlayRandomDance()
    {
        SimpleMovement.OrientToDirection(commonComponents.simpleMovement.subMesh, Vector3.back);
        int dance = Random.Range(1, 5);

        commonComponents.animator.Play("Dance" + dance);
    }
Esempio n. 2
0
    // 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());
        }
    }
Esempio n. 3
0
    public override void UpdateAI()
    {
        if (mCurrentState == AIState.Teleporting && mTeleport.CanTeleport())
        {
            mNumTeleports++;
            mTeleport.Teleport(mNumTeleports == mMaxTeleports);

            if (mNumTeleports == mMaxTeleports)
            {
                mCurrentState = AIState.Throwing;

                mMaxTeleports = Random.Range(4, 7) + mCurrentPhase;
            }
        }
        else if (mCurrentState == AIState.Throwing)
        {
            SimpleMovement.OrientToDirection(mSimpleMovement.subMesh, TowardPlayer());
            mProjectileThrower.ThrowProjectile(20, TowardPlayer());

            mCurrentState = AIState.Delay;

            mNumTeleports = 0;
            mDelayTimer   = 0f;
        }
        else if (mCurrentState == AIState.Delay)
        {
            if (mDelayTimer > 1.5f - mCurrentPhase * 0.5f)
            {
                mCurrentState = AIState.Teleporting;
                mNumTeleports = 0;
            }
        }
    }
Esempio n. 4
0
    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;
    }
Esempio n. 5
0
    private void ThrowProjectile()
    {
        SimpleMovement.OrientToDirection(GetComponent <SimpleMovement>().subMesh, TargetDirection());

        int magic = GetComponent <CharacterStatistics>().ModifiedStatValue(CharacterStatType.Magic, gameObject);

        float speedModifier = 1f;

        if (Game.instance.playerStats.IsItemEquipped <BlackCoffee>())
        {
            speedModifier = 0.65f;
        }

        mProjectileThrower.ThrowProjectile(magic, TargetDirection(), null, speedModifier);

        mThrowCounter = 2;
    }
Esempio n. 6
0
    private IEnumerator PlayExitDungeonSequence()
    {
        // Find the player and place them at the correct location
        PlayerController avatar = Game.instance.avatar;

        avatar.enabled = false;

        SimpleMovement.OrientToDirection(avatar.commonComponents.simpleMovement.subMesh, new Vector3(0f, 0f, -1f));
        // Find the dungeon entrance they just escaped from
        GameObject entrance = DungeonEntranceWithId(Game.instance.dungeonEntranceId);

        avatar.transform.position = entrance.transform.position + new Vector3(0f, 0f, -4f);
        Vector3 roundedPos = avatar.transform.position;

        roundedPos.x = Mathf.FloorToInt(roundedPos.x);
        roundedPos.z = Mathf.RoundToInt(roundedPos.z);
        avatar.transform.position = roundedPos;

        Vector3 originPos  = avatar.modelContainer.transform.localPosition;
        Vector3 backPos    = avatar.modelContainer.transform.localPosition + new Vector3(0f, 0f, 6f);
        Vector3 fallTarget = originPos + new Vector3(0f, -0.25f, 0f);

        avatar.commonComponents.animator.Play("FallingSpecial");

        avatar.modelContainer.transform.localPosition = backPos;
        avatar.modelContainer.transform.DOLocalJump(fallTarget, 1f, 1, 1f);

        yield return(new WaitForSeconds(0.9f));

        avatar.commonComponents.animator.speed = 0.0f;
        yield return(new WaitForSeconds(0.4f));

        avatar.commonComponents.animator.speed = 1f;

        avatar.modelContainer.transform.DOLocalMove(originPos, 0.25f);

        avatar.enabled = true;

        yield break;
    }
Esempio n. 7
0
    private void OnHit(Killable entity)
    {
        if (!string.IsNullOrEmpty(activationCinematicEvent) && !mActivationCinematicEventFired)
        {
            if (playSound)
            {
                Game.instance.soundManager.PlaySound("boss_intro");
            }

            mActivationCinematicEventFired = true;
            Game.instance.cinematicDirector.PostCinematicEvent(activationCinematicEvent);

            Vector3 dir = Game.instance.avatar.transform.position - transform.position;
            dir.y = 0f;
            if (Mathf.Abs(dir.x) > Mathf.Abs(dir.y))
            {
                dir.y = 0f;
            }
            else
            {
                dir.x = 0f;
            }
            dir.Normalize();

            SimpleMovement.OrientToDirection(GetComponentInChildren <Animator>().gameObject, dir);
        }

        if (enemyMeleeController != null)
        {
            enemyMeleeController.enabled = true;
        }

        if (enemyProjectileController != null)
        {
            enemyProjectileController.enabled = true;
        }
    }
Esempio n. 8
0
    // Update is called once per frame
    void Update()
    {
        if (finale)
        {
            return;
        }
        if (Game.instance.cinematicDirector.IsCinematicPlaying())
        {
            return;
        }
        if (Game.instance.transitionManager.isTransitioning)
        {
            return;
        }
        if (!isAlive)
        {
            return;
        }
        if (transitioning)
        {
            return;
        }

        MinimapCamera minimapCamera = Game.instance.minimapCamera;

        if (minimapCamera.showingWholeMap)
        {
            return;
        }

        if (Game.instance.dialogManager != null && Game.instance.dialogManager.AnyDialogsOpen())
        {
            return;
        }

        // Queue spells while moving / attack to be executed once those actions end.
        if (Game.instance.actionSet.Spell.WasPressed)
        {
            mSpellQueued = true;
        }

        if (Game.instance.actionSet.Dance.WasPressed && Game.instance.playerData.IsFlagSet("dance_purchased"))
        {
            mDanceQueued = true;
        }

        if (commonComponents.simpleMovement.isMoving || commonComponents.simpleAttack.isAttacking)
        {
            return;
        }

        SpellCaster caster = GetComponentInChildren <SpellCaster>();

        if (caster != null && caster.isCasting)
        {
            return;
        }

        ProjectileThrower thrower = GetComponentInChildren <ProjectileThrower>();

        if (thrower != null && thrower.isThrowing)
        {
            return;
        }

        if (mSpellQueued)
        {
            mSpellQueued = false;
            CastSpellIfPossible();
            return;
        }

        if (mTeleportQueued)
        {
            mTeleportQueued = false;
            TeleportIfPossible();
            return;
        }

        if (mDanceQueued)
        {
            mDanceQueued = false;
            PlayRandomDance();
            return;
        }

        if (!Game.instance.realTime && Game.instance.whoseTurn != 0)
        {
            return;
        }

        Vector3 followerDirection = transform.position - follower.transform.position;

        followerDirection.y = 0f;
        followerDirection.Normalize();

        Vector3 intendedDirection = Vector3.zero;

        float moveThreshold = 0.5f;

        if (Game.instance.actionSet.Move.Y > moveThreshold)
        {
            intendedDirection = new Vector3(0f, 0f, 1f);
        }
        else if (Game.instance.actionSet.Move.Y < -moveThreshold)
        {
            intendedDirection = new Vector3(0f, 0f, -1f);
        }
        else if (Game.instance.actionSet.Move.X < -moveThreshold)
        {
            intendedDirection = new Vector3(-1f, 0f, 0f);
        }
        else if (Game.instance.actionSet.Move.X > moveThreshold)
        {
            intendedDirection = new Vector3(1f, 0f, 0f);
        }

        intendedDirection = SpaceCadetQuirk.ApplyQuirkIfPresent(intendedDirection);

        if (intendedDirection.magnitude > 0.8f)
        {
            direction = intendedDirection;

            if (Game.instance.actionSet.HoldPosition.IsPressed)
            {
                SimpleMovement.OrientToDirection(commonComponents.animator.gameObject, intendedDirection);
            }
            else
            {
                if (commonComponents.simpleAttack.CanAttack(intendedDirection))
                {
                    commonComponents.simpleAttack.Attack(intendedDirection);
                    AttackFollower(intendedDirection);
                }
                else if (commonComponents.simpleMovement.CanMove(intendedDirection))
                {
                    commonComponents.simpleMovement.Move(intendedDirection);
                    commonComponents.animator.Play("Idle");
                    MoveFollower(intendedDirection, transform.position + intendedDirection);
                }
                else
                {
                    SimpleMovement.OrientToDirection(commonComponents.animator.gameObject, intendedDirection);

                    if (HasFollower())
                    {
                        SimpleMovement.OrientToDirection(follower.commonComponents.animator.gameObject, intendedDirection);
                    }
                }
            }
        }
    }
Esempio n. 9
0
    private IEnumerator AttackCoroutine(Vector3 direction)
    {
        if (mIsAttacking)
        {
            yield break;
        }

        SimpleMovement.OrientToDirection(commonComponents.animator.gameObject, direction);

        mIsAttacking = true;
        GameObject target = TargetInDirection(direction);

        if (target == null)
        {
            mIsAttacking = false;
            yield break;
        }

        Vector3 startPosition = subMesh.transform.position;
        Vector3 hitPosition   = startPosition + (target.transform.position - startPosition) * 0.7f;

        // Before we actually start playing the attack animation, ensure the target is still there;
        // there can be some lag before we start the attack animation, and the enemy may
        // have teleported out of the way.
        if (Vector3.Distance(transform.position, hitPosition) > 1.5f)
        {
            mIsAttacking = false;
            yield break;
        }

        bool damageDone = false;

        if (gameObject.layer == mPlayerLayer || noDamage)
        {
            Game.instance.soundManager.PlaySound("enemy_hit");
        }

        float time = 0f;

        while (time < 1f)
        {
            time += Time.deltaTime * 3f;
            float d = time / 0.5f;
            if (d > 1f)
            {
                d = 2f - d;
            }
            subMesh.transform.position = Vector3.Lerp(startPosition, hitPosition, d);

            if (time > 0.6f && !damageDone)
            {
                // Ensure the target is still in an attackable position - some enemies can
                // teleport away very erratically, and killing them post-teleport looks awkward
                // But this shouldn't apply to enemies that are just running - they still get stitches
                if (target != null &&
                    Vector3.Distance(transform.position, hitPosition) < 1.5f &&
                    Vector3.Distance(target.transform.position, hitPosition) < 1.5f)
                {
                    DealDamage(target);

                    damageDone = true;
                }
            }

            yield return(null);
        }

        subMesh.transform.localPosition = mSubMeshLocalPosition;

        if (onAttackFinished != null)
        {
            onAttackFinished(gameObject, target);
        }

        mIsAttacking = false;
        yield break;
    }
Esempio n. 10
0
 // Start is called before the first frame update
 void Start()
 {
     GetComponent <Killable>().onHit += OnHit;
     SimpleMovement.OrientToDirection(GetComponentInChildren <Animator>().gameObject, Vector3.back);
 }
Esempio n. 11
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();
        }
    }
Esempio n. 12
0
 public void UpdateAI(CharacterComponentBase ccb)
 {
     SimpleMovement.OrientToDirection(ccb.commonComponents.simpleMovement.subMesh, new Vector3(0, 0, -1));
     ccb.commonComponents.animator.Play("Dizzy");
 }