Пример #1
0
 public GridModel(int sizeOfSide)
 {
     this.grid = new Grid(sizeOfSide);
     this.countOfEmptyCells = this.grid.numberOfCells;
     this.winner = ECellType.Empty;
     this.currentPlayer = ECellType.X;
 }
Пример #2
0
 public static string CellTypeToText(ECellType cell_type)
 {
     if (cell_type == ECellType.LiFePo4)
     {
         return("LiFePo4");
     }
     if (cell_type == ECellType.LiFePo4_Full)
     {
         return("LiFePo4 Full");
     }
     if (cell_type == ECellType.LiIon)
     {
         return("LiIon");
     }
     if (cell_type == ECellType.LiPo)
     {
         return("LiPo");
     }
     if (cell_type == ECellType.PbAcid3)
     {
         return("Pb Acid 3 cells");
     }
     if (cell_type == ECellType.PbAcid6)
     {
         return("Pb Acid 6 cells");
     }
     return("<unknown>");
 }
Пример #3
0
        public void CopyFrom(SerializableCell _cell)
        {
            cellStatus = (ECellStatus)_cell.cellStatus;
            cellType   = (ECellType)_cell.cellType;

            if (cellType == CellScript.ECellType.Number)
            {
                intCellContent = int.Parse(_cell.cellContent);
                m_currentColor = LevelEditor.instance.colorConfiguration.numberBlockColor;
            }
            else if (cellType == CellScript.ECellType.Operation)
            {
                charCellContent = _cell.cellContent.ToCharArray()[0];
                CurrentColor    = LevelEditor.instance.colorConfiguration.operationBlockColor;
            }
            else
            {
                CurrentColor = LevelEditor.instance.colorConfiguration.unusedBlockColor;
            }

            if (cellStatus == CellScript.ECellStatus.Hidden)
            {
                PreviousColor = CurrentColor;
                CurrentColor  = LevelEditor.instance.colorConfiguration.hiddenBlockColor;
            }
        }
    public void OnPointerClick(PointerEventData eventData)
    {
        if (eventData.button != PointerEventData.InputButton.Left && eventData.button != PointerEventData.InputButton.Right)
        {
            return;
        }

        int CellType = (int)CurrentCellType;

        if (eventData.button == PointerEventData.InputButton.Left)
        {
            CellType += 1;
        }
        else if (eventData.button == PointerEventData.InputButton.Right)
        {
            CellType -= 1;
        }

        if (CellType < 0)
        {
            CellType = 4;
        }
        else if (CellType > 4)
        {
            CellType = 0;
        }

        CurrentCellType = (ECellType)CellType;
        UpdateSprite();
    }
Пример #5
0
 /// <summary>
 /// .ctor
 /// </summary>
 /// <param name="iX"></param>
 /// <param name="iY"></param>
 /// <param name="enCellType"></param>
 public CCell(int iX, int iY, ECellType enCellType)
 {
     X        = iX;
     Y        = iY;
     CellType = enCellType;
     IsExit   = (enCellType == ECellType.Place);
 }
Пример #6
0
 public void Clear()
 {
     if (_type != ECellType.WALL)
     {
         _type = ECellType.EMPTY;
     }
 }
Пример #7
0
 public GridModel(int sizeOfSide)
 {
     this.grid = new Grid(sizeOfSide);
     this.countOfEmptyCells = this.grid.numberOfCells;
     this.winner            = ECellType.Empty;
     this.currentPlayer     = ECellType.X;
 }
Пример #8
0
        private void Update()
        {
            if (!_currentPath.Empty)
            {
                TargetCell  = _currentPath.Nodes.LastOrDefault().CurrentCellType;
                CurrentCell = MyPosition.CurrentCellType;
                var rotation = Quaternion.LookRotation(_currentPath.Nodes[0].Position - transform.position);
                transform.rotation = Quaternion.Slerp(transform.rotation, rotation, 0.1f);

                if (_currentPath.Nodes[0].CurrentCellType == ECellType.Busy)
                {
                    BeginMovementByPath(Pathfinder.FindPathToDestination(MyPosition.GridPosition, _currentPath.Nodes.Last().GridPosition));
                    if (!_currentPath.Empty)
                    {
                        MoveToTarget(_currentPath.Nodes[0].Position);
                    }
                    else
                    {
                        ToggleAnimationState(EMovableObjectState.Standing);
                    }
                }
                else
                {
                    MoveToTarget(_currentPath.Nodes[0].Position);
                }

                DrawDebugPath();
            }
        }
Пример #9
0
        public void SetState(ECellType statue, int mineCount = 0)
        {
            if ((statue != ECellType.Number && this.statue == statue) ||
                (statue == ECellType.Number && mineCountInBorder == mineCount))
            {
                //is the same do not need reflash
                return;
            }

            this.statue = statue;
            switch (statue)
            {
            case ECellType.UnOpened: {
                SetStatus(false, false, true, false, "");
                break;
            }

            case ECellType.Number: {
                SetStatus(false, true, false, false, mineCount == 0 ? "" : mineCount.ToString());
                break;
            }

            case ECellType.Flag: {
                SetStatus(true, false, true, false, "");
                break;
            }

            case ECellType.Mine: {
                SetStatus(false, false, false, true, "");
                break;
            }
            }
        }
Пример #10
0
    public MapData(int sizeX, int sizeY, ECellType fullFillCellType = ECellType.Air)
    {
        SizeX = sizeX;
        SizeZ = sizeY;

        FullFillMapData(fullFillCellType);
        InitializeBorder();
    }
Пример #11
0
 bool checkStep(Cell cell, ECellType type)
 {
     if (cell.state == ECellType.Empty && type != ECellType.Empty)
     {
         return(true);
     }
     return(false);
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ECellType celltype = (ECellType)value;

            switch (celltype)
            {
            case ECellType.Dark:
                return(new SolidColorBrush(Colors.CadetBlue));

            case ECellType.Light:
                return(new SolidColorBrush(Colors.White));
            }
            throw new ArgumentException("Invalid input, could not convert");
        }
Пример #13
0
    private void FullFillMapData(ECellType cellType)
    {
        Cells = new ECellType[SizeZ + 2][];
        Level = new int[SizeZ + 2][];

        for (int j = 0; j < SizeZ + 2; j++)
        {
            Cells[j] = new ECellType[SizeX + 2];
            Level[j] = new int[SizeX + 2];
            for (int i = 0; i < SizeX + 2; i++)
            {
                Cells[j][i] = cellType;
                Level[j][i] = 0;
            }
        }
    }
Пример #14
0
    private GameObject getPrefabType(ECellType cellType)
    {
        switch (cellType)
        {
        case ECellType.AirWall:
            return(airWallPrefab);

        case ECellType.Air:
            return(null);

        case ECellType.Ground:
            return(groundPrefab);

        case ECellType.Stone:
            return(stonePrefab);

        default:
            return(null);
        }
    }
Пример #15
0
    public override void OnInspectorGUI()
    {
        map = serializedObject.targetObject as GridMap2D;
        map.m_GridCustom         = EditorGUILayout.ObjectField("自定义网格类型", map.m_GridCustom, typeof(GridCustom), true) as GridCustom;
        map.m_rowCount           = EditorGUILayout.IntField("行数", map.m_rowCount);
        map.m_colCount           = EditorGUILayout.IntField("列数", map.m_colCount);
        map.m_cellWidth          = EditorGUILayout.FloatField("单元格宽度", map.m_cellWidth);
        map.m_cellHeight         = EditorGUILayout.FloatField("单元格高度", map.m_cellHeight);
        map.m_offsetInWorldSapce = EditorGUILayout.Vector3Field("世界空间偏移", map.m_offsetInWorldSapce);
        map.Fit();
        EditorGUILayout.LabelField("总宽度", map.Length.ToString());
        EditorGUILayout.LabelField("总高度", map.Height.ToString());

        m_from = EditorGUILayout.Vector2Field("从", m_from);
        m_to   = EditorGUILayout.Vector2Field("到", m_to);

        if (GUILayout.Button("寻路"))
        {
            FindPath(false);
        }
        if (GUILayout.Button("寻路(忽略对角)"))
        {
            FindPath(true);
        }

        if (m_curSelectedPoint != IPoint.Unavailable)
        {
            ECellType type = (ECellType)map.GetType(m_curSelectedPoint.X, m_curSelectedPoint.Y);
            ECellType s    = (ECellType)EditorGUILayout.EnumPopup("单元格类型", type);
            map.SetType(m_curSelectedPoint.X, m_curSelectedPoint.Y, (int)s);
        }

        if (m_curOverCellPos != null)
        {
            EditorGUILayout.LabelField("当前选中", m_curSelectedPoint.ToString());
        }

        EditorUtility.SetDirty(map);
    }
Пример #16
0
 public bool Step(int row, int col)
 {
     if (row < 0 || row >= this.grid.sizeOfSide || col < 0 || col >= this.grid.sizeOfSide)
     {
         OnDisplay("Указана ячейка, не содержащаяся в таблице");
         return false;
     }
     Cell cell = this.grid.getCell(row, col);
     ECellType type = this.currentPlayer;
     if (!checkStep(cell, type))
     {
         OnDisplay("Ячейка не пустая");
         return false;
     }
         
     cell.state = type;
     countOfEmptyCells--;
     this.winner = checkWinner(row, col);
     changeCurrentPlayer();
     OnDisplay();
     return true;
 }
Пример #17
0
        public bool Step(int row, int col)
        {
            if (row < 0 || row >= this.grid.sizeOfSide || col < 0 || col >= this.grid.sizeOfSide)
            {
                OnDisplay("Указана ячейка, не содержащаяся в таблице");
                return(false);
            }
            Cell      cell = this.grid.getCell(row, col);
            ECellType type = this.currentPlayer;

            if (!checkStep(cell, type))
            {
                OnDisplay("Ячейка не пустая");
                return(false);
            }

            cell.state = type;
            countOfEmptyCells--;
            this.winner = checkWinner(row, col);
            changeCurrentPlayer();
            OnDisplay();
            return(true);
        }
Пример #18
0
 public ECell(int x, int y)
 {
     _point = new MPoint(x, y);
     _type  = ECellType.EMPTY;
 }
Пример #19
0
 public CLayerCell(string eType, string _name, int _ID)
 {
     CellType = (ECellType)Enum.Parse(typeof(ECellType), eType);
     Name     = _name;
     ID       = _ID;
 }
Пример #20
0
 public CLayerCell()
 {
     CellType = ECellType.GC_string;
 }
Пример #21
0
 public Cell(ECellType eCellType, Vector2 gridPos) : this(eCellType)
 {
     GridPos = gridPos;
 }
Пример #22
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public Cell(ECellType type, params int []  values)
 {
     mCellType = type;
     mValues   = values;
 }
Пример #23
0
            public CLogEntry(EtaLoggingChargerControl logging_charger_control, CDevice device, uint start_sector, string name, CSample[] samples, ECellType cell_type, bool is_discharging)
            {
                LoggingChargerControl = logging_charger_control; Device = device; StartSector = start_sector; Name = name; Samples = samples; IsDischarging = is_discharging; CellType = cell_type;
                ProcessingTime        = new TimeSpan(0, 0, Samples.Length / 2);
                double _avarage_current = 0, _midpoint_voltage = 0, _amp_hour = 0, _watt = 0;

                foreach (CSample _sample in Samples)
                {
                    _amp_hour         += _sample.CellCurrent;
                    _midpoint_voltage += _sample.CellVoltage;
                    _watt             += (_sample.CellVoltage * _sample.CellCurrent);
                }
                AvarageCurrent  = _amp_hour / Samples.Length;
                MidpointVoltage = _midpoint_voltage / Samples.Length;
                AmpHour         = _amp_hour / 7200;
                Wattage         = _watt / 7200;
            }
Пример #24
0
 public void MarkAsQuestion(Color _questionColor)
 {
     cellType = ECellType.Question;
     m_imageReference.color  = _questionColor;
     m_textReference.enabled = false;
 }
Пример #25
0
 public void Initialize()
 {
     m_SpriteRenderer = GetComponent <SpriteRenderer>();
     CurrentCellType  = ECellType.Ground;
     UpdateSprite();
 }
Пример #26
0
 public void MarkAsAnswer()
 {
     cellType = ECellType.Answer;
 }
Пример #27
0
 public void MarkAsAnswered(GameplayCell _other)
 {
     cellType = ECellType.Hint;
     m_imageReference.color  = _other.CellColor;
     m_textReference.enabled = true;
 }
Пример #28
0
 /// <summary>
 /// デフォルトコンストラクタ
 /// </summary>
 public Cell()
 {
     mCellType = ECellType.Wall;
     mValues   = null;
 }
Пример #29
0
 public void SetType(ECellType type)
 {
     _type = type;
 }
Пример #30
0
        /// <summary>
        /// セルイメージを取得する
        /// </summary>
        /// <param name="cellType"></param>
        /// <param name="ownerPlayer"></param>
        /// <returns></returns>
        private Image GetCellImage(ECellType cellType, EPlayerType ownerPlayer)
        {
            // 該当するイメージのインデックス
            ECellImage cellImageIndex = ECellImage.FLOOR_NONE;

            // セルタイプで分岐
            switch (cellType)
            {
            // 通常床
            case ECellType.FLOOR:
                // 所有者で分岐
                switch (ownerPlayer)
                {
                case EPlayerType.NO_PLAYER:
                    cellImageIndex = ECellImage.FLOOR_NONE;
                    break;

                case EPlayerType.PLAYER1:
                    cellImageIndex = ECellImage.FLOOR_1;
                    break;

                case EPlayerType.PLAYER2:
                    cellImageIndex = ECellImage.FLOOR_2;
                    break;

                case EPlayerType.PLAYER3:
                    cellImageIndex = ECellImage.FLOOR_3;
                    break;

                case EPlayerType.PLAYER4:
                    cellImageIndex = ECellImage.FLOOR_4;
                    break;
                }
                break;

            // スタート台
            case ECellType.START:
                // 所有者で分岐
                switch (ownerPlayer)
                {
                case EPlayerType.NO_PLAYER:
                    cellImageIndex = ECellImage.START_NONE;
                    break;

                case EPlayerType.PLAYER1:
                    cellImageIndex = ECellImage.START_1;
                    break;

                case EPlayerType.PLAYER2:
                    cellImageIndex = ECellImage.START_2;
                    break;

                case EPlayerType.PLAYER3:
                    cellImageIndex = ECellImage.START_3;
                    break;

                case EPlayerType.PLAYER4:
                    cellImageIndex = ECellImage.START_4;
                    break;
                }
                break;

            // 壁
            case ECellType.WALL:
                cellImageIndex = ECellImage.WALL;
                break;

            // 網床
            case ECellType.WIRE_MESH:
                cellImageIndex = ECellImage.WIRE_MESH;
                break;
            }

            // 結果を返す
            return(_cellImageList[(int)cellImageIndex]);
        }
Пример #31
0
 public Cell()
 {
     this.state = ECellType.Empty;
 }
Пример #32
0
 public Cell(ECellType eCellType)
 {
     ECellType = eCellType;
 }
Пример #33
0
 bool checkStep(Cell cell, ECellType type)
 {
     if (cell.state == ECellType.Empty && type != ECellType.Empty)
         return true;
     return false;
 }
Пример #34
0
 /// <summary>
 /// コピー
 /// </summary>
 public void CopyFrom(Cell src)
 {
     mCellType = src.CellType;
     mValues   = src.Values;
 }