示例#1
0
        private IEnumerator Start()
        {
            FennelDeath.isDying          = false;
            On.HealthManager.TakeDamage += HealthManager_TakeDamage;
            _hm.OnDeath += _hm_OnDeath;
            //SetSoundSettings(_aud);
            gameObject.layer = 11;

            gameObject.transform.SetPosition3D(HeroController.instance.transform.position.x + 10f, GROUND_Y, 0f);
            _hm.hp           = HP_MAX;
            _hm.IsInvincible = true;
            _bc.isTrigger    = true;
            _rc.SetRecoilSpeed(15f);
            _rb.gravityScale = 0f;

            //More of Katie's image code
            afterimages = new GameObject[10];
            for (int i = 0; i < afterimages.Length; i++)
            {
                afterimages[i] = new GameObject("afterimage");
                afterimages[i].AddComponent <SpriteRenderer>();
                afterimages[i].GetComponent <SpriteRenderer>().material = _sr.material;
                afterimages[i].AddComponent <AfterimageFader>();
            }

            yield return(new WaitForSeconds(0.1f));

            moves           = gameObject.GetComponent <FennelMoves>();
            moves.distToGnd = _bc.bounds.extents.y;
            movesCount.Add(moves.Attack, 0);
            movesCount.Add(moves.SlamGround, 0);
            movesCount.Add(moves.AirAttack, 0);
            movesCount.Add(moves.Dash, 0);
            movesCount.Add(moves.BackFlip, 0);
            movesCount.Add(moves.JumpDive, 0);
            movesCount.Add(moves.Buff, 0);

            _anim.Play("intro1");
            yield return(new WaitWhile(() => _anim.IsPlaying()));

            StartCoroutine(IntroText());
            StartCoroutine(IntroAnim());
            AssignFields();
        }
示例#2
0
        private void Start()
        {
            PropDeath.isDying = false;

            ModHooks.Instance.TakeHealthHook += Instance_TakeHealthHook;
            On.HealthManager.TakeDamage      += HealthManager_TakeDamage;
            _hm.OnDeath += _hm_OnDeath;

            SetSoundSettings(_aud);
            gameObject.layer = 11;
            gameObject.transform.SetPosition3D(HeroController.instance.transform.position.x + 10f, HeroController.instance.transform.position.y + 6f, 0f);
            gameObject.transform.localScale = new Vector2(gameObject.transform.localScale.x * -1f, gameObject.transform.localScale.y);

            _hm.hp        = HP_MAX;
            _bc.isTrigger = true;
            _rc.SetRecoilSpeed(15f);
            _rb.gravityScale = 0f;
            origHeight       = gameObject.transform.position.y;
            idleTime         = 0.3f;
            for (float i = 88.5f; i < 116.5f; i += 3.3f)
            {
                SpawnPlatform(0, i, 21f, 0f, 180f);
                var spk = SpawnPlatform(1, i - 0.1f, 21f - 1.7f, 0.5f, 180f);
                spk.transform.localScale *= 1.2f;
                spk.transform.localScale  = new Vector2(spk.transform.localScale.x * 1.4f, spk.transform.localScale.y);
                spk.AddComponent <SpikeCollider>();
            }

            for (float i = 5f; i < 22f; i += 2)
            {
                GameObject spk = SpawnPlatform(1, 87.2f, i, 0.5f, 270f);
                spk.AddComponent <SpikeCollider>();
            }

            for (float i = 5f; i < 22f; i += 2f)
            {
                GameObject spk = SpawnPlatform(1, 118.8f, i, 0.5f, 90f);
                spk.AddComponent <SpikeCollider>();
            }
            _anim.Play("fly");
            StartCoroutine(AttackChoice());
            AssignFields();
        }
示例#3
0
        private IEnumerator IdleAndChooseNextAttack()
        {
            Log("Idle");
            _anim.PlayAnimation("Idle", true);
            _recoil.SetRecoilSpeed(15f);

            StartCoroutine(FaceKnight());

            float minWait  = 0.25f;
            float maxWait  = 0.5f;
            float waitTime = (float)(_rand.NextDouble() * maxWait) + minWait;

            yield return(new WaitForSeconds(waitTime));

            int    index    = _rand.Next(_moves.Count);
            Action nextMove = _moves[index];

            // Make sure moves don't occur more than twice in a row
            while (_repeats[nextMove] >= 2)
            {
                index = _rand.Next(_moves.Count);
                Log("Index: " + index);
                nextMove = _moves[index];
            }

            foreach (Action move in _moves)
            {
                if (move == nextMove)
                {
                    _repeats[move]++;
                }
                else
                {
                    _repeats[move] = 0;
                }
            }

            Vector2 pos     = transform.position;
            Vector2 heroPos = HeroController.instance.transform.position;

            if (Mathf.Sqrt(Mathf.Pow(pos.x - heroPos.x, 2) + Mathf.Pow(pos.y - heroPos.y, 2)) < 4.0f)
            {
                int randNum   = _rand.Next(100);
                int threshold = 70;
                if (randNum < threshold)
                {
                    if (_direction == 1 && pos.x - LeftX > 3.0f || (_direction == -1 && RightX - pos.x > 3.0f))
                    {
                        nextMove = TisoEvade;
                    }
                }
            }
            else if (Mathf.Abs(pos.x - heroPos.x) <= 2.0f && heroPos.y - pos.y > 2.0f)
            {
                int randNum   = _rand.Next(100);
                int threshold = 50;
                if (randNum < threshold)
                {
                    nextMove = TisoUpslash;
                }
            }

            if (_knightDead)
            {
                nextMove = TisoDab;
            }

            Log("Next Move: " + nextMove.Method.Name);
            nextMove.Invoke();
        }