// Initialization
    void Start()
    {
        GameObject tile;
        GameObject piece;
        bool isBlack = true;
        for (int row = 0; row < Sizes.BOARD; row++) {
            for(int column = 0; column < Sizes.BOARD; column++){
                GameTile gameTile = new GameTile();

                // init tile object
                tile = (GameObject)Instantiate(Resources.Load (isBlack? "BlackTile": "WhiteTile"));
                tile.transform.position = new Vector3(column*Sizes.TILE, row*Sizes.TILE, ZLayers.TILE);
                gameTile.tile = tile;

                // init piece object if there is one for this tile
                TileMeta tileMeta = boardMeta.getTile(row, column);
                PieceMeta pieceMeta = tileMeta.pieceMeta;
                if(pieceMeta != null){
                    piece = (GameObject)Instantiate(Resources.Load(getResourceColor(pieceMeta.playerId) + getResourceName(pieceMeta.pieceId)));
                    piece.transform.position = new Vector3(column*Sizes.TILE, row*Sizes.TILE, ZLayers.PIECE);
                    gameTile.piece = piece;
                }

                gameBoard[row, column] = gameTile;
                isBlack = !isBlack;
            }

            isBlack = !isBlack;
        }
    }
    void CheckTileRaycast()
    {
        if (!Input.mousePresent) return;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitInfo;
        if (Physics.Raycast(ray, out hitInfo))
        {
            //Debug.Log("Called");
            var obj = hitInfo.collider.gameObject;
            var tileCmp = obj.GetComponent<GameTile>();
            if (tileCmp == null) return;

            if (!tileCmp.Equals(curMouseOver))
            {
                if (curMouseOver != null)
                    curMouseOver.MouseLeave();
                curMouseOver = tileCmp;
                tileCmp.MouseOver();
            }

            //Debug.Log("Hit");
            //tileCmp.LightUp()
        }
        else
        {
            if (curMouseOver != null) curMouseOver.MouseLeave();
            curMouseOver = null;
        }
    }
Exemplo n.º 3
0
 public void addTile(GameTile tileTemplate, Data_GameTile tileOptions)
 {
     GameTile tile = (GameTile)Instantiate(tileTemplate);
     tile.name = ("Tile_"+tileOptions.position.x+","+tileOptions.position.y+","+tileOptions.position.z);
     tile.transform.parent = tileHolder.transform;
     //tile.myData.loadData(tileOptions.saveData());
     tile.myData = tileOptions;
     tiles.Add(tile.myData.position, tile);
     levelData.tiles.Add (tile.myData);
 }
Exemplo n.º 4
0
    public void RefreshPosition()
    {
        GameTile tile = gameManager.GetTile(this.GetCoordinates());

        if (tile != null)
        {
            Debug.Assert(tile.GetCharacter() == null || tile.GetCharacter() == this);
            if (tile.GetCharacter() != this)
            {
                Debug.LogError("Player moved to tile, but tile was not updated");
                tile.SetCharacter(this);
            }
        }
    }
Exemplo n.º 5
0
    //private
    private void AddAllNeighbours(ref List <GameTile> list, GameTile tile)
    {
        //GetAllTilesInRange helper function, returns a list containing the neighbours surrounding a tile
        List <GameTile> tileNeighbours = GetTileCardinalNeighbours(tile);

        foreach (GameTile neighbour in tileNeighbours)
        {
            if (!neighbour.IsMarked())
            {
                neighbour.SetIsMarked(true);
                list.Add(neighbour);
            }
        }
    }
Exemplo n.º 6
0
 private bool IsBorder(GameTile gameTile)
 {
     if (gameTile.OwnerId == BotId)
     {
         for (int i = 0; i < 6; i++)
         {
             if (GameField[GameFieldTiles.instance.OddrOffsetNeighbor(gameTile.LocalPlace, i)].OwnerId != BotId)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 7
0
    public override bool Check()
    {
        if ((destination - this.coordinates).sqrMagnitude != 1)
        {
            return(false);
        }
        GameTile tile = gameManager.GetTile(destination);

        if (tile == null || !tile.IsWalkable())
        {
            return(false);
        }
        return(true);
    }
Exemplo n.º 8
0
    protected IPath.SearchResult InitSeatch(Enemy owner, GameTile startPos, GameTile goalPos)
    {
        ResetSearch();
        PathNode ob = new PathNode();

        ob.fCost = 0f;
        ob.gCost = 0f;
        ob.tile  = startPos;
        openBlocks.Add(ob);

        IPath.SearchResult search = DoSearch(owner, goalPos);

        return(search);
    }
Exemplo n.º 9
0
    public bool TryGetGameTile(int index, out GameTile gameTile)
    {
        bool bExists = false;

        gameTile = null;

        if (index < board.Length)
        {
            gameTile = board[index];
            bExists  = true;
        }

        return(bExists);
    }
Exemplo n.º 10
0
    public void PlaceOnBoard(GameTile tile, bool flip, bool enemyT, bool ps)
    {
        //GetComponent<MeshRenderer>().enabled = false;
        //transform.GetChild(0).GetComponent<MeshRenderer>().enabled = false;
        pointScored            = ps;
        goingHome              = flip;
        enemyTile              = enemyT;
        armIK.counterOnTheMove = this;
        currentTile            = tile;
        onTheMove              = true;
        armIK.gameObject.GetComponent <Animator>().SetTrigger("BeginMovement");

        ikTarget.transform.position = transform.position;
    }
Exemplo n.º 11
0
    private void CmdHandleTouch(Vector3 origin, Vector3 direction, int touchPhase)
    {
        int score = 0;

        if (touchPhase == 0)
        {
            Ray        ray = new Ray(origin, direction);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 150f, _layerMask))
            {
                int hitLayerValue = ((1 << hit.collider.gameObject.layer) & _layerMask);
                if (hitLayerValue == TILE_LAYER)
                {
                    GameTile gt = hit.collider.gameObject.GetComponent <GameTile>();
                    if (!gt.touched)
                    {
                        gt.RpcChangeColor(_hitColor, gt.note.length);
                        gt.DisableTouch();
                        score        = gt.note.rewardValue;
                        playerScore += score;
                        string sound = gt.note.soundName;
                        if (!_soundManager)
                        {
                            _soundManager = GetComponent <SoundManager>();
                        }
                        _soundManager.RpcPlaySound(sound);
                    }
                }
                else if (hitLayerValue == UI_LAYER)
                {
                    return;
                }
                else if (hitLayerValue == TILE_RUNWAY_LAYER)
                {
                    CmdMissTile(hit.point, networkIdentity.isServer);
                    RpcReducePlayerScore();
                }
            }
        }
        if (!_gameUIManager)
        {
            _gameUIManager = GetComponent <GameUIManager>();
        }
        if (!player)
        {
            player = GetComponent <Player>();
        }
        _gameUIManager.SetScore(player.id, playerScore + score);
    }
Exemplo n.º 12
0
    internal void AddTile(GameTile tile)
    {
        if (!MergedTiles.Contains(tile))
        {
            MergedTiles.Add(tile);

            Health++;
            Power++;
        }

        foreach (var m_tile in MergedTiles)
        {
            m_tile.UpdateDamageText();
        }
    }
Exemplo n.º 13
0
    void SetGameTilePosition(Vector3Int nextPosition)
    {
        if (gameTile != null)
        {
            gameTile.DeleteUnit(this);
        }

        var newGameTile = Pathfinder.GetGameTile(nextPosition);

        if (newGameTile != null)
        {
            newGameTile.AddUnit(this);
            gameTile = newGameTile;
        }
    }
Exemplo n.º 14
0
    public void AddCapitalStructure(Vector3Int buildPos, int playerId)
    {
        GameTile gameTile = tiles[buildPos];

        gameTile.OwnerId           = playerId;
        gameTile.OwnerInfluence    = 1000;
        gameTile.GameFieldTileType = GameTile.TileType.Structure;
        gameTile.StructType        = GameTile.StructureType.Capital;
        gameTile.BuildingLvl       = 1;
        if (gameTile.tileGameObject != null)
        {
            Destroy(gameTile.tileGameObject);
        }
        gameTile.tileGameObject = Instantiate(capitalPrefab, tilemap.CellToLocal(buildPos), Quaternion.identity);
    }
Exemplo n.º 15
0
 Vector2Int GetTileCoordinate(GameTile tile)
 {
     for (int i = 0; i < gridTiles.Length; i++)
     {
         for (int j = 0; j < gridTiles[i].Length; j++)
         {
             if (gridTiles[i][j] == tile)
             {
                 return(new Vector2Int(i, j));
             }
         }
     }
     Debug.LogError("Error: couldn't find coordinates for tile " + tile, tile.gameObject);
     return(Vector2Int.zero);
 }
Exemplo n.º 16
0
    // Returns the highest-level GameTile that can be found at the given coordinates
    // (buildings and terrain will be returned first, then ground tiles)
    public GameTile GetGameTileAt(int xPos, int yPos)
    {
        Tile     currentTile = (Tile)terrainMap.GetTile(new Vector3Int(xPos, yPos, 1));
        GameTile foundTile   = GetGameTile(currentTile);

        if (foundTile != null)
        {
            return(foundTile);
        }

        currentTile = (Tile)groundMap.GetTile(new Vector3Int(xPos, yPos, 0));
        foundTile   = GetGameTile(currentTile);

        return(foundTile);
    }
Exemplo n.º 17
0
 public void Init(GameTile tile, GameBoard board, int actorId, GameObjectFactory factory, object[] payloads)
 {
     identity           = idGen++;
     this.Tile          = tile;
     this.Board         = board;
     this.OriginFactory = factory;
     transform.SetParent(tile.transform);
     transform.localPosition = new Vector3(0, 0, 0);
     Id = actorId;
     Init0(payloads);
     InitState();
     InitStateRank();
     board.AddActor(this);
     transform.parent = board.transform;
 }
Exemplo n.º 18
0
    public void LinkTile(GameTile nextTile)
    {
        PreviousTile = (_tileStack.Count > 0) ? _tileStack.Peek() : null;

        _tileStack.Push(nextTile);
        nextTile.FillTile(_goalTotal, PreviousTile);

        if (nextTile.GetType() == typeof(NumberTile))
        {
            PathTotal = (int)_stf.Eval(_equationGenerator.GetEquationString(this, true));
            _goalTotal.CheckComplete();
        }

        pathUpdatedEvent.Invoke();
    }
Exemplo n.º 19
0
 public void setSpaceWalking(bool enable)
 {
     foreach (Vector2Int pos in spaceTiles.Keys)
     {
         foreach (Vector2Int dir in VectorUtils.cardinalDirections)
         {
             GameTile tile = getTileAt(pos + dir);
             if (tile != null && tile.isSideADoor(-dir))
             {
                 spaceTiles[pos].setSpaceWalking(enable);
                 break;
             }
         }
     }
 }
Exemplo n.º 20
0
    override protected void FinishSearch(IPath.Path foundPath, GameTile startPos, GameTile goalPos)
    {
        GameTile tile = goalPos;

        while (true)
        {
            if (tile == null || tile == startPos)
            {
                break;
            }

            foundPath.path.Push(tile);
            tile = blockStates.parentTile[(int)tile.num];
        }
    }
Exemplo n.º 21
0
 GameObject tileContainsWEAKLING(GameTile gt)
 {
     if (gt != null)
     {
         List <GameObject> MEATS = GameManager.instance.GetPlayersInGame();
         for (int i = 0; i < MEATS.Count; i++)
         {
             if (MEATS [i].GetComponent <Player> () != null && RoundVectorToFives(MEATS [i].transform.position) == gt.transform.position)
             {
                 return(MEATS [i]);
             }
         }
     }
     return(null);        //tile contains nature nature not weak
 }
Exemplo n.º 22
0
    ///
    /// (Just get the total number of fish -- Don't need to store the tiles themselves)
    ///
    public int TallyLegalTiles(string sIDTileOrigin)
    {
        int totalNumFish = 0;

        GameTile startTile = m_refTM.tileTable[sIDTileOrigin];   // Get starting tile from ID

        // Traverse all legal paths and place tiles in list
        //
        foreach (ITileTraverse tile in startTile.AllPaths(m_refTM))
        {
            totalNumFish += tile.numFish;
        }

        return(totalNumFish);  // Return total number of fish on tiles -- List of tiles themselves stored in workTable
    }
Exemplo n.º 23
0
    public void UnlinkTile()
    {
        GameTile removedTile = _tileStack.Pop();

        if (removedTile.GetType() != typeof(NumberTile))
        {
            PathTotal = (int)_stf.Eval(_equationGenerator.GetEquationString(this, true));
        }

        removedTile.EmptyTile(_goalTotal);

        _goalTotal.CheckComplete();

        pathUpdatedEvent.Invoke();
    }
Exemplo n.º 24
0
 void HandleTouch()
 {
     GameTile tile = board.GetTile(TouchRay);
     if (tile != null)
     {
         if (Input.GetKey(KeyCode.LeftShift))
         {
             board.ToggleTower(tile, selectedTowerType);
         }
         else
         {
             board.ToggleWall(tile);
         }
     }
 }
Exemplo n.º 25
0
    private void _Load()
    {
        Debug.Log("Building map");

        for (int i = 0; i < mapWidth; i++)
        {
            for (int j = 0; j < mapHeight; j++)
            {
                GameObject instance = Instantiate(floorTiles[0]) as GameObject;
                GameTile   gt       = instance.GetComponent <GameTile>();
                gt.Load(new Point(i, j));
                tiles.Add(gt.pos, gt);
            }
        }
    }
Exemplo n.º 26
0
    private int countWaterNeighbours(GameTile tile)
    {
        //atempt water expansion helper count water tiles in cardinal directions
        int             count      = 0;
        List <GameTile> neighbours = board.GetTileCardinalNeighbours(tile);

        foreach (GameTile q in neighbours)
        {
            if (q.IsWater())
            {
                count++;
            }
        }
        return(count);
    }
Exemplo n.º 27
0
 private bool FreeSpace(RaycastHit[] hitElements)
 {
     foreach (RaycastHit element in hitElements)
     {
         GameTile tileInfo = element.transform.GetComponent <GameTile>();
         if (tileInfo != null)
         {
             if (!tileInfo.Free)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemplo n.º 28
0
 public MapObject(
     string name,
     string description,
     GameTile presentation,
     bool passable    = true,
     bool transparent = true,
     Func <Actor?, Point2i, GameState, bool>?interaction = null)
 {
     Name         = name;
     Description  = description;
     Presentation = presentation;
     Passable     = passable;
     Transparent  = transparent;
     Interaction  = interaction;
 }
Exemplo n.º 29
0
 void HandleAlternativeTouch()
 {
     GameTile tile = board.GetTile(TouchRay);
     if (tile != null)
     {
         if (Input.GetKey(KeyCode.LeftShift))
         {
             board.ToggleDestination(tile);
         }
         else
         {
             board.ToggleSpawnPoint(tile);
         }
     }
 }
Exemplo n.º 30
0
    private List <GameTile> GetFloorTilesAroundTile(GameTile tile)
    {
        //water expansion helper function get the floor tiles around a tile in the cardinal directions
        List <GameTile> neighbours      = board.GetTileCardinalNeighbours(tile);
        List <GameTile> validNeighbours = new List <GameTile>();

        foreach (GameTile q in neighbours)
        {
            if (q.OpenForPlacement())
            {
                validNeighbours.Add(q);
            }
        }
        return(validNeighbours);
    }
Exemplo n.º 31
0
 public void updateNewPlayerTile(GameTile newPlayerTile)
 {
     playerTile.SetIsOccupied(false);
     playerTile.SetIsWalkAble(true);
     playerTile.GetObject().GetComponent <SpriteRenderer>().sprite = playerTile.GetOriginalSprite();
     playerTile.GetObject().GetComponent <SpriteRenderer>().color  = playerTile.GetOriginalColor();
     playerTile = newPlayerTile;
     playerTile.GetObject().GetComponent <SpriteRenderer>().sprite = playerSprite;
     playerTile.GetObject().GetComponent <SpriteRenderer>().color  = playerColor;
     playerTile.SetIsOccupied(true);
     playerTile.SetIsWalkAble(false);
     playerTile.SetIsVisible(true);
     vision.UpdateVision(ref playerTile, ref map, 5);         //TODO:Make max view (5) publicly changeable
     vision.PostProcessingForPlayerView(ref playerTile, ref map);
 }
Exemplo n.º 32
0
    public List <GameTile> Neighbours(GameTile tile)
    {
        List <GameTile> ret = new List <GameTile>();
        CubeIndex       o;

        for (int i = 0; i < 6; i++)
        {
            o = tile.index + directions[i];
            if (tilesDictionary.ContainsKey(o.ToString()))
            {
                ret.Add(tilesDictionary[o.ToString()]);
            }
        }
        return(ret);
    }
Exemplo n.º 33
0
    private IEnumerator AttemptToHitTileCoroutine(GameTile gt)
    {
        yield return(new WaitForSeconds(_tapDelayTime));

        int chance = Random.Range(1, 8);

        if (chance % 5 > 0)
        {
            HitTile(gt);
        }
        else if (chance % 4 == 0)
        {
            MissTile();
        }
    }
Exemplo n.º 34
0
        public Entity(Game mGame, int mX, int mY, int mZ, string mName, bool mObstacle)
        {
            game = mGame;
            gameTile = game.GameTiles[mX, mY, mZ];
            x = mX;
            y = mY;
            z = mZ;
            startX = mX;
            startY = mY;
            startZ = mZ;
            name = mName;
            obstacle = mObstacle;
            uID = lastUID;
            lastUID++;

            game.LogAdd("#" + UID + ": new 'Entity' named '" + name + "' - (" + X + ";" + Y + ")", true);
        }
Exemplo n.º 35
0
        public MoveResult HandleMove(Player player, GameTile gameTile)
        {
            if (player == null) { throw new ArgumentNullException("Players was null"); }
            if (gameTile == GameTile.Unknown) { throw new ArgumentOutOfRangeException("GameTile was out of range"); }

            var moveManager = GetMoveManager(player);

            var attemptResult = moveManager.MakeMove(gameTile);
            var isAtEndOfSequence = moveManager.IsAtEndOfSequence;
            var lastMoveIndex = moveManager.LastMoveIndex;

            return new MoveResult
                       {
                           AttemptResult = attemptResult, 
                           IsAtEndOfSequence = isAtEndOfSequence,
                           CurrentLevel = lastMoveIndex
                       };
        }
    private void ProccesMouse()
    {
        var curMousePos = GetMousePosition();
        Vector2 vectorDir = new Vector2((curMousePos.x - _player.transform.position.x), (curMousePos.z - _player.transform.position.z));

        if (vectorDir.magnitude > 1 && vectorDir.magnitude < 2.5)
        {
            Vector2 moveOffset = GetHexDirection(vectorDir);
            var moveTarget = _gameManager.GameMap.GetTile(_playerPosition + moveOffset);

            if (moveTarget && moveTarget.GetComponent<GameTile>().CurrentTileStatus == GameTile.TileStatus.CLEAR)
            {
                _highlightedTile = moveTarget.GetComponent<GameTile>();
                _highlightedTile.Highlighted = true;

                if (Input.GetMouseButtonUp(0))
                {

                    if (moveTarget.GetComponent<GameTile>().IsHidden)
                        moveTarget.GetComponent<GameTile>().ShowObject();

                    if (_highlightedTile)
                    {
                        _highlightedTile.Highlighted = false;
                        _highlightedTile = null;
                    }

                    _player.SetMoveStart(moveTarget.transform.position);
                    _playerPosition += moveOffset;
                }
            }
        }
    }
Exemplo n.º 37
0
    protected override void ActivateBadTile(GameTile curTile)
    {
        if (_arrowTransform)
            _arrowTransform.gameObject.SetActive(false);

        if (!IsImune)
        {
            GameOver(false);
            Destroy(gameObject);
        }
        else
        {
            GameMap.LowerNeighbourDangerCounter(_playerController.PlayerPosition);
            HiddenTileList.Remove(HiddenTileList.Find(v => v == new Vector2(curTile.Q, curTile.R)));
            Destroy(curTile.GetComponent<GameTile>().HiddenObject);
            AudioManager.Instance.PlaySound("KrakenDiesSfx");
            ++CurKrakenAmmount;
        }
    }
Exemplo n.º 38
0
 protected override void ActivateImuneTile(GameTile curTile)
 {
     HiddenTileList.Remove(HiddenTileList.Find(v => v == new Vector2(curTile.Q, curTile.R)));
     AudioManager.Instance.PlaySound("GlassClink", 1.0f);
     if (RumLevel <= MaxRumStack)
         RumLevel++;
 }
Exemplo n.º 39
0
        private async Task HandleButtonPressedAsync(Player player, GameTile gameTilePressed, string successAudioFileName)
        {
            var result = _gameBoardEngine.HandleMove(player, gameTilePressed);

            if (result.AttemptResult == AttemptResult.Valid)
            {
                await _audioManager.Play(successAudioFileName);
                GameLevel = result.CurrentLevel;

                if ( result.IsAtEndOfSequence )
                {
                    _gameBoardEngine.ResetSequenceCounter(Player);

                    //Task.Delay(5000);

                    ShowPlayerSequence();
                }
            }
            else
            {
                await _audioManager.Play("Buzzer.mp3");
                StopGame();

                StartNewGameCommand.RaiseCanExecuteChanged();
            }
        }
Exemplo n.º 40
0
    protected override void ActivateTileKeg(GameTile curTile)
    {
        List<GameObject> tiles = new List<GameObject>();

        if (curTile)
        {
            HiddenTileList.Remove(HiddenTileList.Find(v => v == new Vector2(curTile.Q, curTile.R)));
        }

        foreach (var neighbour in GameMap.GetNeighBours(_playerController.PlayerPosition))
        {
            if (neighbour)
            {
                if (neighbour.GetComponent<GameTile>().IsHidden)
                {
                    neighbour.GetComponent<GameTile>().ShowEmphasis(3.0f);
                    tiles.Add(neighbour);
                }
                if (neighbour.GetComponent<GameTile>().ThisType == GameTile.TileType.BAD
                    && neighbour.GetComponent<GameTile>().CurrentTileStatus == GameTile.TileStatus.CLEAR
                    && !neighbour.GetComponent<GameTile>().IsActivated
                    && neighbour.GetComponent<GameTile>().IsHidden)
                {
                    ++CurKrakenAmmount;
                }

                neighbour.GetComponent<GameTile>().ShowObject();
                neighbour.GetComponent<GameTile>().ShowEmphasis(3.0f);

                switch (neighbour.GetComponent<GameTile>().ThisType)
                {
                    case GameTile.TileType.MAP:
                        if (!_tutorialIsShown[(int)TutorialInfo.MapActivate])
                            ShowTutorialInfo(TutorialInfo.Map, new List<GameObject>() { neighbour.gameObject });
                        break;
                    case GameTile.TileType.IMUNE:
                        if (!_tutorialIsShown[(int)TutorialInfo.ImmunityActivate])
                            ShowTutorialInfo(TutorialInfo.Immunity, new List<GameObject>() { neighbour.gameObject });
                        break;
                    case GameTile.TileType.POWDERKEG:
                        if (!_tutorialIsShown[(int)TutorialInfo.PowderkegActivate])
                            ShowTutorialInfo(TutorialInfo.Powderkeg, new List<GameObject>() { neighbour.gameObject });
                        break;
                    default:
                        ShowTutorialInfo((TutorialInfo)neighbour.GetComponent<GameTile>().ThisType + 1, new List<GameObject>() { neighbour.gameObject });
                        break;
                }

                HiddenTileList.Remove(HiddenTileList.Find(v => v == new Vector2(neighbour.GetComponent<GameTile>().Q, neighbour.GetComponent<GameTile>().R)));
            }
        }

        if (curTile)
        {
            ShowTutorialInfo(TutorialInfo.PowderkegActivate, tiles);
            _tutorialIsShown[(int)TutorialInfo.Powderkeg] = true;
        }

        AudioManager.Instance.PlaySound("ExplosionSfx", 0.35f);
    }
Exemplo n.º 41
0
    protected override void ActivateImuneTile(GameTile curTile)
    {
        HiddenTileList.Remove(HiddenTileList.Find(v => v == new Vector2(curTile.Q, curTile.R)));
        AudioManager.Instance.PlaySound("GlassClink", 1.0f);
        if (RumLevel <= MaxRumStack)
            RumLevel++;

        ShowTutorialInfo(TutorialInfo.ImmunityActivate, null);
        _tutorialIsShown[(int)TutorialInfo.Immunity] = true;
    }
Exemplo n.º 42
0
 protected virtual void ActivateTileMap(GameTile curTile)
 {
 }
Exemplo n.º 43
0
 protected virtual void ActivateBadTile(GameTile curTile)
 {
 }
Exemplo n.º 44
0
 protected virtual void ActivateImuneTile(GameTile curTile)
 {
 }
Exemplo n.º 45
0
 protected virtual void ActivateTreasureTile(GameTile curTile)
 {
 }
    // Update is called once per frame
    void Update()
    {
        if (_highlightedTile)
        {
            _highlightedTile.Highlighted = false;
            _highlightedTile = null;
        }

        if (_player.IsMoving || _gameManager.GameState != GameState.Play)
            return;

        #if UNITY_IOS || UNITY_ANDROID

        ////
        /// Mobile Only
        ///

        if (Input.touchCount == 1)
        {
            if (!_isSwiping)
            {
                _startSwipePos = Input.GetTouch(0).position;
                _isSwiping = true;
            }
        }

        if (_isSwiping)
        {
            if (Input.touchCount > 0)
            {
                _endSwipePos = Input.GetTouch(0).position;
                if (Vector3.Distance(_endSwipePos, _startSwipePos) > SwipeMoveTreshold)
                {
                    Vector2 moveOffset = GetHexDirection(_endSwipePos - _startSwipePos);
                    var moveTarget = _gameManager.GameMap.GetTile(_playerPosition + moveOffset);

                    if (moveTarget && moveTarget.GetComponent<GameTile>().CurrentTileStatus == GameTile.TileStatus.CLEAR)
                    {
                        _highlightedTile = moveTarget.GetComponent<GameTile>();
                        _highlightedTile.Highlighted = true;
                    }
                }
            }
            else
            {
                if (_highlightedTile)
                {
                    _highlightedTile.Highlighted = false;
                    _highlightedTile = null;
                }

                if (Vector3.Distance(_endSwipePos, _startSwipePos) > SwipeMoveTreshold)
                {
                    Vector2 moveOffset = GetHexDirection(_endSwipePos - _startSwipePos);
                    var moveTarget = _gameManager.GameMap.GetTile(_playerPosition + moveOffset);

                    if (moveTarget && moveTarget.GetComponent<GameTile>().CurrentTileStatus == GameTile.TileStatus.CLEAR)
                    {
                        EndSwipe(moveTarget, moveOffset);
                    }
                }
                else
                {
                    ProcessMobileClick();
                }

                _isSwiping = false;
            }
        }

        #else

        ///
        /// Desktop only
        ///

        if (_enableSwipe)
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (!_isSwiping)
                {
                    _startSwipePos = Input.mousePosition;
                    _isSwiping = true;
                }
            }

            if (_isSwiping)
            {
                Vector3 curTouchPos = Input.mousePosition;

                if (Vector3.Distance(curTouchPos, _startSwipePos) > SwipeMoveTreshold)
                {
                    Vector2 moveOffset = GetHexDirection(curTouchPos - _startSwipePos);
                    var moveTarget = _gameManager.GameMap.GetTile(_playerPosition + moveOffset);

                    if (moveTarget && moveTarget.GetComponent<GameTile>().CurrentTileStatus == GameTile.TileStatus.CLEAR)
                    {
                        _highlightedTile = moveTarget.GetComponent<GameTile>();
                        _highlightedTile.Highlighted = true;

                        if (Input.GetMouseButtonUp(0))
                        {
                            _endSwipePos = curTouchPos;
                            if (_highlightedTile)
                            {
                                _highlightedTile.Highlighted = false;
                                _highlightedTile = null;
                            }
                            EndSwipe(moveTarget, moveOffset);
                            _isSwiping = false;
                        }
                    }
                }

                if (Input.GetMouseButtonUp(0))
                {
                    if (_highlightedTile)
                    {
                        _highlightedTile.Highlighted = false;
                        _highlightedTile = null;
                    }
                    _isSwiping = false;
                }

            }
        }
        else
        {
            if (!_player.IsMoving)
            {
                ProccesMouse();
            }
        }

        if (_rightClickCounter <= 0)
        {
            if (Input.GetMouseButtonDown(1))
            {
                ProcessRightMouseClick();
                _rightClickCounter = TimeBetweenRightClick;
            }
        }

        if (_rightClickCounter > 0)
        {
            _rightClickCounter -= Time.deltaTime;
        }

        #endif
    }
Exemplo n.º 47
0
	private void InstantiateCells(){
//	Instantiates the squares and assigns their x and y cordinate values relative to the memory matrix. 
		for (int i = 0; i <numCols; i++){
			for (int j = 0; j<numRows; j++){
				squareObject = (GameObject)Instantiate(whiteSquare, new Vector3((float)i-(float)numCols/2,(float)j-(float)numRows/2,0), Quaternion.identity);
				//objectMatrix[i,j] = squareObject;

				objectMatrix[i,j] = new GameTile(squareObject, i , j);



			}
		}
	}
Exemplo n.º 48
0
        public AttemptResult MakeMove( GameTile move )
        {
            var gameSequence = GameSequence[LastMoveIndex];

            if ( gameSequence == move )
            {
                LastMoveIndex++;

                return AttemptResult.Valid;
            }

            return AttemptResult.InValid;
        }
Exemplo n.º 49
0
 public bool IsTimberAvailable(GameTile tile)
 {
     throw new NotImplementedException ();
     //return tile.Timber > 0;
 }
Exemplo n.º 50
0
    protected override void ActivateTreasureTile(GameTile curTile)
    {
        HiddenTileList.Remove(HiddenTileList.Find(v => v == new Vector2(curTile.Q, curTile.R)));
        AudioManager.Instance.PlaySound("coinSfx", 1.2f);
        ++CollectedTreasureAmount;

        if (TreasureParticles != null)
        {
            var ps = Instantiate(TreasureParticles, curTile.transform.position, Quaternion.Euler(-90, 0, 0)) as ParticleSystem;
            ps.Play();
            Destroy(ps, 2.0f);
        }
    }
Exemplo n.º 51
0
 public void AddMove( GameTile move )
 {
     GameSequence.Add(move);
 }
Exemplo n.º 52
0
    protected override void ActivateTileKeg(GameTile curTile)
    {
        List<GameObject> tiles = new List<GameObject>();

        if (curTile)
        {
            HiddenTileList.Remove(HiddenTileList.Find(v => v == new Vector2(curTile.Q, curTile.R)));
        }

        foreach (var neighbour in GameMap.GetNeighBours(_playerController.PlayerPosition))
        {
            if (neighbour)
            {
                if (neighbour.GetComponent<GameTile>().IsHidden)
                {
                    neighbour.GetComponent<GameTile>().ShowEmphasis(3.0f);
                    tiles.Add(neighbour);
                }
                if (neighbour.GetComponent<GameTile>().ThisType == GameTile.TileType.BAD
                    && neighbour.GetComponent<GameTile>().CurrentTileStatus == GameTile.TileStatus.CLEAR
                    && !neighbour.GetComponent<GameTile>().IsActivated
                    && neighbour.GetComponent<GameTile>().IsHidden)
                {
                    ++CurKrakenAmmount;
                }

                neighbour.GetComponent<GameTile>().ShowObject();
                neighbour.GetComponent<GameTile>().ShowEmphasis(3.0f);

                HiddenTileList.Remove(HiddenTileList.Find(v => v == new Vector2(neighbour.GetComponent<GameTile>().Q, neighbour.GetComponent<GameTile>().R)));
            }
        }

        AudioManager.Instance.PlaySound("ExplosionSfx", 0.35f);
    }
Exemplo n.º 53
0
 void SelectNewTile(Vector2 newPos)
 {
     if (selectedTile != null)
                     selectedTile.DeSelect ();
             if (newPos != -Vector2.one) {
                     selectedTile = tiles [(int)newPos.x, (int)newPos.y];
                     selectedTile.Select ();
             } else {
                     selectedTile = null;
             }
 }
Exemplo n.º 54
0
    protected override void ActivateTileMap(GameTile curTile)
    {
        if (curTile)
        {
            HiddenTileList.Remove(HiddenTileList.Find(v => v == new Vector2(curTile.Q, curTile.R)));
        }

        AudioManager.Instance.PlaySound("ShieldGongSfx", 0.6f);
        List<GameObject> tiles = new List<GameObject>(MapTilePower);

        for (int i = 0; i < MapTilePower; ++i)
        {
            if (HiddenTileList.Count <= 0)
                return;

            int randomIndex = Random.Range(0, HiddenTileList.Count);
            var tileCoords = HiddenTileList[randomIndex];

            var tile = GameMap.GetTile(tileCoords);
            if (tile != null)
            {
                tiles.Add(tile);
                tile.GetComponent<GameTile>().ShowObject();
                tile.GetComponent<GameTile>().ShowEmphasis(3.0f);
                switch (tile.GetComponent<GameTile>().ThisType)
                {
                    case GameTile.TileType.MAP:
                        if (!_tutorialIsShown[(int)TutorialInfo.MapActivate])
                            ShowTutorialInfo(TutorialInfo.Map, new List<GameObject>() { tile.gameObject });
                        break;
                    case GameTile.TileType.IMUNE:
                        if (!_tutorialIsShown[(int)TutorialInfo.ImmunityActivate])
                            ShowTutorialInfo(TutorialInfo.Immunity, new List<GameObject>() { tile.gameObject });
                        break;
                    case GameTile.TileType.POWDERKEG:
                        if (!_tutorialIsShown[(int)TutorialInfo.PowderkegActivate])
                            ShowTutorialInfo(TutorialInfo.Powderkeg, new List<GameObject>() { tile.gameObject });
                        break;
                    default:
                        ShowTutorialInfo((TutorialInfo)tile.GetComponent<GameTile>().ThisType + 1, new List<GameObject>() { tile.gameObject });
                        break;
                }

                if (tile.GetComponent<GameTile>().ThisType == GameTile.TileType.BAD && tile.GetComponent<GameTile>().CurrentTileStatus == GameTile.TileStatus.CLEAR)
                    ++CurKrakenAmmount;
                HiddenTileList.RemoveAt(randomIndex);
            }
        }

        ShowTutorialInfo(TutorialInfo.MapActivate, tiles);
        _tutorialIsShown[(int)TutorialInfo.Map] = true;
    }
Exemplo n.º 55
0
    protected override void ActivateTileMap(GameTile curTile)
    {
        if (curTile)
        {
            HiddenTileList.Remove(HiddenTileList.Find(v => v == new Vector2(curTile.Q, curTile.R)));
        }

        AudioManager.Instance.PlaySound("ShieldGongSfx", 0.6f);
        List<GameObject> tiles = new List<GameObject>(MapTilePower);

        for (int i = 0; i < MapTilePower; ++i)
        {
            if (HiddenTileList.Count <= 0)
                return;

            int randomIndex = Random.Range(0, HiddenTileList.Count);
            var tileCoords = HiddenTileList[randomIndex];

            var tile = GameMap.GetTile(tileCoords);
            if (tile != null)
            {
                tiles.Add(tile);
                tile.GetComponent<GameTile>().ShowObject();
                tile.GetComponent<GameTile>().ShowEmphasis(3.0f);

                if (tile.GetComponent<GameTile>().ThisType == GameTile.TileType.BAD && tile.GetComponent<GameTile>().CurrentTileStatus == GameTile.TileStatus.CLEAR)
                    ++CurKrakenAmmount;
                HiddenTileList.RemoveAt(randomIndex);
            }
        }
    }