Exemplo n.º 1
0
        private void UpdateView()
        {
            const float cameraSpeed  = 4.5f; //Set this to 5 to get rid of the slingshot effect
            const float cameraMargin = 0.45f;

            float xoff = this.position.X - view.GamePosition.X;
            float yoff = this.position.Y - view.GamePosition.Y;

            GameVector move = new GameVector(0, 0);

            if (xoff > (1 - cameraMargin) * view.Width)
            {
                move.X = cameraSpeed;
            }
            else if (xoff < cameraMargin * view.Width)
            {
                move.X = -cameraSpeed;
            }

            if (yoff > (1 - cameraMargin) * view.Height)
            {
                move.Y = cameraSpeed;
            }
            else if (yoff < cameraMargin * view.Height)
            {
                move.Y = -cameraSpeed;
            }

            view.Move(move, this.map.Width, this.map.Height);
        }
Exemplo n.º 2
0
        public Pew(float x, float y)
        {
            this.position.X = x;
            this.position.Y = y;

            this.speed = new GameVector(10, 0);

            this.sprite = new Sprite2d("pewpew");

            //For collision detection
            this.mask = new RectangleMask(0, 16, 0, 16);

            fuse    = false;
            fuseLen = 100;
        }
Exemplo n.º 3
0
        protected override void UpdateObject(Microsoft.Xna.Framework.GameTime gameTime)
        {
            const float moveSpeed = 5;
            GameVector  offset    = new GameVector(0, 0);

            var keyboardState = GameState.Keyboard;

            if (keyboardState.IsKeyDown(Keys.Up))
            {
                offset.Y = -moveSpeed;
            }
            else if (keyboardState.IsKeyDown(Keys.Down))
            {
                offset.Y = moveSpeed;
            }

            if (keyboardState.IsKeyDown(Keys.Left))
            {
                offset.X = -moveSpeed;
            }
            else if (keyboardState.IsKeyDown(Keys.Right))
            {
                offset.X = moveSpeed;
            }

            this.position += offset;

            //Make a bullet
            if (keyboardState.IsKeyDown(Keys.Space))
            {
                this.map.AddObject(new Pew(this.position.X, this.position.Y));
            }

            //Move the camera
            UpdateView();
        }
Exemplo n.º 4
0
    // Update is called once per frame
    public override void Update()
    {
        if (StartCount.GetGameStart())
        {
            anm.ChangeAnimation(QuerySDMecanimController.QueryChanSDAnimationType.NORMAL_WALK);
            //NORMAL_LOSE
        }

        // ゲームオーバ処理終了 リトライポップ
        if (gameOverCnt != -1)
        {
            gameOverCnt++;
            if (gameOverCnt == gameOverTime)
            {
                Instantiate(prefabRetry);
            }
        }

        // ゲーム開始フラグがたっていれば
        if (StartCount.GetGameStartFlag() == false ||
            StartCount.GetGameEndFlag() == true)
        {
            return;
        }


        transform.position += (transform.forward * speed);

        GameVector stickVec = GetVectorStick();

        dstickDir = stickVec;

        // 生成フラグが立っているなら時間をカウントし特定時間になったら球体得点を生成
        if (sphereCnt != -1)
        {
            sphereCnt++;
            if (sphereCnt > sphereTime)
            {
                System.Random rnd = new System.Random(stickCount);
                Vector3       vec = new Vector3(rnd.Next(-4, 4), 0.37f, rnd.Next(-4, 4));
                Instantiate(prefabSphere, vec, Quaternion.identity);

                // 生成したのでフラグを下す
                sphereCnt = -1;
            }
        }



        // 一つ後ろの胴体が参照する状態を更新
        BodyInfo info = new BodyInfo();

        info.pos = transform.position;
        info.qua = transform.rotation;
        ofterPos.Enqueue(info);

        // ofterFrm以上の情報は必要ではない
        if (ofterPos.Count > ofterFrm)
        {
            ofterPos.Dequeue();
        }


        // 時間毎にプレイヤーの情報を格納
        posCnt++;
        if ((posCnt % posTime) == 0)
        {
            BodyInfo body = new BodyInfo();
            body.pos = transform.position;
            body.qua = transform.rotation;
            bodyInfo.Push(body);
        }

        // 操作受付時間を満たしていないなら無視
        stickCount++;
        if (stickTime > stickCount)
        {
            return;
        }

        // stick操作なしなら無視
        if (stickVec == GameVector.Non)
        {
            return;
        }

        // 同じ向きなら操作を無視
        if (stickVec == playerDir)
        {
            return;
        }

        switch (stickVec)
        {
        case GameVector.Up:
        {
            if (playerDir == GameVector.Down)
            {
                break;
            }

            transform.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f);
            playerDir          = GameVector.Up;
            stickCount         = 0;
            break;
        }

        case GameVector.Down:
        {
            if (playerDir == GameVector.Up)
            {
                break;
            }

            transform.rotation = Quaternion.Euler(0.0f, 180.0f, 0.0f);
            playerDir          = GameVector.Down;
            stickCount         = 0;
            break;
        }

        case GameVector.Right:
        {
            if (playerDir == GameVector.Left)
            {
                break;
            }

            transform.rotation = Quaternion.Euler(0.0f, 90.0f, 0.0f);
            playerDir          = GameVector.Right;
            stickCount         = 0;
            break;
        }

        case GameVector.Left:
        {
            if (playerDir == GameVector.Right)
            {
                break;
            }

            transform.rotation = Quaternion.Euler(0.0f, 270.0f, 0.0f);
            playerDir          = GameVector.Left;
            stickCount         = 0;
            break;
        }
        }
    }