Esempio n. 1
0
    public void resetAfterFightModeScene()
    {
        int[] arrayOfPossitions = { 0, -90, 90, -180 };

        for (int i = 0; i < displayParty.getNumberOfHeroesAlive(); i++)
        {
            if (displayParty.getHeroIsAlive()[i] == true)
            {
                movementButton.getHeroesObjects()[i].transform.localPosition = new Vector3(arrayOfPossitions[i], movementButton.getHeroesObjects()[i].transform.localPosition.y, 0);
                //Now i'm gonna scale it down to 5/7 of the original size (35)
                movementButton.getHeroesObjects()[i].transform.localScale = new Vector3(35, 35, 1);
            }
        }
        Debug.Log("DungeonsGenerator || resetAfterFightModeScene || Heroes objects reset!");
    }
Esempio n. 2
0
    public void checkIfThereShouldBeAFight(int currentCorridorId)
    {
        int howManyEnemyPartiesAreThere = dungeonManager.getLevelsArray().Find(x => x.getIdOfLevel() == currentCorridorId).getEnemyParties().Count;

        //I should mind that it is not needed if there are no enemy parties at all at this corridor
        //So first we need to check if there is atleast one party and if so -> get needed unitWidth from it
        if (howManyEnemyPartiesAreThere != 0)
        {
            //There is atleast one party -> so we are going to get value from that one (0)
            float enemyPartyWidth       = dungeonManager.getLevelsArray().Find(x => x.getIdOfLevel() == currentCorridorId).getEnemyParties()[0].getOverallEnemyWidth();
            int   howManyHeroesAreThere = buttonForCameraMovement.getSizeOfParty();
            //Check how many heroes are there
            //iterate through objects in unity gui and check who is furthest in booth sides
            //that way you dont need ButtonForCameraMovement
            //Had to initialize it due to uncertain initialization conditions(i made sure they are certain tho)
            float furthestPosition = 0;
            float nearestPosition  = 0;

            //Checking what point of party is the furthest
            for (int i = 0; i < howManyHeroesAreThere; i++)
            {
                if (displayParty.getHeroIsAlive()[i] == true)
                {
                    if (i == 0)
                    {
                        furthestPosition = GameObject.Find("HeroObject" + (i + 1)).transform.position.x;
                        nearestPosition  = furthestPosition;
                    }
                    else
                    {
                        if (GameObject.Find("HeroObject" + (i + 1)).transform.position.x > furthestPosition)
                        {
                            furthestPosition = GameObject.Find("HeroObject" + (i + 1)).transform.position.x;
                        }
                        if (GameObject.Find("HeroObject" + (i + 1)).transform.position.x < furthestPosition)
                        {
                            nearestPosition = GameObject.Find("HeroObject" + (i + 1)).transform.position.x;
                        }
                    }
                }
            }
            //To aquire furthest point we have to add unit legth to the value because now its rendered fom thi point
            furthestPosition += enemyPartyWidth;
            bool noCollisionDetected = true;

            //Now it's time to find enemies like that
            //For now only checking it with furthest point -> encounters only from going right
            for (int i = 0; i < howManyEnemyPartiesAreThere; i++)
            {
                //Getting initial possition of party to check
                float initX       = dungeonManager.getLevelsArray().Find(x => x.getIdOfLevel() == currentCorridorId).getEnemyParties()[i].getInitialPositionX();
                float sizeOfParty = dungeonManager.getLevelsArray().Find(x => x.getIdOfLevel() == currentCorridorId).getEnemyParties()[i].getEnemyObjectArray().Count;

                if ((furthestPosition > initX) && (furthestPosition <= initX + (sizeOfParty * enemyPartyWidth)))
                {
                    noCollisionDetected    = false;
                    colidedWithPartyNumber = i;
                    i = howManyEnemyPartiesAreThere;
                }

                //If there were collisions
                if (noCollisionDetected == false)
                {
                    Debug.Log("FightMode || checkIfThereShouldBeAFight || Encountered enemy troops!");
                    partyIsInFightMode = true;
                    loadFightMode(colidedWithPartyNumber);
                    Debug.Log("FightMode || checkIfThereShouldBeAFight || Encountered enemy troops!" + colidedWithPartyNumber);
                    //If there will be a problem actualize current corridor id here
                    previousCorridorId = buttonForUsage.getPreviousCorridorId();
                    arrayIdOfPartyWeAreFightingWith = i;
                    break;
                }
            }
        }
    }