private void updateSkillsKeysSelection()
 {
     // skills (0 - 9)
     for (int i = 48, j = 0; i <= 57; ++i, ++j)
     {
         if (Input.GetKeyDown((KeyCode)i))
         {
             if (_skillsTiles[j].transform.childCount > 0)
             {
                 Chip chipScript = _skillsTiles[j].transform.GetChild(0).GetComponent <Chip>();
                 if (chipScript.Type == Chip.ChipType.STATE || chipScript.Type == Chip.ChipType.CONSUMABLE)
                 {
                     if (chipScript.IsActive)
                     {
                         chipScript.Deactivate();
                     }
                     else
                     {
                         chipScript.Activate();
                     }
                 }
                 else if (chipScript.Type == Chip.ChipType.SKILL)
                 {
                     Inventory.Instance.ActivateChipExclusively(chipScript);
                 }
             }
         }
     }
 }
Beispiel #2
0
    // =====================================================================================================
    // activate chip and deactivate all Others at the same type
    public void ActivateChipExclusively(Chip chip)
    {
        // return if already active
        if (chip.IsActive)
        {
            return;
        }

        // deactivate all the rest with the same type
        Transform grid = chip.transform.parent.parent;

        foreach (Transform tileItem in grid)
        {
            if (tileItem.childCount > 0)
            {
                Chip chipInTileScript = tileItem.GetChild(0).GetComponent <Chip>();
                if (chipInTileScript.IsActive && chipInTileScript.Type == chip.Type)
                {
                    chipInTileScript.Deactivate();
                }
            }
        }

        // activate chosen
        chip.Activate();
    }
Beispiel #3
0
    /// <summary>
    /// Tells the character to use the appropiate chip, if that chip is not available it automatically use the default Chip
    /// It also check if Chips are usable in the first place so it can be called any time without worrying about the state of the character
    /// </summary>
    /// <param name="chipSlot">The slot of the chip (1-4) any other number will result in using the default chip </param>
    public void UseChip(int chipSlot)
    {
        Transform chipTransform; //Tranform property of the chip slot to check if it has a child

        if (characterState.CurrentState == PlayerStates.idle || characterState.CurrentState == PlayerStates.moving)
        {
            switch (chipSlot)
            {
            case 1:
                chipTransform = transform.FindChild("Chip1");
                if (chipTransform.childCount > 0)
                {
                    //If it has a chlid it means that the slot contains an usable chip
                    chipTransform.GetChild(0).SendMessage("Activate", 1);     //so we activate it
                }
                else
                {
                    //If is empty
                    UseChip(-1);     //we call the use chip function to use the default chip instead
                }
                break;

            case 2:
                chipTransform = transform.FindChild("Chip2");
                if (chipTransform.childCount > 0)
                {
                    //If it has a chlid it means that the slot contains an usable chip
                    chipTransform.GetChild(0).SendMessage("Activate", 2);     //so we activate it
                }
                else
                {
                    //If is empty
                    UseChip(-1);     //we call the use chip function to use the default chip instead
                }
                break;

            case 3:
                chipTransform = transform.FindChild("Chip3");
                if (chipTransform.childCount > 0)
                {
                    //If it has a chlid it means that the slot contains an usable chip
                    chipTransform.GetChild(0).SendMessage("Activate", 3);     //so we activate it
                }
                else
                {
                    //If is empty
                    UseChip(-1);     //we call the use chip function to use the default chip instead
                }
                break;

            case 4:
                chipTransform = transform.FindChild("Chip4");
                if (chipTransform.childCount > 0)
                {
                    //If it has a chlid it means that the slot contains an usable chip
                    chipTransform.GetChild(0).SendMessage("Activate", 4);     //so we activate it
                }
                else
                {
                    //If is empty
                    UseChip(-1);     //we call the use chip function to use the default chip instead
                }
                break;

            default:
                chipTransform = transform.FindChild("DefaultChip");
                //chipTransform.GetChild(0).SendMessage("Activate");
                Chip currentChip = chipTransform.GetChild(0).GetComponent <Chip>();
                if (currentChip.IsReady())
                {
                    currentChip.Activate(-1);
                }
                break;
            }
        }
        else
        {
            //Play a sound... maybe
        }
    }