예제 #1
0
 public void AddTileType(TileType tileType)
 {
     if (!tileTypes.ContainsKey(tileType))
     {
         tileTypes[tileType] = 1;
     }
     else
     {
         tileTypes[tileType]++;
     }
     tileEvent.Invoke(tileType);
 }
예제 #2
0
    ////Event handler
    //void OnMouseUp()
    //{
    //    clicked.Invoke(this);
    //}

    public void OnPointerClick(PointerEventData eventData)
    {
        if (eventData.button == PointerEventData.InputButton.Left)
        {
            clicked.Invoke(this);
        }
    }
예제 #3
0
    /// <summary>Sets the grid space as occupied with the given character grid object.</summary>
    /// <param name="newObject">Parameter for the grid object that will occupy the grid space.</param>
    /// <returns>Returns true if the grid object is not null and returns false if it is null.</returns>
    public bool OccupySpace(GridObject newObject)
    {
        if (newObject != null)
        {
            // Remove current occupant if there is one
            if (HasGridObject())
            {
                UnoccupySpace();
            }

            gridObject = newObject;
            if (IsObjectType(ObjectType.Wall))
            {
                SetWallTriggers();
                UpdateGridButtonPosition();
            }
            if (GameToolTipManager.Instance.IsActive() && GameToolTipManager.Instance.IsShowingToolTip(this))
            {
                GameToolTipManager.Instance.Deactivate();
                GameToolTipManager.Instance.Activate(this);
            }

            // Call on Enter
            onEnter?.Invoke(this);
            return(true);
        }
        Debug.LogWarning("WARNING: Grid Object Passed to Grid Space is null!");
        return(false);
    }
예제 #4
0
 public void BoosterGoOff()
 {
     if (boosterEvent != null && boosterTile != null)
     {
         boosterEvent.Invoke(boosterTile);
     }
 }
예제 #5
0
    public void Capture(Tile newBorder, UnityAction <WorldTile> capturedCallback)
    {
        PlayerBorderTilemap.SetTile(LocalPlace, newBorder);

        tileCaptured.Invoke(this);
        tileCaptured.RemoveAllListeners();
        tileCaptured.AddListener(capturedCallback);
    }
예제 #6
0
    public static void TriggerEvent(string eventName, TaskableBase location)
    {
        TileEvent thisEvent = null;

        if (instance.tileEventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(location);
        }
    }
예제 #7
0
    private void OnMouseExit()
    {
        //Conditions: 1. Must have tile selected 2. this must not be the one selected already
        if (boardHandler.Tiles.Count == 0 || boardHandler.Tiles.Contains(this) == false || boardHandler.Tiles.First() == this)
        {
            return;
        }

        //Call Event
        OnDisconnectTile.Invoke(this);
    }
예제 #8
0
    private void OnMouseEnter()
    {
        //Conditions: 1. Must have tile selected 2
        if (boardHandler.Tiles.Count == 0)
        {
            return;
        }

        //Call Event
        OnConnectTile.Invoke(this);
    }
예제 #9
0
    IEnumerator MoveTo(Vector3 targetPosition)
    {
        NewLocation     = targetPosition;
        InitialLocation = targetPosition;

        while (true)
        {
            yield return(new WaitForEndOfFrame());

            if (Vector3.Distance(rectTransform.localPosition, NewLocation) > MINIMUM_DIST)
            {
                rectTransform.localPosition = Vector3.MoveTowards(rectTransform.localPosition, NewLocation, Speed);
            }
            else
            {
                OnReachLocation.Invoke(this);
                yield break;
            }
        }
    }
예제 #10
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector3    pos           = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector3Int mousePosition = new Vector3Int((int)pos.x, (int)pos.y, 0);
            TileBase   tile          = tilemap.GetTile(mousePosition);

            if (tile != null)
            {
                Debug.Log(tile.name + " clicked");
                for (int i = 0; i < hexTypes.Count; i++)
                {
                    if (tile.name == hexTypes[i].name)
                    {
                        TileClicked.Invoke(hexTypes[i], mousePosition);
                    }
                }
            }
        }
    }
예제 #11
0
 // Start is called before the first frame update
 void Awake()
 {
     tileCreated.Invoke(this);
 }
예제 #12
0
 public void Buy(GameObject buyer)
 {
     ChangeState(InteriorTileState.Opend);
     GetComponent <BoxCollider2D>().enabled = false;
     onBuy.Invoke(this);
 }
예제 #13
0
 private void OnMouseDown()
 {
     //Call Event
     OnSelectTile.Invoke(this);
 }
예제 #14
0
 private void OnMouseUp()
 {
     //Call Event
     OnDeselectTile.Invoke(this);
 }
예제 #15
0
파일: Army.cs 프로젝트: SirGavin/MyRepo
 public void MoveToTile(WorldTile tile)
 {
     movement--;
     transform.position = new Vector3(tile.WorldLocation.x, tile.WorldLocation.y, -9);
     captureTile.Invoke(tile);
 }
예제 #16
0
    private void Update()
    {
        Vector2 cameraPositionInMeters = new Vector2(Camera.main.transform.position.x, Camera.main.transform.position.z);

        cameraPositionInMeters += OriginInMeters;
        cameraPositionInMeters += new Vector2(-NumericConstants.TILE_SIZE, NumericConstants.TILE_SIZE);

        Tile currentTile = GeoPositioningHelper.GetTileFromCoordinate(
            GeoPositioningHelper.GetCoordinateFromMeters(cameraPositionInMeters),
            Zoom);

        if (Tilemap.CenterTile != currentTile)
        {
            Tilemap.UpdateCenterTile(currentTile);

            for (int i = 0; i < osmFileParsers.Count; i++)
            {
                if (Tilemap.IsTileOnMap(osmFileParsers[i].Tile))
                {
                    osmFileParsers.RemoveAt(i);
                    break;
                }
            }

            for (int i = 0; i < osmGeoJSONParsers.Count; i++)
            {
                if (Tilemap.IsTileOnMap(osmGeoJSONParsers[i].Tile))
                {
                    osmGeoJSONParsers.RemoveAt(i);
                    break;
                }
            }
        }

        if (Tilemap.HasTilesToRemove())
        {
            OnTileRemoved.Invoke(Tilemap.DequeueTileToRemove());
        }

        if (Tilemap.HasTilesToVisualize())
        {
            DownloadAndVisualizeTile(Tilemap.DequeueTileToVisualize());
        }

        for (int i = 0; i < osmFileParsers.Count; i++)
        {
            if (osmFileParsers[i].IsCompleted)
            {
                OnOsmFileParsed.Invoke(osmFileParsers[i]);
                osmFileParsers.RemoveAt(i);
                break;
            }
        }

        for (int i = 0; i < osmGeoJSONParsers.Count; i++)
        {
            if (osmGeoJSONParsers[i].IsCompleted)
            {
                OnGeoJSONParsed.Invoke(osmGeoJSONParsers[i]);
                osmGeoJSONParsers.RemoveAt(i);
                break;
            }
        }
    }