예제 #1
0
        /// <summary>
        /// ShotAI搭載時の向き変更
        /// </summary>
        private void UpdateShotMyDir()
        {
            Character target = mediator.GetPlayer();

            if (target == null)
            {
                return;
            }

            float targetPosX = target.Position.X;

            myDirectionX = Direction.Right;
            if (targetPosX < this.Position.X)
            {
                myDirectionX = Direction.Left;
            }
        }
예제 #2
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            //カウントダウンタイマーを起動
            time.Update(gameTime);
            if (!time.IsTime())
            {
                                //まだ時間が残っている
                {
                    //ラスボス「鬼」の現在位置を特定し、それを自分の座標にする
                    Position = mediator.GetBoss().Position;
                    //ターゲットの現在位置を取得
                    playerPos = mediator.GetPlayer().Position;
                    //自分とターゲットとの座標の差を計算
                    playerV = playerPos - Position;

                    var velocity = Vector2.Zero;

                    num += 3;                                  //角度を増やしていく
                    float angle = MathHelper.ToRadians(num);   //角度を弧度法に変換

                    //角度に応じた移動量を算出(三角関数を用いる)
                        velocity = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));
                    velocity.Normalize();             //角度で指定された移動方向のみを取得
                        Position += velocity * 100;   //その方向に向かって一気に進む(角度が動的に変わるため軌道も変化していく)
                }
            }
            else                               //時間切れになった
            {
                playerV.Normalize();           //ターゲットへの方向のみ取得
                    Position += playerV * 8;   //ターゲットに向かって進む

                var velocity = Vector2.Zero;

                num += 5;                                  //角度を変えていく
                float angle = MathHelper.ToRadians(num);   //角度を弧度法に変換

                //角度に応じた移動量を算出(三角関数を用いる)
                    velocity = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));
                velocity.Normalize();           //角度で指定された移動方向のみ取得
                    Position += velocity * 6;   //角度に応じて進む
            }
        }
예제 #3
0
        public override void Updata(GameTime gameTime)
        {
            player = mediator.GetPlayer();
            Vector2 otherPosition = player.GetPosition();

            if (otherPosition.X - position.X <= p && otherPosition.X - position.X >= -p)
            {
                if (otherPosition.Y - position.Y <= p && otherPosition.X - position.X >= -p)
                {
                    velocity = otherPosition - position;
                    velocity.Normalize();
                }
                else
                {
                    velocity = Vector2.Zero;
                }
            }
            else
            {
                velocity = Vector2.Zero;
            }

            position += velocity * 3;
        }
예제 #4
0
        /// <summary>
        /// ターゲットに向かって高速突進
        /// </summary>
        /// <param name="gameTime"></param>
        private void JumpAttack(GameTime gameTime)
        {
            if (stateNum == 0)
            {
                               //サーチモード(ターゲットの位置を確認する)
                {
                    //描画モーションをアイドリングにする
                    setMotionAndAsset(MotionName.idling);

                    CD = new CountDownTimer(0.8f);
                    float a = CD.Now();

                    //プレイヤーの位置情報を取得
                    playerPos =
                        mediator.GetPlayer().Position;
                    alpha = (1 - a);
                    //プレイヤーの座標が変わらなければ
                    if (playerPos == mediator.GetPlayer().Position)
                    {
                        stateNum += 1;  //攻撃アルゴリズムを変更
                    }
                }
            }
            else if (stateNum == 1)
            {
                                    //ひたすら突進攻撃
                {
                    //描画モーションを突進にする
                    setMotionAndAsset(MotionName.attack);

                    velocity = (playerPos + new Vector2(0, -150)) - Position;  //移動量を設定
                    if (!invincible)
                    {
                                 //ダメージ状態でなければ
                        {
                            //紫のオーラをまとわせる
                            color = Color.Purple;
                        }
                    }
                    velocity.Normalize();  //移動の方向のみ取得
                    //特定の条件に一致いるか確認
                    if ((playerPos.Y - Position.Y) < 165 && (playerPos.Y - Position.Y) > 130)
                    {
                        //攻撃アルゴリズムを変更
                        CD.Update(gameTime);
                        float a = CD.Now();

                        alpha += (1 - a);
                        if (CD.IsTime())
                        {
                                     //一定時間たったら
                            {
                                stateNum = 2;
                            }
                        }
                    }
                    else
                    {
                        //プレイヤーのいたおよその方向に向かって突進
                        Position += velocity * 20;
                    }
                }
            }
            else if (stateNum == 2)
            {
                                    //突進&仕上げの気玉同時放出
                {
                    //ターゲットのY座標を取得
                    playerPos.Y = mediator.GetPlayer().Position.Y;

                    //自分とターゲットとの縦方向の距離が10より大きければ
                    if (Math.Abs(Position.Y - playerPos.Y) > 10f)
                    {
                        //ターゲットへの方向と距離を取得
                        velocity = playerPos - Position;
                        //方向のみを取得
                        velocity.Normalize();
                        //ターゲットに向かって突進
                        Position += velocity * 20;
                    }
                    else //ある程度ターゲットに近づいた
                    {
                        //気玉を多方向に放出
                        mediator.AddCharacter(new BossBullet(Position, gameDevice, 1, 2));
                        mediator.AddCharacter(new BossBullet(Position, gameDevice, 1, 4));
                        mediator.AddCharacter(new BossBullet(Position, gameDevice, 1, -2));
                        mediator.AddCharacter(new BossBullet(Position, gameDevice, 1, -4));

                        //気玉を放つ戦闘態勢に変更
                        ChangeState(BossState.ShotAttack);
                    }
                }
            }
        }