Exemplo n.º 1
0
    //this is how we tell if a hex is occupied
    public void OccupiedHex()
    {
        string clickTile;
        //open and access the map and click
        GameObject       board = GameObject.Find("map");
        Map_v12          map   = board.GetComponent <Map_v12>();
        ClickableTile_v5 click = board.GetComponent <ClickableTile_v5>();

        clickTile = click.clickCoor;
        //access the lizard battle so it runs on that, not the general battle script
        GameObject liz       = GameObject.Find("Lizard");
        Lizard_v3  lizClass  = liz.GetComponent <Lizard_v3>();
        Battle_v3  lizBattle = liz.GetComponent <Battle_v3>();

        //Debug.Log(clickTile);
        //this is how battle is called, and the condition is if the hex is in occupied hex list AND is in the lizards neighbor list
        if ((lizBattle.OccupiedHexs.ContainsKey(clickTile)) && (lizClass.actualNeighbors.Contains(clickTile)))
        {
            GameObject bird      = GameObject.Find(lizBattle.OccupiedHexs[clickTile]);
            Bird_v3    birdClass = bird.GetComponent <Bird_v3>();
            lizBattle.enemy = birdClass.unit;
            lizBattle.Battle();
        }

        //Healing
        if ((lizClass.healingTiles.Contains(clickTile)) && (lizClass.actualNeighbors.Contains(clickTile)))
        {
            Debug.Log("Lizard walked into a healing fountain and replenished 10 Health");
            self.health += 10;
            lizClass.healingTiles.Remove(clickTile);

            //lizBattle.healing();
            Debug.Log(self.health);
        }
    }
Exemplo n.º 2
0
    //test movement module
    public void lizardMove()
    {
        //declarations
        string xstr;
        string ystr;

        xstr = xTile.ToString();
        ystr = yTile.ToString();
        float charHeight;

        //new, for 2-Y movement in a turn
        int    twoYup      = yTile + 1;
        int    twoYDown    = yTile - 1;
        string twoYUpStr   = twoYup.ToString();
        string twoYDownStr = twoYDown.ToString();

        //finds, assignments
        GameObject       board = GameObject.Find("map");
        Map_v10          map   = board.GetComponent <Map_v10>();
        ClickableTile_v4 click = board.GetComponent <ClickableTile_v4>();
        GameObject       liz   = GameObject.Find("Lizard");
        //finds the hex on which the lizard sits
        GameObject currentHex = GameObject.Find("Hex_" + xstr + "_" + ystr);
        //2Yup neighbor game object
        GameObject twoYUpHex = GameObject.Find("Hex_" + xstr + "_" + twoYUpStr);
        //2YDown neighbor ob
        GameObject twoYDownHex = GameObject.Find("Hex_" + xstr + "_" + twoYDownStr);
        //pulls the neighbors for that hex
        Neighbor_v2 neighbors = currentHex.GetComponent <Neighbor_v2>();
        //also pulls the neighbor for 1UpYaxis so he can move 1 X, 1 Y, or 2 Y in a single turn
        Neighbor_v2 neighbor2Yup = twoYUpHex.GetComponent <Neighbor_v2>();
        //pulls neighbor 1DownAxis
        Neighbor_v2 neighbor2YDown = twoYDownHex.GetComponent <Neighbor_v2>();



        //new, used to find battle
        Battle_v3 battle = liz.GetComponent <Battle_v3>();

        //valid neighbor click
        if (neighbors.neighborX.Contains(click.clickCoor) || neighbors.neighborY.Contains(click.clickCoor) ||
            neighbor2Yup.neighborY.Contains(click.clickCoor) || neighbor2YDown.neighborY.Contains(click.clickCoor))
        {
            //string unityCoor;
            float unityX;
            float unityY;

            //unityCoor = map.tileLocPairs[click.clickCoor];
            unityX     = click.xLoc;
            unityY     = click.yLoc;
            charHeight = .5f;



            //new shit to make occupied hexs un-enterable
            if (battle.OccupiedHexs.ContainsKey(click.clickCoor))
            {
                battle.Battle();
            }
            //otherwise, move if it is a valid destination
            else
            {
                liz.transform.position = new Vector3(unityX, charHeight, unityY);
            }
        }
        //too far to move there
        else
        {
            Debug.Log("Cannot move this far");
        }
    }
Exemplo n.º 3
0
    //test movement module
    public void lizardMove()
    {
        GameObject       board = GameObject.Find("map");
        Map_v11          map   = board.GetComponent <Map_v11>();
        ClickableTile_v5 click = board.GetComponent <ClickableTile_v5>();
        //declarations
        string xstr;
        string ystr;

        xstr = click.x.ToString();
        ystr = click.y.ToString();
        float charHeight;

        //new, for 2-Y movement in a turn
        int    twoYup      = yTile + 1;
        int    twoYDown    = yTile - 1;
        string twoYUpStr   = twoYup.ToString();
        string twoYDownStr = twoYDown.ToString();

        //finds, assignments
        GameObject liz = GameObject.Find("Lizard");

        /*
         *
         *
         * //finds the hex on which the lizard sits
         * GameObject currentHex = GameObject.Find("Hex_" + xstr + "_" + ystr);
         * //2Yup neighbor game object
         * GameObject twoYUpHex = GameObject.Find("Hex_" + xstr + "_" + twoYUpStr);
         * //2YDown neighbor ob
         * GameObject twoYDownHex = GameObject.Find("Hex_" + xstr + "_" + twoYDownStr);
         * //pulls the neighbors for that hex
         * Neighbor_v3 neighbors = currentHex.GetComponent<Neighbor_v3>();
         * //also pulls the neighbor for 1UpYaxis so he can move 1 X, 1 Y, or 2 Y in a single turn
         * Neighbor_v3 neighbor2Yup = twoYUpHex.GetComponent<Neighbor_v3>();
         * //pulls neighbor 1DownAxis
         * Neighbor_v3 neighbor2YDown = twoYDownHex.GetComponent<Neighbor_v3>();
         *
         */



        //new, used to find battle
        Battle_v3 battle = liz.GetComponent <Battle_v3>();

        //valid neighbor click
        if (((click.clickX == xTile + 1 || click.clickX == xTile + 2 ||
              click.clickX == xTile - 1 || click.clickX == xTile - 2) &
             ((click.clickY == yTile + 1) || (click.clickY == yTile - 1) ||
              (click.clickY == yTile))) ||
            ((click.clickY == yTile + 1 || click.clickY == yTile - 1) & click.clickX == xTile))
        {
            //string unityCoor;
            float unityX;
            float unityY;

            //unityCoor = map.tileLocPairs[click.clickCoor];
            unityX     = click.xLoc;
            unityY     = click.yLoc;
            charHeight = .5f;



            //new shit to make occupied hexs un-enterable
            if (battle.OccupiedHexs.ContainsKey(click.clickCoor))
            {
                battle.Battle();
            }
            //otherwise, move if it is a valid destination
            else
            {
                liz.transform.position = new Vector3(unityX, charHeight, unityY);
            }
        }
        //too far to move there
        else
        {
            GameObject textEd = GameObject.Find("textControl");
            textEd.BroadcastMessage("textUpdate", "Cannot move this far");
            Debug.Log("Cannot move this far");
        }
    }