public void Reset(){
		state = TileState.empty;
		if(attachedPiece!=null){
			attachedPiece.Fall(attachedPiece.transform.position.normalized * 4 + new Vector3(0,8,0));
			attachedPiece=null;
		}
	}
	public void SetTile(int _x, int _y){
		state = TileState.empty;
		idX = _x;
		idY = _y;
		gameObject.SetActive(true);
		transform.position = new Vector3(-7+_x,0,-7+_y);
	}
Example #3
0
	public void SetAllStates(TileState toSet)
	{
		foreach(Tile curTile in Tiles)
		{
			curTile.CurTileState = toSet;
		}
	}
Example #4
0
        public void Initialize( ContentManager content, 
                                float X, 
                                float Y, 
                                int viewPortWidth, 
                                int viewPortHeight, 
                                string assetName)
        {
            _state = TileState.Blank;

            _position.X = X;
            _position.Y = Y; 
            _viewPortWidth = viewPortWidth;
            _viewPortHeight = viewPortHeight;

            _tileGraphic = content.Load<Texture2D>(assetName);

            _X = content.Load<Texture2D>("BoardX");
            _O = content.Load<Texture2D>("BoardO");

            _XMoveClip = content.Load<SoundEffect>("XMove");
            _OMoveClip = content.Load<SoundEffect>("OMove");

            jiggleState = JiggleState.Center;
            jiggleDirection = JiggleDirection.Left;
        }
	public void DetachPiece(){
		if (attachedPiece!=null){
			attachedPiece.transform.parent = null;
			attachedPiece = null;
			state = TileState.empty;
		}
	}
Example #6
0
    public Sprite this[TileState key] {
        get {
            switch (key.unit)
            {
            case UnitType.Arrow:
                return(Arrow);

            case UnitType.Bomb:
                return(Bomb);

            case UnitType.Empty:
                return(Empty);

            case UnitType.Fang:
                return(Fang);

            case UnitType.Fire:
                return(Fire);

            case UnitType.Shield:
                return(Shield);

            case UnitType.Sword:
                return(Sword);

            case UnitType.Hole:
                return(Empty);

            default:
                throw new System.Exception("No sprite for unit type: " + key);
            }
        }
    }
Example #7
0
 private void CreateStateQue()
 {
     _stateQue.Enqueue(new DirtyState(_dirtyMaterial, null));
     _stateQue.Enqueue(new PlowedState(_plowedMaterial, null));
     _stateQue.Enqueue(new PlantedState(_plantedMaterial, SpawnProduction));
     _state = _stateQue.Dequeue();
 }
Example #8
0
    public ITileInfo DoMove(Vector2 direction)
    {
        ITileInfo tileInfo = m_World.GetTileInfo(m_Position + direction);

        if (tileInfo.GetState() == TileState.BorderRight)
        {
            if (m_World.gameManager.bPaneCleared || m_World.IsInTuto())
            {
                Debug.Log("Loading Next Pane");
                m_World.NextCache();
                m_Position.x = 0;
                m_World.SetObject(this, m_Position);
                m_World.gameManager.SwitchPane();
                return(tileInfo);
            }
            else
            {
                return(tileInfo);
            }
        }
        else if (tileInfo.GetState() == TileState.Occupied || tileInfo.GetState() == TileState.Ennemy)
        {
            return(tileInfo);
        }
        else if (tileInfo.GetState() == TileState.Border)
        {
            return(tileInfo);
        }
        TileState tileState = m_World.MoveObject(m_Position, direction);

        m_Position += direction;
        return(tileInfo);
    }
Example #9
0
    public Sprite this [TileState state] {
        get {
            if (state.incomingMove)
            {
                return(Instance.FriendlyIdle);
            }
            if (state.fireIncoming)
            {
                return(Instance.EnemyIdle);
            }
            if (state.unit == UnitType.Hole)
            {
                return(Instance.Transparent);
            }
            switch (state.Friendliness)
            {
            case Friendliness.Neutral:
            default:
                return(Instance.Empty);

            case Friendliness.Friendly:
                if (state.isSelected)
                {
                    return(Instance.FriendlyActive);
                }
                if (state.CanBeSelected && Selector.Get.ShouldAllowInput)
                {
                    return(Instance.FriendlyIdle);
                }
                else
                {
                    return(Instance.Empty);
                }

            case Friendliness.Hostile:
                if (Selector.Get.ShouldAllowInput || state.unit == UnitType.Fire)
                {
                    if (state.alerted)
                    {
                        return(Instance.EnemyActive);
                    }
                    else
                    {
                        return(Instance.EnemyIdle);
                    }
                }
                else
                {
                    if (state.isSelected)
                    {
                        return(Instance.EnemyActive);
                    }
                    else
                    {
                        return(Instance.Empty);
                    }
                }
            }
        }
    }
Example #10
0
    private void OnPlayFinished(TileState ts)
    {
        ts.setTileState(this.currentTurn);
        this.player_tiles[this.currentTurn].Add(ts);
        availableTiles.Remove(ts);
        //int go = CheckGameOver();
        int go = HexGridUtil.CheckGameOver(0, player_tiles[0], player_tiles[1]);

        if (go != -1)
        {
            //Debug.Log("GameOver: " + go);
            uiGameOver.SetActive(true);
            if (this.currentTurn == 0)
            {
                textCurrentPlayer.text = "Winner: " + players[0].name;
            }
            else
            {
                textCurrentPlayer.text = "Winner: " + players[1].name;
            }
            Stats.RecordGame(players[0].gameObject.name, players[1].gameObject.name, tossWon, this.currentTurn);
            Stats.Print();
            //Restart();
            return;
        }
        //ts.updateTileSet();
        //Debug.LogError("ts chain length: " + ts.tileSet.GetRoot().chainLength);
        TestEvaluationFunction();
        this.currentTurn = (this.currentTurn + 1) % 2;
        // this is necessary to switch to next turn after each turn is finished
        isCurrentTurnUpdated = true;
    }
    public void ChangeTileState(TileState tileState)
    {
        _currentTileState = tileState;

        switch (tileState)
        {
        case TileState.EMPTY:
            _renderer.material.color = emptyColor;
            break;

        case TileState.TRACK:
            if (_renderer != null)
            {
                _renderer.material.color = trackColor;
            }
            break;

        case TileState.FILLED:
            _renderer.material.color = filledColor;
            transform.Translate(0, 1, 0);
            // if(OnStateChange!=null) the same
            //     OnStateChange();
            OnStateChange?.Invoke();
            break;
        }
    }
Example #12
0
    public void RefreshView(TileState state)
    {
        switch (state)
        {
        case TileState.free:
            image.color = free;
            break;

        case TileState.occupied:
            image.color = occupied;
            break;

        case TileState.readyToBeOccupied:
            image.color = readyToBeOccupied;
            break;

        case TileState.inAttackRange:
            image.color = inAttackRange;
            break;

        case TileState.active:
            image.color = active;
            break;
        }
    }
Example #13
0
        /// <summary>
        /// Shoots a missile at location
        /// </summary>
        /// <param name="location"> location to shoot </param>
        /// <param name="hitMarkers"> Collection of hitmarkers to add shot to</param>
        private void Shoot(Coordinate location, Player targetPlayer)
        {
            // get tile state
            TileState tileState = targetPlayer.GameBoard[location.YCoord, location.XCoord];

            // if boat: display red 'x' on grid
            if (tileState == TileState.Boat)
            {
                AddHitMarker(location, targetPlayer, TileState.Hit);

                // Locates the boat that has a coordinate equal to the coordinate being shot i.e. get the boat being shot
                IBoat boatToHit = (from boat in targetPlayer.Boats
                                   from coord in boat.CoordinateRange.GetAllCoordinates()
                                   where coord.ToString() == location.ToString()
                                   select boat).ElementAt(0);
                boatToHit.Health--;

                // TODO: better way of doing this
                OnPropertyChanged(nameof(User.Health));
                OnPropertyChanged(nameof(Computer.Health));

                _boatApearanceManager.CheckForSunkBoats(targetPlayer.Boats);
            }
            // if empty: display green 'o' on grid
            else if (tileState == TileState.Empty)
            {
                AddHitMarker(location, targetPlayer, TileState.Miss);
            }
        }
Example #14
0
    IndexPair RequestMove(TileState currentColor)
    {
        switch (currentColor)
        {
        case TileState.Black:
            if (playerOneType == PlayerType.Agent)
            {
                return(RequestAgentMove(TileState.Black));
            }
            else
            {
                return(RequestPlayerMove(TileState.Black));
            }

        case TileState.White:
            if (playerTwoType == PlayerType.Agent)
            {
                return(RequestAgentMove(TileState.White));
            }
            else
            {
                return(RequestPlayerMove(TileState.White));
            }

        default:
            Debug.LogError("Color is neither black or white.");
            return(new IndexPair(width, height));
        }
    }
Example #15
0
        //TODO: update to support multiple expansions
        public void NewGame()
        {
            TileGrid.GameState = GameStates.Playing;

            title = new TimedTitle(Font, new Vector2(0, 30), "", false, Color.Black);
            counter = 0;
            tileState = TileState.Free;
            selectedEntityID = activeEntity = null;
            entities.Clear();
            entityInfo.Clear();

            for (int i = 0; i < bannerManager.LobbyBannerCount; i++)
            {
                AddEntityInfo(new LargeSoldier(), bannerManager.BannerColor(i + 1), 1, LargeSoldierLocation(i), LargeSoldierRectangle(i));
                AddEntityInfo(new Soldier(), bannerManager.BannerColor(i + 1), 7,SoldierLocation(i), SoldierRectangle(i));
            }
            
            spawner.ButtonLocation = SpawnerLocation(bannerManager.LobbyBannerCount);
            bannerManager.NewGame();
            AddEntityInfoItems();

            TileGrid.ResetGrid();
            deckManager.NewGame();
            ShuffleDecks();
        }
Example #16
0
 public TileSet(TileState ts)
 {
     size  = 1;
     high  = low = HexGridUtil.getHexIndexForPlayer(ts.currentState, ts);
     state = ts.currentState;
     root  = null;
 }
Example #17
0
    public static IEnumerator TakeAITurn()
    {
        foreach (var state in TileState.AllTiles()
                 .Where(x => x.Friendliness == Friendliness.Hostile)
                 .OrderBy(x => - x.playOrder))
        {
            if (state.Friendliness == Friendliness.Hostile)
            {
                yield return(TakeTurn(state));

                if (state.unit != UnitType.Fire && state.alerted)
                {
                    yield return(new WaitForSeconds(0.6f));
                }
            }
        }
        foreach (var state in TileState.AllTiles())
        {
            if (state.fireIncoming)
            {
                state.unit    = UnitType.Fire;
                state.alerted = true;
                if (!Generator.isRunning)
                {
                    SFXController.PlayFire();
                    yield return(new WaitForSeconds(0.1f));
                }
            }
        }
        yield return(YieldFast.Get);
    }
Example #18
0
    IEnumerator Wait()
    {
        yield return(new WaitForSeconds(timeUntilReady));

        tileState = TileState.READY_TO_COLLECT;
        anim.SetInteger("TileState", 2);
    }
Example #19
0
        private void CycleState()
        {
            var c = _currentState;

            // The image must have been loaded first.
            if (!_hasImageLoaded)
            {
                return;
            }

            switch (c)
            {
            case TileState.Image:
                _currentState = TileState.Text;
                break;

            case TileState.Partial:
                _currentState = TileState.Image;
                break;

            case TileState.Text:
                _currentState = TileState.Partial;
                break;
            }

            UpdatePosition(true);
        }
Example #20
0
        public Wall(TileState state, RectangleF rect, Direction dir)
            : base(state, rect)
        {
            ConnectSprite = true;
            Opaque = true;
            _dir = dir;
            name = "Wall";

            if (dir == Direction.East)
            {
                Sprite = _resourceManager.GetSprite("wall_EW");
                topSprite = _resourceManager.GetSprite("wall_top_EW");
                topSpriteNW = _resourceManager.GetSprite("wall_top_2");
                topSpriteSE = _resourceManager.GetSprite("wall_top_8");
                wallEndE = _resourceManager.GetSprite("wall_end_e");
                wallEndW = _resourceManager.GetSprite("wall_end_w");
            }
            else
            {
                Sprite = _resourceManager.GetSprite("wall_NS");
                topSprite = _resourceManager.GetSprite("wall_top_NS");
                topSpriteNW = _resourceManager.GetSprite("wall_top_4");
                topSpriteSE = _resourceManager.GetSprite("wall_top_1");
            }

            

            mapMgr = IoCManager.Resolve<IMapManager>();
        }
Example #21
0
        private IEnumerator UpdateView(TileState state)
        {
            yield return(new WaitForSeconds(_updateTime));

            _renderer.material = state.Material;
            state.StateAction?.Invoke();
        }
Example #22
0
        public Wall(TileState state, RectangleF rect, Direction dir)
            : base(state, rect)
        {
            ConnectSprite = true;
            Opaque        = true;
            _dir          = dir;
            name          = "Wall";

            if (dir == Direction.East)
            {
                Sprite      = _resourceManager.GetSprite("wall_EW");
                topSprite   = _resourceManager.GetSprite("wall_top_EW");
                topSpriteNW = _resourceManager.GetSprite("wall_top_2");
                topSpriteSE = _resourceManager.GetSprite("wall_top_8");
                wallEndE    = _resourceManager.GetSprite("wall_end_e");
                wallEndW    = _resourceManager.GetSprite("wall_end_w");
            }
            else
            {
                Sprite      = _resourceManager.GetSprite("wall_NS");
                topSprite   = _resourceManager.GetSprite("wall_top_NS");
                topSpriteNW = _resourceManager.GetSprite("wall_top_4");
                topSpriteSE = _resourceManager.GetSprite("wall_top_1");
            }



            mapMgr = IoCManager.Resolve <IMapManager>();
        }
Example #23
0
 public Tile(string texName, Game1 game, int row, int col, int offsetX, int offsetY)
 {
     if (texName != "   ")
     {
         tileTexture = game.Content.Load <Texture2D>(texName);
         if (texName == "w1")
         {
             tileState = TileState.IMPASSABLE;
         }
         else
         {
             tileState = TileState.PASSABLE;
         }
     }
     else
     {
         tileTexture = game.Content.Load <Texture2D>(DEFAULT_TILE);
         tileState   = TileState.IMPASSABLE;
     }
     animationFrames = tileTexture.Width / TILE_SIZE;
     sourceRectangle = new Rectangle(0, 0, TILE_SIZE, TILE_SIZE);
     x = col * TILE_SIZE + offsetX;
     y = row * TILE_SIZE + offsetY;
     animationCounter = 0;
 }
Example #24
0
        public void ChooseTileState(TileState s)
        {
            LineRenderer li = GetComponent <LineRenderer>();

            state = s;
            switch (state)
            {
            case TileState.Normal: {
                li.startColor = Color.red;
                li.endColor   = Color.magenta;
            }
            break;

            case TileState.Block:
                li.startColor = Color.black;
                li.endColor   = Color.magenta;
                break;

            case TileState.Tree:
                li.startColor = Color.gray;
                li.endColor   = Color.cyan;
                break;

            default:
                break;
            }
        }
Example #25
0
    public void UpdateTIle(TileState t_state)
    {
        switch (t_state)
        {
        case TileState.Hovered:
            m_sp.color = new Color(1, 0, 0, .5f);
            break;

        case TileState.Selected:
            if (selected)
            {
                UpdateTIle(TileState.Default);
            }
            else
            {
                m_sp.color = new Color(1, 0, 1, 1);
                selected   = true;
            }
            break;

        default:
            m_sp.color = new Color(0, 0, 0, .05f);
            selected   = false;
            break;
        }
    }
Example #26
0
        public bool CheckInput(GamePadState a_state)
        {
            bool temp;

            switch (inputCat)
            {
            case InputCat.Button:
                temp = CheckButton(a_state);
                break;

            case InputCat.DPad:
                temp = CheckDpad(a_state);
                break;

            case InputCat.ThumbStick:
                temp = CheckThumbStick(a_state);
                break;

            case InputCat.Trigger:
                temp = CheckTrigger(a_state);
                break;

            default:
                temp = false;
                break;
            }
            if (temp)
            {
                state = TileState.Dead;
            }
            return(temp);
        }
Example #27
0
        /// <summary>
        /// Checks if the target is in a valid tile i.e. not a tile already shot
        /// </summary>
        public void UpdateValidPlacement()
        {
            TileState targetOverTileState = Computer.GameBoard[Target.Row, Target.Column];

            ValidTargetLocation = (targetOverTileState == TileState.Boat || targetOverTileState == TileState.Empty);
            OnPropertyChanged(nameof(CanUserShoot));
        }
Example #28
0
    public void SetState(string placestate)
    {
        switch (placestate)
        {
        case "WALK":
            state = TileState.WALK;
            break;

        case "BLOCK":
            state = TileState.BLOCK;
            break;

        case "EMPTY":
            state = TileState.EMPTY;
            break;

        case "BASE1":
            state = TileState.BASE1;
            break;

        case "BASE2":
            state = TileState.BASE2;
            break;

        default:
            Debug.LogErrorFormat("{0} cannot be set as a PlaceState!", placestate);
            break;
        }
    }
Example #29
0
    // Use this for initialization
    void Start()
    {
        selectedState = TileState.OPEN;
        tileCollider  = GetComponent <Collider2D>();

        Messenger.GetInstance().RegisterListener(new GameOverMsg(), GameOver);
    }
 public Tile(Board _board, int x, int y)
 {
     board  = _board;
     xIndex = x;
     yIndex = y;
     state  = TileState.Empty;
 }
Example #31
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            tileState = TileState.Tile1;
            toolState = ExternalToolState.MainTool;


            this.IsMouseVisible = true;
            texturePosition     = new Rectangle();
            //Mouse.WindowHandle = Window.Handle;
            //Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height/2);
            viewportAdapter = new ScalingViewportAdapter(GraphicsDevice, 2560, 1440);
            mousePosition   = ms.Position.ToVector2();
            mapGrid         = new string[20, 11];

            for (int i = 0; i < mapGrid.GetLength(0); i++)
            {
                for (int j = 0; j < mapGrid.GetLength(1); j++)
                {
                    mapGrid[i, j] = "0";
                }
            }

            tile1Positions = new List <Vector2>();
            texture        = new Dictionary <string, Texture2D>();

            saveCounter = 1;



            base.Initialize();
        }
Example #32
0
    internal static GameObject CreateCell(Tile tileHit, GridManager grid, TileState tileState)
    {
        var newCellObject = Instantiate(tileHit.GetComponent <Tile>().CellPrefab, new Vector3(tileHit.transform.position.x, tileHit.transform.position.y, 0.33f), Quaternion.identity);

        newCellObject.name = $"{newCellObject.transform.position}";
        tileHit.Cell       = newCellObject;
        newCellObject.GetComponent <Cell>().Tile = tileHit;
        tileHit.IsAlive = true;
        tileHit.State   = tileState;
        if (tileHit.Row > grid.BiggestRowRectangle)
        {
            grid.BiggestRowRectangle = tileHit.Row;
        }
        if (tileHit.Row < grid.SmallestRowRectangle)
        {
            grid.SmallestRowRectangle = tileHit.Row;
        }
        if (tileHit.Column > grid.BiggestColumnRectangle)
        {
            grid.BiggestColumnRectangle = tileHit.Column;
        }
        if (tileHit.Column < grid.SmallestColumnRectangle)
        {
            grid.SmallestColumnRectangle = tileHit.Column;
        }
        return(newCellObject);

        //Debug.Log($"Name After : {tileHit.GetComponent<Tile>().Cell.name}");
    }
Example #33
0
    void OnMouseOver()
    {
        //Do not edit while pathfinding is in progress
        if (PathfindingManager.instance.isRunning)
        {
            return;
        }

        if (Input.GetMouseButton(0))
        {
            if (UIManager.instance.isOrigin)
            {
                if (this.isObstacle)
                {
                    return;
                }
                UIManager.instance.lastTile.state = TileState.Empty;
                this.state = TileState.Origin;
                PathfindingManager.instance.origin = this;
                UIManager.instance.lastTile        = PathfindingManager.instance.origin;
            }
            else if (UIManager.instance.isDestination)
            {
                if (this.isObstacle)
                {
                    return;
                }
                UIManager.instance.lastTile.state = TileState.Empty;
                this.state = TileState.Destination;
                PathfindingManager.instance.destination = this;
                UIManager.instance.lastTile             = PathfindingManager.instance.destination;
            }
            else if (UIManager.instance.isFilling)
            {
                isObstacle = true;
            }
            else if (UIManager.instance.isErasing)
            {
                isObstacle = false;
            }
            else
            {
                if (state == TileState.Origin)
                {
                    UIManager.instance.isOrigin = true;
                    UIManager.instance.lastTile = this;
                }
                else if (state == TileState.Destination)
                {
                    UIManager.instance.isDestination = true;
                    UIManager.instance.lastTile      = this;
                }
                else
                {
                    UIManager.instance.isFilling = !isObstacle;
                    UIManager.instance.isErasing = isObstacle;
                }
            }
        }
    }
Example #34
0
    public void onTileButtonPressed()
    {
        if (m_tilemark_state != TileState.NONE)
        {
            Debug.LogError("Cannot choose this tile, it has already been marked.");
        }
        else
        {
            if (m_input_state == TileState.NONE)
            {
                Debug.Log("This tile is not ready for input");
            }
            else
            {
                //input is valid, set the persistent tilemark_state to match the current players mark and input state
                Sprite marking_sprite = m_player_mark_sprites[(int)m_input_state];//[(int)m_input_state is equivalent to the index of the player who made this selection

                setMarkImageSprite(marking_sprite);
                m_tilemark_state = m_input_state;

                //inform the game that the user made input and marked his tile
                m_game_manager.recordMoveInHistory((int)m_input_state, m_column_index, m_row_index);
                m_game_manager.playerTileChoiceComplete();
            }
        }
    }
Example #35
0
    public void EnactOperationState(TileState state, Vector2Int index)
    {
        var oldElement = Get(index);

        if (state.Type == TileType.EMPTY)
        {
            if (oldElement.m_Type != TileType.EMPTY)
            {
                EraseTile(index);
            }
            else
            {
                // TODO: maybe care about this?
            }
        }
        else
        {
            if (oldElement.m_Type != TileType.EMPTY)
            {
                EraseTile(index);
            }

            CreateTile(index, state, cloning: true);
        }
    }
Example #36
0
 void Start()
 {
     value                      = initValue;
     spriteRenderer             = GetComponent <SpriteRenderer>();
     lastState                  = null;
     runningTransitionCoroutine = null;
 }
Example #37
0
        public Space(TileState state, RectangleF rect)
            : base(state, rect)
        {
            ConnectSprite = false;
            name = "Space";

            Sprite = _resourceManager.GetSprite("space_texture");
            Sprite.SetPosition(Position.X, Position.Y);
        }
Example #38
0
        public Floor(TileState state, RectangleF rect)
            : base(state, rect)
        {
            ConnectSprite = false;
            name = "Floor";

            Sprite = _resourceManager.GetSprite("floor_texture");
            Sprite.SetPosition(Position.X, Position.Y);
        }
Example #39
0
        public Pathfinder(int RoomId, TileState[,] Tiles, double[,] HeightMap, RoomModel Model)
        {
            this.RoomId = RoomId;
            this.Tiles = Tiles;
            this.HeightMap = HeightMap;
            this.Model = Model;

            this.Lock = new ReaderWriterLock();
            this.FoundPath = false;
        }
Example #40
0
 public void AddOrRemoveState(TileState newState, bool isAdd)
 {
     if (isAdd)
     {
         this.State = this.State | newState;
     }
     else
     {
         this.State = this.State ^ (this.State & newState);
     }
 }
Example #41
0
        protected Tile(TileState state, RectangleF rect)
        {
            _resourceManager = IoCManager.Resolve<IResourceManager>();
            _lightManager = IoCManager.Resolve<ILightManager>();

            tileState = state;

            bounds = rect;

            Sprite = _resourceManager.GetSprite("space_texture");
            Sprite.SetPosition(Position.X, Position.Y);
        }
            public LogReader(string log, int player, int width, int height)
            {
                Debug.Assert(File.Exists(log));

                this.width = width;
                this.height = height;
                this.gridTopBottom = "+" + new string('-', width) + "+";

                reader = new StreamReader(log);
                playerTile = (player == 0) ? TileState.Player1 : TileState.Player2;

                // Read in the empty board.
                lastState = GetNextState();
            }
Example #43
0
    public void ChangeTileState(TileState newState)
    {
        if (state == newState)
            return;

        switch(newState)
        {
            case TileState.NORMAL:
                cover.GetComponent<Renderer>().material = NormalMaterial;
                state = newState;
                break;
            case TileState.MOVABLE:
                if (state == TileState.NORMAL || state == TileState.MOVE)
                {
                    cover.GetComponent<Renderer>().material = MovableMaterial;
                    state = newState;
                }
                break;
            case TileState.MOVE:
                if (state == TileState.MOVABLE)
                {
                    cover.GetComponent<Renderer>().material = MoveMaterial;
                    state = newState;
                }
                break;

            case TileState.ATTACKABLE:
                if (state == TileState.NORMAL || state == TileState.ATTACK)
                {
                    cover.GetComponent<Renderer>().material = AttackableMaterial;
                    state = newState;
                }
                break;

            case TileState.ATTACK:
                if (state == TileState.ATTACKABLE || state == TileState.NORMAL)
                {
                    cover.GetComponent<Renderer>().material = AttackMaterial;
                    state = newState;
                }
                break;
            default:
                break;
        }
    }
Example #44
0
 private void SetTileState(TileState newState)
 {
     currentTileState = newState;
     if ( newState == TileState.CROSS ) {
         myObject = (GameObject)Instantiate(crossObject);
         Vector3 pos = this.transform.position;
         myObject.transform.position = pos;
     } else if ( newState == TileState.RING ) {
         myObject = (GameObject)Instantiate(ringObject);
         Vector3 pos = this.transform.position;
         myObject.transform.position = pos;
     }
     else if ( newState == TileState.EMPTY ) {
         if (myObject!=null) Destroy(myObject);
     } else {
         myObject = null;
     }
 }
Example #45
0
    protected void handleStateTransitions()
    {
        if(WaterMonitor.WaterLevel > transform.position.y )
        {
            if(myState == TileState.StateAbove)
            {
                myLastState = myState;
                myState = TileState.StateBelow;
            }

        }
        else
        {
            if(myState == TileState.StateBelow)
            {
                myLastState = myState;
                myState = TileState.StateAbove;
            }
        }
    }
Example #46
0
        public Tile(Vector2 a_position, int a_height, TileMap a_tileMap)
            : base(a_position * new Vector2(TILE_WIDTH - 32, TILE_HEIGHT) - new Vector2(0, a_height * 40))
        {
            X = (int)a_position.X;
            Y = (int)a_position.Y;
            m_layer = 0.500f - a_position.Y / 1000f;
            m_tileMap = a_tileMap;

            if (MathManager.isEven((int)a_position.X)) {
                m_layer -= 0.0001f;
            }

            m_tileState = TileState.Normal;
            m_color = Color.White;
            m_heightSprites = new Sprite[a_height];
            m_height = a_height;
            m_tileMap = ((GameState)Game.getInstance().getCurrentState()).getTileMap();

            for (int i = 0; i < a_height; i++) {
                m_heightSprites[i] = new Sprite("Tiles//" + m_tileMap.getTileSet() + "mellangrej.png", 1);
            }
        }
Example #47
0
 private void FillPlayer1Dots(TileState[,] Board)
 {
     this.Board.EachPlayer1Dot((i ,j) => Board[i,j] = TileState.Player1);
 }
Example #48
0
        private void FloodIfEqualAndUnmarked(TileState[,] Board, bool[,] marks, int line, int col, TileState state)
        {
            if (line < 0 || line >= marks.GetLength(0))
                return;

            if (col < 0 || col >= marks.GetLength(1))
                return;

            if (marks[line, col])
                return;

            if (state != Board[line, col])
                return;

            FloodFill(Board, marks, line, col);
        }
Example #49
0
        private void FloodFill(TileState[,] Board, bool[,] marks, int line, int col)
        {
            marks[line, col] = true;

            FloodIfEqualAndUnmarked(Board, marks, line+1, col, Board[line, col]);
            FloodIfEqualAndUnmarked(Board, marks, line - 1, col, Board[line, col]);
            FloodIfEqualAndUnmarked(Board, marks, line, col + 1, Board[line, col]);
            FloodIfEqualAndUnmarked(Board, marks, line, col - 1, Board[line, col]);
        }
 public void DismissAffirmation()
 {
     State = TileState.Pricing;
     Affirmation = null;
 }
 public void DismissError()
 {
     State = TileState.Pricing;
     Error = null;
 }
Example #52
0
 public void restoreState()
 {
     m_hoverOverToggle = false;
     m_tileState = TileState.Normal;
 }
Example #53
0
        public override void update()
        {
            m_hitbox.update();
            bool l_collided = CollisionManager.hexagonContains(this, MouseHandler.worldMouse(), TILE_WIDTH, TILE_HEIGHT);

            if (l_collided && !m_ignoreMouse && !m_tileMap.p_ignoreMouse) {
                m_tileMap.p_hover = this;
                if (m_tileAbove != null) {
                    m_tileAbove.ignoreMouse(true);
                }
                switch (m_tileState) {
                    case TileState.Normal:
                        m_tileState = TileState.Hover;
                        break;
                    case TileState.Hover:
                        if (MouseHandler.lmbDown()) {
                            m_tileState = TileState.Pressed;
                        }
                        break;
                    case TileState.Pressed:
                        if (MouseHandler.lmbUp()) {
                            m_tileState = TileState.Hover;
                        }
                        break;
                    case TileState.Toggle:
                        if (MouseHandler.lmbUp()) {
                            m_tileState = TileState.Normal;
                        }
                        m_tileState = TileState.Hover;
                        break;
                }
            } else {
                if (m_hoverOverToggle) {
                    m_tileState = TileState.Toggle;
                } else {
                    m_tileState = TileState.Normal;
                }
                if (m_tileAbove != null) {
                    m_tileAbove.ignoreMouse(false);
                }
            }
            base.update();
        }
 public void resetTile()
 {
     this.BackgroundImage = null;
     this.BackColor = Color.Black;
     m_image = null;
     this.Dragable = false;
     this.Clickable = true;
     this.State = TileState.Empty;
     m_upperLayerImage.Image = null;
     m_upperLayerImage.Hide();
     this.Clickable = false;
     this.Dragable = false;
     this.Size = new Size(TILE_EDGE_LENGTH,TILE_EDGE_LENGTH);
 }
            private TileState[,] GetNextState()
            {
                // Find the start of the grid.
                for (string line = reader.ReadLine(); !reader.EndOfStream && line != gridTopBottom;
                    line = reader.ReadLine()) ;

                if (reader.EndOfStream)
                {
                    // Switch to human player?
                }

                TileState[,] state = new TileState[height, width];

                // Read the grid.
                for (int row = height - 1; row >= 0; row--)
                {
                    string gridLine = reader.ReadLine();

                    Debug.Assert(gridLine != gridTopBottom, "Grid is too short.");
                    Debug.Assert(gridLine.StartsWith("|") && gridLine.EndsWith("|"),
                        "Grid line \"" + gridLine + "\" must start and end with \"|\"");
                    Debug.Assert(gridLine.Length == width + 2,
                        "Grid line \"" + gridLine + "\" should be " + (width + 2)
                        + " characters long");

                    for (int column = 0; column < width; column++)
                    {
                        state[row, column] = ToTileState(gridLine[column + 1]);
                    }
                }

                Debug.Assert(reader.ReadLine() == gridTopBottom, "Grid is too long.");

                return state;
            }
Example #56
0
 public TileSaveData(TileState state, int sprIndex, bool isVisited)
 {
     this.state = state;
     this.sprIndex = sprIndex;
     this.isVisited = isVisited;
 }
Example #57
0
 public void LoadContent(Vector2 position, Rectangle sourceRect, TileState state)
 {
     this.position = position;
     this.sourceRect = sourceRect;
     this.state = state;
 }
Example #58
0
    public void SetState(TileState state, bool invalidate = true)
    {
        _State = state;

        if (invalidate)
        {
            if (IsWall)
            {
                _SprRenderer.sprite = TileSpriteManager.Instance.GetRandomWallSprite(out _SprIndex);
                //_BoxCollider.enabled = true;
            }
            else if(IsExit)
            {
                _SprRenderer.sprite = TileSpriteManager.Instance.GetExitSprite();
            }
            else
            {
                _SprRenderer.sprite = TileSpriteManager.Instance.GetRandomGroundSprite(out _SprIndex);
                //_BoxCollider.enabled = false;
            }
        }
    }
Example #59
0
	public void Init(int x, int y, TileState state)
    {
        _CachedTransform.position = new Vector2(x, y);
        _Pos = new Position(x, y);

        _IsVisited = false;

        this.SetState(state);

        _CachedTransform.SetParent(TileManager.Instance._TileGroup);
        //Invalidate();
    }
Example #60
0
    public void ApplySaveData(TileSaveData data)
    {
        _State = data.state;
        _SprIndex = data.sprIndex;
        _IsVisited = data.isVisited;

        if(IsWall)
        {
            _SprRenderer.sprite = TileSpriteManager.Instance.GetWallSpriteFromIndex(_SprIndex);
        }
        else if(IsExit)
        {
            _SprRenderer.sprite = TileSpriteManager.Instance.GetExitSprite();
        }
        else
        {
            _SprRenderer.sprite = TileSpriteManager.Instance.GetGroundSpriteFromIndex(_SprIndex);
        }
    }