Exemple #1
0
        public void GetReboundStrategyTest1()
        {
            NonPassableArenaObjectFactory factory = new NonPassableArenaObjectFactory();
            ObstacleBuilder objBuilder            = new ObstacleBuilder().AddDuration(10).AddHeigth(10).AddPosX(10).AddWidth(10).AddPosY(10);
            Obstacle        obstacle = factory.CreateObstacle(objBuilder);

            Assert.AreEqual(ArenaObjectType.NonPassable, obstacle.Type);
        }
Exemple #2
0
 private void InitializeBuilders()
 {
     platformBuilder = new PlatformBuilder(platformParent, platformsStats.Platform, platformsStats.Corner, platformsStats.Finish,
                                           platformsStats.LengthOfPlatform, platformsStats.WidthOfPlatform);
     coinBuilder = new CoinBuilder(coinsParent, coinsStats.CoinsPrefab, maxLengthAmountCoins,
                                   maxWidthAmountCoins, coinsStats.CoinsSide, PositionToSpawn.AfterObstacles);
     obstacleBuilder = new ObstacleBuilder(obstaclesParent, obstaclesStats.ObstaclesPrefab, obstaclesStats.SideOfObstacles);
     cubeBuilder     = new CubeBuilder(cubesParent, cubesStats.CubesPrefab, cubesStats.SideCubes, PositionToSpawn.BeforeObstacles);
 }
Exemple #3
0
        public void CreateObjectTest()
        {
            ObstacleBuilder builder = new ObstacleBuilder();

            builder.AddDuration(10).AddHeigth(10).AddPosX(10).AddPosY(10).AddWidth(10);
            ArenaObject obj = builder.CreateObject();

            Assert.IsTrue(obj.Duration == 10 && obj.Heigth == 10 && obj.PosX == 10 && obj.PosY == 10 && obj.Width == 10);
        }
Exemple #4
0
        public void AddHeigthTest()
        {
            ObstacleBuilder builder = new ObstacleBuilder();

            builder.AddHeigth(10);
            ArenaObject obj = builder.CreateObject();

            Assert.AreEqual(10, obj.Heigth);
        }
Exemple #5
0
        public void AddPosYTest()
        {
            ObstacleBuilder builder = new ObstacleBuilder();

            builder.AddPosY(10);
            ArenaObject obj = builder.CreateObject();

            Assert.AreEqual(10, obj.PosY);
        }
Exemple #6
0
        public void AddDurationTest()
        {
            ObstacleBuilder builder = new ObstacleBuilder();

            builder.AddDuration(10);
            ArenaObject obj = builder.CreateObject();

            Assert.AreEqual(10, obj.Duration);
        }
Exemple #7
0
        public void AddPosTest()
        {
            ObstacleBuilder builder = new ObstacleBuilder();
            Vector2         pos     = new Vector2(10, 10);

            builder.AddPos(pos);
            ArenaObject obj = builder.CreateObject();

            Assert.IsTrue(obj.PosX == 10 && obj.PosY == 10);
        }
        public void CreateObstacleTest()
        {
            PassableArenaObjectFactory factory    = new PassableArenaObjectFactory();
            ObstacleBuilder            objBuilder = new ObstacleBuilder().AddDuration(10).AddHeigth(10).AddPosX(10).AddWidth(10).AddPosY(10);
            Obstacle obstacle = factory.CreateObstacle(objBuilder);

            Assert.IsTrue(obstacle.Type == ArenaObjectType.Passable &&
                          obstacle.Duration == 10 && obstacle.Heigth == 10 && obstacle.PosX == 10 &&
                          obstacle.Width == 10 && obstacle.PosY == 10);
        }
    private void CreateObstacleGUIButton(string name, ObstacleBuilder.ObstacleType type)
    {
        EditorGUILayout.BeginHorizontal();
        bool isButtonPressed = GUILayout.Button(name, EditorGUIStyles.ButtonStyle);

        EditorGUILayout.EndHorizontal();
        if (isButtonPressed)
        {
            ObstacleBuilder.CreateObstacle(type);
        }
    }
Exemple #10
0
        protected override void Spawn()
        {
            var width    = Params.RollWidth();
            var height   = Params.RollHeight();
            var duration = Params.RollDuration();
            var pos      = Params.RollPosition();

            var obstacleBuilder = new ObstacleBuilder().AddHeigth(width).AddWidth(height).AddDuration(duration).AddPos(pos);
            var obstacle        = Factories[RandomNumber.NextInt(0, Factories.Length)].CreateObstacle(obstacleBuilder);

            ArenaFacade.Instance.OnArenaObjectCreated(obstacle);

            SpawnInterval = Params.RollInterval();
            LastSpawnTime = Time;
        }
Exemple #11
0
        public void CheckCollisionWithArenaObjectsTest()
        {
            Vector2         startingDir            = new Vector2(1, 1);
            Ball            testBall               = Ball.CreateBall(0, BallType.Normal, new Vector2(225.5 + 200.5, 225.5), GameData.DefaultBallSpeed, startingDir, GameData.DefaultBallSize);
            ObstacleBuilder objBuilder             = new ObstacleBuilder().AddDuration(10).AddHeigth(1000).AddPosX(225.5f).AddWidth(1000).AddPosY(225.5f);
            var             Factories              = new NonPassableArenaObjectFactory();
            var             obstacle               = Factories.CreateObstacle(objBuilder);
            Dictionary <byte, ArenaObject> obsDict = new Dictionary <byte, ArenaObject>();

            obsDict.Add(obstacle.Id, obstacle);
            testBall.CheckCollisionWithArenaObjects(obsDict);
            Vector2 dirAfterCollision = testBall.Direction;

            Assert.AreNotEqual(startingDir, dirAfterCollision);
        }
    private void CreateNewChains()
    {
        ChainCreator myScript = (ChainCreator)target;

        for (int i = 0; i < myScript.WallMounts.Count; i++)
        {
            GameObject root = new GameObject();
            ObstacleBuilder.CreateLogChain(root, myScript.WallMounts[i], myScript.ObstacleMounts[i]);
            ObstacleBuilder.AttachChain(root.GetComponent <VampLamp.Core.Obstacles.Chain.Chain>(),
                                        myScript.WallMounts[i], myScript.ObstacleMounts[i]);
            root.name = "Chain" + i.ToString();
            root.transform.SetParent(myScript.transform);
            myScript.Chains.Add(root);
        }
    }
Exemple #13
0
        public void ReboundPositionTest()
        {
            NonPassableObstacleStrategy strategy = new NonPassableObstacleStrategy();
            Paddle  paddle     = new NormalPaddle(10, PaddleDataFactory.GetPaddleData(PaddleType.Normal));
            Vector2 vector     = new Vector2(10, 10);
            Vector2 normalised = new Vector2(1, 0);
            Ball    b          = Ball.CreateBall(0, BallType.Deadly, vector, 10, vector, 10);

            NonPassableArenaObjectFactory factory = new NonPassableArenaObjectFactory();
            ObstacleBuilder objBuilder            = new ObstacleBuilder().AddDuration(10).AddHeigth(10).AddPosX(5).AddWidth(10).AddPosY(5);
            Obstacle        obstacle = factory.CreateObstacle(objBuilder);

            Vector2 result = strategy.ReboundPosition(b, normalised, paddle, obstacle);

            Assert.IsFalse(vector == result);
        }
Exemple #14
0
    GameObject obstaclePrefab; //future: change to array

    private void Awake()
    {
        current = this;

        obstaclePrefab = Resources.Load("Prefabs/Obstacles/CubeObstacle") as GameObject;
    }