コード例 #1
0
ファイル: UIController.cs プロジェクト: DefaultV/Unity
 public void TriggerCategory_Spell()
 {
     if (GC.getActionPoints() <= 0)
     {
         return;
     }
     //Do UI stuff
     ShowSpells(true);
     if (!chosenSpell)
     {
         chosenSpell      = true;
         currentItemChild = 0;
         MoveMenuSelector(GameObject.Find("SpellPanel"));
         Debug.Log("Moving ...");
     }
     else if (chosenSpell)
     {
         if (resolveSpell)
         {
             GameObject[] spell_tiles = GameObject.FindGameObjectsWithTag("Tile");
             foreach (GameObject tile in spell_tiles)
             {
                 tileClass tc    = tile.GetComponent <tileClass>();
                 int       calc2 = Math.Abs(SC.getX() - tc.getX()) + Math.Abs(SC.getY() - tc.getY()); // Manhattan distance
                 if (calc2 <= SC.getCurrentSpellAoe())
                 {
                     if (tc.getCurrentCreature() != null)
                     {
                         GetSelectedSpell().trigger(tc.getCurrentCreature().GetComponent <CreatureClass>());
                         Debug.Log("Triggering spell on creature in range: " + tc.getCurrentCreature().GetComponent <CreatureClass>().getName());
                     }
                 }
             }
             Debug.Log("Resolving spell");
             chosenSpell  = false;
             resolveSpell = false;
             SC.setMoveMode(false);
             SC.clearCache();
             //HACKFIX
             //REDACTED resetPointer();
             //currentCategory = GameObject.Find("UI_Playmode_panel").transform.GetChild(0).transform.GetChild(0).gameObject;
             ShowUI_PLAYMODE();
             UpdateUI_PLAYMODE();
             //REDACTED MoveOutCategory();
             GC.actionPointSpent();
             SB.play(SB.SpellBuff);
             SC.AttackCreatureSpell_stockhold();
             //hideSkillBook();
         }
         else if (!resolveSpell)
         {
             SC.setCurrentSpellRange(GetSelectedSpell().getRange());
             SC.setCurrentSpellAoe(GetSelectedSpell().getAoE());
             SC.SelectCreatureOnTile(SC.getX(), SC.getY(), 4);
             SC.setMoveMode(true);
             HideUI_PLAYMODE();
             Debug.Log("setting spell: " + GetSelectedSpell().getSpellName());
             resolveSpell = true;
         }
         //END
     }
 }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        translation = Input.GetAxis("Vertical");
        rotation    = Input.GetAxis("Horizontal");

        if (playMode)
        {
            EnterPlayMode();
        }
        else
        {
            EnterDebugMode();
        }

        if (Input.GetKeyDown(KeyCode.W) && !playMode)
        {
            SetSelectorPosition(c_X - 1, c_Y);
            soundbox.play(soundbox.selectMove);
        }
        if (Input.GetKeyDown(KeyCode.A) && !playMode)
        {
            SetSelectorPosition(c_X, c_Y - 1);
            soundbox.play(soundbox.selectMove);
        }
        if (Input.GetKeyDown(KeyCode.S) && !playMode)
        {
            SetSelectorPosition(c_X + 1, c_Y);
            soundbox.play(soundbox.selectMove);
        }
        if (Input.GetKeyDown(KeyCode.D) && !playMode)
        {
            SetSelectorPosition(c_X, c_Y + 1);
            soundbox.play(soundbox.selectMove);
        }

        //DEBUG TESTING
        if (Input.GetKeyDown(KeyCode.Space) && !playMode)
        {
            if (creatureSelected)
            {
                MoveCreatureToTile(c_X, c_Y);
            }
            else
            {
                SelectCreatureOnTile(c_X, c_Y, 1);
            }
        }
        //DEBUG TESTING
        if (Input.GetKeyDown(KeyCode.K) && !playMode)
        {
            if (creatureSelected)
            {
                AttackCreatureMelee(c_X, c_Y);
            }
        }
        if (Input.GetKeyDown(KeyCode.L) && !playMode)
        {
            if (creatureSelected)
            {
                AttackCreatureSpell(c_X, c_Y, currentCreatureSelected.GetComponent <CreatureClass>().getSpells()[0]);
            }
        }
        if (Input.GetKeyDown(KeyCode.P))
        {
            playMode = !playMode;
        }
        Controls();
    }