public void changePositionAnimation(Origami robot)
    {
        float stepSize = 3.0f;
        float xDiff    = 0.0f;

        if (robot.oldPosition.x > robot.newPosition.x)
        {
            xDiff = robot.oldPosition.x - robot.newPosition.x;
        }
        else
        {
            xDiff = robot.newPosition.x - robot.oldPosition.x;
        }

        if (xDiff < stepSize)
        {
            robot.transform.position = newPosition;
        }

        Vector3 nextPosition = new Vector3
        {
            x = robot.oldPosition.x + stepSize,
            y = robot.oldPosition.y + stepSize,
            z = robot.oldPosition.z + stepSize
        };

        robot.transform.position = nextPosition;
    }
예제 #2
0
        public void SolveFirstPuzzle()
        {
            var sut = new Origami(REAL_INSTRUCTIONS);

            sut.FoldAlongX(655);
            Assert.Equal(751, sut.GetPointCount());
        }
예제 #3
0
        public void ParseInstructionsCorrectly(string instructions, int expectedPoints, int expectedFolds)
        {
            var sut = new Origami(instructions);

            Assert.Equal(expectedPoints, sut.GetPointCount());
            Assert.Equal(expectedFolds, sut.GetFoldCount());
        }
예제 #4
0
        public void FoldPaperAlongYaxisCorrectly_WhenUsingSampleInstructions()
        {
            var sut = new Origami(SAMPLE_INSTRUCTIONS);

            sut.FoldAlongY(7);
            Assert.Equal(17, sut.GetPointCount());
        }
 public void AddSignal(string signal)
 {
     if (signal.Equals("Awake"))
     {
         Awake       = true;
         sentasignal = false;
     }
     else if (Awake)
     {
         receivedSignals.Add(signal);
         Awake = false;
         if (!sentasignal)
         {
             sentasignal = true;
             List <Origami> origamis = GetComponent <GameManager>().origamis;
             foreach (DTGameObject o in origamis)
             {
                 if (o.Name.Contains("ORI") && this is Origami)
                 {
                     Origami otherOrigami = (Origami)o;
                     Origami origami      = (Origami)this;
                     if (IsInRange(origami.GameObject, otherOrigami.GameObject, GameManager.OrigamiDZRADIUS) && (!origami.Equals(otherOrigami)))
                     {
                         otherOrigami.AddSignal(signal);
                     }
                 }
             }
         }
     }
 }
 // find all origami close to the given origami
 // and send the message to the origami
 public void SendSignal(DTGameObject gameObject, string signal)
 {
     if (!gameObject.Equals(null))
     {
         List <Origami> origamis = GameManagerObj.GetComponent <GameManager>().origamis;
         foreach (DTGameObject o in origamis)
         {
             if (o.Name.Contains("ORI"))
             {
                 Origami origami = (Origami)o;
                 if (gameObject is Origami otherOrigami)
                 {
                     if (IsInRange(otherOrigami.GameObject, origami.GameObject, GameManager.OrigamiDZRADIUS) && (!gameObject.Name.Equals(origami.Name)))
                     {
                         origami.AddSignal(signal);
                     }
                 }
                 else if (gameObject is Obstacle obstacle)
                 {
                     if (IsInRange(origami.GameObject, obstacle.GameObject, GameManager.ObstacleDZRADIUS))
                     {
                         o.AddSignal(signal);
                         GetComponent <Swarm_behaviour>().newObstacle     = true;
                         GetComponent <Swarm_behaviour>().ObstaclePattern = obstacle.Pattern;
                         print("Sent Pattern: " + obstacle.Pattern);
                     }
                 }
             }
         }
     }
 }
예제 #7
0
        protected override void Displaying(ConnectorDisplayContext model, Origami.Services.ModelShapeContext context) {

            var connTitle = model.ConnectorContent.As<TitlePart>();
            if (connTitle != null && !String.IsNullOrWhiteSpace(connTitle.Title)) {
                context.Paradigms.Add("TitleOverride");
            }
            var connBody = model.ConnectorContent.As<BodyPart>();
            if (connBody != null && !String.IsNullOrWhiteSpace(connBody.Text)) {
                context.Paradigms.Add("BodyOverride");
            }

        }
예제 #8
0
        public void SolveSecondPuzzle()
        {
            var sut = new Origami(REAL_INSTRUCTIONS);

            sut.FoldAccordingToInstructions();
            Assert.Equal(@"###...##..#..#.###..#..#.#....#..#.#....
#..#.#..#.#..#.#..#.#.#..#....#.#..#....
#..#.#....####.#..#.##...#....##...#....
###..#.##.#..#.###..#.#..#....#.#..#....
#....#..#.#..#.#.#..#.#..#....#.#..#....
#.....###.#..#.#..#.#..#.####.#..#.####.", sut.PlotPoints());
        }
예제 #9
0
        public void PlotPointsCorrectly()
        {
            var sut = new Origami(SAMPLE_INSTRUCTIONS);

            sut.FoldAccordingToInstructions();
            Assert.Equal(@"#####
#...#
#...#
#...#
#####
.....
.....", sut.PlotPoints());
        }
    public void AwakeOrigami()
    {
        List <Origami> origamis = GameManagerObj.GetComponent <GameManager>().origamis;

        foreach (DTGameObject o in origamis)
        {
            if (o.Name.Contains("ORI"))
            {
                Origami origami = (Origami)o;
                origami.AddSignal("Awake");
            }
        }
    }
    //function used to generate a single origami robot.. call in a loop to create many
    public void addNewOrigami(int iFromLoop)
    {
        myMesh = new Mesh();

        Origami origami = new Origami();

        origami.GameObject = new GameObject("Origami " + Convert.ToString(iFromLoop + 1));
        origami.GameObject.AddComponent <MeshFilter>().mesh = myMesh;

        Material mat = AssetDatabase.GetBuiltinExtraResource <Material>("Sprites-Default.mat");

        origami.GameObject.AddComponent <MeshRenderer>().material = mat;

        origami.GameObject.transform.position = new Vector3(5, iFromLoop * 5, iFromLoop * 5);

        string newRobot = "";

        if (iFromLoop > 19)
        {
            newRobot = initializationList[iFromLoop / 10];
        }
        else
        {
            newRobot = initializationList[iFromLoop];
        }

        origami.Pattern = newRobot;
        origami.Age     = 0;
        //origamis[iFromLoop].inPosition = origami.transform.position;
        GetComponent <GameManager>().AddOrigami(origami);

        StringMatcher(newRobot);

        myMesh.Clear();
        myMesh.vertices  = myVertices;
        myMesh.triangles = myTriangles;
        myMesh.colors    = colors;
    }
예제 #12
0
 internal object Model(Origami.Services.ModelShapeContext context) {
     throw new NotImplementedException();
 }
예제 #13
0
 // Remove origami
 public bool RemoveOrigami(Origami origami)
 {
     return(origamis.Remove(origami));
 }
예제 #14
0
 // Add origami
 public void AddOrigami(Origami origami)
 {
     origamis.Add(origami);
 }