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
 void OnMoveWall()
 {
     print("OnMoveWall");
     if (base.FirstZoneIndex.Equals(base.FirstZoneIndexPrevious))//this.BuildingBehavior.BuildingLogicData.BuildingPosition))
     {
         if (base.IsBuild)
         {
             base.UnBuild();
             UIManager.Instance.HidePopuBtnByCurrentSelect(true);
         }
     }
     if (base.MouseOrTouchDictionary.Count > 0)
     {
         List <UICamera.MouseOrTouch> mouseOrTouchList = new List <UICamera.MouseOrTouch>(base.MouseOrTouchDictionary.Values);
         TilePosition touchDownZone = PositionConvertor.GetBuildingTileIndexFromScreenPosition(mouseOrTouchList[0].pos);
         TilePosition offsetZone    = touchDownZone - base.TouchDownZone;
         if (!((base.FirstZoneIndexPrevious + offsetZone).Equals(base.FirstZoneIndex)))
         {
             AudioController.Play("BuildingMoving");
         }
         base.FirstZoneIndex = base.FirstZoneIndexPrevious + offsetZone;
         Vector3 position = PositionConvertor.GetWorldPositionByBuildingTileIndex(base.FirstZoneIndex);
         position.z = base.BUILDING_PICK_AXIS_Z;
         this.transform.position = position;
         //this.BuildingBehavior.EnableCreate =
         base.CheckTile();
         base.SetButtonOkState();
     }
 }
Beispiel #3
0
 void OnMoveBuilding()
 {
     if (base.MouseOrTouchDictionary.Count > 0)
     {
         List <UICamera.MouseOrTouch> mouseOrTouchList = new List <UICamera.MouseOrTouch>(base.MouseOrTouchDictionary.Values);
         TilePosition touchDownZone = PositionConvertor.GetBuildingTileIndexFromScreenPosition(mouseOrTouchList[0].pos);
         TilePosition offsetZone    = touchDownZone - base.TouchDownZone;
         if (!((base.FirstZoneIndexPrevious + offsetZone).Equals(base.FirstZoneIndex)))
         {
             AudioController.Play("BuildingMoving");
         }
         base.FirstZoneIndex = base.FirstZoneIndexPrevious + offsetZone;
         this.LimitBuildingPosition();
         Vector3 position = PositionConvertor.GetWorldPositionByBuildingTileIndex(base.FirstZoneIndex);
         position.z = BUILDING_PICK_AXIS_Z;
         this.transform.position = position;
         base.CheckTile();
         base.SetButtonOkState();
     }
 }
Beispiel #4
0
    public void Construct(Vector2 position)
    {
        TilePosition mousePosition = PositionConvertor.GetBuildingTileIndexFromScreenPosition(position);

        mousePosition.Row    = Mathf.Clamp(mousePosition.Row, 0, ClientSystemConstants.BUILDING_TILE_MAP_SIZE.height - 1);
        mousePosition.Column = Mathf.Clamp(mousePosition.Column, 0, ClientSystemConstants.BUILDING_TILE_MAP_SIZE.width - 1);

        UICheckbox check = null;

        UICheckbox[] checks = this.m_SelectionGroup.GetComponentsInChildren <UICheckbox>();
        foreach (UICheckbox c in checks)
        {
            if (c.isChecked)
            {
                check = c;
                break;
            }
        }

        PropsButtonInformation propsInfo = check.transform.parent.GetComponent <PropsButtonInformation>();

        bool isUseProps = propsInfo != null &&
                          !(ConfigInterface.Instance.PropsConfigHelper.GetPropsData(propsInfo.Type).FunctionConfigData is PropsArmyConfigData) &&
                          !(ConfigInterface.Instance.PropsConfigHelper.GetPropsData(propsInfo.Type).FunctionConfigData is PropsMercenaryConfigData);



        bool isValidPosition = true;

        if (mousePosition.IsEdgeBuildingTilePosition())
        {
            isValidPosition = true;
        }
        else if (!mousePosition.IsValidBuildingTilePosition())
        {
            this.m_GridFactory.DisplayGrid();
            isValidPosition = false;
        }
        else if (BattleMapData.Instance.CharacterForbiddenArray[mousePosition.Row, mousePosition.Column] &&
                 !isUseProps)
        {
            this.m_GridFactory.DisplayGrid();
            isValidPosition = false;
        }

        if (isValidPosition && (BattleDirector.Instance == null || !BattleDirector.Instance.IsBattleFinished))
        {
            ArmyButtonInformation      armyInfo      = check.transform.parent.GetComponent <ArmyButtonInformation>();
            MercenaryButtonInformation mercenaryInfo = check.transform.parent.GetComponent <MercenaryButtonInformation>();

            if (armyInfo != null)
            {
                if (armyInfo.Dropable)
                {
                    Vector3 worldPosition = CameraManager.Instance.MainCamera.ScreenToWorldPoint(new Vector3(position.x, position.y, 0));
                    worldPosition = PositionConvertor.ClampWorldPositionOfBuildingTile(worldPosition);

                    ArmyIdentity id = armyInfo.DropArmy();
                    this.m_ConstructArmyList.Add(new ConstructArmyCommand()
                    {
                        Position = worldPosition,
                        Identity = id, Level = armyInfo.ArmyLevel
                    });
                }
                else
                {
                    UIErrorMessage.Instance.ErrorMessage(ClientStringConstants.NO_ARMY_TO_DROP_WARNING_MESSAGE);
                }
            }
            else if (mercenaryInfo != null)
            {
                if (mercenaryInfo.Dropable)
                {
                    Vector3 worldPosition = CameraManager.Instance.MainCamera.ScreenToWorldPoint(new Vector3(position.x, position.y, 0));
                    worldPosition = PositionConvertor.ClampWorldPositionOfBuildingTile(worldPosition);

                    MercenaryIdentity id = mercenaryInfo.DropArmy();
                    this.m_ConstructMercenaryList.Add(new UserCommand <MercenaryIdentity>()
                    {
                        Position = worldPosition,
                        Identity = id
                    });
                }
                else
                {
                    UIErrorMessage.Instance.ErrorMessage(ClientStringConstants.NO_ARMY_TO_DROP_WARNING_MESSAGE);
                }
            }
            else if (propsInfo != null)
            {
                if (propsInfo.Dropable)
                {
                    Vector3 worldPosition = CameraManager.Instance.MainCamera.ScreenToWorldPoint(new Vector3(position.x, position.y, 0));
                    worldPosition = PositionConvertor.ClampWorldPositionOfBuildingTile(worldPosition);

                    int no = propsInfo.DropArmy();
                    this.m_UsePropsList.Add(new UsePropsCommand()
                    {
                        Position = worldPosition,
                        Identity = no, PropsType = propsInfo.Type
                    });
                }
                else
                {
                    UIErrorMessage.Instance.ErrorMessage(ClientStringConstants.NO_PROPS_TO_DROP_WARNING_MESSAGE);
                }
            }
        }
        else
        {
            if (isUseProps)
            {
                UIErrorMessage.Instance.ErrorMessage(ClientStringConstants.CAN_NOT_USE_PROPS_WARNING_MESSAGE);
            }
            else
            {
                UIErrorMessage.Instance.ErrorMessage(ClientStringConstants.CAN_NOT_DROP_ARMY_WARNING_MESSAGE);
            }
        }
    }