//изменяет размер Блока перед созданием пула
    private GameObject ChangeBlock(GameObject Block)
    {
        SingleBlock BlockScript = Block.GetComponent <SingleBlock>();

        BlockScript.MaxHealthPoint = GlobalMaxHp;
        return(Block);
    }
Esempio n. 2
0
 //передаем через этот метод массив сингблоков в мувментКонтроллер
 public SingleBlock[] GetSingleBlocksFromPool()
 {
     SingleBlock[] _singleBlocksForMovement = new SingleBlock[_singleBlockPool.Length];
     for (int i = 0; i < _singleBlockPool.Length; i++)
     {
         _singleBlocksForMovement[i] = _singleBlockPool[i].GetComponent <SingleBlock>();
     }
     return(_singleBlocksForMovement);
 }
Esempio n. 3
0
    //возвращает блок в пул
    public void ReturnBlockIntoPool(GameObject Block)
    {
        SingleBlock BlockScript = Block.GetComponent <SingleBlock>();

        for (int j = 0; j < _singleBlockPool.Length; j++)
        {
            if (_singleBlockPool[j] == null)
            {
                _singleBlockPool[j] = Block;
                break;
            }
        }
        Block.transform.position = _notfarPosition;
    }
 //пускает рэйкаст и растягивает лазер по длине рейкаста
 private void FixedUpdate()
 {
     _raycastHit = Physics2D.Raycast(_objectTransform.position, _objectTransform.up, 10f, BlockLayer);
     if (_raycastHit.collider != null)
     {
         if (_blockForHiting != null && _blockForHiting != _raycastHit.collider.gameObject.GetComponent <SingleBlock>())
         {
             _blockForHiting.SetEffectOn(false);
             _blockForHiting = _raycastHit.collider.gameObject.GetComponent <SingleBlock>();
         }
         else if (_blockForHiting == null)
         {
             _blockForHiting = _raycastHit.collider.gameObject.GetComponent <SingleBlock>();
         }
         else
         {
             _blockForHiting.GetDamage();
             _blockForHiting.SetEffectOn(true);
         }
         _laserLength = _raycastHit.distance;
         _highGlowLaserEffectsPosition           = _raycastHit.point;
         HighGlowLaserEffects.transform.position = _highGlowLaserEffectsPosition;
         ParticleLaserEffects.transform.position = _highGlowLaserEffectsPosition;
         if (!_effectsOn)
         {
             TurnEffectsOn(true);
         }
     }
     else
     {
         if (_blockForHiting != null)
         {
             _blockForHiting.SetEffectOn(false);
             _blockForHiting = null;
         }
         if (_effectsOn)
         {
             TurnEffectsOn(false);
         }
         _laserLength = 0;
     }
     _laserPosition.y       = _laserLength / 2;
     LaserObject.position   = _objectTransform.position + _laserPosition;
     _laserScale.y          = _laserLength * 7f;
     LaserObject.localScale = _laserScale;
 }
Esempio n. 5
0
    //спавнит фигуры
    public void SpawnFigure()
    {
        switch (_counter)
        {
        case 0:
            _columnNum = 1;
            _counter++;
            break;

        case 1:
            _columnNum = 3;
            _counter++;
            break;

        case 2:
            _columnNum = 5;
            _counter   = 0;
            break;
        }
        CreateFigure RandomFigure = _blockPatterns[Random.Range(0, _blockPatterns.Length)];

        for (int i = 0; i < RandomFigure.SingleBlocks.Length; i++)
        {
            for (int j = 0; j < _singleBlockPool.Length; j++)
            {
                if (_singleBlockPool[j] != null)
                {
                    _blocksGameObjects[i] = _singleBlockPool[j];
                    _singleBlockPool[j]   = null;
                    break;
                }
            }
            _spawnPosition = _spawnPoints[RandomFigure.SingleBlocks[i].YCordinat, _columnNum + RandomFigure.SingleBlocks[i].XCordinat];
            _blocksGameObjects[i].transform.position = _spawnPosition;
            _singleBlockForActivation = _blocksGameObjects[i].GetComponent <SingleBlock>();
            _singleBlockForActivation.ActivateBlockForSpawn();

            //_blocksGameObjects[i] = Instantiate(_singleBlockPrefab, _spawnPoints[RandomFigure.SingleBlocks[i].YCordinat, _columnNum + RandomFigure.SingleBlocks[i].XCordinat],Quaternion.identity);
        }
    }
Esempio n. 6
0
 //говорит соседним блокам что пора в ячейку встать
 private void PlaceOtherBlocks()
 {
     _raycastHit = Physics2D.Raycast(BlockTransform.position, BlockTransform.up, SideRaycastLength, SingleBlockLayer);
     if (_raycastHit.collider != null)
     {
         _anotherSingleBlock = _raycastHit.collider.gameObject.GetComponent <SingleBlock>();
         if (_anotherSingleBlock.CanMove)
         {
             _anotherSingleBlock.PlaceBlock();
         }
     }
     _raycastHit = Physics2D.Raycast(BlockTransform.position, BlockTransform.up, -SideRaycastLength, SingleBlockLayer);
     if (_raycastHit.collider != null)
     {
         _anotherSingleBlock = _raycastHit.collider.gameObject.GetComponent <SingleBlock>();
         if (_anotherSingleBlock.CanMove)
         {
             _anotherSingleBlock.PlaceBlock();
         }
     }
     _raycastHit = Physics2D.Raycast(BlockTransform.position, BlockTransform.right, SideRaycastLength, SingleBlockLayer);
     if (_raycastHit.collider != null)
     {
         _anotherSingleBlock = _raycastHit.collider.gameObject.GetComponent <SingleBlock>();
         if (_anotherSingleBlock.CanMove)
         {
             _anotherSingleBlock.PlaceBlock();
         }
     }
     _raycastHit = Physics2D.Raycast(BlockTransform.position, BlockTransform.right, -SideRaycastLength, SingleBlockLayer);
     if (_raycastHit.collider != null)
     {
         _anotherSingleBlock = _raycastHit.collider.gameObject.GetComponent <SingleBlock>();
         if (_anotherSingleBlock.CanMove)
         {
             _anotherSingleBlock.PlaceBlock();
         }
     }
 }
Esempio n. 7
0
 //заполняет ячейку
 public void SetBusy(SingleBlock Block)
 {
     //Debug.Log("oh no");
     PlacedBlock = Block;
     IsBusy      = true;
 }
Esempio n. 8
0
 //освобождает ячейку
 public void SetFree()
 {
     //Debug.Log("хозяин подарил Доби носок");
     PlacedBlock = null;
     IsBusy      = false;
 }
Esempio n. 9
0
        private void loadAlternative(XElement node)
        {
            AlternativeBlock ab = null;

            foreach (XElement item_node in node.Elements("item"))
            {
                int chance;

                if ("".Equals(item_node.Attribute("chance").GetString()))
                {
                    Messages.AddWarning("Can't read chance tag of doodad item node.");
                    continue;
                }

                chance = item_node.Attribute("chance").GetInt32();

                Item item = Item.Create(Global.items.items[item_node.Attribute("id").GetInt32()]);
                if (item.Type == null)
                {
                    Messages.AddWarning("Can't read chance tag of doodad item node.");
                    continue;
                }
                ItemType it = item.Type;
                if (it.Id != 0)
                {
                    it.doodad_brush = this;
                }
                SingleBlock sb = new SingleBlock();
                sb.chance = chance;
                sb.item   = item;
                if (ab == null)
                {
                    ab = new AlternativeBlock();
                }
                ab.single_items.Add(sb);
                ab.single_chance += chance;
            }
            foreach (XElement composite_node in node.Elements("composite"))
            {
                int            chance;
                CompositeBlock cb = new CompositeBlock();
                if ("".Equals(composite_node.Attribute("chance").GetString()))
                {
                    Messages.AddWarning("Can't read chance tag of doodad item node.");
                    continue;
                }

                chance = composite_node.Attribute("chance").GetInt32();
                if (chance == 0)
                {
                    Messages.AddWarning("Can't read chance tag of doodad composite node.");
                    continue;
                }
                cb.chance = chance;
                if (ab == null)
                {
                    ab = new AlternativeBlock();
                }
                ab.composite_chance += cb.chance;
                cb.chance            = ab.composite_chance;

                foreach (XElement tile_composite_node in composite_node.Elements("tile"))
                {
                    int x = 0, y = 0, z = 0;

                    x = tile_composite_node.Attribute("x").GetInt32();
                    y = tile_composite_node.Attribute("y").GetInt32();
                    z = tile_composite_node.Attribute("z").GetInt32();

                    /*
                     *
                     * if (!readXMLValue(composite_child, "x", x))
                     * {
                     *  wxString warning;
                     *  warning = wxT("Couldn't read positionX values of composite tile node.");
                     *  warnings.push_back(warning);
                     *  composite_child = composite_child->next;
                     *  continue;
                     * }
                     * if (!readXMLValue(composite_child, "y", y))
                     * {
                     *  wxString warning;
                     *  warning = wxT("Couldn't read positionY values of composite tile node.");
                     *  warnings.push_back(warning);
                     *  composite_child = composite_child->next;
                     *  continue;
                     * }
                     * readXMLValue(composite_child, "z", z); // Don't halt on error
                     *
                     * if (x <= -0x8000 || x >= +0x8000)
                     * {
                     *  wxString warning;
                     *  warning = wxT("Invalid range of x value on composite tile node.");
                     *  warnings.push_back(warning);
                     *  composite_child = composite_child->next;
                     *  continue;
                     * }
                     * if (y <= -0x8000 || y >= +0x8000)
                     * {
                     *  wxString warning;
                     *  warning = wxT("Invalid range of y value on composite tile node.");
                     *  warnings.push_back(warning);
                     *  composite_child = composite_child->next;
                     *  continue;
                     * }
                     * if (z <= -0x8 || z >= +0x8)
                     * {
                     *  wxString warning;
                     *  warning = wxT("Invalid range of z value on composite tile node.");
                     *  warnings.push_back(warning);
                     *  composite_child = composite_child->next;
                     *  continue;
                     * } */

                    Tile t = new Tile(x, y, z);
                    foreach (XElement item_tile_composite_node in tile_composite_node.Elements("item"))
                    {
                        Item item = Item.Create(Global.items.items[item_tile_composite_node.Attribute("id").GetInt16()]);
                        if (item.Type != null)
                        {
                            t.addItem(item);
                            ItemType it = item.Type;
                            if (it.Id != 0)
                            {
                                it.doodad_brush = this;
                            }
                        }
                    }
                    if (t.size() > 0)
                    {
                        cb.tiles.Add(t);
                    }
                }
                ab.composite_items.Add(cb);
            }
            if (ab != null)
            {
                alternatives.Add(ab);
            }
        }