public void toggleIsInMovementMode()
    {// (wip) will toggle weather this character is in movement mode or in action mode
        Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();

        if (isInMovementMode)
        {
            if (numOfAvailibleActions > 0)
            {
                isInMovementMode = false;
                Grid_Character_Movement.resetAreaOfMovement();

                print("Is in action mode");
            }
        }
        else
        {
            if (remainingMovement > 0)
            {
                isInMovementMode = true;
                Grid_Character_Movement.findAreaOfMovement(currentX: Creature_Stats.currentX, currentY: Creature_Stats.currentY, currentZ: Creature_Stats.currentZ, numOfSteps: remainingMovement);

                print("Is in movement mode");
            }
        }
    }
    // ------------------ turn management ---------------------------

    public void startTurn()
    {//(wip) will reset all of a creatures stats at start of turn, will be called at start of turn
        remainingMovement          = maxMovement;
        numOfAvailibleActions      = numOfMaxActions;
        numOfAvailibleBonusActions = numOfMaxBonusActions;
        isInMovementMode           = true;

        Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();

        // will pull up area of movement for that creature
        Grid_Character_Movement.findAreaOfMovement(currentX: Creature_Stats.currentX, currentY: Creature_Stats.currentY, currentZ: Creature_Stats.currentZ, numOfSteps: maxMovement);

        isTurn = true;
    }
    private bool endOfTurn()
    {//(wip) this script will check all the end of turn conditions
        if (remainingMovement == 0 && numOfAvailibleActions == 0)
        {
            Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();

            Grid_Character_Movement.resetAreaOfMovement();

            return(true);
        }
        else
        {
            return(false);
        }
    }
    public void doAction(string actionType = "Wait")
    {//(wip) this script will be called when a creature inputs an action command
        if (isTurn)
        {
            if (numOfAvailibleActions > 0)
            {
                ActionDatabase actData = new ActionDatabase();
                Action         act     = actData.callUpAction(actionType);

                if (selectionChecker(act))
                {// wait for selection
                    currentAct       = act;
                    requestSelection = true;

                    Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();

                    Grid_Character_Movement.resetAreaOfMovement();

                    Grid_Character_Movement.findAreaOfMovement(currentX: Creature_Stats.currentX, currentY: Creature_Stats.currentY, currentZ: Creature_Stats.currentZ, numOfSteps: act.range);

                    print("target selection is needed");
                }
                else
                {// run without selection
                    Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();

                    Grid_Character_Movement.resetAreaOfMovement();

                    Grid_Character_Movement.findAreaOfMovement(currentX: Creature_Stats.currentX, currentY: Creature_Stats.currentY, currentZ: Creature_Stats.currentZ, numOfSteps: act.range);

                    outgoingActionProcessing(act: act, creaturePos: new int[] { Creature_Stats.currentX, Creature_Stats.currentY, Creature_Stats.currentZ }, targetPos: new int[, ] {
                        { Creature_Stats.currentX, Creature_Stats.currentY, Creature_Stats.currentZ }
                    });
                }
                print("this creature did something");
            }
            else
            {
                print("this creature has no more actions left");
            }
        }
        else
        {
            print("It is not this creatures turn");
        }
    }
    // ------------------ ui/options per turn -------------------------


    public void moveCreature(int x, int y, int z)
    {//(wip) this script will be called when a creature inputs a move command
        Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();

        if (isTurn)
        {
            if (remainingMovement > 0)
            {
                if (Grid_Character_Movement.canMoveToSpace(endX: x, endY: y, endZ: z))
                {
                    //animate character moving

                    int startX = Creature_Stats.currentX;
                    int startY = Creature_Stats.currentY;
                    int startZ = Creature_Stats.currentZ;

                    GameObject[] path = Grid_Character_Movement.findPathOfMovement(startX: startX, startY: startY, startZ: startZ, endX: x, endY: y, endZ: z);

                    Grid_Character_Model_Movement.startModelMoveAnimation(path);
                    Grid_Character_Movement.resetAreaOfMovement();
                    Creature_Stats.currentX = x;
                    Creature_Stats.currentY = y;
                    Creature_Stats.currentZ = z;

                    //-------------------------

                    // update amount moved here
                    // -------------------------
                    remainingMovement = 0; // needs to be updated when pathing system is in place
                }
                else
                {
                    print("This creature can't move there");
                }
            }
            else
            {
                print("This creature has no movement left");
            }
        }
        else
        {
            print("It is not this creatures turn");
        }
    }
    //---- used to 'teleport' creatures across the map--------------

    public void moveModel(GameObject[] path = null, int currentX = 0, int currentY = 0, int currentZ = 0, int endX = 1, int endY = 1, int endZ = 1)
    {//(wip) this function will move the model across the grid
        Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();

        g = Grid_Character_Movement.findGridUnitByCordinate(endX, endY, endZ);

        if (g == null)
        {
            print("There seems to be a problem");
        }
        else
        {
            creature.transform.position = g.transform.position; // is just a place holder for now

            // animate character moving
            // must read the array and animate the model accordingling
        }
    }
    public void Update()
    {//(wip) will reset and update the animation movement process
        if (isMoving)
        {
            print("character model is moving");
            //run moving animations
            if (arrayPosition < path.Length)
            {
                print("the array position is not null");
                moveAnimationProcessing(path[arrayPosition]);
            }
            else
            {
                Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();
                Grid_Character_Movement.resetPathOfMovement();

                arrayPosition = 0;
                isMoving      = false;

                preformAnimationBool("isMoving");
            }
        }
    }
예제 #8
0
    public void ai_mouseHover(int x, int y, int z, bool unselect = false)
    {//(wip) this function will update the mouse selection
        if (unselect == false)
        {
            Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();

            GameObject g = Grid_Character_Movement.findGridUnitByCordinate(x, y, z);
            script = g.GetComponent <Grid_Unit_Script>();

            selectedGridUnit.x = script.x;
            selectedGridUnit.y = script.y;
            selectedGridUnit.z = script.z;

            script.selection.SetActive(true);
        }

        if (unselect == true)
        {
            script.selection.SetActive(false);
        }

        print("The enemy has selected a space");
    }
    // ------------------- action processing -----------------------------

    public void outgoingActionProcessing(int[] creaturePos, int[,] targetPos, Action act = null)
    {//(wip) this script will find the creature to do the action to and will send the needed data to that given creature
        if (isTurn)
        {
            if (numOfAvailibleActions > 0)
            {
                Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();

                if (currentAct != null)
                {
                    act = currentAct;
                }
                if (act == null)
                {
                    print("this creature needs an action selected first");
                }
                else
                {
                    print("processing the action " + act.name);

                    Grid_Character_Movement.resetAreaOfMovement();

                    Grid_Character_Movement.findAreaOfMovement(currentX: creaturePos[0], currentY: creaturePos[1], currentZ: creaturePos[2], numOfSteps: act.range);

                    GameObject[] creatures = GameObject.FindGameObjectsWithTag("creature");

                    for (int i = 0; i < targetPos.GetLength(0); i++)
                    {
                        int x = targetPos[i, 0];
                        int y = targetPos[i, 1];
                        int z = targetPos[i, 2];

                        foreach (GameObject creature in creatures)
                        {
                            int creatureX = creature.GetComponent <Creature_Stats>().currentX;
                            int creatureY = creature.GetComponent <Creature_Stats>().currentY;
                            int creatureZ = creature.GetComponent <Creature_Stats>().currentZ;

                            if (creatureX == x && creatureY == y && creatureZ == z && !Grid_Character_Movement.gridUnitChecker(Grid_Character_Movement.findGridUnitByCordinate(x, y, z)))
                            {
                                print("a target has been found");
                                foundTarget = true;

                                creature.GetComponent <Grid_Character_Turn_Manager>().incomingActionProcessing(act);
                            }
                        }
                    }

                    //run polish here--------------

                    if (act.animationName != null)
                    {
                        if (act.animationAccessType == "trigger")
                        {
                            Grid_Character_Model_Movement.preformAnimationTrigger(act.animationAccessID);
                        }
                        if (act.animationAccessType == "bool")
                        {
                            Grid_Character_Model_Movement.preformAnimationBool(act.animationAccessID);
                        }
                    }

                    //----------------------------

                    numOfAvailibleActions--;
                    Grid_Character_Movement.resetAreaOfMovement();
                }
            }
            else
            {
                print("this creature has no more actions avalible");
            }
        }
        else
        {
            print("it is not this creatures turn");
        }
    }
예제 #10
0
    // Update is called once per frame
    void Update()
    {
        // grid inputs
        if (Input.GetKeyDown("g") == true)
        {// generates a grid
            int rows        = Grid_Generator_Script.rows;
            int columns     = Grid_Generator_Script.columns;
            int layers      = Grid_Generator_Script.layers;
            int unitSpacing = Grid_Generator_Script.unitSpacing;
            int startX      = Grid_Generator_Script.startX;
            int startY      = Grid_Generator_Script.startY;
            int startZ      = Grid_Generator_Script.startZ;

            Grid_Generator_Script.GenerateGrid(rows, columns, layers, startX, startY, startZ, unitSpacing);
            if (Grid_Generator_Script.debugLogs_02)
            {
                print("A Grid has been made");
            }
        }
        if (Input.GetKeyDown("0") == true)
        {// will reveal the entire grid
            GameObject[] gArray = GameObject.FindGameObjectsWithTag("gridUnit");

            foreach (GameObject g in gArray)
            {
                g.GetComponent <Grid_Unit_Script>().stepNum = 1;
            }
        }
        if (Input.GetKeyDown("1") == true)
        {// will make grid combination number 1
            Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();
            Grid_Character_Movement.updateGridSub(new int[, ] {
                { 4, 0, 0 }, { 4, 0, 1 }, { 4, 0, 2 }, { 4, 0, 3 }, { 4, 0, 4 }, { 5, 0, 0 }, { 5, 0, 1 }, { 5, 0, 2 }, { 5, 0, 3 }, { 5, 0, 4 }, { 0, 0, 4 }, { 1, 0, 4 }, { 7, 0, 5 }, { 7, 0, 6 }, { 8, 0, 5 }, { 8, 0, 6 }, { 9, 0, 5 }, { 9, 0, 6 }, { 4, 0, 8 }, { 4, 0, 9 }, { 5, 0, 8 }, { 5, 0, 9 }
            });
        }
        if (Input.GetKeyDown("c") == true)
        {//clears any area of movement
            Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();
            Grid_Character_Movement.resetAreaOfMovement();
            print("C was pressed");
        }
        if (Input.GetKeyDown("p") == true)
        {// will draw a creature path
            Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();
            path = Grid_Character_Movement.findPathOfMovement(endX: endX, endZ: endZ);

            int x, y, z;

            int num = 0;

            if (path != null)
            {
                foreach (GameObject unit in path)
                {
                    x = unit.GetComponent <Grid_Unit_Script>().x;
                    y = unit.GetComponent <Grid_Unit_Script>().y;
                    z = unit.GetComponent <Grid_Unit_Script>().z;

                    //print ("The path point " + num + " is at the cordinate (" + x + "," + y + "," + z + ")");

                    num++;
                }

                Grid_Character_Movement.updateGridUnits(path);
            }

            print("p was pressed");
        }
        if (Input.GetKeyDown("r") == true)
        {// will reset the drawn path
            Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement();

            Grid_Character_Movement.resetPathOfMovement();
        }
        if (Input.GetKeyDown("w") == true)
        {
            GameObject g;
            g = Grid_Turn_Manager.turnOrder[Grid_Turn_Manager.currentTurn];

            g.GetComponent <Grid_Character_Model_Movement>().startModelMoveAnimation(path);

            print("w was pressed");
        }

        /*
         * if (Input.GetKeyDown("w") == true)
         * {//test the findAreaOfMovement funtion
         * int currentX = Grid_Character_Movement.currentX;
         * int currentY = Grid_Character_Movement.currentY;
         * int currentZ = Grid_Character_Movement.currentZ;
         * int numOfSteps = Grid_Character_Movement.numOfSteps;
         *
         * Grid_Character_Movement.findAreaOfMovement(currentX: currentX, currentY: currentY, currentZ: currentZ, numOfSteps: numOfSteps);
         * if(Grid_Character_Movement.debugLogs_Input) print ("W was pressed");
         * }
         * if (Input.GetKeyDown("c") == true)
         * {//clears any area of movement
         * Grid_Character_Movement.resetAreaOfMovement();
         * if(Grid_Character_Movement.debugLogs_Input) print ("C was pressed");
         * }
         */

        /*
         * if (Input.GetKeyDown("s") == true)
         * {// finds the area of movement based on given creature
         * int currentX = Creature_Stats.currentX;
         * int currentY = Creature_Stats.currentY;
         * int currentZ = Creature_Stats.currentZ;
         * int numOfSteps = Creature_Stats.speed;
         *
         * Grid_Character_Movement.findAreaOfMovement(currentX: currentX, currentY: currentY, currentZ: currentZ, numOfSteps: numOfSteps);
         * }
         * if (Input.GetKeyDown("m") == true)
         * {// moves given creature to its end position, if it can
         * int endX = Creature_Stats.endX;
         * int endY = Creature_Stats.endY;
         * int endZ = Creature_Stats.endZ;
         *
         * if (Grid_Character_Movement.canMoveToSpace(endX: endX, endY: endY, endZ: endZ))
         * {
         *  Grid_Character_Movement.resetAreaOfMovement();
         *
         *  Creature_Stats.currentX = endX;
         *  Creature_Stats.currentY = endY;
         *  Creature_Stats.currentZ = endZ;
         *
         *  Grid_Character_Model_Movement.moveModel(endX: endX, endY: endY, endZ: endZ);
         * }
         * else
         * {
         *
         * }
         * }
         * if (Input.GetKeyDown("p") == true)
         * {// moves given creature model to its starting position
         * int endX = Creature_Stats.currentX;
         * int endY = Creature_Stats.currentY;
         * int endZ = Creature_Stats.currentZ;
         *
         * Grid_Character_Model_Movement.moveModel(endX: endX, endY: endY, endZ: endZ);
         * }
         */

        // frame work set up
        if (Input.GetKeyDown("s") == true)
        {// sets up the grid
            Grid_Turn_Manager.setUpTurnOrder();
            Grid_Turn_Manager.setUpGrid();
            Grid_Turn_Manager.nextTurn();

            print("s was pressed");
        }

        // creature turn options

        /*
         * if (Input.GetKeyDown("e") == true)
         *  {// will end the current creatures turn
         *
         * GameObject g;
         * g = Grid_Turn_Manager.turnOrder[Grid_Turn_Manager.currentTurn];
         *
         * g.GetComponent<Grid_Character_Turn_Manager>().remainingMovement = 0;
         * g.GetComponent<Grid_Character_Turn_Manager>().numOfAvailibleActions = 0;
         *
         * print ("e was pressed");
         *  }
         */

        if (Input.GetKeyDown("m") == true)
        {// will move the creature whos turn it is to there given end point
            GameObject g;
            g = Grid_Turn_Manager.turnOrder[Grid_Turn_Manager.currentTurn];

            g.GetComponent <Grid_Character_Model_Movement>().preformAnimationBool("isMoving");

            print("m was pressed");
        }
        if (Input.GetKeyDown("d") == true)
        {// will have the creature whos turn it is do the wait action
            GameObject g;
            g = Grid_Turn_Manager.turnOrder[Grid_Turn_Manager.currentTurn];

            g.GetComponent <Grid_Character_Model_Movement>().preformAnimationBool("isDead");

            print("d was pressed");
        }
        if (Input.GetKeyDown("a") == true)
        {// will have the creature whos turn it is do the attack action
            GameObject g;
            g = Grid_Turn_Manager.turnOrder[Grid_Turn_Manager.currentTurn];

            g.GetComponent <Grid_Character_Model_Movement>().preformAnimationTrigger("isAttacking");
            print("a was pressed");
        }
        if (Input.GetKeyDown("h") == true)
        {// will have the creature whos turn it is do the attack action
            GameObject g;
            g = Grid_Turn_Manager.turnOrder[Grid_Turn_Manager.currentTurn];

            g.GetComponent <Grid_Character_Model_Movement>().preformAnimationTrigger("isHit");
            print("h was pressed");
        }
        if (Input.GetKeyDown("z") == true)
        {// will select a target for the creature to attack
            GameObject g;
            g = Grid_Turn_Manager.turnOrder[Grid_Turn_Manager.currentTurn];

            int[] currentPos = new int[] { g.GetComponent <Creature_Stats>().currentX, g.GetComponent <Creature_Stats>().currentY, g.GetComponent <Creature_Stats>().currentZ };
            int[,] targetPos = new int[, ] {
                { (int)actTarget.x, (int)actTarget.y, (int)actTarget.z }
            };

            g.GetComponent <Grid_Character_Turn_Manager>().outgoingActionProcessing(currentPos, targetPos);

            print("z was pressed");
        }

        /*
         *
         * if( Input.GetAxisRaw("Fire1") != 0)//(wip) this will call the onclick function
         * {
         *   if(m_isAxisInUse == false)
         *   {
         *       // Call your event function here.
         *       Grid_UI_Manager.onClick();
         *
         *       print ("Left mouse button was pressed");
         *       m_isAxisInUse = true;
         *   }
         * }
         * if( Input.GetAxisRaw("Fire1") == 0)
         * {
         *   m_isAxisInUse = false;
         * }
         *
         * if (Input.GetKeyDown("t") == true)
         * {
         * Grid_UI_Manager.toggleType();
         *
         * print ("t was pressed");
         * }
         */
    }