Пример #1
0
        public void Fertiliser(int buff)
        {
            if (buff > 1)
            {
                int x = Position.Key;
                int y = Position.Value;

                Cellule cell = Grille.GetInstance().GetCellule(x + 1, y);
                if (cell)
                {
                    cell.Fertiliser(buff - 1);
                }

                cell = Grille.GetInstance().GetCellule(x - 1, y);
                if (cell)
                {
                    cell.Fertiliser(buff - 1);
                }

                cell = Grille.GetInstance().GetCellule(x, y + 1);
                if (cell)
                {
                    cell.Fertiliser(buff - 1);
                }

                cell = Grille.GetInstance().GetCellule(x, y - 1);
                if (cell)
                {
                    cell.Fertiliser(buff - 1);
                }
            }
        }
Пример #2
0
        public int Distance(Cellule cell)
        {
            int distX = Mathf.Abs(Position.Key - cell.Position.Key);
            int distY = Mathf.Abs(Position.Value - cell.Position.Value);

            return(distX + distY);
        }
Пример #3
0
        public void OnDrop()
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100))
            {
                Cellule toPlant = hit.collider.gameObject.GetComponent <Cellule>();
                toPlant.Planter(Type);
            }


            GameObject DragObject = Instantiate(DragSlot);

            DragObject.transform.SetParent(transform.parent, false);

            DragObject.GetComponent <Image>().color = new Color(1, 1, 1, 0);
            DragObject.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);

            Destroy(this.gameObject);
        }