Пример #1
0
        private void SetPositions(Rect screenRect, bool convertToWorldSpace)
        {
            Vector3 topBorderPosition    = new Vector3(screenRect.x + screenRect.width / 2f, screenRect.yMax);
            Vector3 bottomBorderPosition = new Vector3(screenRect.x + screenRect.width / 2f, screenRect.y);
            Vector3 leftBorderPosition   = new Vector3(screenRect.x, screenRect.y + screenRect.height / 2f);
            Vector3 rightBorderPosition  = new Vector3(screenRect.xMax, screenRect.y + screenRect.height / 2f);

            if (convertToWorldSpace)
            {
                topBorderPosition = Camera.ScreenToWorldPoint(!Camera.orthographic
                    ? topBorderPosition.WithZ(PerspectiveZOffset)
                    : topBorderPosition);
                bottomBorderPosition = Camera.ScreenToWorldPoint(!Camera.orthographic
                    ? bottomBorderPosition.WithZ(PerspectiveZOffset)
                    : bottomBorderPosition);
                leftBorderPosition = Camera.ScreenToWorldPoint(!Camera.orthographic
                    ? leftBorderPosition.WithZ(PerspectiveZOffset)
                    : leftBorderPosition);
                rightBorderPosition = Camera.ScreenToWorldPoint(!Camera.orthographic
                    ? rightBorderPosition.WithZ(PerspectiveZOffset)
                    : rightBorderPosition);
            }

            topBorder.transform.position    = topBorderPosition.AddY(Thickness / 2f);
            bottomBorder.transform.position = bottomBorderPosition.AddY(-Thickness / 2f);
            leftBorder.transform.position   = leftBorderPosition.AddX(-Thickness / 2f);
            rightBorder.transform.position  = rightBorderPosition.AddX(Thickness / 2f);
        }
Пример #2
0
        public override EnemyBullet[] GetBullets(Vector3 enemyFirePos)
        {
            var ret = PoolManager.Instance.EnemyBulletPool.GetMany <RingEnemyBullet>(2);

            var left = ret[0];

            left.transform.position = enemyFirePos.AddX(-left.OffsetX);
            left.Velocity           = left.LeftVelocity;
            left.OnSpawn();

            var right = ret[1];

            right.transform.position = enemyFirePos.AddX(right.OffsetX);
            right.Velocity           = right.RightVelocity;
            right.OnSpawn();

            return(ret);
        }
Пример #3
0
        public void add_x_test()
        {
            //Arrange
            Vector3 input = Vector3.one;

            //Act
            input = input.AddX(1);

            //Assert
            Assert.AreEqual(2, input.x);
            Assert.AreEqual(1, input.y);
            Assert.AreEqual(1, input.z);
        }
Пример #4
0
 private void InitBullet(NomadEnemyBullet bullet, Vector3 enemyFirePos, float spawnOffsetX)
 {
     bullet.transform.position = enemyFirePos.AddX(spawnOffsetX);
     bullet.OnSpawn();
 }
Пример #5
0
 private void CalculateStartingPosition()
 {
     startingPosition = screenOriginPosition.AddX(-1f * (totalGridWidth * 0.5f)).AddY(totalGridHeight * 0.5f);
 }