Пример #1
0
        private void SetBossState(BossState bossState)
        {
            if (bossState == _currentBossState)
            {
                return;
            }

            _currentBossState = bossState;
            switch (_currentBossState)
            {
            case BossState.Idle:
                _bossTimer = idleSwitchTimer;
                break;

            case BossState.SingleArmShot:
            case BossState.DualArmShot:
            case BossState.FrenzySpinningShot:
            case BossState.AbilityAttack:
                // Don't do anything here as the base attack handles the return state
                break;

            case BossState.Dead:
                // TODO: Add Something here probably
                break;

            default:
                throw new ArgumentException();
            }
        }
Пример #2
0
 public override void Hit(Character character)
 {
     if (isDead == true)
     {
         return;
     }
     if (character.ToString().Contains("Player") && bossState != BossState.Swoon && bossState != BossState.Crushing)    //プレイヤーグループと当たる
     {
         hp--;
         if (hp == 100)
         {
             bossState = BossState.Swoon;
             name      = "Boss2";
             counter   = 0;
             return;
         }
         if (hp > 0)
         {
             return;
         }
         bossState = BossState.Crushing;
         counter   = 0;
         gameManager.SetScore(gameManager.GetScore() + 10000);
     }
 }
Пример #3
0
    //执行一条指令
    void Execute(Instruction instruction)
    {
        if (instruction == null)
        {
            return;
        }
        switch (instruction.type)
        {
        case InstructionType.MOVEMENT:
            bossState = BossState.MOVING;
            moveController.MoveTo(instruction.targetPoint, instruction.speed);
            break;

        case InstructionType.DIVE:
            bossState = BossState.MOVING;
            moveController.DiveForPlayer();
            break;

        case InstructionType.STAY:
            bossState = BossState.STAY;
            moveController.stayingForSeconds(instruction.stayingTime);
            break;

        case InstructionType.FIRE:
            ExecuteFireInstruction(instruction);
            break;
        }
        if (loopStarted)
        {
            historyQueue.Enqueue(instruction);
        }
    }
Пример #4
0
    void OnTriggerEnter2D(Collider2D col)
    {
        //detecta a colisão com os tiros
        if (col.tag == "PlayerBulletTag")
        {
            //HP do Boss -1
            BossHP -= 1;

            //Se HP for Zerado
            if (BossHP <= 0)
            {
                //add X pontos pontos para o score
                scoreUITextGO.GetComponent <GameScore>().Score += BossPoint;

                PlayExplosion();

                //destrói a nave inimiga
                Destroy(gameObject);
            }

            //Se HP For menor que a Variavel HPLv2
            if (BossHP <= HPLv2)
            {
                BState = BossState.Lv2;
            }
        }
    }
    IEnumerator BossDeathDelay()
    {
        yield return(new WaitForSeconds(1));

        bossState = BossState.Standby;
        gameObject.SetActive(false);
    }
Пример #6
0
    private void rage()
    {
        int chosenAttack = 3;

        if (initialMeeting == false)
        {
            chosenAttack = Random.Range(1, 4);
        }
        print(chosenAttack);

        if (chosenAttack == 1 && bossFeelings == BossState.WALKING)
        {
            bossFeelings = BossState.RAGING;
            animator.SetBool("raging", true);
            animator.SetBool("walking", false);
            turnTowardsPlayer();
        }
        else if (chosenAttack == 2 && bossFeelings == BossState.WALKING)
        {
            bossFeelings = BossState.REPRIMAND;
            animator.SetBool("reprimand", true);
            animator.SetBool("walking", false);
            turnTowardsPlayer();
            mouth.calculatedBarrage();
        }
        else if (chosenAttack == 3 && bossFeelings == BossState.WALKING)
        {
            bossFeelings = BossState.GLARE;
            turnTowardsPlayer();
            mouth.piercingLanguage();
        }

        GetComponent <NavMeshAgent>().isStopped = true;
        Invoke("stopRaging", 4f);
    }
    void Update()
    {
        if (boss_State == BossState.SEARCH_FOR_PLAYER)
        {
            if (Vector3.Distance(transform.position, player_Target.position) > attack_Distance)
            {
                boss_State = BossState.GO_TO_PLAYER;
            }
            else
            {
                boss_State = BossState.ATTACK;
            }
        }

        if (boss_State == BossState.GO_TO_PLAYER)
        {
            GoTowardsPlayer();
        }

        if (boss_State == BossState.ATTACK)
        {
            AttackPlayer();
        }

        if (boss_State == BossState.MOVE_AWAY_FROM_PLAYER)
        {
            MoveAwayFromPlayer();
        }
    }
Пример #8
0
    void StateCheck()
    {
        switch (state)
        {
        case BossState.APPEAR:
            if (transform.localScale.x >= 1f)
            {
                state = BossState.SPAWN;
            }
            break;

        case BossState.SPAWN:
            Services.enemyController.SpawnEnemy(transform.position);
            break;

        case BossState.FIRE:
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                Services.bulletController.FireAround(BulletControl.BulletRef.ENEMY_NORMAL, transform.position);
                timer = 2f;
            }
            break;

        case BossState.CHASE:
            MoveTowardsPlayer();
            Services.enemyController.SpawnEnemy(transform.position);
            break;
        }
    }
    IEnumerator ShotDelay()
    {
        List <int> randomshot = new List <int> {
            1, 2, 3, 4
        };

        for (int i = 1; i < 5; i++)
        {
            int a = Random.Range(randomshot.Min(), randomshot.Max());
            if (randomshot.Contains(a))
            {
                randomshot.Remove(a);
                anim.SetTrigger("Enemy_ShotAttack" + a);
                yield return(new WaitForSeconds(1.0f));

                GameObject Ins = Instantiate(Inkbullet, Ink[a - 1].transform.position, Quaternion.identity);
                Ins.name = "Ink" + a;
                anim.ResetTrigger("Enemy_ShotAttack" + a);
            }
            else
            {
                i--;
            }
        }
        _bossState   = BossState.Idle;
        _isAttacking = false;
    }
    void GoTowardsPlayer()
    {
        navAgent.isStopped = false;
        navAgent.SetDestination(player_Target.position);

        if (navAgent.velocity.sqrMagnitude == 0)
        {
            bossAnim.Walk(false);
        }
        else
        {
            bossAnim.Walk(true);
        }

        if (Vector3.Distance(transform.position, player_Target.position) <= attack_Distance)
        {
            navAgent.velocity  = Vector3.zero;
            navAgent.isStopped = true;

            bossAnim.Walk(false);

            boss_State   = BossState.ATTACK;
            attack_Timer = wait_Before_Attack_Time / 2f;
        }
    }
Пример #11
0
    public void ChargeAtPlayer()
    {
        //Debug.Log("Charging at player");
        if (!hasNewLerpPositions)
        {
            //Debug.Log("Charge new positions");
            startPosition       = transform.position;
            endPosition         = player.transform.position;
            hasNewLerpPositions = true;
            hasReachedChargePos = false;
        }

        if (!hasReachedChargePos)
        {
            //Debug.Log("Lerp to player");
            LerpMovement(ref hasReachedChargePos, chargeSpeed);
        }
        else
        {
            //Debug.Log("Done Lerping");
            currentState        = BossState.Return;
            hasNewLerpPositions = false;
            hasReachedChargePos = true;
        }
    }
Пример #12
0
 // plays the bgm for the next boss stage
 public static void PlayBossNextBGM()
 {
     if (self.state is BossState)
     {
         BossState.NextClip();
     }
 }
Пример #13
0
    IEnumerator switchState(BossState switchedState, float delayTime)
    {
        yield return(new WaitForSeconds(delayTime));

        state   = switchedState;
        invoked = false;
    }
Пример #14
0
    // Update is called once per frame
    void Update()
    {
        switch (currentstate)
        {
        case (BossState.Offline):
            Offline();
            break;

        case (BossState.Follow):
            Follow();
            break;

        case (BossState.RocketAttack):
            RocketMode();
            break;

        case (BossState.CarMode):
            CarMode();
            break;
        }

        if (!notInRoom)
        {
            if (currentstate == BossState.Offline)
            {
                currentstate = BossState.Follow;
                StartCoroutine(StateTimer(Random.Range(4f, 8f)));
            }
        }
        else
        {
            currentstate = BossState.Offline;
        }
    }
 void Jump()
 {
     _isAttacking = true;
     JumpEffect.SetActive(false);
     _bossState = BossState.Jump;
     r2d.AddForce(Vector2.up * vy, ForceMode2D.Impulse);
 }
Пример #16
0
    private IEnumerator LeapAttack()
    {
        var startingPos = transform.position;

        var halfWayPos = startingPos;

        halfWayPos.y += 8;
        float timePassed = 0;

        rigidBody.useGravity = false;
        while (Vector3.Distance(transform.position, halfWayPos) > 0.02f)
        {
            timePassed        += Time.deltaTime;
            transform.position = Vector3.Lerp(startingPos, halfWayPos, timePassed / 0.52f);
            if (timePassed >= 0.5f)
            {
                transform.position = halfWayPos;
                break;
            }
            yield return(new WaitForFixedUpdate());
        }
        timePassed = 0;
        var targetPos = GameManager.Instance.PlayerPosition;

        targetPos.y = startingPos.y;
        startingPos = transform.position;
        while (Vector3.Distance(transform.position, targetPos) > 0.02f)
        {
            timePassed        += Time.deltaTime;
            transform.position = Vector3.Slerp(startingPos, targetPos, timePassed / 0.33f);
            if (timePassed >= 0.33f)
            {
                transform.position = targetPos;
                break;
            }
            yield return(new WaitForFixedUpdate());
        }

        rigidBody.useGravity = true;
        switch (phase)
        {
        case 1:
            yield return(new WaitForSeconds(timeBetweenAttacks));

            bossState = BossState.StartingAnAttack;
            break;

        case 2:
            ThunderWave(1);
            break;

        case 3:
            ThunderWave(1);
            break;

        case 4:
            ThunderWave(1);
            break;
        }
    }
Пример #17
0
 private void ChangeState(BossState _state)
 {
     m_state        = _state;
     m_timeInState  = 0.0f;
     m_stateChanged = true;
     Debug.Log($"Change State: {m_state.ToString()}");
 }
Пример #18
0
    IEnumerator WaitingState()
    {
        yield return(new WaitForSeconds(timeBetweenEachState));

        boss_state = BossState.ATTACKING;
        timeBetweenStateCountdown = timeBetweenEachState;
    }
Пример #19
0
 //当某一条移动或者停驻指令结束的时候会收到改回调,在这里面改变BossState
 public void OnBossMoveCompleted(bool changeState)
 {
     if (changeState)
     {
         bossState = BossState.IDLE;
     }
 }
Пример #20
0
    IEnumerator ChangeState()
    {
        bool changed = false;

        while (!changed)
        {
            yield return(null);

            if (changingToAttack)
            {
                if (bossDefense.ChangeState())
                {
                    bossAbility.attackMode  = true;
                    bossDefense.defenseMode = false;
                    changed          = true;
                    stateBoss        = BossState.Ability;
                    changingToAttack = false;
                }
            }
            else if (changingToDefence)
            {
                if (bossAbility.ChangeState())
                {
                    bossDefense.defenseMode = true;
                    bossAbility.attackMode  = false;
                    changed           = true;
                    changingToDefence = false;
                    stateBoss         = BossState.Defense;
                }
            }
        }
        bossAgent.isStopped = true;
    }
Пример #21
0
    private void ChangeState()
    {
        body.velocity = Vector2.zero;
        if (currentState != BossState.MOVING)
        {
            currentState = BossState.MOVING;
        }
        else
        {
            int state = Random.Range(0, 2);
            switch (state)
            {
            case 0:
                currentState = BossState.LAUNCHING;
                interval     = 6;
                break;

            case 1:
                currentState = BossState.SPINNING;
                interval     = Random.Range(3, 6);
                break;
                //any other states go here
            }
        }

        spinning = false;

        body.drag = 20f;
        launching = false;
        animator.SetBool("IsFiring", false);
    }
Пример #22
0
 // Use this for initialization
 void Start()
 {
     s_State       = BossState.Move;
     m_LookCounter = 0;
     m_Controller  = GetComponent <CharacterController>();
     m_Anim        = GetComponent <Animator>();
 }
Пример #23
0
    private float f_Anger;                             //怒り値

    // Start is called before the first frame update
    void Start()
    {
        bs_State = gameObject.GetComponent <BossState>();

        f_Anger = 0.0f;
        b_Flag  = false;
    }
Пример #24
0
 private void Patrol()
 {
     if (currPatrolTime <= 0 && Vector2.Distance(transform.position, currentDestination.position) < offset)
     {
         currentState        = BossState.Idle;
         currPatrolIntroTime = patrolIntroDuration;
         currPatrolTime      = patrolDuration;
     }
     else
     {
         if (currPatrolTime == patrolDuration)
         {
             anim.SetTrigger("isPatrolling");
         }
         if (Vector2.Distance(transform.position, currentDestination.position) < offset)
         {
             if (currentDestination == patrolSpots[0])
             {
                 currentDestination = patrolSpots[1];
             }
             else if (currentDestination == patrolSpots[1])
             {
                 currentDestination = patrolSpots[0];
             }
         }
         transform.position = Vector2.MoveTowards(transform.position, currentDestination.position, patrolSpeed * Time.deltaTime);
         currPatrolTime    -= Time.deltaTime;
         Debug.Log("Patrolling");
     }
 }
Пример #25
0
 public void OnPlayerEntered(Player player)
 {
     Debug.Log("Player entered");
     bossState                  = BossState.TransitToAttack;
     targetPosition             = AttackPosition;
     networkID.SendRealtimeData = true;
 }
Пример #26
0
        public BaseBoss(Vector2 startingPosition)
        {
            this.Position = startingPosition;

            this.damagePercentage = 1f;
            this.MainColor = Color.White;
            this.freezeResistance = 0.8f;
            this.freezeReviving = 0.005f;
            this.slidingFactor = 1;
            this.Direction = OGE.Random.Next(360);
            this.score = 0;
            this.MainColor = Color.White;
            this.status = BossState.Enterance;
            this.isHit = false;
            this.SlowFactor = 1;
            this.hitAlarm = new Alarm(0.2f, TweenType.OneShot, () => { isHit = false; });
            AddTween(hitAlarm);

            this.images = new Dictionary<BossState, Image>();
            this.actions = new Dictionary<BossState, Action>();

            this.freezeImage = new Image(OGE.Content.Load<Texture2D>(@"Graphics\Entities\Bosses\Ice"));
            this.freezeImage.CenterOrigin();

            this.EntityCollisionType = CollisionType.Boss;
        }
Пример #27
0
    IEnumerator RunTimer()
    {
        yield return(new WaitForSeconds(runTime));

        state = BossState.Chase;
        StartCoroutine(SlashTimer());
    }
Пример #28
0
 /// <summary>
 /// 플레이어 추척상태일때의 동작
 /// </summary>
 public void TraceUpdate()
 {
     if (bossState == BossCtrl.BossState.trace)
     {
         Vector3 diff      = playerTr.position - bossTr.position;
         Vector3 direction = diff.normalized;
         direction = new Vector3(direction.x, 0.0f, direction.z);
         Vector3 moveAmount = direction * runSpeed * Time.deltaTime;
         moveAmount.y = 0.0f;
         if (diff.magnitude < AttackRange)
         {
             bossState = BossState.attack;
             return;
         }
         bossTr.Translate(moveAmount, Space.World);
         bossTr.LookAt(playerTr.position);//바라보게 하기
     }
     else if (bossState == BossCtrl.BossState.back)
     {
         Vector3 diff      = bosshomeTr - bossTr.position;
         Vector3 direction = diff.normalized;
         direction = new Vector3(direction.x, 0.0f, direction.z);
         Vector3 moveAmount = direction * runSpeed * Time.deltaTime;
         moveAmount.y = 0.0f;
         bossTr.Translate(moveAmount, Space.World);
         Vector3 look = Vector3.Slerp(bossTr.forward, diff.normalized, Time.deltaTime);
         bossTr.rotation = Quaternion.LookRotation(look, Vector3.up);
         if (diff.magnitude < 2f)
         {
             bossState = BossState.idle;
             return;
         }
     }
 }
Пример #29
0
    public void ReturnAfterCharge()
    {
        // Just go back to our starting position prior to the charge
        if (!hasNewLerpPositions)
        {
            //
            //return to the start pos
            //
            endPosition   = startPosition;
            startPosition = transform.position;

            hasNewLerpPositions = true;
        }

        if (!hasReachedReturnPos)
        {
            LerpMovement(ref hasReachedReturnPos, speed);
        }
        else
        {
            //
            //treat charge as patrol
            //
            hasReachedPatrolPos = true;
            currentState        = BossState.Patrol;
        }
    }
Пример #30
0
    void Hide()
    {
        PlatformGridObject[] boats = FindObjectsOfType <PlatformGridObject>();
        // Destroy boats
        int i = 0;

        while (i < boats.Length)
        {
            boats[i].Destructor();
            i++;
        }

        // Destroy fireballs
        i = 0;
        while (i < fireballs.Count)
        {
            Fireball fireball = fireballs[i];
            fireballs.RemoveAt(i);

            if (fireball)
            {
                Destroy(fireball.gameObject);
            }
        }

        // Hide boss
        isInvulnerable = true;
        state          = BossState.StartHide; // to stop idle animation

        StartCoroutine(HideAnimation());
    }
Пример #31
0
    IEnumerator Recovery()
    {
        yield return(new WaitForSeconds(10.0f));

        s_State = BossState.Look;
        m_SearchArea.SetActive(true);
    }
Пример #32
0
    public void Awake()
    {
        // get the sprite renderer of this object
        spriteRenderer = GetComponent<SpriteRenderer>();
        parentState = parent.currentState;

        target = GameObject.FindGameObjectWithTag("Player").transform.parent;
    }
Пример #33
0
 // Use this for initialization
 void Start()
 {
     //shadow = Resources.Load ("Sprites/Enemies/IceShadow")as Texture;
     currentState = BossState.Shooting;
     stateTime = 0;
     mapX = transform.position.x;
     mapY = transform.position.y;
     gameObject.AddComponent<RangedAttack>();
 }
Пример #34
0
        public void BeginBossBattle()
        {
            _targetNode = dropToStartNode;
            currentState = BossState.FallingToNode;

            _timeForNextEvent = 0f;
            health = _startHealth;
            _isDead = false;
        }
Пример #35
0
 /// <summary>
 /// Construct a new Boss.  Takes an EnemyData structure, a texture to represent it, a texture to represent its projectiles, and the vector holding the coordinates where the spawns
 /// </summary>
 /// <param name="data"></param>
 /// <param name="tex"></param>
 /// <param name="cBTex"></param>
 /// <param name="start"></param>
 public Boss1(EnemyData data, Texture2D tex, Texture2D cBTex, Vector2 start)
     : base(data, tex, cBTex)
 {
     bossState = BossState.MovingToPosition;
     startingPos = start;
     CANNON_BALL_PERIOD = (float)(Math.PI);
     burstCount = 0;
     TOTAL_PER_BURST = 10;
 }
Пример #36
0
    public void takeDamage()
    {
        health -=1;
        attackSpeed = 10000f;
        transform.localScale *= 0.7f;
        enemyLight.radius *= 0.7f;

        if (health == 0) {
            state = BossState.Dying;
        }
    }
Пример #37
0
 public void SetStart(EnemyData ed, BossState bs)
 {
     switch (bs)
     {
         case BossState.StartBattle:
             StartBattle(ed);
             break;
         case BossState.Lost:
             break;
         case BossState.Win:
             break;
     }
 }
 //change the current state to the selected state
 public void ChangeState(eBossState _newState)
 {
     switch (_newState)
     {
         case eBossState.Spawn: m_CurrentState = m_StateSpawn; break;
         case eBossState.CreateMuzzle: m_CurrentState = m_StateCreateMuzzle; break;
         case eBossState.DeleteMuzzle: m_CurrentState = m_StateDeleteMuzzle; break;
         case eBossState.Attack: m_CurrentState = m_StateAttack; break;
         case eBossState.Retreat: m_CurrentState = m_StateRetreat; break;
         case eBossState.DeleteEntity: m_CurrentState = m_StateDeleteEntity; break;
         case eBossState.Move: m_CurrentState = m_StateMove; break;
     }
     m_CurrentState.Enter();
 }
        public HackintoshBossFanController(HackintoshBoss boss, float damage)
        {
            this.boss = boss;
            this.Position = new Vector2(boss.Position.X, boss.Position.Y);
            this.status = BossState.Wait;
            this.angle = OGE.Random.Next(360);
            this.fanList = new List<HackintoshBossFan>();

            for (int i = 0; i < fanNumber; i++)
            {
                HackintoshBossFan fan = new HackintoshBossFan(Position +
                    OGE.GetProjection(distance, angle + i * 360.0f / fanNumber), damage);
                OGE.CurrentWorld.AddEntity(fan);
                this.fanList.Add(fan);
            }
        }
Пример #40
0
    public void Awake()
    {
        S = this;

        transform.GetComponent<Renderer>().sortingLayerName = "Default";
        transform.GetComponent<Renderer>().sortingOrder = 16;

        Events.Register<OnTorchGroupLitEvent>((e) => {
            if(e.group == TorchGroup.BossFight) // Trigger Stage Two
            {
                state = BossState.Chasing;
                enemyComponent.enabled = true;
                enemyComponent.emitSmoke();
                MainCam.ShakeForSeconds(2f);
                //state = BossState.Dying;
            }
        });

        Events.Register<OnPauseEvent>(OnPause);
    }
Пример #41
0
    // Update is called once per frame
    protected void Update()
    {
        // apply the correct sprite based on the current health
        if (parentState == BossState.FullHealth)
        {
            spriteRenderer.sprite = fullHealth;
        }
        else if (parentState == BossState.ReducedHealth)
        {
            spriteRenderer.sprite = reducedHealth;
            //isSmoking = true;
        }
        else if (parentState == BossState.HalfHealth)
        {
            spriteRenderer.sprite = halfHealth;
            //isOnFire = true;
        }
        else if (parentState == BossState.LowHealth)
        {
            spriteRenderer.sprite = lowHealth;
        }

        // Calls the parent method
        //base.Update();

        // direction of target
        var dir = target.position - transform.position;

        // get the angle
        var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;

        // makes sure its facing the right direction
        angle = angle + 90;

        // set the rotation to the angle found
        transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
        trajectory = transform.rotation;

        //get the parents state
        parentState = parent.currentState;
    }
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            angle = (angle + rotationSpeed * OGE.EnemySlowFactor) % 360;
            for (int i = 0; i < fanList.Count; i++)
            {
                fanList[i].Position = Position + OGE.GetProjection(distance, angle + i * 360.0f / fanList.Count);
            }

            if (status == BossState.Move)
            {
                Position = Position + OGE.GetProjection(speed * OGE.EnemySlowFactor, OGE.GetAngle(Position, destinationPosition));
                if (OGE.GetDistance(Position, destinationPosition) < 1.5 * speed)
                {
                    status = BossState.Wait;
                    boss.Position = new Vector2(Position.X, Position.Y);
                    OGE.CurrentWorld.AddEntity(boss);
                }
            }
        }
        public void createBoss()
        {
            if (boss == null)
            {
                boss = new Sprite();

                boss.Texture = bossTexture;
                boss.Width = boss.Texture.Width / numFrames;
                boss.Height = boss.Texture.Height / 2;

                boss.Speed = 2.5f;
                boss.ScaleFactor = 1f;
                boss.LayerDepth = 0f;
                boss.Rotation = 0f;
                boss.Color = ColorHandler.getCurrentColor();

                boss.Active = true;

                this.CurrentState = BossState.IDLE;//BossState.SWARM;

                boss.Move(-boss.Width * 0.5f, (boss.Height * 0.5f));
            }
        }
Пример #44
0
        private void collisioncheck()
        {
            if (IsActive == true)
            {
                if (m_BossState == BossState.CHARGING)
                {
                    if (LaserManager.collisionCheck(m_HornDamageRect))
                    {
                        //take damge
                        m_Health--;
                        if (m_Health <= 0)
                        {
                            m_BossState = BossState.DYING;

                            for (int i = 0; i < m_Particles.Length; i++)
                            {
                                m_Particles[i].Stop = true;
                            }
                        }
                    }
                }

                if (CollisionCheck.collisionCheck(m_CollisionRect, Player.collisionRectangle()))
                {
                    //for overkill damage
                    Player.instantDeath();
                }
            }
        }
    void Start()
    {
        m_StateSpawn = new BossStateSpawn(this);
        m_StateCreateMuzzle = new BossStateCreateMuzzle(this);
        m_StateDeleteMuzzle = new BossStateDeleteMuzzle(this);
        m_StateAttack = new BossStateAttack(this);
        m_StateRetreat = new BossStateRetreat(this);
        m_StateDeleteEntity = new BossStateDeleteEntity(this);
        m_StateMove = new BossStateMove(this);

         Boss = GameObject.Find("Boss_1");
         enemyProp = Boss.GetComponent<EnemyProperties>();

         ChangeState(eBossState.Spawn);
    }
Пример #46
0
        public static void reset()
        {
            m_Position = m_StartPos + m_Hidden;
            m_Health = INITIAL_HEALTH;
            m_BossState = BossState.IDLE;
            m_NarwhalGun.clear();
            m_LavaWave.reset();
            m_BeamManager.reset();

            for (int i = 0; i < m_Particles.Length; i++)
            {
                m_Particles[i].Stop = true;
            }
        }
Пример #47
0
        public void update(GameTime gameTime)
        {
            if (IsActive == true)
            {
                if (m_BossState != BossState.DYING && m_BossState != BossState.DEAD)
                {
                    float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

                    if (m_BossState == BossState.IDLE)
                    {
                        Vector2 temp;
                        Vector2.Subtract(ref m_Position, ref m_StartPos, out temp);
                        if (temp.Length() > (m_IdleMoveDist - (m_IdleMoveDist * m_LerpDist)))
                        {
                            do
                            {
                                m_TargetPos = new Vector2(m_Random.Next(100) - 50, m_Random.Next(100) - 50);
                            } while (m_TargetPos.X == 0 && m_TargetPos.Y == 0);
                            m_TargetPos.Normalize();
                            m_TargetPos.X = m_TargetPos.X * m_IdleMoveDist;
                            m_TargetPos.Y = m_TargetPos.Y * m_IdleMoveDist;

                        }
                        m_Position = Vector2.Lerp(m_Position, m_StartPos + m_TargetPos, m_LerpAmount);
                        Position = m_Position;

                        m_StateChangeTimer += elapsedTime;

                        if (m_StateChangeTimer > m_StateDelay)
                        {
                            m_StateChangeTimer = 0.0f;
                            do
                            {
                                m_BossState = (BossState)(m_Random.Next((int)BossState.COUNT));
                                //m_BossState = BossState.CHARGING;
                            } while (m_BossState == BossState.LAVA_WAVE && m_LavaWave.IsActive == true);
                        }
                        m_Animate.changAnimation(1);
                    }
                    else if (m_BossState == BossState.CHARGING)
                    {
                        //boss is charging here ------------------------------------------------------------------------------------------------

                        for (int i = 0; i < m_Particles.Length; i++)
                        {
                            Vector2 temp;
                            temp = new Vector2(m_Random.Next(100) - 50, m_Random.Next(100) - 50);
                            temp.Normalize();
                            temp.X = temp.X * m_ChargeDist;
                            temp.Y = temp.Y * m_ChargeDist;

                            m_Particles[i].SpawnPoint = new Vector2(m_Animate.DestinationRectangle.X, m_Animate.DestinationRectangle.Y) + temp;
                            m_Particles[i].DominantDirection = new Vector2(m_Animate.DestinationRectangle.X, m_Animate.DestinationRectangle.Y) - m_Particles[i].SpawnPoint;

                            m_Particles[i].Stop = false;

                            m_BossLaserPlayed = false;
                            if (m_BossChargingSoundPlayer == false)
                            {
                                Sounds.playSound("BossCharging", 1.0f);
                                m_BossChargingSoundPlayer = true;
                            }
                        }

                        m_StateChangeTimer += elapsedTime;

                        if (m_StateChangeTimer > m_StateDelay)
                        {
                            m_StateChangeTimer = 0.0f;

                            m_BossState = BossState.FIRING;

                            for (int i = 0; i < m_Particles.Length; i++)
                            {
                                m_Particles[i].Stop = true;
                            }

                            m_PlayerPos = new Vector2(Player.collisionRectangle().Center.X, Player.collisionRectangle().Center.Y);
                            if (m_Animate.DestinationRectangle.Y < m_PlayerPos.Y)
                            {
                                m_Direction = MovementValue.DOWN;
                            }
                            else
                            {
                                m_Direction = MovementValue.UP;
                            }
                        }
                    }
                    else if (m_BossState == BossState.FIRING)
                    {
                        m_Position.Y += m_Speed * elapsedTime * (int)m_Direction;
                        Position = m_Position;

                        m_BossChargingSoundPlayer = false;

                        if (m_Direction == MovementValue.DOWN && m_Animate.DestinationRectangle.Y > m_PlayerPos.Y || m_Direction == MovementValue.UP && m_Animate.DestinationRectangle.Y < m_PlayerPos.Y)
                        {
                            //boss shoots here ---------------------------------------------------------------------------
                            if (m_BossLaserPlayed == false)
                            {
                                Sounds.playSound("BossLaser", 1.0f);
                                m_BossLaserPlayed = true;
                            }

                            m_BeamManager.addBeam(new Vector2(m_Animate.DestinationRectangle.X, m_Animate.DestinationRectangle.Y), m_PlayerPos);

                            m_BossState = BossState.IDLE;
                            m_Direction = MovementValue.NONE;
                        }
                    }
                    else if (m_BossState == BossState.LAVA_WAVE)
                    {
                        if (m_Position.X < m_StartPos.X + m_RetreatPos.X)
                        {
                            m_Position.X += m_Speed * elapsedTime;
                        }
                        else if ((m_Position.Y - m_Animate.DestinationRectangle.Height / 2 > m_StartPos.Y + m_RetreatPos.Y) && m_Drop == false)
                        {
                            m_Position.Y -= m_Speed * elapsedTime;

                            if (m_Position.Y - m_Animate.DestinationRectangle.Height / 2 < m_StartPos.Y + m_RetreatPos.Y)
                            {
                                m_Drop = true;
                            }
                        }
                        else if (m_Position.Y < m_StartPos.Y && m_Drop == true)
                        {
                            m_Position.Y += m_Speed * elapsedTime;
                            if (m_BossWavePlayed == false)
                                {
                                    Sounds.playSound("Wave", 1.0f);
                                    m_BossWavePlayed = true;
                                }

                            if (m_Position.Y > m_StartPos.Y)
                            {
                                m_LavaWave.SpawnTheWave(new Vector2(m_Position.X, Level.getHeightOfArray() * 32 - 2));
                                m_Drop = false;
                                m_BossState = BossState.IDLE;
                                m_BossWavePlayed = false;

                            }
                        }
                        Position = m_Position;
                    }
                    else if (m_BossState == BossState.NARWHAL)
                    {
                        if (Vector2.Subtract(m_Position, m_StartPos + m_RainPos).Length() > m_RainJumpDist)
                        {
                            Vector2 temp = new Vector2(m_StartPos.X + m_RainPos.X - m_Position.X, m_StartPos.Y + m_RainPos.Y - m_Position.Y);
                            temp.Normalize();
                            m_Position += temp * m_Speed / 4.0f * elapsedTime;

                        }
                        else
                        {
                            if (m_BossRoarPlayed == false)
                            {
                                Sounds.playSound("BossRoar", 1.0f);
                                m_BossRoarPlayed = true;
                            }
                            m_StateChangeTimer += elapsedTime;

                            Vector2 temp;
                            do
                            {
                                temp = new Vector2(m_Random.Next(100) - 50, m_Random.Next(100) - 50);
                            } while (temp.X == 0 && temp.Y == 0);

                            temp.Normalize();
                            temp.X *= m_RainJumpDist;
                            temp.Y *= m_RainJumpDist;

                            m_Position = m_StartPos + m_RainPos + temp;

                            m_NarwhalGun.NARWHAL(new Vector2(m_Position.X + m_GunPos.X, m_Position.Y + m_GunPos.Y));

                            //spitting narwhals here------------------------------------------------------------------------

                            if (m_StateChangeTimer > RAIN_LENGTH)
                            {
                                m_StateChangeTimer = 0.0f;
                                m_BossState = BossState.IDLE;
                                m_BossRoarPlayed = false;
                            }
                        }
                        Position = m_Position;
                    }
                }
                else if (m_BossState == BossState.DYING)
                {
                    m_Position = Vector2.Lerp(m_Position, m_StartPos + m_Hidden, m_LerpAmount);

                    //boss is dead here------------------------------------------------------------------------------------------
                    if (m_BossDeathPlayed == false)
                    {
                        Sounds.playSound("BossDeath", 1.0f);
                        m_BossDeathPlayed = true;
                    }

                    Vector2 temp;
                    do
                    {
                        temp = new Vector2(m_Random.Next(100) - 50, m_Random.Next(100) - 50);
                    } while (temp.X == 0 && temp.Y == 0);

                    temp.Normalize();
                    temp.X *= m_RainJumpDist / 2;
                    temp.Y *= m_RainJumpDist / 2;

                    m_Position += temp;
                    Position = m_Position;

                    if (m_Position.Y > m_StartPos.Y + m_Hidden.Y)
                    {
                        m_BossState = BossState.DEAD;
                    }
                }
                else
                {
                    if (m_Position.Y < m_StartPos.Y + m_Hidden.Y + m_MoreHidden.Y)
                    {
                        m_Position.Y++;
                        Position = m_Position;
                        Vector2 tempy = m_Lava.Pos;
                        tempy.Y++;
                        m_Lava.Pos = tempy;
                    }
                }

                collisioncheck();

                m_NarwhalGun.update(gameTime);
                m_BeamManager.update(gameTime);
                m_LavaWave.update(gameTime);
                m_Animate.update(gameTime);

                m_Lava.update(gameTime);

                for (int i = 0; i < m_Particles.Length; i++)
                {
                    m_Particles[i].update(gameTime);
                }
            }
        }
 public void GoToPosition(Vector2 newPosition)
 {
     status = BossState.Move;
     destinationPosition = newPosition;
 }
Пример #49
0
    // Update is called once per frame
    void Update()
    {
        if (state == BossState.Waiting) {
            //check if player is in sightrange and move to stealing if true
            if(Vector2.Distance(Navi.S.transform.position, transform.position) < sightRange)
            {
                state = BossState.Attacking;
            }
        }
        else if (state == BossState.Attacking) {
            //check if dead

            if(nextAttackTime < Time.time)
            {
                //spawn enemy
                GameObject proj = Instantiate(projectile);
                proj.transform.position = this.transform.position;
                nextAttackTime = Time.time + attackSpeed;
            }
        }
        else if (state == BossState.Chasing)
        {
            if (Vector2.Distance(Player.S.transform.position, transform.position) > 15f)
            {
                enemyComponent.followSpeed = 16f;
            }
            else
            {
                enemyComponent.followSpeed = 5.5f;
            }
        }
        if (state == BossState.Dying) {
            enemyComponent.die();
            Music.S.setDefaultMusic();
            MainCam.ShakeForSeconds(5f);
            Destroy(gameObject);
        }
    }
        public IEnumerator ChangeState(BossState STATE)
        {
            _changingState = true;
            switch(currentState)
            {
            case BossState.Attack:
                yield return StartCoroutine(ExitAttack());
                break;
            case BossState.Search:
                yield return StartCoroutine(ExitSearch());
                break;
            case BossState.Patrol:
                yield return StartCoroutine(ExitPatroll());
                break;
            case BossState.Die:
                yield return StartCoroutine(ExitDie());
                break;
            case BossState.Heal:
                yield return StartCoroutine(ExitHeal());
                break;
            case BossState.Stagger:
                yield return StartCoroutine(ExitStagger());
                break;
            }

            switch(STATE)
            {
            case BossState.Attack:
                yield return StartCoroutine(EnterAttack());
                break;
            case BossState.Search:
                yield return StartCoroutine(EnterSearch());
                break;
            case BossState.Patrol:
                yield return StartCoroutine(EnterPatroll());
                break;
            case BossState.Die:
                yield return StartCoroutine(EnterDie());
                break;
            case BossState.Heal:
                yield return StartCoroutine(EnterHeal());
                break;
            case BossState.Stagger:
                yield return StartCoroutine(EnterStagger());
                break;
            }
            // Handleing _lastState is a bit strange.
            _lastState = currentState;

            currentState = STATE;
            yield return null;
            _changingState = false;
        }
Пример #51
0
 public void Start()
 {
     state = BossState.Waiting;
     enemyComponent = GetComponent<Enemy>();
     enemyComponent.enabled = false;
 }
Пример #52
0
    // Update is called once per frame
    protected override void Update()
    {
        StartCoroutine (FadeIn (4f));

        if (healthBar != null)
        {
            healthBar.fillAmount = CurrentHP / MaxHP;
        }

        // apply the correct sprite based on the current health
        if (CurrentHP > (MaxHP * .75f))
        {
            spriteRenderer.sprite = fullHealth;
            currentState = BossState.FullHealth;
        }
        else if (CurrentHP <= (MaxHP * .75f) && CurrentHP > (MaxHP * .5f))
        {
            spriteRenderer.sprite = reducedHealth;
            currentState = BossState.ReducedHealth;
            //isSmoking = true;
        }
        else if (CurrentHP <= (MaxHP * .5f) && CurrentHP > (MaxHP * .25f))
        {
            spriteRenderer.sprite = halfHealth;
            currentState = BossState.HalfHealth;
            //isOnFire = true;
        }
        else if (CurrentHP <= (MaxHP * .25))
        {
            spriteRenderer.sprite = lowHealth;
            currentState = BossState.LowHealth;
        }
        else if (CurrentHP <= 0)
        {
            Application.LoadLevel("GameOver");
        }
        // Calls the parent method
        base.Update();

        // if active
        // Check each weapon in the list of primary weapons
        if (isActive)
            foreach (var weapon in primaryWeapons)
            {
                // if the weapon can fire
                // fire weapon
                if (weapon.ReadyToFire)
                    weapon.FireBegin();
                // if the weapon cannot fire
                // stop firing weapon
                else
                    weapon.FireEnd();
            }

        //  if object is within certain distance of player
        // check the phases of the game
        switch (phase)
        {
            // linearly interpolates between the two vectors
            // the position of the object
            case 0:
                transform.position = Vector3.Lerp(transform.position, transform.position + new Vector3(0, -.0125f), speed);
                break;
            // linearly interpolates between the two vectors
            // the position of the object
            case 1:
                transform.position = Vector3.Lerp(transform.position, transform.position, speed);
                break;
            // linearly interpolates between the two vectors
            // the position of the object
            case 2:
                transform.position = Vector3.Lerp(transform.position, transform.position + new Vector3(-.05f, 0), speed);
                break;
            // linearly interpolates between the two vectors
            // the position of the object
            case 3:
                transform.position = Vector3.Lerp(transform.position, transform.position, speed);
                break;
            case 4:
                transform.position = Vector3.Lerp(transform.position, transform.position + new Vector3(.1f, 0), speed);
                break;
            // default case
            case 5:
                transform.position = Vector3.Lerp(transform.position, transform.position, speed);
                break;
            case 6:
                transform.position = Vector3.Lerp(transform.position, transform.position + new Vector3(-.1f, 0), speed); break;
            case 7:
                transform.position = Vector3.Lerp(transform.position, transform.position, speed);
                break;
            default:
                break;
        }

        // if the timer is greater than 50
        if (timer > 100)
        {
            // if it is in the third phase
            // set phase to 0
            if (phase == 7)
            {
                phase = 4;
            }
            // if it is in a different phase
            // increase the phase
            else
            {
                phase++;
            }
            // set timer to 0
            timer = 0;
        }
        // if the timer is less than 50
        // increase the timer
        else
        {
            timer++;
        }
    }
Пример #53
0
        private void KillBoss()
        {
            if (_isDead)
                return;

            _isDead = true;
            var deathFxParticle = (GameObject) Instantiate(bossDeathFX);
            deathFxParticle.transform.position = dropFXSpawnPoint.transform.position;

            OnEnemyDied(EnemyType.Boss);

            transform.position = inActiveNode.position;
            currentState = BossState.Idle;
            _timeForNextEvent = 0f;
            _enemiesLeftToKill = enemiesToStartBattle;
        }
Пример #54
0
        void Update()
        {
            switch (currentState)
            {
                case BossState.Idle:
                    break;
                case BossState.FallingToNode:
                    if (transform.position.y > _targetNode.position.y)
                    {
                        transform.Translate(new Vector3(0f, -moveSpeed * Time.deltaTime, 0f));

                        if (transform.position.y < _targetNode.position.y)
                        {
                            transform.position = _targetNode.position;
                        }
                    }
                    else
                    {
                        CreateDropFX();

                        _timeForNextEvent = 0f;
                        currentState = BossState.WaitingToJump;
                    }
                    break;
                case BossState.WaitingToFall:
                    if (_timeForNextEvent < float.Epsilon)
                    {
                        _timeForNextEvent = Time.time + eventWaitDelay;
                    }
                    else if (_timeForNextEvent < Time.time)
                    {
                        _targetNode = dropNodeList[Random.Range(0, dropNodeList.Count)];

                        transform.position = GetSkyPositionOfNode(_targetNode);

                        currentState = BossState.FallingToNode;
                        _timeForNextEvent = 0f;
                    }
                    break;
                case BossState.WaitingToJump:
                    if (_timeForNextEvent < float.Epsilon)
                    {
                        _timeForNextEvent = Time.time + eventWaitDelay;
                    }
                    else
                    {
                        _targetPosition = GetSkyPositionOfNode(_targetNode);
                        currentState = BossState.JumpingOffPlatform;
                        _timeForNextEvent = 0f;

                        _targetNode = null;
                    }
                    break;
                case BossState.JumpingOffPlatform:
                    if (transform.position.y < _targetPosition.y)
                    {
                        transform.Translate(new Vector3(0f, moveSpeed*Time.deltaTime, 0f));

                        if (transform.position.y > _targetPosition.y)
                            transform.position = _targetPosition;
                    }
                    else
                    {
                        _timeForNextEvent = 0f;
                        currentState = BossState.WaitingToFall;
                    }
                    break;
            }
        }
Пример #55
0
        /// <summary>
        /// Update all projectiles and move the boss
        /// </summary>
        /// <param name="gameTime">Snapshot of time values</param>
        /// <param name="player">Player data so that the boss can respond to events accordingly</param>
        public override void UpdateAndMove(TimeSpan gameTime, Ship player)
        {
            float distance = Vector2.Distance(position, startingPos);

            if (distance <= 50)
                bossState = BossState.Firing;

            //if the boss is moving to position, just move towards it
            if (bossState == BossState.MovingToPosition)
            {
                //calculate the angle towards the player and set the enemy's angle to that angle
                this.angle = TurnToFace(position, startingPos, this.angle, turnSpeed);
                Vector2 heading = new Vector2((float)Math.Cos(this.angle), (float)Math.Sin(this.angle));
                this.position += heading * this.speed;
            }

                //if the boss is set to fire, start firing projectiles
            else if (bossState == BossState.Firing)
            {
                //assume the firing position.
                this.angle = TurnToFire(position, player.Position, this.angle, turnSpeed);
                Vector2 heading = new Vector2((float)Math.Cos(this.angle), (float)Math.Sin(this.angle));

                //the boss fires a burst of 10 projectiles with a break between each projectile in the burst, and a break in between each full burst
                if (gameTime.TotalMilliseconds - lastFire.TotalMilliseconds > rateOfFire && gameTime.TotalMilliseconds - lastBurst.TotalMilliseconds > TIME_BETWEEN_BURSTS)
                {
                    //update time of last burst
                    lastBurst = gameTime;
                    //fire another salvo of projectiles
                    this.Fire(gameTime);

                    if (++burstCount > TOTAL_PER_BURST)
                    {
                        //Burst is complete, so this round of firing is complete too, reset burst count to 0, and set lastFire to current time
                        burstCount = 0;
                        lastFire = gameTime;
                    }
                }

                //Move cannon balls
                this.Update(gameTime);
            }
        }
Пример #56
0
    // Update is called once per frame
    void Update()
    {
        //print (transform.position.x + "," + transform.position.y + "\n");
        //if(drawShadow)
        //Graphics.DrawTexture (new Rect (stompTarget.x, stompTarget.y, 10, 10), shadow);
        stateTime += Time.deltaTime;
        switch (currentState) {
        case BossState.Moving:
            if (!inAir&&!stomped) {
                collider2D.enabled=false;
                stompTarget=GameObject.FindGameObjectsWithTag("Player")[0].transform.position;
                Jump (stompTarget.x);
            }
            else if (inAir&&!stomped) {
                if(!stomped && transform.position==(Vector3)moveTo){
                Stomp (stompTarget);
                    break;
                }
                else if(!stomped){
                    updatePosition(moveTo);
                    break;}

            }
            else if(stomped){
                inAir=false;
                if(transform.position==(Vector3)stompTarget){
                    collider2D.enabled=true;
                    stomped=false;
                    currentState=BossState.Shooting;
                    drawShadow=false;
                    stateTime=0;
                }
                else{
                    updatePosition(stompTarget);
                }
                break;
            }

            break;

        case BossState.Shooting:
            inAir=false;
            collider2D.enabled=true;
            if(stateTime>5.5){
                stateTime=0;
                currentState=BossState.Moving;
                break;
            }

            if (stateTime < 5&&stateTime>1&&reload<=0) {
                reload=.25f;
                gameObject.GetComponent<RangedAttack>().Fire(20);
            }
            else
                reload-=Time.deltaTime;

            break;

        case BossState.Stunned:
            if (stateTime >= 5) {

                //Jump ();
            }

            break;
        case BossState.Reset:
            Stomp(new Vector2(mapX,mapY));
            break;
        }
    }
        public void updateBoss(GameTime time)
        {
            if (boss != null && boss.Active)
            {
                if (debug)
                {
                    Console.WriteLine("Update Boss");
                }
                switch (this.CurrentState)
                {
                    case BossState.ASSEMBLED:
                        if (boss.Position.Y < heroRef.heroStartPosition.Y)
                        {
                            boss.Move(boss.Position.X, boss.Position.Y + boss.Speed);
                        }
                        else
                        {
                            boss.Move(boss.Position.X + RandomHandler.GetRandomFloat(-1f, 1f), boss.Position.Y + RandomHandler.GetRandomFloat(-1f, 1f));

                            heroRef.CurrentState = Hero.HeroState.FIGHTING;

                            Console.WriteLine("Boss starts the hero fighting");
                        }
                        break;
                    case BossState.ASSEMBLING:
                        boss.Move(boss.Position.X + RandomHandler.GetRandomFloat(-1f, 1f), boss.Position.Y + RandomHandler.GetRandomFloat(-1f, 1f));
                        break;
                    case BossState.SWARM:
                        if (boss.Position.X >= assembleAtX)
                        {
                            this.CurrentState = BossState.ASSEMBLING;
                            if (debug)
                            {
                                Console.WriteLine("Boss is now assembling");
                            }
                        }
                        else
                        {
                            if (debug)
                            {
                                Console.WriteLine("Move boss to the right");
                            }
                            boss.Move(boss.Position.X + boss.Speed, boss.Position.Y);
                        }
                        break;
                }
            }
        }
        public void drawBoss(SpriteBatch batch, GameTime time)
        {
            if (boss != null && boss.Active)
            {
                int yPos = 0,
                    xPos = -1;
                switch (this.CurrentState)
                {
                    case BossState.ASSEMBLED: yPos = boss.Height; break;
                    case BossState.ASSEMBLING: yPos = 0; break;
                    case BossState.SWARM: yPos = 0;
                                          xPos = 0;
                                          break;
                }

                int animationX = 0;
                if (xPos == -1)
                {
                    animationX = (int)(time.TotalGameTime.TotalSeconds * bossAnimSpeed) % numFrames;

                    if (this.CurrentState == BossState.ASSEMBLING)
                    {
                        if (debug)
                        {
                            Console.WriteLine("X: " + animationX.ToString());
                        }
                        if (animationX > numFrames-1)
                        {
                            this.CurrentState = BossState.ASSEMBLED;

                            if (debug)
                            {
                                Console.WriteLine("Boss is now assembled");
                            }
                        }
                    }
                }
                else
                {
                    animationX = xPos;
                }

                Rectangle animCycle = new Rectangle(animationX * boss.Width, yPos, boss.Width, boss.Height);

                batch.Draw(boss.Texture, boss.Position, animCycle, boss.Color, boss.Rotation,
                        new Vector2(0, (boss.Height * 0.5f)), boss.ScaleFactor, SpriteEffects.None, boss.LayerDepth);
            }
        }