Exemplo n.º 1
0
        public void ExitPointKnowsWhereItLeadsTest()
        {
            var arbitraryGUID = new Guid();
            var exitPoint     = new ExitPoint(Vector2Int.ZeroVector, arbitraryGUID);

            Assert.Equal(arbitraryGUID, exitPoint.Destination);
        }
Exemplo n.º 2
0
        /// <summary>
        /// The default exit point for an activity
        /// </summary>
        public static ExitPoint GetDefaultExitPoint(this WfActivity activity)
        {
            ExitPoint result = null;

            var ioe = activity.As <EntityWithArgsAndExits>();

            if (ioe != null)
            {
                result = ioe.ExitPoints.FirstOrDefault(ep => ep.IsDefaultExitPoint ?? false);
            }

            if (result == null)
            {
                var aType = activity.IsOfType.FirstOrDefault(t => t.Is <ActivityType>());

                if (aType != null)
                {
                    result = aType.Cast <ActivityType>().ExitPoints.FirstOrDefault(ep => ep.IsDefaultExitPoint ?? false);
                }
            }

            if (result == null)
            {
                throw new ApplicationException(string.Format("Unable to find the default exit point for {0}({1})", activity.Name ?? "[Unnamed]", activity.Id));
            }

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a transition between the given activity instances for the named exit point
        /// </summary>
        public static void AddTermination(Workflow wf, WfActivity from, string fromExitPointName = null, string wfExitPointName = null)
        {
            ExitPoint fromExitPoint = fromExitPointName == null? @from.GetDefaultExitPoint() : GetNamedExitPoint(@from, fromExitPointName);

            ExitPoint wfExitPoint = null;

            if (wfExitPointName == null)
            {
                wfExitPoint = wf.GetDefaultExitPoint();

                if (wfExitPoint == null)
                {
                    wf.AddDefaultExitPoint();
                    wfExitPoint = wf.GetDefaultExitPoint();
                }
            }
            else
            {
                wfExitPoint = GetNamedExitPoint(wf.As <WfActivity>(), wfExitPointName);
            }

            if (fromExitPoint == null)
            {
                throw new ArgumentException("From activity missing named exit point.");
            }

            if (wfExitPoint == null)
            {
                throw new ArgumentException("Workflow missing named exit point.");
            }

            AddTermination(wf, @from, fromExitPoint, wfExitPoint);
        }
Exemplo n.º 4
0
        public void OnSearchTrackComplete(
            SearchTrackManager searchTrackManager)
        {
            searchTrackManager.OnSearchTrackComplete -= OnSearchTrackComplete;

            foreach (var guard in _allSquadMembers)
            {
                // old implementation reliant on searchmode behaviours
                // neds to be remade
                // guard.GetComponent<SearchModeBehaviour>()
                //                 .EndSearchParticipation();
            }

            _currentSearchTrackIndex++;

            if (_currentSearchTrackIndex >= _searchTracks.Count)
            {
                ExitPoint exit = UnityEngine.Object
                                 .FindObjectOfType <ExitPoint>();

                // todo: move logic for initexit etc. to SquadMember
                // _allSquadMembers.ForEach(
                //  (squadBehaviour) => squadBehaviour.InitExit(exit)
                // );
                OnSquadClearingComplete?.Invoke();
            }
            else
            {
                TakeNextSearchTrack();
            }
        }
Exemplo n.º 5
0
        public void TryRemoveExitPointSucceedsOnExitPointMissingTest()
        {
            var chunk = new MapChunk();
            var point = new ExitPoint(Vector2Int.ZeroVector, new Guid());

            var result = chunk.TryRemoveExitPoint(point);

            Assert.True(result);
        }
Exemplo n.º 6
0
        public void TryRemoveExitPointFailsOnInvalidPositionTest()
        {
            var chunk = new MapChunk();
            var point = new ExitPoint(invalidPosition, new Guid());

            var result = chunk.TryRemoveExitPoint(point);

            Assert.False(result);
        }
Exemplo n.º 7
0
        public void TryRemoveExitPointFailsOnInvalidPositionTest()
        {
            var region = new MapRegion();
            var point  = new ExitPoint(invalidPosition, new Guid());

            var result = region.TryRemoveExitPoint(point);

            Assert.False(result);
        }
Exemplo n.º 8
0
        public void TrySetExitPointSucceedsOnValidPositionTest()
        {
            var chunk = new MapChunk();
            var point = new ExitPoint(Vector2Int.ZeroVector, new Guid());

            var result = chunk.TrySetExitPoint(point);

            Assert.True(result);
        }
Exemplo n.º 9
0
 public void TestInitialize( )
 {
     using (new AdministratorContext( ))
     {
         _alternateExitPoint = new ExitPoint( );
         _alternateExitPoint.Save( );
         ToDelete.Add(_alternateExitPoint.Id);
     }
 }
Exemplo n.º 10
0
 private void ClearLevel()
 {
     DoorList.Clear();
     SwitchList.Clear();
     foodList.Clear();
     player._Position = new Vector2(0, 0);
     currentExit      = null;
     rectList.Clear();
     player.SetPlayerSize(4);
 }
Exemplo n.º 11
0
        public void CreateDefault_ShouldThrowArgumentNullExceptionInCaseOfAnyNullArgument_Tiles()
        {
            //Arrange
            tiles     = null;
            turtle    = new Turtle(new Tile(1, 2), Direction.EastDirection);
            mines     = new Mine[] { new Mine(1, 1) };
            exitPoint = new ExitPoint(0, 0);

            //Act
            Assert.Throws <ArgumentNullException>(() => CreateDefault());
        }
Exemplo n.º 12
0
        public void TryRemoveExitPointSucceedsOnExitPointExistsTest()
        {
            var region = new MapRegion();
            var point  = new ExitPoint(Vector2Int.ZeroVector, new Guid());

            region.TrySetExitPoint(point);

            var result = region.TryRemoveExitPoint(point);

            Assert.True(result);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Attempts to assign the given exit point.
        /// If an exit point already exists at this location, it is replaced.
        /// </summary>
        /// <param name="in_point">The point to set.</param>
        /// <returns><c>true</c>, if the point was set, <c>false</c> otherwise.</returns>
        public bool TrySetExitPoint(ExitPoint in_point)
        {
            var result = false;

            if (TryRemoveExitPoint(in_point))
            {
                _specialPoints.Add(in_point);
                result = true;
            }

            return(result);
        }
Exemplo n.º 14
0
        public void CreateDefault_ShouldMineFieldIfAllArgumentsAreNotNull()
        {
            //Arrange
            tiles     = new Tile[3, 2];
            turtle    = new Turtle(new Tile(1, 2), Direction.EastDirection);
            mines     = new Mine[] { new Mine(1, 1) };
            exitPoint = new ExitPoint(0, 0);

            //Act
            var minefield = CreateDefault();

            Assert.That(minefield != null);
        }
Exemplo n.º 15
0
        private void LoadLevel(int v)
        {
            DoorList.Clear();
            SwitchList.Clear();
            foodList.Clear();
            currentExit = null;
            rectList.Clear();
            //v = 5;

            Level nl = levelsList[v];

            player._Position = nl.SpawnPoint;
            player.SetPlayerSize(4);
            currentExit           = new ExitPoint();
            currentExit._Position = nl.ExitPoint;
            currentExit.LoadContent(@"Art/Exit", Content);

            foreach (DoorInfo di in nl.DoorList)
            {
                Door nd = new Door();
                nd.myRect = new Rectangle((int)di.pos.X, (int)di.pos.Y, di.width, di.height);
                nd.ChangeColor(di.color);
                nd.LoadContent(@"Art/Door", Content);
                DoorList.Add(nd);
            }


            foreach (WallInfo di in nl.WallList)
            {
                SpriteRectangle nd = new SpriteRectangle();
                nd.myRect = new Rectangle((int)di.pos.X, (int)di.pos.Y, di.width, di.height);
                //nd.currentColor = di.color;
                //nd.LoadContent(@"Art/Door", Content);
                rectList.Add(nd);
            }

            foreach (SwitchInfo si in nl.SwitchList)
            {
                Switch ns = new Switch();
                ns.LoadContent(@"Art/Switch", Content);

                ns.ChangeColor(si.color);
                ns._Position = si.pos;
                SwitchList.Add(ns);
            }

            foreach (FoodInfo fi in nl.FoodList)
            {
                CreateFood(fi.goodFood, fi.pos);
            }
        }
Exemplo n.º 16
0
        private void TestResult(Workflow wf, string inputString, ExitPoint expectedExit)
        {
            var input = new Dictionary <string, object>
            {
                {
                    "wfInString", inputString
                }
            };

            var run = (RunWorkflow(wf, input, null, true));

            var exitPoint = run.GetExitPoint();

            Assert.AreEqual(exitPoint.Id, expectedExit.Id, string.Format("Ensure input of '{0}' should result in a '{1}' decision", inputString, expectedExit.Name));
        }
Exemplo n.º 17
0
        public static (Point, List <Mine>, ExitPoint, Turtle) ReadFromFile()
        {
            var lines = File.ReadAllLines(@"C:\Users\Catalin Hotea\source\repos\EscapeMines\input.txt");

            var boardSizes = lines[0].Split(' ');

            var board = new Point
            {
                X = int.Parse(boardSizes[0]),
                Y = int.Parse(boardSizes[1])
            };

            var rawMines = lines[1].Split(' ').ToList();

            var mines = rawMines.Select(mine =>
            {
                var parsedMine = mine.Split(',');
                return(new Mine
                {
                    X = int.Parse(parsedMine[0]),
                    Y = int.Parse(parsedMine[1])
                });
            }).ToList();

            var rawExitPoint = lines[2].Split(' ').Select(int.Parse).ToList();

            var exitPoint = new ExitPoint
            {
                X = rawExitPoint[0],
                Y = rawExitPoint[1]
            };

            var turtleStartPoint = lines[3].Split(' ').ToList();

            var moves = lines[4].Split(' ').ToList().Concat(lines[5].Split(' ').ToList()).ToList();

            var turtle = new Turtle
            {
                X           = int.Parse(turtleStartPoint[0]),
                Y           = int.Parse(turtleStartPoint[1]),
                Orientation = turtleStartPoint[2],
                Moves       = moves
            };

            return(board, mines, exitPoint, turtle);
        }
        public void Setup()
        {
            TheWorld = new World();

            // Create a 3 x 3 room
            // which is really a 4 x 4 because the walls occupy
            // a single square unit a piece.
            var floorPlan = Room.CreateEmptyRoom(5, 5);
            floorPlan[2][2] = new EntryPoint();
            floorPlan[1][2] = new ExitPoint();

            TheRoom = TheWorld.CreateRoom(floorPlan);
            TheWarrior = TheWorld.CreateWarrior();
            TheWorld.EnterRoom(TheWarrior, TheRoom);

            Context();
            Because();
        }
Exemplo n.º 19
0
 public void Write(BinaryWriter writer)
 {
     writer.Write(ID);
     writer.Write(Encoding.UTF8.GetByteCount(Name));
     writer.Write(Encoding.UTF8.GetBytes(Name));
     writer.Write(SPlusTime);
     writer.Write(STime);
     writer.Write(ATime);
     writer.Write(BTime);
     writer.Write(CTime);
     writer.Write((ushort)Prisms.Count);
     Size.Write(writer);
     writer.Write(Temp1);
     writer.Write(Temp2);
     LegacyMinimapSize.Write(writer);
     writer.Write((byte)10);
     writer.Write((ushort)(Size.Length - 1));
     writer.Write((ushort)0);
     LegacyMinimap.Write(writer);
     CollisionMap.Write(writer);
     SpawnPoint.Write(writer);
     writer.Write(Zoom);
     if (Zoom < 0)
     {
         writer.Write(Value);
         writer.Write(ValueIsAngle);
     }
     ExitPoint.Write(writer);
     MovingPlatforms.Write(writer);
     Bumpers.Write(writer);
     FallingPlatforms.Write(writer);
     Checkpoints.Write(writer);
     CameraTriggers.Write(writer);
     Prisms.Write(writer);
     Fans.Write(writer);
     Buttons.Write(writer);
     OtherCubes.Write(writer);
     Resizers.Write(writer);
     MiniBlocks.Write(writer);
     writer.Write(Theme);
     writer.Write(MusicJava);
     writer.Write(Music);
 }
Exemplo n.º 20
0
        public void Setup()
        {
            TheWorld = new World();

            // Create a 3 x 3 room
            // which is really a 4 x 4 because the walls occupy
            // a single square unit a piece.
            var floorPlan = Room.CreateEmptyRoom(5, 5);

            floorPlan[2][2] = new EntryPoint();
            floorPlan[1][2] = new ExitPoint();

            TheRoom    = TheWorld.CreateRoom(floorPlan);
            TheWarrior = TheWorld.CreateWarrior();
            TheWorld.EnterRoom(TheWarrior, TheRoom);

            Context();
            Because();
        }
Exemplo n.º 21
0
        public static ExitPoint GetNamedExitPoint(this WfActivity activity, string name)
        {
            ExitPoint result = null;

            var actAsDyn = activity.As <EntityWithArgsAndExits>();

            if (actAsDyn != null)
            {
                result = actAsDyn.ExitPoints.FirstOrDefault(ep => ep.Name == name);
            }

            if (result != null)
            {
                return(result);
            }
            else
            {
                return(activity.IsOfType.Select(t => t.As <EntityWithArgsAndExits>()).First(t => t != null).ExitPoints.FirstOrDefault(ep => ep.Name == name));
            }
        }
Exemplo n.º 22
0
        public async Task IsStillMovingOnAsync_ShouldReturnTrueIfDancerDoesNotMoveAnywhereDueToMines()
        {
            //Arrange
            var tiles        = new Tile[3, 2];
            var mines        = new Mine[] { new Mine(1, 1) };
            var exitPoint    = new ExitPoint(0, 0);
            var mockedTurtle = new Mock <IDancer>();

            mockedTurtle.SetupGet(x => x.Tile).Returns(mines.First());

            var movements = new Movement[] { Movement.LeftRotate, Movement.RightRotate };

            mockedMovementFactory.Setup(x => x.GetNextMovementsAsync()).Returns(Task.FromResult(movements));

            minefield = new Minefield(mockedMovementFactory.Object, tiles, mines, exitPoint, mockedTurtle.Object);

            //Act
            var isFinished = await minefield.IsStillMovingOnAsync();

            //Assert
            Assert.IsTrue(isFinished);
        }
Exemplo n.º 23
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        exitPoint = (ExitPoint)serializedObject.targetObject;
        serializedObject.Update();

        exitPoint.GetData().title = EditorGUILayout.TextField("Title", exitPoint.GetData().title);

        string[] pistaKeys  = exitPoint.manager.textureManager.getPistaKeys();
        int      imageValue = EditorGUILayout.Popup("Ícone pista", exitPoint.manager.textureManager.getIndexByKeyPista(exitPoint.GetData().icon_frame), pistaKeys);

        exitPoint.GetData().icon_frame = pistaKeys[imageValue];

        string[] cursors = new string[] {
            "Left", "Right", "Up", "Down"
        };
        int opt = EditorGUILayout.Popup("Cursor Direction", exitPoint.GetData().iCursor, cursors);

        exitPoint.SetCursorDirection(opt);

        string[] options = new string[SceneManager.sceneCountInBuildSettings];
        for (int i = 0; i < options.Length; i++)
        {
            options[i] = SceneUtility.GetScenePathByBuildIndex(i);
        }
        exitPoint.SetExitPoint(EditorGUILayout.Popup("Exit Point", exitPoint.GetExitPoint(), options));
        exitPoint.SetEnabled(EditorGUILayout.Toggle("Destravado:", exitPoint.GetData().enabled));

        exitPoint.data.unlockMessage = EditorGUILayout.TextField("Mensagem de desbloqueio: ", exitPoint.data.unlockMessage);

        //serializedObject.ApplyModifiedProperties();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(exitPoint);
            EditorSceneManager.MarkSceneDirty(exitPoint.gameObject.scene);
        }
    }
Exemplo n.º 24
0
        /// <summary>
        /// Create a transition between the given activity instances for the provided exit point
        /// </summary>
        public static void AddTermination(Workflow wf, WfActivity from, ExitPoint fromExitPoint, ExitPoint wfExitPoint)
        {
            // remove exiting conflicting transitions
            var toRemove = @from.ForwardTransitions.Where(t => t.FromExitPoint.Id == fromExitPoint.Id).ToList();

            @from.ForwardTransitions.RemoveRange(toRemove);
            Entity.Delete(toRemove.Select(t => t.Id));

            // remove existing conflicting terminations
            var toRemoveTerm = wf.Terminations.Where(t => t.FromActivity.Id == from.Id && t.FromExitPoint.Id == fromExitPoint.Id).ToList();

            wf.Terminations.RemoveRange(toRemoveTerm);
            Entity.Delete(toRemoveTerm.Select(t => t.Id));


            var term = new Termination()
            {
                Name = fromExitPoint.Name, FromActivity = @from, FromExitPoint = fromExitPoint, WorkflowExitPoint = wfExitPoint
            };

            @from.ForwardTransitions.Add(term.As <TransitionStart>());
            wf.Terminations.Add(term);
        }
Exemplo n.º 25
0
        public async Task IsStillMovingOnAsync_ShouldReturnFalseIfMovementsIsEmpty()
        {
            //Arrange
            var testTile     = new Tile(0, 1);
            var tiles        = new Tile[3, 2];
            var mines        = new Mine[] { new Mine(1, 1) };
            var exitPoint    = new ExitPoint(0, 0);
            var mockedTurtle = new Mock <IDancer>();

            mockedTurtle.SetupGet(x => x.Tile).Returns(testTile);

            var movements = new Movement[] {};

            mockedMovementFactory.Setup(x => x.GetNextMovementsAsync()).Returns(Task.FromResult(movements));

            minefield = new Minefield(mockedMovementFactory.Object, tiles, mines, exitPoint, mockedTurtle.Object);

            //Act
            var isFinished = await minefield.IsStillMovingOnAsync();

            //Assert
            Assert.IsFalse(isFinished);
        }
Exemplo n.º 26
0
    // Movement Code
    void Update()
    {
        if (gameControl.IsPaused())
        {
            return;
        }

        Vector2 directionToDestination = ((Vector2)destination - (Vector2)this.transform.position).normalized;

        if (!gameControl.toggleWBC)
        {
            this.renderer.enabled = false;
        }
        else
        {
            this.renderer.enabled = true;
        }

        if (this.speed != gameControl.rbcSpeed)
        {
            this.speed = gameControl.rbcSpeed / 250.0f;
        }

        if (!currentBlock.notClotted)
        {
            speed = gameControl.rbcSpeed / 1000.0f;
        }
        else
        {
            speed = gameControl.rbcSpeed / 250.0f;
        }

        //If disease has reached is destination
        if ((destination - this.transform.position).magnitude < 0.07)
        {
            //If were captured then we just reached the inside of White Blood Cell. Immobilze ourselves and attach to White Blood Cell
            if (captured)
            {
                Destroy(gameObject.GetComponent <Rigidbody>());
                Destroy(gameObject.GetComponent <CircleCollider2D>());
            }
            else
            {
                // Else we just reached a waypoint. Choose next destination.
                // Roll a random dice with 3% chance of exiting
                float dice = Random.value;
                bool  exit = dice >= 0.97f;
                if (exit)
                {
                    ExitPoint[] exitPoints = destBlock.GetExitPoints();
                    ExitPoint   exitPoint  = exitPoints[(Random.Range(0, exitPoints.Length))];                    //Not -1 since exclusive
                    destBlock   = exitPoint.nextBlock;
                    destination = destBlock.GetRandomPoint();
                }
                else
                {
                    destination = destBlock.GetRandomPoint();
                }
                StartCoroutine(ChangeRotation(directionToDestination));
            }
        }

        if (!captured)
        {
            this.transform.position = new Vector3((directionToDestination.x * speed) + this.transform.position.x,
                                                  (directionToDestination.y * speed) + this.transform.position.y,
                                                  this.transform.position.z);
        }
    }
Exemplo n.º 27
0
	private IEnumerator BeginGame () {
		audio.PlayOneShot(_Introduction, 1f);
		mazeInstance = Instantiate(mazePrefab) as Maze;
		yield return StartCoroutine(mazeInstance.Generate());
        SpawnPlayer();
        SpawnMinotaur();
		exitInstance = Instantiate(exitPrefab) as ExitPoint;
		exitInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates));
        Lives = 1;
        alive = true;
		winState = false;
        gameOver = false;
        restart = false;

		
	}
Exemplo n.º 28
0
        public void SwitchTest( )
        {
            var wf = new Workflow
            {
                Name = "ConnectingParameters Wf"
            };
            var wfAs = wf.Cast <WfActivity>( );

            wf.InputArguments.Add((new StringArgument
            {
                Name = "wfInString"
            }).Cast <ActivityArgument>( ));

            var wfYesExit = new ExitPoint
            {
                IsDefaultExitPoint = true,
                Name = "Wf Yes"
            };
            var wfNoExit = new ExitPoint
            {
                Name = "Wf No"
            };
            var wfMaybeExit = new ExitPoint
            {
                Name = "Wf Maybe"
            };
            var wfDontKnowExit = new ExitPoint
            {
                Name = "Wf Dont know"
            };

            wf.ExitPoints.Add(wfYesExit);
            wf.ExitPoints.Add(wfNoExit);
            wf.ExitPoints.Add(wfMaybeExit);
            wf.ExitPoints.Add(wfDontKnowExit);

            var switch1 = new SwitchActivity
            {
                Name = "Switch1"
            };
            var switch1As = switch1.Cast <WfActivity>( );

            ActivityTestHelper.AddFirstActivityWithMapping(
                wf,
                switch1As,
                null);

            ActivityTestHelper.CreateArgumentInstance(wf, wfAs, wfAs.GetInputArgument("wfInString"));
            ActivityTestHelper.AddExpressionToActivityArgument(wf, switch1As, "Value to Switch On", "wfInString", false);

            var switchYesExit = new ExitPoint
            {
                IsDefaultExitPoint = true,
                Name = "Yes"
            };
            var switchNoExit = new ExitPoint
            {
                Name = "No"
            };
            var switchMaybeExit = new ExitPoint
            {
                Name = "Maybe"
            };

            switch1.ExitPoints.Add(switchYesExit);
            switch1.ExitPoints.Add(switchNoExit);
            switch1.ExitPoints.Add(switchMaybeExit);

            ActivityTestHelper.AddTermination(
                wf,
                switch1As,
                switchYesExit,
                wfYesExit);

            ActivityTestHelper.AddTermination(
                wf,
                switch1As,
                switchNoExit,
                wfNoExit);

            ActivityTestHelper.AddTermination(
                wf,
                switch1As,
                switchMaybeExit,
                wfMaybeExit);

            var otherwiseExit = Entity.Get <ExitPoint>(new EntityRef("core", "switchActivityOtherwiseExitPoint"));

            ActivityTestHelper.AddTermination(
                wf,
                switch1As,
                otherwiseExit,
                wfDontKnowExit);

            ActivityTestHelper.AddMissingExpressionParametersToWorkflow(wf);

            wf.Save( );
            ToDelete.Add(wf.Id);
            ToDelete.Add(switch1.Id);

            TestResult(wf, "Yes", wfYesExit);
            TestResult(wf, "No", wfNoExit);
            TestResult(wf, "Maybe", wfMaybeExit);
            TestResult(wf, "Something else", wfDontKnowExit);
        }
Exemplo n.º 29
0
    public Map(string fileName)
    {
        Walls           = new List <Wall>();
        Platforms       = new List <Platform>();
        DangerousFloors = new List <DangerousFloor>();
        Ladders         = new List <Ladder>();
        Enemy           = new List <Enemy>();
        XMap            = 0;
        YMap            = 720;
        BackGround      = new Image("Map/FondoFinal.png", 4800, 1440);

        string[] lines = File.ReadAllLines(fileName);
        if (lines.Length > 0)
        {
            Width  = (short)(lines[0].Length * XMeasure);
            Height = (short)(lines.Length * YMeasure);

            for (int i = 0; i < lines.Length; i++)
            {
                for (int j = 0; j < lines[i].Length; j++)
                {
                    if (lines[i][j] == '5')
                    {
                        AddWall(new Wall(5, (short)(j * XMeasure), (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == '4')
                    {
                        AddWall(new Wall(4, (short)(j * XMeasure), (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == '6')
                    {
                        AddWall(new Wall(6, (short)(j * XMeasure), (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == '7')
                    {
                        AddWall(new Wall(7, (short)(j * XMeasure), (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == '8')
                    {
                        AddWall(new Wall(8, (short)(j * XMeasure), (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == '9')
                    {
                        AddWall(new Wall(9, (short)(j * XMeasure), (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == '1')
                    {
                        AddWall(new Wall(1, (short)(j * XMeasure), (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == '2')
                    {
                        AddWall(new Wall(2, (short)(j * XMeasure), (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == '3')
                    {
                        AddWall(new Wall(3, (short)(j * XMeasure), (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == 'p')
                    {
                        AddPlatform(new Platform(1, (short)(j * XMeasure),
                                                 (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == 'P')
                    {
                        AddPlatform(new Platform(2, (short)(j * XMeasure),
                                                 (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == 'Y')
                    {
                        AddDangerousFloor(new DangerousFloor((short)(j * XMeasure),
                                                             (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == 'L')
                    {
                        AddLadder(new Ladder((short)(j * XMeasure),
                                             (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == 'A')
                    {
                        Enemy.Add(new AerialEnemy((short)(j * XMeasure),
                                                  (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == 'J')
                    {
                        Enemy.Add(new JumpEnemy((short)(j * XMeasure),
                                                (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == 'T')
                    {
                        Enemy.Add(new LandEnemy((short)(j * XMeasure),
                                                (short)(i * YMeasure)));
                    }
                    else if (lines[i][j] == 'X')
                    {
                        XMap = (short)(j * XMeasure);
                        YMap = (short)(i * YMeasure);
                    }
                    else if (lines[i][j] == 'x')
                    {
                        XMap = (short)(j * XMeasure);
                        YMap = (short)(i * YMeasure);
                    }
                    else if (lines[i][j] == 'S')
                    {
                        AddWall(new Wall(8, (short)(j * XMeasure), (short)(i * YMeasure)));
                        Start = new StartPoint((short)(j * XMeasure), (short)(i * YMeasure));
                    }
                    else if (lines[i][j] == 'E')
                    {
                        Exit = new ExitPoint((short)(j * XMeasure), (short)(i * YMeasure));
                    }
                }
            }
        }
    }
Exemplo n.º 30
0
        public void DecisionTest()
        {
            var wf = new Workflow
            {
                Name = "ConnectingParameters Wf"
            };
            var wfAs = wf.Cast <WfActivity>();

            wf.InputArguments.Add((new IntegerArgument
            {
                Name = "wfInInt"
            }).Cast <ActivityArgument>());

            var yesExit = new ExitPoint
            {
                IsDefaultExitPoint = true,
                Name = "Yes"
            };
            var noExit = new ExitPoint
            {
                Name = "No"
            };

            wf.ExitPoints.Add(yesExit);
            wf.ExitPoints.Add(noExit);

            var decision1 = new DecisionActivity
            {
                Name = "Decision1"
            };
            var decision1As = decision1.Cast <WfActivity>();


            ActivityTestHelper.AddFirstActivityWithMapping(
                wf,
                decision1As,
                null);

            string wfInIntSubString = ActivityTestHelper.CreateArgumentInstance(wf, wfAs, wfAs.GetInputArgument("wfInInt"));

            ActivityTestHelper.AddExpressionToActivityArgument(wf, decision1As, "DecisionArgument", wfInIntSubString + " > 5", false);

            ActivityTestHelper.AddTermination(
                wf,
                decision1As,
                Entity.Get <ExitPoint>(new EntityRef("core", "decisionActivityYesExitPoint")),
                yesExit);

            ActivityTestHelper.AddTermination(
                wf,
                decision1As,
                Entity.Get <ExitPoint>(new EntityRef("core", "decisionActivityNoExitPoint")),
                noExit);

            ActivityTestHelper.AddMissingExpressionParametersToWorkflow(wf);

            wf.Save();
            ToDelete.Add(wf.Id);
            ToDelete.Add(decision1.Id);

            var input = new Dictionary <string, object>
            {
                {
                    "wfInInt", 10
                }
            };

            var run = RunWorkflow(wf, input);

            Assert.AreEqual(run.GetExitPoint().Id, yesExit.Id, "Input of '10' should result in a 'yes' decision");

            input = new Dictionary <string, object>
            {
                {
                    "wfInInt", 1
                }
            };

            run = RunWorkflow(wf, input);

            Assert.AreEqual(WorkflowRunState_Enumeration.WorkflowRunCompleted, run.WorkflowRunStatus_Enum, "Finished without errors");

            Assert.AreEqual(noExit.Id, run.GetExitPoint().Id, "Input of '1' should results in a 'no' decision");
        }
Exemplo n.º 31
0
    void Fire()
    {
        if (!m_shotTransform)
        {
            return;
        }

        // Check here for obstacles, and early out if necessary.
        if (m_checkForObstacles)
        {
            // TODO : handle case for parabolic shots

            // make a rough guess for the predicted position of the target...
            float   distanceToTarget   = (m_aimer.m_targetObject.transform.position - m_shotTransform.position).magnitude;
            Vector3 estimatedTargetPos = (m_shotTransform.forward * distanceToTarget) + m_shotTransform.position;

            RaycastHit hitInfo;
            if (Physics.Linecast(m_shotTransform.position, estimatedTargetPos, out hitInfo, m_obstacleLayers))
            {
                if (!hitInfo.collider.transform.IsChildOf(m_aimer.m_targetObject.transform))
                {
                    // Don't shoot if it's not the target tag
                    return;
                }
            }
        }

        Quaternion rotation = m_shotTransform.rotation;

        if (m_firingCone != 0.0f)
        {
            float      xAngle    = m_firingCone * Mathf.Sqrt(UnityEngine.Random.Range(0.0f, 1.0f));
            Quaternion xRotation = Quaternion.Euler(xAngle, 0.0f, 0.0f);

            float      zAngle    = UnityEngine.Random.Range(0, 360.0f);
            Quaternion zRotation = Quaternion.Euler(0.0f, 0.0f, zAngle);

            rotation = rotation * (zRotation * xRotation);
        }

        Vector3 startPos = m_shotTransform.position;

        if (m_exitPoints.Length > 0)
        {
            ExitPoint point     = m_exitPoints[m_fireIndex];
            Vector3   offsetPos = point.calculatedStartPos;
            offsetPos.z = 0.0f;
            startPos    = m_shotTransform.TransformPoint(offsetPos);

            if (point.firingAnimation)
            {
                point.firingAnimation.Play();
            }

            m_fireIndex = (m_fireIndex + 1) % m_exitPoints.Length;
        }


        GameObject bullet   = GameObject.Instantiate(m_bulletPrefab, startPos, rotation) as GameObject;
        Rigidbody  bulletRb = bullet.GetComponent <Rigidbody>();

        bulletRb.AddRelativeForce(new Vector3(0, 0, m_aimer.m_projectileSpeed), ForceMode.VelocityChange);
        bulletRb.useGravity = m_enableGravity;

        Destroy(bullet, m_bulletLifetime);

        if (m_firingAnimation)
        {
            m_firingAnimation.Play();
        }

        if (m_firingMessage != "")
        {
            SendMessage(m_firingMessage, SendMessageOptions.DontRequireReceiver);
        }
    }
Exemplo n.º 32
0
    private ExitPoint exit;                     //ExitPoint 스크립트의 CountDown 함수를 불러오기위함

    //초기화
    void Start()
    {
        ani  = GetComponent <Animator>();
        exit = GameObject.FindGameObjectWithTag("ExitPoint").GetComponent <ExitPoint>();
    }