Beispiel #1
0
    void OnMoveAllWall()
    {
        //print("OnMoveAllWall");
        //m_EnableBuildAll = true;
        for (int i = 0; i < SceneManager.Instance.SelectedAllWallList.Count; i++)
        {
            WallBehavior wallBehavior = SceneManager.Instance.SelectedAllWallList[i];
            if (wallBehavior.FirstZoneIndex.Equals(wallBehavior.BuildingLogicData.BuildingPosition))
            {
                if (wallBehavior.IsBuild)
                {
                    wallBehavior.UnBuild();
                    this.SetSelectWallState();
                }
            }
            UIManager.Instance.HidePopuBtnByCurrentSelect(true);
            List <UICamera.MouseOrTouch> mouseOrTouchList = new List <UICamera.MouseOrTouch>(base.MouseOrTouchDictionary.Values);
            TilePosition touchDownZone = PositionConvertor.GetBuildingTileIndexFromScreenPosition(mouseOrTouchList[0].pos);
            TilePosition offsetZone    = touchDownZone - base.TouchDownZone;

            if (!((wallBehavior.FirstZoneIndexPrevious + offsetZone).Equals(wallBehavior.FirstZoneIndex)))
            {
                AudioController.Play("BuildingMoving");
            }
            wallBehavior.FirstZoneIndex = wallBehavior.FirstZoneIndexPrevious + offsetZone;
            Vector3 position = PositionConvertor.GetWorldPositionByBuildingTileIndex(wallBehavior.FirstZoneIndex);
            position.z = wallBehavior.BUILDING_PICK_AXIS_Z;
            wallBehavior.transform.position = position;
            wallBehavior.CheckTile();
        }
    }
Beispiel #2
0
    private void BreakWallTile(string objName)
    {
        GameObject objFind = GameObject.Find(objName);

        if (objFind)
        {
            WallBehavior wallInfo = objFind.GetComponent <WallBehavior>();
            wallInfo.TryBreakWall();
        }
    }
Beispiel #3
0
    public void OnUnSelectAllWall(bool isCancel)
    {
        bool enableBuild = SceneManager.Instance.GetAllBuildingEnableState();

        for (int i = 0; i < SceneManager.Instance.SelectedAllWallList.Count; i++)
        {
            WallBehavior wallBehavior = SceneManager.Instance.SelectedAllWallList[i];
            wallBehavior.SetArrowState(false);
            wallBehavior.IsClick = false;
            this.RebuildWall(wallBehavior, enableBuild);
            wallBehavior.OnActiveBuildingFX(false);
            wallBehavior.AjustBoxColliderSize(false);
        }
        //this.m_EnableBuildAll = false;
        SceneManager.Instance.DestroyBuildingBorder();
        UIManager.Instance.HidePopuBtnByCurrentSelect(isCancel);
        SceneManager.Instance.ClearAllWallList();
    }
Beispiel #4
0
 void Attack()
 {
     if (myCollider.IsTouchingLayers(LayerMask.GetMask("Structure")))
     {
         if (!target)
         {
             return;
         }
         WallBehavior targetScript = target.GetComponent <WallBehavior>();
         if (targetScript != null)
         {
             targetScript.TakeDamage(strength);
         }
     }
     if (myCollider.IsTouchingLayers(LayerMask.GetMask("Player")))
     {
         if (!target)
         {
             return;
         }
         PlayerMovement targetScript = target.GetComponent <PlayerMovement>();
         if (targetScript != null)
         {
             targetScript.TakeDamage(strength);
         }
     }
     if (myCollider.IsTouchingLayers(LayerMask.GetMask("Enemy")))
     {
         if (!target)
         {
             return;
         }
         Zombie targetScript = target.GetComponent <Zombie>();
         if (targetScript != null)
         {
             targetScript.TakeDamage(strength);
         }
     }
     if (target == null)
     {
         isAttacking = false;
     }
 }
Beispiel #5
0
    WallBehavior FindNeighourWallBehavior(BuildingObstacleDirection wallDirection, TilePosition refTilePosition, int index)
    {
        TilePosition tilePositionNext = null;
        GameObject   go = null;

        switch (wallDirection)
        {
        case BuildingObstacleDirection.Top:
            tilePositionNext = new TilePosition(refTilePosition.Column, refTilePosition.Row + index);
            break;

        case BuildingObstacleDirection.Bottom:
            tilePositionNext = new TilePosition(refTilePosition.Column, refTilePosition.Row - index);
            break;

        case BuildingObstacleDirection.Left:
            tilePositionNext = new TilePosition(refTilePosition.Column - index, refTilePosition.Row);
            break;

        case BuildingObstacleDirection.Right:
            tilePositionNext = new TilePosition(refTilePosition.Column + index, refTilePosition.Row);
            break;
        }
        if (tilePositionNext.Row < 0 || tilePositionNext.Column < 0 || tilePositionNext.Row >= ClientSystemConstants.BUILDING_TILE_MAP_SIZE.height || tilePositionNext.Column >= ClientSystemConstants.BUILDING_TILE_MAP_SIZE.width)
        {
            return(null);
        }
        go = SceneManager.Instance.GetBuildingObjectFromBuildingObstacleMap(tilePositionNext.Row, tilePositionNext.Column);
        if (go == null)
        {
            return(null);
        }
        else
        {
            WallBehavior bhv = go.GetComponent <WallBehavior>();
            if (bhv.BuildingType == BuildingType.Wall)
            {
                return(bhv);//(WallBehavior)bhv.BuildingCommon;
            }
        }
        return(null);
    }
Beispiel #6
0
    public void OnSelectWallRow()
    {
        print("OnSelectWallRow");
        SceneManager.Instance.ClearAllWallList();
        int rightIndex = 1;

        while (FindNeighourWallNotNull(BuildingObstacleDirection.Right, rightIndex).HasValue)
        {
            //if (FindNeighourWall(BuildingObstacleDirection.Right, rightIndex).Value)
            {
                WallBehavior wallBehavior = this.GetWallBehavior(BuildingObstacleDirection.Right, rightIndex);
                wallBehavior.SetTileState(true);
                SceneManager.Instance.WallListRight.Add(wallBehavior);
                wallBehavior.AjustBoxColliderSize();
            }
            rightIndex++;
        }
        int leftIndex = 1;

        while (FindNeighourWallNotNull(BuildingObstacleDirection.Left, leftIndex).HasValue)
        {
            //if (FindNeighourWall(BuildingObstacleDirection.Left, leftIndex).Value)
            {
                WallBehavior wallBehavior = this.GetWallBehavior(BuildingObstacleDirection.Left, leftIndex);
                wallBehavior.SetTileState(true);
                SceneManager.Instance.WallListLeft.Add(wallBehavior);
                wallBehavior.AjustBoxColliderSize();
            }
            leftIndex++;
        }
        if (SceneManager.Instance.WallListRight.Count > 0 || SceneManager.Instance.WallListLeft.Count > 0)
        {
            base.SetTileState(true);
            SceneManager.Instance.SelectedAllWallList.AddRange(SceneManager.Instance.WallListLeft);
            SceneManager.Instance.SelectedAllWallList.Add(this);
            SceneManager.Instance.SelectedAllWallList.AddRange(SceneManager.Instance.WallListRight);
            SceneManager.Instance.WallSelectedMode = WallSelectedMode.Row;
            UIManager.Instance.HidePopuBtnByCurrentSelect(true);
            UIManager.Instance.ShowPopupBtnByCurrentSelect();
            this.SetArrowPosition(false);
            //this.m_EnableBuildAll = true;
            return;
        }

        int topIndex = 1;

        while (FindNeighourWallNotNull(BuildingObstacleDirection.Top, topIndex).HasValue)
        {
            //if (FindNeighourWall(BuildingObstacleDirection.Top, topIndex).Value)
            {
                WallBehavior wallBehavior = this.GetWallBehavior(BuildingObstacleDirection.Top, topIndex);
                wallBehavior.SetTileState(true);
                SceneManager.Instance.WallListTop.Add(wallBehavior);
                wallBehavior.AjustBoxColliderSize();
            }
            topIndex++;
        }
        int bottomIndex = 1;

        while (FindNeighourWallNotNull(BuildingObstacleDirection.Bottom, bottomIndex).HasValue)
        {
            //if (FindNeighourWall(BuildingObstacleDirection.Bottom, bottomIndex).Value)
            {
                WallBehavior wallBehavior = this.GetWallBehavior(BuildingObstacleDirection.Bottom, bottomIndex);
                wallBehavior.SetTileState(true);
                SceneManager.Instance.WallListBottom.Add(wallBehavior);
                wallBehavior.AjustBoxColliderSize();
            }
            bottomIndex++;
        }
        if (SceneManager.Instance.WallListTop.Count > 0 || SceneManager.Instance.WallListBottom.Count > 0)
        {
            base.SetTileState(true);
            SceneManager.Instance.SelectedAllWallList.AddRange(SceneManager.Instance.WallListTop);
            SceneManager.Instance.SelectedAllWallList.Add(this);
            SceneManager.Instance.SelectedAllWallList.AddRange(SceneManager.Instance.WallListBottom);
            SceneManager.Instance.WallSelectedMode = WallSelectedMode.Column;

            UIManager.Instance.HidePopuBtnByCurrentSelect(true);
            UIManager.Instance.ShowPopupBtnByCurrentSelect();
            this.SetArrowPosition(false);
            //this.m_EnableBuildAll = true;
        }
    }
Beispiel #7
0
 void Repair(WallBehavior wall)
 {
     //reuses attack animation, though not an actual attack
     wall.GetRepaired(strength * healingFactor);
 }