예제 #1
0
 // Update is called once per frame
 void Update()
 {
     //Triggered Swinging
     if (Input.GetMouseButtonDown(1) && kState != KingState.ducking)
     {
         kState = KingState.ducking;
         StartCoroutine(Dodge());
     }
     else  if (Input.GetMouseButtonDown(0) && kState == KingState.idle)
     {
         StartCoroutine(activateSword(swingTime));
         timer = delayTimer;
         liegeAnim.Stop();
         liegeAnim.PlayQueued("Attack");
         kState = KingState.attacking;
     }
     //Cooldown
     else if (timer >= 0)
     {
         timer -= Time.deltaTime;
     }
     //Cooldown over
     else
     {
         kState = KingState.idle;
         timer = 0;
     }
 }
예제 #2
0
 // Update is called once per frame
 void Update()
 {
     //Triggered Swinging
     if (Input.GetMouseButtonDown(1) && kState != KingState.ducking)
     {
         kState = KingState.ducking;
         StartCoroutine(Dodge());
     }
     else if (Input.GetMouseButtonDown(0) && kState == KingState.idle)
     {
         StartCoroutine(activateSword(swingTime));
         timer = delayTimer;
         liegeAnim.Stop();
         liegeAnim.PlayQueued("Attack");
         kState = KingState.attacking;
     }
     //Cooldown
     else if (timer >= 0)
     {
         timer -= Time.deltaTime;
     }
     //Cooldown over
     else
     {
         kState = KingState.idle;
         timer  = 0;
     }
 }
예제 #3
0
        private void Move()
        {
            if (!this.doOnce)
            {
                int val = Random.Range(0, this.summoningPoints.Length + 1);
                if (val >= this.summoningPoints.Length)
                {
                    this.movementLocation = this.hero.position;
                }
                else
                {
                    this.movementLocation = this.summoningPoints[val].transform.position;
                }

                LookAt(this.movementLocation);
                this.doOnce = true;
            }

            if (Vector2.Distance(this.movementLocation, this.transform.position) < .1f)
            {
                LookAt(this.hero.position);
                this.rgbdy.velocity = Vector2.zero;
                this.currentState   = KingState.Idle;
            }
            else
            {
                LookAt(this.movementLocation);
                this.rgbdy.velocity = -this.transform.up * this.moveSpeed;
            }
        }
예제 #4
0
        private void Stun()
        {
            if (!this.doOnce)
            {
                this.stunTimer = this.stunTime;
                this.weaponCollider.enabled = false;
                this.doOnce = true;
            }

            if ((this.stunTimer -= Time.deltaTime) < 0)
            {
                this.currentState = KingState.Idle;
            }
        }
예제 #5
0
        protected override void LocalUpdate()
        {
            if (invunTimer > 0)
            {
                if (flashTimer > flashInterval)
                {
                    isVisible  = !isVisible;
                    flashTimer = 0;
                    foreach (SpriteRenderer b in this.sprites)
                    {
                        b.enabled = isVisible;
                    }
                }
                flashTimer += Time.deltaTime;
                invunTimer -= Time.deltaTime;
            }
            else if (!isVisible || isInvulnerable)
            {
                isVisible = true;
                foreach (SpriteRenderer b in this.sprites)
                {
                    b.enabled = true;
                }
                isInvulnerable = false;
            }

            KingState temp = this.currentState;

            this.animationTime = this.anim.GetCurrentAnimatorStateInfo(0).normalizedTime;
            switch (this.currentState)
            {
            case KingState.Idle: Idle(); break;

            case KingState.Move: Move(); break;

            case KingState.Attack: Attack(); break;

            case KingState.Shield: Shield(); break;

            case KingState.Stun: Stun(); break;

            case KingState.Shoot: Shoot(); break;
            }

            if (temp != currentState)
            {
                this.doOnce = false;
            }
        }
예제 #6
0
        private void Attack()
        {
            if (!this.doOnce)
            {
                LookAt(this.hero.position);
                this.weaponCollider.enabled = true;
                this.doOnce = true;
            }

            if (this.animationTime > .9f)
            {
                this.weaponCollider.enabled = false;
                this.anim.SetTrigger(meleeOverHash);
                this.currentState = KingState.Idle;
            }
        }
예제 #7
0
        private void Shoot()
        {
            if (!this.doOnce)
            {
                LookAt(this.hero.position);
                this.gun.ReInit();
                this.doOnce = true;
            }

            if (this.gun.WeaponUpdate())
            {
                this.currentState = KingState.Idle;
                this.gun.CleanUp();
                this.anim.SetTrigger(this.summonOverHash);
                this.currentState = KingState.Idle;
            }
        }
예제 #8
0
        private void Shield()
        {
            if (!this.doOnce)
            {
                this.sfx.PlaySong(0);
                LookAt(this.hero.position);
                foreach (SummoningField s in this.summoningPoints)
                {
                    GameObject e = s.Spawn();
                    if (e != null)
                    {
                        this.spawnedEnemies.Add(e);
                    }
                }

                this.shield.SetActive(true);
                this.doOnce = true;
            }

            bool allDead = true;

            foreach (GameObject e in this.spawnedEnemies)
            {
                if (e.gameObject.activeInHierarchy)
                {
                    allDead = false;
                }
            }

            if (allDead)
            {
                this.shield.SetActive(false);
                this.spawnedEnemies.Clear();
                this.anim.SetTrigger(this.summonOverHash);
                this.currentState = KingState.Stun;
            }
        }
예제 #9
0
        private void Idle()
        {
            if (!this.doOnce)
            {
                this.idleTimer = idleTime;
                this.doOnce    = true;
            }

            if (Vector2.Distance(this.hero.position, this.transform.position) < this.meleeRange)
            {
                this.anim.SetTrigger(this.meleeHash);
                this.currentState = KingState.Attack;
            }

            if ((this.idleTimer -= Time.deltaTime) < 0)
            {
                float val = Random.Range(0f, 1f);
                if (val < .10f)
                {
                    this.anim.SetTrigger(this.summonHash);
                    this.currentState = KingState.Shield;
                }
                else if (val < .5f)
                {
                    this.currentState = KingState.Move;
                }
                else if (val < .75f)
                {
                    this.anim.SetTrigger(this.summonHash);
                    this.currentState = KingState.Shoot;
                }
                else
                {
                    this.doOnce = false;
                }
            }
        }