Пример #1
0
    private void HandleMouse()
    {
        //Check if the left Mouse button is clicked
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            //Set up the new Pointer Event
            m_PointerEventData = new PointerEventData(m_EventSystem);
            //Set the Pointer Event Position to that of the mouse position
            m_PointerEventData.position = Input.mousePosition;

            //Create a list of Raycast Results
            List <RaycastResult> results = new List <RaycastResult>();

            //Raycast using the Graphics Raycaster and mouse click position
            m_Raycaster.Raycast(m_PointerEventData, results);

            //For every result returned, output the name of the GameObject on the Canvas hit by the Ray
            foreach (RaycastResult result in results)
            {
                SlotController slotController = result.gameObject.GetComponent <SlotController>();
                if (slotController != null)
                {
                    Debug.Log("Texture set for slot: " + slotController.gameObject.name);
                    slotController.Texture = selectedTurret;
                }
                Debug.Log("Hit " + result.gameObject.name);
            }
        }
    }
Пример #2
0
    void upgradeChosse(SlotController sc, slot s)
    {
        int i = 0;                 // indice

        foreach (Cards c in Cards) // em todos os itens da card
        {
            if (slotChosse[i]._GameController == null)
            {
                slotChosse[i]._GameController = this;     // para pegar a instancia do prorpio script
            }
            if (slotChosse[i].Card == null)
            {
                slotChosse[i].Card = c;
            }

            slotChosse[i].sc = sc;
            slotChosse[i].s  = s;

            slotChosse[i].upgradeInfoCard();    //para atualizar as informaçoes

            if (slotChosse[i].Card.isLiberate == true)
            {
                slotChosse[i].gameObject.SetActive(true);    //ativa
            }

            i++;
        }
    }
 public void CheckTheTriggerKey()
 {
     foreach (GameObject slotControllerObj in SlorControllerToolBar)
     {
         SlotController slotControllerCheck = slotControllerObj.GetComponent <SlotController>();
         if (slotControllerCheck.ReturnKeyCodeObject() == KeyCode.None)
         {
             return;
         }
         else
         {
             if (Input.GetKeyDown(slotControllerCheck.ReturnKeyCodeObject()))
             {
                 foreach (var scriptableObject in ((NetworkRoomManagerExt)NetworkManager.singleton).scriptableObjectToMirror.Select(((value, index) => new { value, index })))
                 {
                     if (slotControllerCheck.ReturnPrefab() == null)
                     {
                         DestoryAllObjectInHandServer(); PlayerController.SetBasicSpeed(); PlayerController.SetDefaultSpeedToVariableCalculate(); return;
                     }
                     else if (scriptableObject.value.name == slotControllerCheck.ReturnPrefab().name)
                     {
                         DestoryAllObjectInHandServer();
                         SendSlotControllerToObjectServer(scriptableObject.index);
                         continue;
                     }
                 }
             }
         }
     }
 }
Пример #4
0
    void ClickSquare()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                _audioManager.PlayClickSlot();

                SlotController __slot = hit.transform.gameObject.GetComponent <SlotController>();

                _boardController.Board[__slot.xPos, __slot.yPos] = _currentPlayer;

                __slot.SetSymbolToSlot(_currentPlayer);

                SwitchPlayer();

                if (_cpuPlaying)
                {
                    _cpuTurn   = true;
                    _notPlayed = true;
                }
            }
        }
    }
Пример #5
0
    /**
     * Get the position of the next empty slot
     */
    public Vector2 getEmptySlotPos()
    {
        int     xPos        = 1;
        int     yPos        = 1;
        bool    isCoordsSet = false;
        Vector2 coords      = new Vector2(xPos, yPos);

        for (int y = 1; y <= invetorySize.y; y++)
        {
            for (int x = 1; x <= invetorySize.x; x++)
            {
                Transform      slot = transform.Find("slot_" + x + "_" + y);
                SlotController sc   = slot.GetComponent <SlotController>();

                if (sc.isEmpty && !isCoordsSet)
                {
                    coords      = sc.coords;
                    isCoordsSet = true;
                    sc.isEmpty  = false;
                    break;
                }
            }
        }
        return(coords);
    }
Пример #6
0
    private void FillUpAfterFall()
    {
        SlotController last = null;

        foreach (var slot in s_spawnSlots)
        {
            if (slot.TrashController.IsAbleToFall())
            {
                if (last != null)
                {
                    last.TrashController.FallDown();
                    SpawnTrash(last);
                }
                last = slot;
            }
        }

        if (last != null)
        {
            last.TrashController.FallDown(true);
            SpawnTrash(last);
        }
        if (last == null && GetLinesForDestroy().Count > 0) //stop moving and have smth to destroy
        {
            AfterSwapCheck();
        }
        if (last == null && GetLinesForDestroy().Count == 0 && !IsAbleToTurn())
        {
            Reshuffle();
        }
    }
Пример #7
0
    public void OnEndDrag(PointerEventData eventData)
    {
        if (m_piece.IsStatic || !m_piece.Interactable)
        {
            return;
        }

        Vector3 position = transform.position;

        PieceCoordinates coord = Layout.PosToCoord(position);

        SlotController slot = Layout.GetSlotAt(coord);

        PieceController other = GameController.Instance.Pieces.Find(p => p.Coordinates == coord);

        if (!slot || other)
        {
            transform.position = m_originalPosition;

            SFX.Instance.PlayOneShot(SFXData.Type.Pop);
        }
        else
        {
            position = Layout.CoordToPos(coord);

            m_piece.Coordinates.Set(coord);

            transform.position = position;

            m_piece.StateChanged();

            SFX.Instance.PlayOneShot(SFXData.Type.Positive);
        }
    }
Пример #8
0
 public override void DrawUi()
 {
     for (int y = 0; y < SlotsHeight; y++)
     {
         for (int x = 0; x < SlotsWidth; x++)
         {
             bool       isSelected = y == 0 && x == SelectedSlot;
             GameObject slot       = SlotController.DrawItemSlotWithSpriteAndDetails(
                 y,
                 x,
                 SlotPrefix,
                 Slots[y, x],
                 Parent.transform,
                 this,
                 DrawLeftPadding,
                 DrawBottomPadding,
                 isSelected,
                 GameObjectSlots);
             if (isSelected)
             {
                 InventorySlot invSlot           = slot.GetComponent <InventorySlot>();
                 Transform     selectedTransform = invSlot.transform;
                 selectedTransform.GetComponent <Image>().sprite = PrefabRepository.Instance.SlotSelectSprite;
             }
         }
     }
 }
Пример #9
0
    // Use this for initialization
    void Start()
    {
        slotController = GetComponent <SlotController>();
        panelNextSlot  = GetComponent <PanelNextSlot>();

        if (slotController != null)
        {
            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    GameObject slot = Instantiate(slotPrefab, this.transform);
                    slot.name = "Slot(" + j + "," + i + ")";
                    TetSlot tetSlot = slot.GetComponent <TetSlot>();
                    slotController.slotList[10 * i + j] = tetSlot;
                }
            }
        }

        if (panelNextSlot != null)
        {
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    GameObject slot = Instantiate(slotPrefab, this.transform);
                    slot.name = "Slot(" + j + "," + i + ")";
                    TetSlot tetSlot = slot.GetComponent <TetSlot>();
                    panelNextSlot.slotList[4 * i + j] = tetSlot;
                }
            }
        }
    }
Пример #10
0
    public void activeSlot(slot s, SlotController sc, int idCard)
    {
        panelChosseCard.SetActive(false);
        s.slotCard = Cards[idCard];

        iconBuild.sprite       = s.slotCard.spriteCard;
        buyDescriptionTxt.text = "Você liberou <color=#FFFF00>" + s.slotCard.cardName + "</color>";

        panelBuy.SetActive(true);

        getGold(s.slotPrice * -1);    //tirar o dinheiro
        s.isPurchased         = true; // comprou
        s.slotCard.isLiberate = true; //liberou
        s.startSlotScriptable();      //inicializou

        sc.SlotStart();

        //2 Q
        if (isQuest == true && idQuest == 2)
        {
            updateQuest();
        }

        saveSlot(s);
    }
Пример #11
0
        public void ListSlotsView()
        {
            Console.WriteLine("--- List slots ---");

            bool   firstDateTry = true;
            string date         = null;

            do
            {
                if (!firstDateTry)
                {
                    Console.WriteLine($"{date} is not a valid date. Please try again!");
                }
                firstDateTry = false;

                Console.WriteLine("Enter date for slots (dd-mm-yyyy): ");
                date = Console.ReadLine();
            } while (!Utils.ValidateDate(date));

            SlotController slotController = new SlotController();

            List <SlotModel> slots = slotController.GetSlotsByDate(DateTime.ParseExact($"{date} 00:00:00", "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture));

            Console.WriteLine($"Slots on {date}:");
            Console.WriteLine("\tRoom name \tStart time \tStaff ID \tBookings");


            foreach (var slot in slots)
            {
                string time      = slot.startTime.ToString("HH:mm");
                string studentId = slot.student == null ? "-" : slot.student.userId;
                Console.WriteLine($"\t{slot.room.RoomId} \t{time} \t{slot.staff.userId} \t{studentId}");
            }
        }
Пример #12
0
    public void Add(ItemObject item)
    {
        SlotController _freeSlot = GetFreeSlot().GetComponent <SlotController>();
        int            _slotID   = _freeSlot.GetSlotID();

        item.inventoryData.SetSlotID(_slotID);
        _freeSlot.SetItem(item);
    }
Пример #13
0
    /// <summary>
    /// This function helper for set Slot Controller.
    /// </summary>
    /// <returns></returns>
    public void SetSlotController(SlotController slotController)
    {
        this.slotController = slotController;
        hexagon.SetSlot(slotController.GetSlot());
        slotController.SetHexagonController(this);

        SlotChanged?.Invoke(slotController);
    }
Пример #14
0
        /// <summary>
        /// 系统初始化
        /// </summary>
        public void SystemInitialize()
        {
            foreach (var system in mSystem)
            {
                system.Value.Initialize(this);
            }

            mController = new SlotController(this);
        }
Пример #15
0
 public void OnDrag(PointerEventData eventData)
 {
     if (this.GetComponent <SlotController>().item != null)
     {
         SlotController temp = this.GetComponent <SlotController>();
         itemOnDrag         = temp.item.ItemPrefab;
         transform.position = Input.mousePosition;
     }
 }
Пример #16
0
 private void Awake()
 {
     _movingUIHandler = transform.parent.gameObject.GetComponent <MovingUIHandler>();
     for (int i = 0; i < EquipmentController.Instance.Capacity; ++i)
     {
         GameObject     slotGameObject = Instantiate(Slot, ScrollableSlots.transform.Find("SlotsPanel"));
         SlotController slotController = slotGameObject.GetComponent <SlotController>();
         EquipmentController.Instance.AddItemSlot(slotController);
     }
 }
Пример #17
0
 public void CreateSlots()
 {
     for (int i = 0; i < bag.GetSlotCount(); i++)
     {
         GameObject     _slotIns        = Instantiate(slotPref, container.transform);
         SlotController _slotController = _slotIns.GetComponent <SlotController>();
         _slotController.SetSlotID(i);
         _slotController.SetContainerItemType(ItemType.Bag);
     }
 }
Пример #18
0
 // Update card slot colours for player colour
 public void ChangeSlotColours(bool redPlayer)
 {
     foreach (GameObject cardSlot in cardSlots)
     {
         SlotController slotScript = cardSlot.GetComponent <SlotController>();
         slotScript.SetMaterial(redPlayer);
         slotScript.ResetSlot();
         redPlayer = !redPlayer;
     }
 }
Пример #19
0
    void Awake()
    {
        gameScript = gameManager.GetComponent<GameController>();
        actionCards = GameObject.FindGameObjectsWithTag ("ActionCard");
        displaySheep = new GameObject[4];

        slot1 = slotOne.GetComponent<SlotController>();
        slot2 = slotTwo.GetComponent<SlotController>();
        slot3 = slotThree.GetComponent<SlotController>();
        slot4 = slotFour.GetComponent<SlotController>();
    }
Пример #20
0
    void Awake()
    {
        gameScript   = gameManager.GetComponent <GameController>();
        actionCards  = GameObject.FindGameObjectsWithTag("ActionCard");
        displaySheep = new GameObject[4];

        slot1 = slotOne.GetComponent <SlotController>();
        slot2 = slotTwo.GetComponent <SlotController>();
        slot3 = slotThree.GetComponent <SlotController>();
        slot4 = slotFour.GetComponent <SlotController>();
    }
Пример #21
0
    /// <summary>
    /// This function returns Slot Controller by coordinate.
    /// </summary>
    /// <param name="coordinate"></param>
    /// <returns></returns>
    public SlotController GetSlotControllerByCoordinate(Coordinate coordinate)
    {
        SlotController targetSlotController = slotControllers.SingleOrDefault(x => x.GetCoordinate() == coordinate);

        if (targetSlotController == null)
        {
            Debug.LogError($"Target Slot Controller is Null! Coordinate : {coordinate}");
        }

        return(targetSlotController);
    }
Пример #22
0
    private void SpawnTrash(SlotController slot)
    {
        var trashGo  = UnityEngine.Object.Instantiate(_trashPrefab, slot.transform);
        var newTrash = trashGo.GetComponent <TrashController>();

        var typeCount = Enum.GetNames(typeof(TrashType)).Length;

        newTrash.InitService((TrashType)UnityEngine.Random.Range(0, typeCount));
        newTrash.InitView();

        slot.SetItemController(newTrash);
    }
Пример #23
0
    void CreateSlots()
    {
        int _amountOfSlots = equipment.GetSlotData().GetAmountOfSlots();

        for (int i = 0; i < _amountOfSlots; i++)
        {
            GameObject     _slotIns        = Instantiate(slotPref, container.transform);
            SlotController _slotController = _slotIns.GetComponent <SlotController>();
            _slotController.SetSlotID(i);
            _slotController.SetContainerItemType(ItemType.Equipment);
        }
    }
Пример #24
0
 private GameObject CheckObjectItExist(ScriptableObject gameObject, Sprite sprite, List <GameObject> listGameObject)
 {
     foreach (GameObject slotControllerObj in listGameObject)
     {
         SlotController slotController = slotControllerObj.GetComponent <SlotController>();
         if (slotController.ReturnPrefab() == gameObject && slotController.ReturnSprite() == sprite)
         {
             return(slotControllerObj);
         }
     }
     return(null);
 }
Пример #25
0
 private GameObject FindSortEquipObject(List <GameObject> listGameObject)
 {
     foreach (GameObject slotControllerObj in listGameObject)
     {
         SlotController slotController = slotControllerObj.GetComponent <SlotController>();
         if (slotController.ReturnPrefab() == null && slotController.ReturnSprite() == null)
         {
             return(slotControllerObj);
         }
     }
     return(null);
 }
Пример #26
0
    /// <summary>
    /// This function called when related Hexagon's coordinate changed.
    /// </summary>
    /// <param name="slotController"></param>
    private void OnSlotChanged(SlotController slotController)
    {
        if (GameManager.Instance.IsDebugMode())
        {
            m_coordinateText.text = hexagonController.GetCoordinate().ToString();
        }

        if (!hexagonController.GetSelectedState())
        {
            transform.SetParent(hexagonController.GetSlotController().transform, true);
        }
    }
Пример #27
0
    /// <summary>
    /// This function helper for shift some hexagons like gravity..
    /// </summary>
    /// <returns></returns>
    public async UniTask Gravity()
    {
        isGravity = true;
        Debug.Log("Gravity Progress Started.");

        foreach (List <SlotController> verticalSlots in seperateSlotControllers)
        {
            int emptyCount      = 0;
            int interactedCount = 1;

            foreach (SlotController slotController in verticalSlots.AsEnumerable().Reverse().ToList())
            {
                if (slotController.GetHexagonController() == null)
                {
                    emptyCount++;
                    continue;
                }

                if (emptyCount == 0)
                {
                    continue;
                }

                HexagonController hexagonController    = slotController.GetHexagonController();
                SlotController    oldSlotController    = hexagonController.GetSlotController();
                SlotController    targetSlotController = GetSlotControllerByCoordinate(new Coordinate(hexagonController.GetCoordinate().x, hexagonController.GetCoordinate().y + emptyCount));

                if (targetSlotController == null)
                {
                    continue;
                }

                oldSlotController.SetHexagonController(null);
                hexagonController.SetSlotController(targetSlotController);
                ((HexagonView)hexagonController.GetView()).DrawDefaultLayer(true, (float)interactedCount / 10);

                interactedCount++;
            }
        }

        await UniTask.WaitUntil(() => !DOTween.IsTweening(CommonTypes.HEXAGON_GRAVITY_TWEEN_KEY));

        FillEmptySlots();

        await UniTask.WaitUntil(() => !DOTween.IsTweening(CommonTypes.HEXAGON_GRAVITY_TWEEN_KEY));

        await CheckHexagons(hexagonControllers);
        await CheckGameOver();

        isGravity = false;
        Debug.Log("Gravity Progress Completed.");
    }
Пример #28
0
 public void DrawGuiSlotAtPosition(int x, int y, bool isSelected)
 {
     SlotController.DrawItemSlotWithSpriteAndDetails(
         y,
         x,
         SlotPrefix,
         Slots[y, x],
         Parent.transform,
         this,
         DrawLeftPadding,
         DrawBottomPadding,
         isSelected, GameObjectSlots);
 }
Пример #29
0
    private List <SlotController> GetLineForDestroy(string lineType, int lineIndex)
    {
        if (lineType != HORIZONTAL_LINE && lineType != VERTICAL_LINE)
        {
            throw new Exception("Incorrect type of line, use const strings of this class");
        }

        var lineList = new List <SlotController>();

        var isCreatingLine = false;

        for (int i = 1; i < FieldSize; i++)
        {
            var currentX = lineType == HORIZONTAL_LINE ? i : lineIndex;
            var currentY = lineType == VERTICAL_LINE ? i : lineIndex;
            var deltaX   = lineType == HORIZONTAL_LINE ? 1 : 0;
            var deltaY   = lineType == VERTICAL_LINE ? 1 : 0;

            SlotController currentSlot = GetSlotByPosition(currentX, currentY);

            if (currentSlot.IsSameTypeNeighborWith(currentX - deltaX, currentY - deltaY))
            {
                if (currentSlot.IsSameTypeNeighborWith(currentX + deltaX, currentY + deltaY) && !isCreatingLine) //add current and prev if next same
                {
                    isCreatingLine = true;
                    lineList.Add(currentSlot);
                    lineList.Add(GetSlotByPosition(currentX - deltaX, currentY - deltaY));
                }
                else if (isCreatingLine)
                {
                    lineList.Add(currentSlot);
                }
            }
            else
            {
                isCreatingLine = false;
            }
        }
        if (!(lineList.Count == 0 || lineList.Count > 2))
        {
            throw new Exception("Invalid line item count");
        }

        if (lineList.Any(slot => slot.TrashController.IsAbleToFall()))
        {
            return(new List <SlotController>());
        }

        return(lineList);
    }
Пример #30
0
    // Update is called once per frame
    void Update()
    {
        // create a ray cast that orignates from the cursor position
        Vector3 forward = transform.TransformDirection (Vector3.forward) * 5;
        RaycastHit hit;
        if (Physics.Raycast (transform.position, forward, out hit)) {
            if (currentObject == null) { //IF we haved no current object
                currentObject = hit.transform.gameObject; //save the object
                HighlightCurrentObject (); //and highlight it
            } else if (hit.transform != currentObject.transform) { //ELSE IF we have hit a different object
                RestoreCurrentObject (); //THEN restore the old object
                currentObject = hit.transform.gameObject; //save the new object
                HighlightCurrentObject (); //and highlight it

            }
        } else //ELSE no object was hit
            RestoreCurrentObject (); //THEN restore the old object

        //select one slot
        if (Physics.Raycast (transform.position, forward, out hitToSlotOrItem)) {
            itemIsHit = hitToSlotOrItem.transform.gameObject.GetComponent(typeof(Item)) as Item;
            slotIsHit = hitToSlotOrItem.transform.gameObject.GetComponent(typeof(SlotController)) as SlotController;

            //inventoryIsHit = hitToSlotOrItem.transform.gameObject.GetComponent(typeof(InventoryController)) as InventoryController;

            if(slotIsHit != null){
                slotIsHit.RayCastToSlot();
            }
            else{
                //slotIsHit.RayCastNotToSlot();
            }
            if(itemIsHit != null){
                itemIsHit.RayCastToItem();
            }
            else{
                //itemIsHit.RayCastNotToItem();
            }
            /*if(inventoryIsHit != null){
                inventoryIsHit.RayCastToInventory();
            }*/
        }

        if (Input.GetKeyDown (KeyCode.Return) || grab) {
            grab = false;
            if (currentObject != null){
                currentObject.SendMessage("Select");
            }
        }
    }
Пример #31
0
 public void SetObjectIsExist(ScriptableObject scriptableObject, Sprite spriteObj, float countObj)
 {
     if (CheckObjectItExist(scriptableObject, spriteObj, slotToolBar) != null)
     {
         SlotController slotController = CheckObjectItExist(scriptableObject, spriteObj, slotToolBar).GetComponent <SlotController>();
         slotController.SetCount(slotController.ReturnCountObject() + countObj);
         //SendToServerObjectToolBar(slotController, scriptableObject, spriteObj, countObj);
     }
     else if (CheckObjectItExist(scriptableObject, spriteObj, slotEquipmentBox) != null)
     {
         SlotController slotController = CheckObjectItExist(scriptableObject, spriteObj, slotEquipmentBox).GetComponent <SlotController>();
         slotController.SetCount(slotController.ReturnCountObject() + countObj);
         //SendToServerObjectToolBar(slotController, scriptableObject, spriteObj, countObj);
     }
 }
Пример #32
0
    void PlaysRandom()
    {
        int __randomIndex = UnityEngine.Random.Range(0, _boardController.SlotControllers.Length);

        while (_boardController.SlotControllers[__randomIndex].selected)
        {
            __randomIndex = UnityEngine.Random.Range(0, _boardController.SlotControllers.Length);
        }

        SlotController __slot = _boardController.SlotControllers[__randomIndex];

        _boardController.Board[__slot.xPos, __slot.yPos] = _currentPlayer;

        __slot.SetSymbolToSlot(_currentPlayer);
    }