Пример #1
0
    public void CheckAttacks()
    {
        char temp;

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            Debug.Log("Cycling attackS");

            am.ChangeActiveAttack(am.activeIndex + 1);
        }
        if (am.activeAttack != null)
        {
            if (specialToKey.ContainsKey(am.activeText.text[indexer].ToString()))
            {
                if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
                {
                    // check if the user has pressed it
                    if (Input.GetKeyDown(specialToKey[am.activeText.text[indexer].ToString()]))
                    {
                        indexer = 0;
                        am.DestroyActive();
                    }
                }
            }
            else if (am.activeText.text[indexer] == ' ')
            {
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    am.activeOverlay.text += " ";
                    indexer++;
                    if (indexer == am.activeText.text.Length)
                    {
                        indexer = 0;
                        am.DestroyActive();
                    }
                }
            }
            else if (Input.GetKeyDown((temp = am.activeText.text[indexer]).ToString()))
            {
                am.activeOverlay.text += temp;
                indexer++;
                if (indexer == am.activeText.text.Length)
                {
                    indexer = 0;
                    am.DestroyActive();
                }
            }
        }
        // Check attacks FIRST OLD CODE
        //for (int i = 0; i < attacks.Count; i++)
        //{
        //    if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
        //    {
        //        // If this is a special character,
        //        if (specialToKey.ContainsKey(attackWords[i]))
        //        {
        //            // check if the user has pressed it
        //            if (Input.GetKeyDown(specialToKey[attackWords[i]]))
        //            {
        //                // If they have remove the attack
        //                attackRemoved = true;
        //                RemoveAttack(i);
        //                // Reset the overlays/ what the player has typed
        //                ClearOverlays();
        //                i--;
        //                break;

        //            }
        //        }
        //    }
        //    // if user typed one of the defensible chars (and shift is not held)
        //    else if (Input.GetKeyDown(attackWords[i]))
        //    {
        //        attackRemoved = true;
        //        RemoveAttack(i);
        //        i--;
        //        break;
        //    }
        //}
    }