Esempio n. 1
0
    /// <summary>
    /// 버프 타워 초기화 함수.
    /// </summary>
    /// <param name="cellData"></param>
    /// <returns></returns>
    public override bool Initialize(string cellData)
    {
        if (!base.Initialize(cellData))
        {
            return(false);
        }

        CellClass currentCell = GetComponentInParent <CellClass>();

        if (currentCell == null)
        {
            Debug.Log("Failed to Get current Cell");
            return(false);
        }
        mCurrentCellX = currentCell.GetCellX();
        mCurrentCellY = currentCell.GetCellY();
        mMapSizeX     = currentCell.GetMap().GetMapSizeX();
        mMapSizeY     = currentCell.GetMap().GetMapSizeY();

        mObjectPool    = GameManager.Instance.GetObjectPool();
        mEffectObjects = new List <GameObject>();

        mTargetPositions = GetTargetPositions();

        return(true);
    }
Esempio n. 2
0
    /// <summary>
    /// 거리 가져오기.
    /// </summary>
    /// <param name="nodeA"></param>
    /// <param name="nodeB"></param>
    /// <returns></returns>
    private int GetDistance(CellClass nodeA, CellClass nodeB)
    {
        int distX = Mathf.Abs(nodeA.GetCellX() - nodeB.GetCellX());
        int distY = Mathf.Abs(nodeA.GetCellY() - nodeB.GetCellY());

        return(10 * distX + 10 * distY);
    }
Esempio n. 3
0
 /// <summary>
 /// 타워 파괴 함수.
 /// </summary>
 /// <param name="cell"></param>
 public virtual void DestroyTower(CellClass cell)
 {
     cell.GetMap().SetMapData(cell.GetCellX(), cell.GetCellY(), null);
     cell.GetMap().RemoveTower(this);
     GameManager.Instance.GetPlayerInfo().Gold += Mathf.RoundToInt(mPrice * 0.5f);
     StartCoroutine(DestoryCoroutine());
 }
Esempio n. 4
0
    /// <summary>
    /// 타워 짓는 함수.
    /// </summary>
    /// <param name="cell"></param>
    /// <param name="cellData"></param>
    /// <returns></returns>
    public virtual bool Build(CellClass cell, string cellData)
    {
        transform.localPosition = Vector3.zero;
        mOriginScale            = Vector3.one * 2.0f;

        mObjectPool = GameManager.Instance.GetObjectPool();
        if (mObjectPool == null)
        {
            Debug.Log("Failed Get Object Pool");
            return(false);
        }

        mTowerData = null;
        if (!mObjectPool.TowerDataDictionary.ContainsKey(cellData))
        {
            Debug.Log("Failed Find TowerData in TowerDataDictionary");
            return(false);
        }

        mTowerData = mObjectPool.TowerDataDictionary[cellData];

        mPrice     = mTowerData.Price;
        mTowerType = mTowerData.TOWERTYPE;

        cell.GetMap().SetMapData(cell.GetCellX(), cell.GetCellY(), mTowerData.Towerkey);
        StopCoroutine(ApperanceAnim());
        StartCoroutine(ApperanceAnim());

        return(true);
    }
Esempio n. 5
0
    /// <summary>
    /// 주변 이웃 Cell가져오기.
    /// </summary>
    /// <param name="node"></param>
    /// <returns></returns>
    public List <CellClass> GetNeighbours(CellClass node)
    {
        List <CellClass> neighbours = new List <CellClass>();

        // Left
        if (node.GetCellX() - 1 >= 0)
        {
            neighbours.Add(mMap[node.GetCellX() - 1, node.GetCellY()]);
        }
        // Right
        if (node.GetCellX() + 1 < mMapSizeX)
        {
            neighbours.Add(mMap[node.GetCellX() + 1, node.GetCellY()]);
        }
        // Up
        if (node.GetCellY() - 1 >= 0)
        {
            neighbours.Add(mMap[node.GetCellX(), node.GetCellY() - 1]);
        }
        // Down
        if (node.GetCellY() + 1 < mMapSizeY)
        {
            neighbours.Add(mMap[node.GetCellX(), node.GetCellY() + 1]);
        }

        return(neighbours);
    }