Ejemplo n.º 1
0
        public void PlayErrorTest()
        {
            var tsm = new TurtleStateMachine(new BusinessLog());

            tsm.Initialize(
                new Model.Entities.TableConfig
            {
                SizeX         = 2,
                SizeY         = 2,
                StartPosition = new Model.Entities.Position {
                    X = 1, Y = 1, Direction = Model.Enums.Directions.E
                },
                Exit = new Model.Entities.Coordinate {
                    X = 0, Y = 0
                },
                Mines = new System.Collections.Generic.List <Model.Entities.Coordinate>
                {
                    new Model.Entities.Coordinate {
                        X = 0, Y = 1
                    }
                }
            },
                new Model.Entities.MovesConfig {
                Model.Enums.Moves.M
            });
            Assert.AreEqual(tsm.Play(), Model.Enums.State.LeftTable);
        }
Ejemplo n.º 2
0
    public override void PerfDead()
    {
        base.PerfDead();
        TurtleStateMachine stateMachine = GetComponent <TurtleStateMachine>();

        stateMachine.GetComponent <Rigidbody>().velocity = Vector3.zero;
        stateMachine.navAgent.enabled = false;
        GetComponent <TurtleStateMachine>().SetIsDieAnim(true);
    }
Ejemplo n.º 3
0
        public void InitializeErrorTest()
        {
            var tsm = new TurtleStateMachine(new BusinessLog());

            Assert.ThrowsException <BusinessException>(() => tsm.Initialize(new Model.Entities.TableConfig {
            }, new Model.Entities.MovesConfig {
            }));

            Assert.ThrowsException <BusinessException>(() => tsm.Initialize(
                                                           new Model.Entities.TableConfig
            {
                SizeX = 0,
                SizeY = 0,
                Exit  = new Model.Entities.Coordinate {
                    Y = 0, X = 0
                },
                StartPosition = new Model.Entities.Position {
                    X = -1, Y = -1
                }
            },
                                                           new Model.Entities.MovesConfig {
            }));

            Assert.ThrowsException <InvalidPositionException>(() => tsm.Initialize(
                                                                  new Model.Entities.TableConfig
            {
                SizeX = 1,
                SizeY = 1,
                Exit  = new Model.Entities.Coordinate {
                    Y = 0, X = 0
                },
                StartPosition = new Model.Entities.Position {
                    X = -1, Y = -1
                }
            },
                                                                  new Model.Entities.MovesConfig {
            }));

            Assert.ThrowsException <InvalidPositionException>(() => tsm.Initialize(
                                                                  new Model.Entities.TableConfig
            {
                SizeX = 1,
                SizeY = 1,
                Exit  = new Model.Entities.Coordinate {
                    Y = 0, X = 0
                },
                StartPosition = new Model.Entities.Position {
                    X = 1, Y = 1
                }
            },
                                                                  new Model.Entities.MovesConfig {
            }));

            Assert.ThrowsException <InvalidPositionException>(() => tsm.Initialize(
                                                                  new Model.Entities.TableConfig
            {
                SizeX = 2,
                SizeY = 2,
                Exit  = new Model.Entities.Coordinate {
                    Y = 0, X = 0
                },
                StartPosition = new Model.Entities.Position {
                    X = 2, Y = 2
                }
            },
                                                                  new Model.Entities.MovesConfig {
            }));

            Assert.ThrowsException <InvalidPositionException>(() => tsm.Initialize(
                                                                  new Model.Entities.TableConfig
            {
                SizeX         = 2,
                SizeY         = 2,
                StartPosition = new Model.Entities.Position {
                    X = 1, Y = 1
                },
                Exit = new Model.Entities.Coordinate {
                    X = 2, Y = 2
                }
            },
                                                                  new Model.Entities.MovesConfig {
            }));

            Assert.ThrowsException <InvalidPositionException>(() => tsm.Initialize(
                                                                  new Model.Entities.TableConfig
            {
                SizeX         = 2,
                SizeY         = 2,
                StartPosition = new Model.Entities.Position {
                    X = 1, Y = 1
                },
                Exit = new Model.Entities.Coordinate {
                    X = 1, Y = 1
                },
                Mines = new System.Collections.Generic.List <Model.Entities.Coordinate>
                {
                    new Model.Entities.Coordinate {
                        X = -1, Y = -1
                    }
                }
            },
                                                                  new Model.Entities.MovesConfig {
            }));

            Assert.ThrowsException <InvalidPositionException>(() => tsm.Initialize(
                                                                  new Model.Entities.TableConfig
            {
                SizeX         = 2,
                SizeY         = 2,
                StartPosition = new Model.Entities.Position {
                    X = 1, Y = 1
                },
                Exit = new Model.Entities.Coordinate {
                    X = 1, Y = 1
                },
                Mines = new System.Collections.Generic.List <Model.Entities.Coordinate>
                {
                    new Model.Entities.Coordinate {
                        X = 2, Y = 2
                    }
                }
            },
                                                                  new Model.Entities.MovesConfig {
            }));
        }