Example #1
0
    /**
     * Disables the current turn player and moves on to the next
     */
    private void turnOver()
    {
        Debug.Log("Disabling " + battleQueueController.getCharacterRef().charName);

        if (turn == TYPE.PLAYER)
        {
            plyPanel.changeCurrentActivePlayer(players.IndexOf(battleQueueController.getCharacterRef()), false);
        }

        battleQueueController.getCharacterRef().setActive(false);
        battleQueueController = battleQueueController.getNext();
        battleQueueController.getCharacterRef().setActive(true);

        Debug.Log("Enabling " + battleQueueController.getCharacterRef().charName);

        turn = battleQueueController.getCharacterRef().getType();

        if (turn == TYPE.PLAYER)
        {
            heroCursor.reposition(battleQueueController.getCharacterRef().getPosition());
            heroCursor.relocate(1.5f * scale, 0.5f * scale);
            plyPanel.changeCurrentActivePlayer(players.IndexOf(battleQueueController.getCharacterRef()), true);
        }
        else if (turn == TYPE.ENEMY)
        {
            heroCursor.gameObject.SetActive(false);
        }
    }
Example #2
0
 public bool equals(CharacterNode c)
 {
     if (c.getCharacterRef() == this.characterRef)
     {
         return(true);
     }
     return(false);
 }
Example #3
0
    private void addToQueue(Character c)
    {
        if (battleQueue == null)
        {
            battleQueue = new CharacterNode(c, battleQueue);
            battleQueue.setNextRef(battleQueue);
        }
        else
        {
            CharacterNode current = battleQueue;

            //keep traversing as long as c.speed is greater than the one next to it and
            //the next node is not the head node
            while (c.speed >= current.getCharacterRef().speed&& !battleQueue.equals(current.getNext()))
            {
                current = current.getNext();
            }

            current.setNextRef(new CharacterNode(c, current.getNext()));
        }
    }
Example #4
0
    void Awake()
    {
        Debug.Log("Game Starting");

        players     = new List <Character>();
        enemies     = new List <Character>();
        battleQueue = null;

        /* starting up the battle heros*/
        Debug.Log("Setting up Characters");
        monk      = Instantiate(monk, new Vector3(4.25f * scale, 1f * scale, 0), Quaternion.identity);
        swordsmen = Instantiate(swordsmen, new Vector3(4.5f * scale, 0f, 0), Quaternion.identity);

        leafy = Instantiate(leafy, new Vector3(-4f * scale, 0f, 0), Quaternion.identity);

        players.Add(monk);
        players.Add(swordsmen);

        enemies.Add(leafy);

        addToQueue(monk);
        addToQueue(swordsmen);
        addToQueue(leafy);

        //points the queue pointer to the first on in the queue
        battleQueueController = battleQueue;

        //setting up the cursor
        Debug.Log("Setting up hero cursor");
        heroCursorDelay        = 0.25f;
        lastCursorMove         = Time.time;
        currentHeroOptionIndex = 0;

        //setting up the enemy cursor
        Debug.Log("Setting up the enemy cursor");
        targetCursorDelay = 0.25f;
        lastCursorMove    = Time.time;

        //sets the first person in the queue as the person with the first turn
        battleQueueController.getCharacterRef().setActive(true);
        turn = battleQueueController.getCharacterRef().getType();

        // Menu Set up
        plyPanel = Instantiate(plyPanel);
        plyPanel.setUp(canvas, players.Count, players);
        plyPanel.setActivity(true);

        enemyPanel = Instantiate(enemyPanel);
        string[] enemyListNames = new string[enemies.Count];

        for (int count = 0; count < enemies.Count; count++)
        {
            enemyListNames[count] = enemies[count].charName;
        }

        enemyPanel.setUp(canvas, enemies.Count, enemyListNames);
        enemyPanel.setActivity(true);
        enemyPanel.setGlow(false);

        monk.setShitUp(canvas);
        swordsmen.setShitUp(canvas);

        // It it's the players turn first, the cursor will point to the player
        if (turn == TYPE.PLAYER)
        {
            setUpCursor(battleQueueController.getCharacterRef(), true, 1.5f * scale, 0.5f * scale);
            plyPanel.changeCurrentActivePlayer(players.IndexOf(battleQueueController.getCharacterRef()), true);
        }

        setUpCursor(enemies[0], false, 1.5f * scale, 0.5f * scale);//sets up the target cursor temporarily
        targetCursor.setActivity(false);

        selectedCommand = Command.NONE;
        inputWaiter     = Command.NONE;
    }
Example #5
0
    // Update is called once per frame
    // TODO Implement when game is over
    //
    void Update()
    {
        /*once the character says they are over, it's myTurn is false,
         * it's turnOver is reset and the battleQueueController does to the next person
         * in the queue
         */
        if (turn == TYPE.PLAYER)
        {
            Debug.Log("Players Turn");
            if (inputWaiter == Command.NONE)
            {
                Command currentUserInput = cmdInputCheck(Time.time); // gets current time
                if (!heroCursor.gameObject.active)
                {
                    heroCursor.gameObject.SetActive(true);
                }

                if (currentUserInput != Command.NONE)
                {
                    if (currentUserInput == Command.ATTACK)
                    {
                        //battleQueueController.getCharacterRef().getAnimator().SetTrigger("attack");
                        inputWaiter         = Command.ATTACK;
                        targetList          = enemies;
                        targetSelectorIndex = 0;
                        targetCursor.setActivity(true);
                        //targetCursor.reposition(targetList[targetSelectorIndex].getPosition());
                        targetCursor.updatePosition(targetList[targetSelectorIndex]);
                        //targetCursor.relocate(1.5f * scale, 0.5f * scale);
                        Debug.Log("Calling for Attack Input");
                    }
                    else if ((currentUserInput == Command.MAGIC))
                    {
                        inputWaiter = Command.MAGIC;
                        Debug.Log("Calling for Magic Input");
                    }
                    else if ((currentUserInput == Command.ITEMS))
                    {
                        inputWaiter = Command.ITEMS;
                        Debug.Log("Calling for Items Input");
                    }
                }
            }
            else if (inputWaiter == Command.ATTACK)
            {
                Debug.Log("Waiting for Attack Input");
                dummyChar = targetSelection(Time.time);
                if (dummyChar != null)
                {
                    //Debug.Log("Got Target");
                    registerAttack(battleQueueController.getCharacterRef(), dummyChar);
                    turnOver();
                    inputWaiter = Command.NONE;
                }
            }
            else if (inputWaiter == Command.MAGIC)
            {
                Debug.Log("Waiting for Magic Input");
                inputWaiter = Command.NONE;
            }
            else if (inputWaiter == Command.ITEMS)
            {
                Debug.Log("Waiting for Item Input");
                inputWaiter = Command.NONE;
            }
        }
        else if (turn == TYPE.ENEMY)
        {
            Debug.Log("Enemy Turn");
            if (heroCursor.gameObject.active)
            {
                heroCursor.gameObject.SetActive(false);
            }
            registerAttack(battleQueueController.getCharacterRef(), ((Enemy)battleQueueController.getCharacterRef()).enemyAIAction(players, enemies));
            turnOver();
        }
    }