Beispiel #1
0
        public override void RankingUpdate()
        {
            // enemysにエネミーのデータを入れる
            List <Vector2> scale = new List <Vector2>();

            // エネミー一体一体の大きさを個別に保存
            foreach (var enemy in GameObjectManager.FindAll(CharacterID.Enemy))
            {
                scale.Add(enemy.transform.Scale);
            }

            // スケールでソート
            var scaleVar = scale.OrderByDescending(s => s.X).ToList();

            // Rankingの初期値はエネミーの数
            playerRank = scaleVar.Count;

            // プレイヤーのランクを決定
            for (int enemyNumber = 0; enemyNumber < scaleVar.Count; enemyNumber++)
            {
                // プレイヤー全体の大きさが今調べているエネミーの大きさよりも大きかったら
                if ((CompVector2.SumScale(CharacterID.Player).X > scaleVar[enemyNumber].X))
                {
                    // 現在調べているエネミーのナンバーをプレイヤーに入れる
                    playerRank = enemyNumber;

                    // それ以降は処理しない
                    break;
                }
            }
        }
Beispiel #2
0
        public override void Update(GameTime gameTime)
        {
            transform.CenterPosition = radius;

            // 大きさ
            transform.Scale = currentScale;
            EagingScale();

            // 半径が変わるので当たり判定も1フレーム毎にチェック
            collision = new CircleCollision(CompVector2.ScaleConversion(currentScale, radius).X, transform);

            // 移動
            Move();

            // 任意の分裂
            Division(ref futureScale, ref currentScale, transform.Position);

            // クランプ
            transform.Position = Clamp(transform.Position, CompVector2.ScaleConversion(currentScale, radius));

#if DEBUG
            // デバッグ用
            if (input.IsKeyDown(Keys.A))
            {
                isDead = true;
            }
#endif
        }
Beispiel #3
0
        public override void Update(GameTime gameTime)
        {
            // 中心を新しくセット
            transform.CenterPosition = radius;

            // スケールを毎フレーム代入(transform.Scaleがプロパティでrefが使えないため)
            transform.Scale = currentScale;
            EagingScale();

            collision = new CircleCollision(CompVector2.ScaleConversion(currentScale, radius).X, transform);

            // プレイヤーの移動
            PlayerMove();

            // 任意の分裂
            Division(ref futureScale, ref currentScale, transform.Position);

            // クランプ
            transform.Position = Clamp(transform.Position, CompVector2.ScaleConversion(currentScale, radius));


            // デバッグ用
#if DEBUG
            if (input.IsKeyDown(Keys.T))
            {
                // スケール係数を1ずつ足す
                futureScale += new Vector2(1f);
            }
#endif
        }
        /// <summary>
        /// 餌を定期的に追加
        /// </summary>
        /// <returns></returns>
        ///
        //private void RunTask()
        //{
        //    TaskFactory taskFactory = new TaskFactory();
        //    CancellationTokenSource tokenSource = new CancellationTokenSource();

        //    Task task = taskFactory.StartNew(() =>
        //    {
        //        while (true)
        //        {
        //            // キャンセル要求が来ていたらOperationCanceledException例外をスロー
        //            tokenSource.Token.ThrowIfCancellationRequested();

        //            GameObjectManager.Add(new Food(gameManager));

        //            Task.Delay(500);
        //        }
        //    }, tokenSource.Token);

        //    if (sceneEndCheck)
        //    {
        //        try
        //        {
        //            // キャンセル要求出す
        //            tokenSource.Cancel();

        //            // タスクがキャンセルされるまで待機
        //            task.Wait();
        //        }
        //        catch (AggregateException)
        //        {
        //            // タスクがキャンセルされるとここが実行される
        //        }
        //    }
        //}

        // 更新
        public override void Update(GameTime gameTime)
        {
            CameraGroup();

            // 敵を定期的に追加する処理を実行
            EnemyAdd(gameTime);
            // 餌を定期的に追加する処理を実行
            FoodAdd(gameTime);

            PlayerNullCheck();

            Console.WriteLine(CompVector2.SumScale(CharacterID.Player));
        }
 public override void Update(GameTime gameTime)
 {
     //CompVector2.RectInCheck(input.MouseVector2(), Screen.HalfScreen - new Vector2(295.0f, 0.0f), Screen.HalfScreen + new Vector2(295.0f, 189.0f))
     if (CompVector2.RectInCheck(input.MouseVector2(), Screen.HalfScreen - new Vector2(295.0f, 0.0f), Screen.HalfScreen + new Vector2(295.0f, 189.0f)))
     {
         colorValue = 100;
         if (input.LeftClick())
         {
             isEnd = true;
         }
     }
     else
     {
         colorValue = 0;
     }
 }
Beispiel #6
0
        /// <summary>
        /// エネミーの動きに関するもの
        /// </summary>
        /// <param name="gameTime"></param>
        private void EnemyMove(GameTime gameTime)
        {
            if (randCount < intervalCount)
            {
                // 1秒 ~ 10秒の間でインターバルを決定
                randCount = random.Next(1000, 10000);
                randPos   = Vector2.Normalize(
                    transform.Position - new Vector2(
                        random.Next(0, Screen.MapWidth - (int)(CompVector2.ScaleConversion(scale, radius).X)),
                        random.Next(0, Screen.MapHeight - (int)(CompVector2.ScaleConversion(scale, radius).Y))));
                intervalCount = 0;
            }
            transform.Position -= randPos * Speed(speed, scale.X);

            // インターバルをカウント
            intervalCount += gameTime.ElapsedGameTime.Milliseconds;
        }
Beispiel #7
0
        // エネミーに当たった時の反応
        protected void EnemyHit(GameObject other, ref Vector2 scale)
        {
            // 相手と自分の大きさの差が0.45f以下なら何もしない
            if (CompVector2.U_DifferenceValue(other.transform.Scale.X, scale.X) <= 0.45f)
            {
                return;
            }

            // 相手より自分の方が大きければ吸収
            if (other.transform.Scale.X < scale.X)
            {
                // エネミーのスケールを自分のスケールに足す(相手のスケールを5で割る:バランス調整)
                scale += other.transform.Scale / 5;
            }
            else
            {
                isDead = true;
            }
        }
        /*////////////////////////////////////////////
        *
        *
        * ここから下はUpdataに書いた処理が書かれてます
        *
        *
        *  /* /////////////////////////////////////////*/

        /// <summary>
        /// カメラのズームと動き
        /// </summary>
        private void CameraGroup()
        {
            // カメラの初期値
            Camera.Position = Screen.HalfScreen;

            if (CompVector2.SumScale(CharacterID.Player).X <= 17.0f)
            {
                if (!input.IsKeyPush(Keys.Space))
                {
                    // 初期カメラズーム値 / キャラクターのScaleの合計でカメラのズームを決める
                    Camera.Zoom = new Vector2(4f) / CompVector2.SumScale(CharacterID.Player);
                }
            }
            else
            {
                Camera.Zoom = new Vector2(0.23f);
            }

            // カメラを移動させる
            camera.MoveVector2(-(Screen.HalfScreen - CompVector2.ObjectsCenterPos(CharacterID.Player)));
        }
Beispiel #9
0
        /// <summary>
        /// プレイヤーと当たった時の処理
        /// </summary>
        /// <param name="other"></param>
        private void CharacterHit(GameObject other, ref Vector2 scale)
        {
            // 相手と自分の大きさの差が0.004f以下なら何もしない
            if (CompVector2.U_DifferenceValue(other.transform.Scale.X, scale.X) <= 0.45f)
            {
                return;
            }

            // 相手より自分の方が大きければ吸収
            if (other.transform.Scale.X < scale.X)
            {
                // エネミーのスケールを自分のスケールに足す(相手のスケールを2で割る:バランス調整)
                scale += other.transform.Scale / 5;

                // 将来的に敵の半径分を自機の半径に足す機構も作る
                //radius += new Vector2(((CircleCollision)other.GetCollision).Radius) / 2;
            }
            else
            {
                isDead = true;
            }
        }
Beispiel #10
0
        public DivisionPlayer(Vector2 scale, Vector2 radius, float speed, Vector2 position, GameManager gameManager, float x = 0, float y = 0, bool needleHitbone = false)
            : base(gameManager)
        {
            compVector2 = new CompVector2();

            id  = ObjectID.Character;
            Tag = CharacterID.Player;
            drawStruct.textureName = CharacterID.Player;
            this.radius            = radius;
            transform.Position     = position;
            mySpeed    = (speed * scale.X) * 4f;
            bornRadian = (float)compVector2.Radian(position, input.WorldMouseVector2());
            course     = new Vector2((float)Math.Cos(bornRadian),
                                     (float)Math.Sin(bornRadian));
            currentScale = scale;
            futureScale  = currentScale;

            needleHitReact     = new Vector2(x, y);
            this.needleHitbone = needleHitbone;

            scaleMotion = Motion.Stopped;
        }
Beispiel #11
0
        public override void Update(GameTime gameTime)
        {
            collision = new CircleCollision(CompVector2.ScaleConversion(scale, radius).X, transform);

            transform.CenterPosition = radius;

            transform.Scale = scale;


            if (findFoodInterval <= findFoodCount && GetScene == SceneID.GamePlay)
            {
                // 餌が近くにないか探す
                FindFood();

                // インターバル + 0.1秒した値よりカウントが大きくなったらリセット
                if (findFoodInterval + 10 <= findFoodCount)
                {
                    findFoodCount = 0;
                }
            }
            findFoodCount++;

            // エネミーのモードによって行動を決定
            switch (mode)
            {
            // 通常行動
            case EnemyMoveMode.NormalMove:
                EnemyMove(gameTime);
                break;

            // 近くに食べ物が見つかればこの行動に移る
            case EnemyMoveMode.EatMove:
                FoodEatMove();
                break;
            }

            transform.Position = Clamp(transform.Position, CompVector2.ScaleConversion(scale, radius));
        }
Beispiel #12
0
        /// <summary>
        /// 餌を見つける
        /// </summary>
        private void FindFood()
        {
            List <Vector2> FoodPos = new List <Vector2>();

            // 餌を入れる
            foreach (GameObject food in GameObjectManager.FindAll(CharacterID.Food))
            {
                // 餌と自分との距離が301ドット以上離れているならリストに入れない(軽くするため、、、たぶん軽くなるはず)
                if (Vector2.Distance(food.transform.Position, transform.Position + CompVector2.ScaleConversion(scale, radius)) >= 301f)
                {
                    continue;
                }

                // 餌の座標を個別に保存する
                FoodPos.Add(food.transform.Position);
            }

            if (FoodPos.Count != 0)
            {
                // ソート(バグあり)
                FoodPos = FoodPos.OrderBy(o => CompVector2.MinVector2(transform.Position, o.X, o.Y)).ToList();

                // 見つけた餌の座標の自分から一番近いところを入れる
                findFoodPos = FoodPos[0];

                // 餌との距離が0ドット未満になったら中をクリアする
                if (Vector2.Distance(transform.Position, FoodPos[0]) < 0)
                {
                    FoodPos.RemoveAt(0);
                }
            }

            // 近くに餌があったら食べに行く
            if (FoodPos.Count != 0)
            {
                mode = EnemyMoveMode.EatMove;
            }
        }