예제 #1
0
 public SetPropertyCommand(PuzzleLayout sut, TilePos position, string key, object value)
 {
     _sut      = sut;
     _position = position;
     _key      = key;
     _value    = value;
 }
예제 #2
0
    void OnEnable()
    {
        EditorApplication.playModeStateChanged += EditorApplicationOnPlayModeStateChanged;

        m_PuzzleLayout = target as PuzzleLayout;

        var assets = AssetDatabase.FindAssets("t:PuzzlePieceBox");

        foreach (var a in assets)
        {
            string         path    = AssetDatabase.GUIDToAssetPath(a);
            PuzzlePieceBox palette = AssetDatabase.LoadAssetAtPath <PuzzlePieceBox>(path);

            m_AvailablePieces.Add(palette);
        }

        m_PieceProperty = serializedObject.FindProperty("pieces");

        m_HighlightMaterial = new Material(Shader.Find("Hidden/Internal-Colored"));

        m_HighlightMaterial.color = new Color32(255, 238, 0, 255);
        m_HighlightMaterial.SetInt("ZTest", (int)UnityEngine.Rendering.CompareFunction.Always);

        foreach (var p in m_PuzzleLayout.pieces)
        {
            if (p != null)
            {
                p.gameObject.hideFlags = HideFlags.HideInHierarchy;
            }
        }
    }
예제 #3
0
        public void SavedObjectAddsObjectToLayout()
        {
            var puzzleObject = new FlatLayout.PuzzleObject
            {
                Type       = "type",
                Position   = new TilePos(1, 1),
                Properties =
                {
                    new FlatLayout.PuzzleObject.Property
                    {
                        Key   = "key",
                        Type  = "System.Boolean",
                        Value = "true"
                    }
                }
            };

            _savedLayout.Objects.Add(puzzleObject);
            var gameLayout = new PuzzleLayout();

            _sut.LoadFromFlatLayout(_savedLayout, gameLayout);

            var puzzleObjects = gameLayout.GetAllObjects();

            puzzleObjects.Should().HaveCount(1);
            puzzleObjects[0].Type.Should().Be(puzzleObject.Type);
            puzzleObjects[0].Position.Should().Be(puzzleObject.Position);
            puzzleObjects[0].Properties.Should().HaveCount(1);
            var property = puzzleObjects[0].Properties.First().Value;

            property.Key.Should().Be("key");
            property.Type.Should().Be(typeof(bool));
            property.Value.Should().Be(true);
        }
예제 #4
0
        public void SetLinkInfo(PuzzleLayout puzzleLayout, string type, TilePos position)
        {
            HasSetLink   = true;
            PuzzleLayout = puzzleLayout;
            Position     = position;

            SendMessage("LayoutLinkSet");
        }
예제 #5
0
        public SystemsSetup LevelHandlingSystems(PuzzleLayout layout)
        {
            _systems
            .Add(_pool.CreateSystem(new GameLevelLoaderSystem(layout)))
            .Add(_pool.CreateSystem <FinishedLevelLoadSystem>())
            .Add(_pool.CreateSystem <LevelExitSystem>())
            .Add(_pool.CreateSystem <LevelRestartSystem>());

            return(this);
        }
예제 #6
0
        public void SavedConnectionAddsConnectionToLayout()
        {
            var connection = new NodeConnection(new TilePos(0, 0), new TilePos(1, 0));

            _savedLayout.Connections.Add(connection);
            var gameLayout = new PuzzleLayout();

            _sut.LoadFromFlatLayout(_savedLayout, gameLayout);

            gameLayout.GetAllConnections().ShouldAllBeEquivalentTo(new[] { connection });
        }
예제 #7
0
        public void SavesNodeConnectionToLayout()
        {
            var layoutToSave   = new PuzzleLayout();
            var nodeConnection = new NodeConnection(new TilePos(0, 0), new TilePos(1, 1));

            layoutToSave.AddNodeConnections(nodeConnection);

            var savedLayout = _sut.SaveToFlatLayout(layoutToSave);

            savedLayout.Connections[0].Should().Be(nodeConnection);
        }
예제 #8
0
        public void LayoutLinkSet()
        {
            _layout = _layoutLink.PuzzleLayout;
            if (!_layout.HasProperty(_layoutLink.Position, "Health"))
            {
                _layout.SetProperty(_layoutLink.Position, "Health", 3);
            }

            _layout.PropertySet += PropertyChanged;
            _health              = (int)_layout.GetObjectAt(_layoutLink.Position).Properties["Health"].Value;
        }
예제 #9
0
파일: Board.cs 프로젝트: pb0/ID0_Test
 public Board(Rect boardRect, PuzzlePanel puzzlePanel, E_HeroType heroType, MatchingHandler matchHandler, Handler onMatchStart, Handler onMatchFinish, TimeClient timeClient)
 {
     layout = new PuzzleLayout(boardRect);
     this.puzzlePanel = puzzlePanel;
     this.blocks = TableLoader.GetTable<BlockEntity>().GetMany(heroType).Select(x => x.Value).ToDictionary(x => x.BlockType);
     this.blockGenerator = new Block.Generator(heroType);
     this.matchHandler = matchHandler;
     this.onMatchStart = onMatchStart;
     this.onMatchFinish = onMatchFinish;
     fsm = new FSM("PuzzleBoard.fsm", this);
 }
예제 #10
0
        public void LayoutLinkSet()
        {
            _layout = _layoutLink.PuzzleLayout;
            if (!_layout.HasProperty(_layoutLink.Position, "IsLoaded"))
            {
                _layout.SetProperty(_layoutLink.Position, "IsLoaded", false);
            }

            _layout.PropertySet += PropertyChanged;
            var isNowLoaded = (bool)_layout.GetObjectAt(_layoutLink.Position).Properties["IsLoaded"].Value;

            UpdateLoadedState(isNowLoaded);
        }
예제 #11
0
        private void SetupPlaySystems(PuzzleLayout layout)
        {
            _systems.AddSystems(_gamePool, x => x
                                .InputSystems()

                                .UpdateSystems()

                                .RenderSystems()
                                .AnimationSystems()

                                .LevelHandlingSystems(layout)

                                .DestroySystems());
        }
예제 #12
0
 public void LoadFromFlatLayout(FlatLayout savedLayout, PuzzleLayout gameLayout)
 {
     savedLayout.Connections.ForEach(gameLayout.AddNodeConnections);
     savedLayout.Objects.ForEach(puzzleObject =>
     {
         var properties = new SetProperties();
         puzzleObject.Properties.ForEach(property =>
         {
             var type      = Type.GetType(property.Type);
             var converter = System.ComponentModel.TypeDescriptor.GetConverter(type);
             var value     = converter.ConvertFromInvariantString(property.Value);
             properties.Add(property.Key, value);
         });
         gameLayout.PlaceObject(puzzleObject.Type, puzzleObject.Position, properties);
     });
 }
        public void DoesNotCreateOverlappingTiles()
        {
            var layout = new PuzzleLayout();

            layout.AddNodeConnections(new NodeConnection(new TilePos(0, 0), new TilePos(1, 0)));
            layout.PlaceObject("Trap", new TilePos(0, 0));

            var pool = new TestGamePool();

            new Systems()
            .Add(pool.CreateSystem <PositionsCacheUpdateSystem>())
            .Add(pool.CreateSystem(new GameLevelLoaderSystem(layout)))
            .Initialize();

            var tilesAtPosition = pool.GetEntitiesAt(new TilePos(0, 0), e => e.IsTile());

            tilesAtPosition.Count.Should().Be(1);
        }
예제 #14
0
 public FlatLayout SaveToFlatLayout(PuzzleLayout layoutToSave)
 {
     return(new FlatLayout
     {
         Connections = layoutToSave.GetAllConnections(),
         Objects = layoutToSave.GetAllObjects()
                   .Select(puzzleObject => new FlatLayout.PuzzleObject
         {
             Type = puzzleObject.Type,
             Position = puzzleObject.Position,
             Properties = puzzleObject.Properties.Values.Select(x => new FlatLayout.PuzzleObject.Property()
             {
                 Key = x.Key,
                 Value = x.Value.ToString(),
                 Type = x.Type.ToString()
             }).ToList()
         })
                   .ToList()
     });
 }
예제 #15
0
파일: Board.cs 프로젝트: pb0/ID0_Test
    public Board(Rect boardRect, PuzzlePanel puzzlePanel, Dart<BlockEntity2> dart, bool permitStartingMatch, MatchingHandler matchHandler, Handler onMatchStart, Handler onMatchFinish, TimeClient timeClient)
    {
        layout = new PuzzleLayout(boardRect);
        this.puzzlePanel = puzzlePanel;
        this.blockGenerator = new Block.Generator(dart);
        this.matchHandler = matchHandler;
        this.onMatchStart = onMatchStart;
        this.onMatchFinish = onMatchFinish;
        fsm = new FSM("PuzzleBoard.fsm", this);

        this.typeToEntity = new Dictionary<BlockType, BlockEntity2>();
        foreach (var entity in dart.Values)
        {
            typeToEntity.Add(entity.blockType, entity);
        }

        FillWithoutAni();
        if (!permitStartingMatch)
        {
            RemoveMatch();
        }
    }
예제 #16
0
 protected PlaceObjectCommand(PuzzleLayout layout, string type, TilePos position)
 {
     Position = position;
     Type     = type;
     Layout   = layout;
 }
예제 #17
0
 public RemoveObjectCommand(PuzzleLayout layout, TilePos position)
 {
     _position             = position;
     _layout               = layout;
     _previousPuzzleObject = _layout.GetObjectAt(_position);
 }
예제 #18
0
 public PlaceNormalObjectCommand(PuzzleLayout layout, string type, TilePos position) : base(layout, type, position)
 {
 }
예제 #19
0
 public ClearLayoutCommand(PuzzleLayout layout)
 {
     _layout             = layout;
     _currentConnections = layout.GetAllConnections();
 }
 public RemoveNodeConnectionCommand(PuzzleLayout layout, NodeConnection connection)
 {
     _layout     = layout;
     _connection = connection;
 }
 public PuzzleEditorAcceptanceTests()
 {
     Sut = new PuzzleLayout();
 }
예제 #22
0
 public SetSingletonObjectCommand(PuzzleLayout layout, string type, TilePos position) : base(layout, type, position)
 {
     _previousPuzzleObject = layout.GetSingleton(type);
 }
예제 #23
0
 /// <summary>
 /// Called by the editor script that place piece to initialize the ExitUsed array to match Exits
 /// </summary>
 public void Placed(PuzzleLayout layoutOwner)
 {
     Owner = layoutOwner;
     ConnectorConnections = new PuzzlePiece[Connectors.Length];
 }
예제 #24
0
    private void DrawObjectProperties(Dictionary <string, PuzzleObject.Property> propertiesObject, PuzzleLayout layout)
    {
        var propertyPosition = Camera.current.WorldToScreenPoint(_propertyDialogPosition.ToV3());

        Handles.BeginGUI();
        GUI.enabled = true;

        GUILayout.BeginArea(new Rect(propertyPosition.x - 100, Screen.height - propertyPosition.y - 100, 220, 200));
        GUILayout.BeginVertical(GUI.skin.box, GUILayout.Width(200));

        if (propertiesObject.Count == 0)
        {
            EditorGUILayout.LabelField("No properties");
        }
        else
        {
            foreach (var property in propertiesObject.Values.ToList())
            {
                if (property.Type == typeof(bool))
                {
                    var currentValue         = (bool)property.Value;
                    var possiblyChangedValue = EditorGUILayout.Toggle(property.Key, currentValue);
                    if (currentValue != possiblyChangedValue)
                    {
                        layout.SetProperty(_propertyDialogPosition, property.Key, possiblyChangedValue);
                    }
                }
                else if (property.Type == typeof(int))
                {
                    var value = (int)property.Value;
                    var possiblyChangedValue = EditorGUILayout.IntField(property.Key, value);
                    if (value != possiblyChangedValue)
                    {
                        layout.SetProperty(_propertyDialogPosition, property.Key, possiblyChangedValue);
                    }
                }
                else if (property.Type == typeof(int))
                {
                    var currentValue         = (int)property.Value;
                    var possiblyChangedValue = EditorGUILayout.IntSlider(property.Key, currentValue, 1, 5);
                    if (currentValue != possiblyChangedValue)
                    {
                        layout.SetProperty(_propertyDialogPosition, property.Key, possiblyChangedValue);
                    }
                }
            }
        }

        GUILayout.EndVertical();
        GUILayout.EndArea();

        Handles.EndGUI();
    }
예제 #25
0
 public GameLevelLoaderSystem(PuzzleLayout layout)
 {
     _layout = layout;
 }
예제 #26
0
    // Start is called before the first frame update
    void Awake()
    {
        _puzzleSet1 = new GameObject("PuzzleSet1");
        _puzzleSet2 = new GameObject("PuzzleSet2");

        Filler      = FillerGameObject.GetComponent <Image>();
        audioSource = GetComponent <AudioSource>();

        _frame        = PuzzleLayout.CreateFrame(FrameName1);
        _puzzleLayout = new PuzzleLayout(170.0f, 170.0f, PuzzleRowsOrCols);
        _frame.transform.SetParent(_puzzleSet1.transform);
        _puzzleLayout.gameObject.transform.SetParent(_puzzleSet1.transform);

        _frame2 = PuzzleLayout.CreateFrame(FrameName2);
        _frame2.transform.SetParent(_puzzleSet2.transform);
        _puzzleLayout2 = new PuzzleLayout(170.0f, 170.0f, PuzzleRowsOrCols);
        _puzzleLayout2.gameObject.transform.SetParent(_puzzleSet2.transform);

        _puzzleSet2.transform.position = new Vector3(0.0f, -600.0f, 0.0f);
        _puzzleSet2.SetActive(false);

        ID = Random.Range(0, MaxImageCount);
        LoadPuzzleImage();

        Neighbours.Instance.CreateGraphForNPuzzle(PuzzleRowsOrCols);

        _fsm = new Patterns.FiniteStateMachine();
        _fsm.Add(new GameState_FADEIN(_fsm, (int)GameState.StateID.FADEIN, this));
        _fsm.Add(new GameState_WAIT(_fsm, (int)GameState.StateID.WAIT, this));
        _fsm.Add(new GameState_PLAYING(_fsm, (int)GameState.StateID.PLAYING, this));
        _fsm.Add(new GameState_WIN(_fsm, (int)GameState.StateID.WIN, this));
        _fsm.Add(new GameState_SHOW_AD(_fsm, (int)GameState.StateID.SHOW_AD, this));
        _fsm.Add(new GameState_COMPARE(_fsm, (int)GameState.StateID.COMPARE, this));
        _fsm.Add(new GameState_RANDOMIZE(_fsm, (int)GameState.StateID.RANDOMIZE, this));
        _fsm.Add(new GameState_NEXT_PUZZLE_IMAGE(_fsm, (int)GameState.StateID.NEXT_PUZZLE_IMAGE, this));
        _fsm.Add(new GameState_SHOW_HINT(_fsm, (int)GameState.StateID.SHOW_HINT, this));
        _fsm.Add(new GameState_CANCEL(_fsm, (int)GameState.StateID.CANCEL, this));
        _fsm.Add(new GameState_SHOW_REWARD_AD(_fsm, (int)GameState.StateID.SHOW_REWARD_AD, this));
        _fsm.Add(new GameState_ASTAR_SOLUTION(_fsm, (int)GameState.StateID.ASTAR_SOLUTION, this));

        _fsm.SetCurrentState((int)GameState.StateID.FADEIN);
        audioSource.Play();

        //mBottomMenu = GameApp.Instance.mBottomMenu;
        //mBottomMenu.SetActive(true);
        //mBottomMenu.btnNext.gameObject.SetActive(false);
        //mBottomMenu.btnPrev.onClick.AddListener(LoadMenu);
        mGameMenuHandler.SetActiveBtnHome(true);

#if FARAMIRA_USE_ADS
        // initialize ADs
#if UNITY_IPHONE
        Advertisement.AddListener(this);
        Advertisement.Initialize(GameID_iOS, testMode);
#endif

#if UNITY_ANDROID
        Advertisement.AddListener(this);
        Advertisement.Initialize(GameID_Android, testMode);
#endif
#endif
    }
예제 #27
0
        public LevelLoadingTests()
        {
            _layout = new PuzzleLayout();

            _pool = new TestGamePool();
        }
예제 #28
0
 private ICommand GetNodeConnectionCommand(PuzzleLayout layout, NodeConnection nodeConnection)
 {
     return(_isDeleting
         ? new RemoveNodeConnectionCommand(layout, nodeConnection) as ICommand
         : new AddNodeConnectionCommand(layout, nodeConnection));
 }