Exemplo n.º 1
0
    public void SpawnQuestion(MapQuestion mp, MapLocationScript mls)
    {
        foreach (GameObject go in currentAnswerList)
        {
            Destroy(go);
        }
        currentAnswerList.Clear();

        currentLocation   = mls;
        currentQuestion   = mp;
        questionText.text = currentQuestion.questionText;

        List <int> randMeshes = GlobalVariables.genUniqueNumbers(0, currentQuestion.answerList.Count, currentQuestion.answerList.Count);

        questionAnswers = currentQuestion.answerList.ToList();

        float offsetStep = 5.0f / (questionAnswers.Count + 1);
        float curOffset  = -3.0f + offsetStep;

        for (int i = 0; i < currentQuestion.answerList.Count; i++)
        {
            GameObject tmpAnsBtn = Instantiate(answerPref, answerHolder.transform);
            tmpAnsBtn.GetComponent <MapAnswerScript>().SetAnswer(questionAnswers[i], ansRocksList[randMeshes[i]], this);
            tmpAnsBtn.transform.localPosition = new Vector3(0.0f, 0.0f, curOffset);

            currentAnswerList.Add(tmpAnsBtn);
            curOffset += offsetStep;
        }


        StartCoroutine(GlobalVariables.FocusOn(Camera.main.transform, transform, 1.5f));
    }
    public MapLocationScript updateInfoBox(MapLocationScript Location)
    {
        Text InfoBoxText = GameObject.Find("ConstituencyPanel").GetComponentInChildren <Text>();


        if (Location.type == "C")
        {
            InfoBoxText.text = string.Format(@"
{0}
Demands: {1}K
Population: {2}K
Rally Money: {3}K
Status:
1 : {4}%
2 : {5}%
3 : {6}% ", Location.CName, Location.Demands, Location.Population, Location.RallyMoney, Location.Status1, Location.Status2, Location.Status3);
        }

        else
        {
            InfoBoxText.text = string.Format("\n{0} ", Location.CName);
        }

        Text InfoBoxText2 = GameObject.Find("ConstituencyPanel2").GetComponentInChildren <Text>();

        InfoBoxText2.text = InfoBoxText.text;

        MapLocationScript temp = CurrentLocation;

        CurrentLocation = Location;
        return(temp);
    }
Exemplo n.º 3
0
    public void changeHighlight()
    {
        MapLocationScript MLS1 = mapitem1.GetComponent <MapLocationScript>(); // gets all components from mapitem scripts aka HIGHLIGHTED
        MapLocationScript MLS2 = mapitem2.GetComponent <MapLocationScript>();
        MapLocationScript MLS3 = mapitem3.GetComponent <MapLocationScript>();
        MapLocationScript MLS4 = mapitem4.GetComponent <MapLocationScript>();

        MLS1.highlighted1 = false; //sets values to false
        MLS2.highlighted1 = false;
        MLS3.highlighted1 = false;
        MLS4.highlighted1 = false;

        highlightedOption = Random.Range(1, 5); // Randomly switches which is highlighted (upper limit has to be +1)

        Debug.Log("changed highlight to " + highlightedOption);

        switch (highlightedOption)
        {
        case 1:
            MLS1.highlighted1 = true;
            break;

        case 2:
            MLS2.highlighted1 = true;
            break;

        case 3:
            MLS3.highlighted1 = true;
            break;

        case 4:
            MLS4.highlighted1 = true;
            break;
        }
    }
Exemplo n.º 4
0
    public MapLocationScript getLocationAt(int ML)
    {
        // Get All Locations
        MapLocationScript[] AllLocations = GameObject.FindObjectsOfType <MapLocationScript>();

        // Get Current Location
        MapLocationScript currentLocation = AllLocations[0];

        for (int i = 0; i < 24; i++)
        {
            if (AllLocations[i].MapLocationNo == ML)
            {
                currentLocation = AllLocations[i];
            }
        }
        return(currentLocation);
    }
Exemplo n.º 5
0
    void ChangeSprite()
    {
        MapLocationScript MLS1 = brain1.GetComponent <MapLocationScript>(); // gets all components from mapitem scripts aka HIGHLIGHTED

        //MapLocationScript MLS2 = brain2.GetComponent<MapLocationScript>();
        //MapLocationScript MLS3 = brain3.GetComponent<MapLocationScript>();
        //MapLocationScript MLS4 = brain3.GetComponent<MapLocationScript>();



        if (MLS1.highlighted1 == true)
        {
            brain1.GetComponent <SpriteRenderer>().sprite = brainSprites[1];
        }// set to green brain


        //brain2.GetComponent<SpriteRenderer>().sprite = brainSprites[1];
        //brain3.GetComponent<SpriteRenderer>().sprite = brainSprites[1];
        //brain4.GetComponent<SpriteRenderer>().sprite = brainSprites[1];
    }
Exemplo n.º 6
0
    void DoneMoving()
    {
        // Stop Any Flash Messages
        FlashStop();

        // We are done moving to the new location
        isMoving = false;

        MapLocationScript currentLocation = getLocationAt(this.currentML);

        GetStats().updateInfoBox(currentLocation);

        if (currentLocation.isSpecial)
        {
            switch (currentLocation.type)
            {
            case "CV":
            {
                getNewVerdict();
                break;
            }

            case "GJ": { GoToJail(); break; }

            case "M": { Media(); break; }
            }
        }
        // TODO: If current place is a special place
        // Execute Special commands here!

        GetStats().UpdateText();

        if (!isMoving)
        {
            StateManager theStateManager = GameObject.FindObjectOfType <StateManager>();
            theStateManager.autoMoveDone(this.currentML);
        }
    }
Exemplo n.º 7
0
    public void recalculateVotes()
    {
        int p1 = GameObject.Find("User-0").GetComponent <UserScript>().BaseVotes;
        int p2 = GameObject.Find("User-1").GetComponent <UserScript>().BaseVotes;
        int p3 = GameObject.Find("User-2").GetComponent <UserScript>().BaseVotes;

        MapLocationScript[] AllLocations = GameObject.FindObjectsOfType <MapLocationScript>();
        for (int j = 0; j < 24; j++)
        {
            MapLocationScript L = AllLocations[j];
            if (L.type == "C")
            {
                p1 += L.Status1 * L.Population / 100;
                p2 += L.Status2 * L.Population / 100;
                p3 += L.Status3 * L.Population / 100;
            }
        }
        if (p1 < 0)
        {
            p1 = 0;
            GameObject.Find("User-0").GetComponent <UserScript>().BaseVotes = 0;
        }
        if (p2 < 0)
        {
            p2 = 0;
            GameObject.Find("User-1").GetComponent <UserScript>().BaseVotes = 0;
        }
        if (p3 < 0)
        {
            p3 = 0;
            GameObject.Find("User-2").GetComponent <UserScript>().BaseVotes = 0;
        }
        GameObject.Find("User-0").GetComponent <UserScript>().Votes = p1;
        GameObject.Find("User-1").GetComponent <UserScript>().Votes = p2;
        GameObject.Find("User-2").GetComponent <UserScript>().Votes = p3;
    }
Exemplo n.º 8
0
    void createAndPlaceMapLocations()
    {
        string[] TypeArray       = new string[24];
        string[] CNameArray      = new string[] { "GO", "Seemapuri", "Mustafabad", "Dilli High Court", "Shahdara", "Tilak Nagar", "Media", "Dwarka", "Rohini", "Election Commition", "Janakpuri", "VIkaspuri", "Tihar Jail", "Gandhi Nagar", "Trilokpuri", "Dilli High Court", "Chandni Chowk", "Karol Bagh", "Go To Jail", "Rajouri Garden", "New Delhi", "Election Commition", "Kalkaji", "Greater Kailash" };
        string[] DemandsArray    = new string[] { "100", "110", "140", "130", "150", "190", "160", "170", "150", "180", "200", "210", "150", "230", "240", "250" };
        string[] PopulationArray = new string[] { "50", "55", "70", "65", "75", "95", "80", "85", "75", "90", "100", "105", "75", "115", "120", "125" };
        string[] RallyMoneyArray = new string[] { "10", "11", "14", "13", "15", "19", "16", "17", "15", "18", "20", "21", "15", "23", "24", "25" };

        // Create MapLocations
        for (int j = 0; j < 24; j++)
        {
            string x = "C";
            if (j % 3 == 0)
            {
                x = "CV";
            }
            TypeArray[j] = x;
        }

        TypeArray[0]  = "G";
        TypeArray[6]  = "M";
        TypeArray[12] = "J";
        TypeArray[18] = "GJ";

        int K = 0;

        for (int i = 0; i < 24; i++)
        {
            // Instantiate a new copy of the stone prefab
            GameObject        newML       = Instantiate(MapLocationPrefab);
            MapLocationScript newMLScript = newML.GetComponent <MapLocationScript>();


            newMLScript.MapLocationNo = i;
            newMLScript.type          = TypeArray[i];
            newMLScript.CName         = CNameArray[i];

            newMLScript.Status1 = 0;
            newMLScript.Status2 = 0;
            newMLScript.Status3 = 0;

            if (newMLScript.type == "C")
            {
                newMLScript.Demands    = int.Parse(DemandsArray[K]);
                newMLScript.Population = int.Parse(PopulationArray[K]);
                newMLScript.RallyMoney = int.Parse(RallyMoneyArray[K]);
                K += 1;
            }

            else
            {
                newMLScript.isSpecial = true;
            }

            if (i == 7)
            {
                newMLScript.Status3 = 50;
            }
            if (i == 13)
            {
                newMLScript.Status1 = 50;
            }
            if (i == 19)
            {
                newMLScript.Status2 = 50;
            }

            if (i == 0)
            {
                GameObject.Find("PlayerStatsPanel").GetComponent <PlayerStatScript>().updateInfoBox(newMLScript);
            }
        }
        recalculateVotes();
    }
 private void OnMouseEnter()
 {
     Old = GameObject.Find("PlayerStatsPanel").GetComponent <PlayerStatScript>().updateInfoBox(this);
 }
Exemplo n.º 10
0
    public void populateOptions(UserScript currentPlayer)
    {
        currentPlayerObj = currentPlayer;
        cl = currentPlayer.getLocationAt(currentPlayer.currentML);

        int me = (currentPlayer.playerNumber + 1);

        int Votes = (cl.Population / 4);
        int Cost  = (cl.Demands / 4);

        int CalledFor = (cl.Status1 + cl.Status2 + cl.Status3);
        int Occupied  = CalledFor;
        int TxCost    = 0;

        switch (me)
        {
        case 1: { CalledFor -= cl.Status1; break; }

        case 2: { CalledFor -= cl.Status2; break; }

        case 3: { CalledFor -= cl.Status3; break; }
        }

        if (CalledFor > 0)
        {
            TxCost = cl.RallyMoney;
        }

        string name = "";

        if (cl.Status1 > 0 && me != 1 && (Cost + TxCost <= currentPlayer.Money))
        {
            name = "AAP";
            string toPay = "To buy 25% [" + Votes + "K Votes] from " + name + " you need to pay " + Cost + "K INR with Rally Cost: " + TxCost + "K INR";
            GameObject.Find("PayAAPButton").GetComponent <Button>().interactable = true;
            GameObject.Find("PayAAPButton").GetComponent <Button>().onClick.AddListener(() => ButtonHandler(Votes, name, Cost, TxCost));
            GameObject.Find("PayAAPButton").GetComponentInChildren <Text>().text = toPay;
            // enable button to pay to Aap
        }
        else
        {
            GameObject.Find("PayAAPButton").GetComponent <Button>().interactable = false;
        }

        if (cl.Status2 > 0 && me != 2 && (Cost + TxCost <= currentPlayer.Money))
        {
            name = "BJP";
            string toPay = "To buy 25% [" + Votes + "K Votes] from " + name + " you need to pay " + Cost + "K INR with Rally Cost: " + TxCost + "K INR";
            GameObject.Find("PayBJPButton").GetComponent <Button>().interactable = true;
            GameObject.Find("PayBJPButton").GetComponent <Button>().onClick.AddListener(() => ButtonHandler(Votes, name, Cost, TxCost));
            GameObject.Find("PayBJPButton").GetComponentInChildren <Text>().text = toPay;
            // enable button to pay to BJP
        }
        else
        {
            GameObject.Find("PayBJPButton").GetComponent <Button>().interactable = false;
        }

        if (cl.Status3 > 0 && me != 3 && (Cost + TxCost <= currentPlayer.Money))
        {
            name = "INC";
            string toPay = "To buy 25% [" + Votes + "K Votes] from " + name + " you need to pay " + Cost + "K INR with Rally Cost: " + TxCost + "K INR";
            GameObject.Find("PayINCButton").GetComponent <Button>().interactable = true;

            GameObject.Find("PayINCButton").GetComponent <Button>().onClick.AddListener(() => ButtonHandler(Votes, name, Cost, TxCost));

            GameObject.Find("PayINCButton").GetComponentInChildren <Text>().text = toPay;
            // enable button to pay to INC
        }
        else
        {
            GameObject.Find("PayINCButton").GetComponent <Button>().interactable = false;
        }

        if (CalledFor < 100 && Occupied != 100 && (Cost + TxCost <= currentPlayer.Money))
        {
            name = "Independent";
            string toPay = "To buy 25% [" + Votes + "K Votes] from " + name + " you need to pay " + Cost + "K INR with Rally Cost: " + TxCost + "K INR";
            GameObject.Find("BuyButton").GetComponent <Button>().interactable = true;
            GameObject.Find("BuyButton").GetComponent <Button>().onClick.AddListener(() => ButtonHandler(Votes, name, Cost, TxCost));

            GameObject.Find("BuyButton").GetComponentInChildren <Text>().text = toPay;
            // enable button to pay to Independent
        }
        else
        {
            GameObject.Find("BuyButton").GetComponent <Button>().interactable = false;
        }
    }