void GetNextWaypoint()
 {
     if (targetindex >= Waypoints.points.Length - 1)
     {
         Target = End;
         return;
     }
     if (Target == End && Vector3.Distance(transform.position, Target.position) <= 3.0f)
     {
         Destroy(gameObject);
     }
     targetindex++;
     Target = Waypoints.points[targetindex];
     house  = (HouseScript)Target.GetComponent <HouseScript>();
 }
Пример #2
0
    private void Reproduce()
    {
        HouseScript home = agentResources.Home.GetComponent("HouseScript") as HouseScript;

        if (home.CanReproduce())
        {
            int dieRoll = UnityEngine.Random.Range(1, 100);

            if (dieRoll < PROCREATE_CHANCE)
            {
                AgentsCreator agentsCreator = transform.parent.gameObject.GetComponent("AgentsCreator") as AgentsCreator;
                agentsCreator.BornAgent(transform.position);
            }
        }
    }
 /* First Definition Part of the Agent*/
 public override void Initialize()
 {
     rb            = this.GetComponent <Rigidbody>();
     m_resetParams = Academy.Instance.EnvironmentParameters;
     hm_render     = hm_obj.GetComponent <HeatMapRenderer>();
     rb.velocity   = new Vector3(2, 0, 2);
     house_script  = new HouseScript();
     for (int i = 0; i < 3; i++)
     {
         if (i + 1 == active_display)
         {
             cameras[i].enabled = true;
         }
         else
         {
             cameras[i].enabled = false;
         }
     }
 }
Пример #4
0
    void trashCard()
    {
        GameScript gameScript = FindObjectOfType <Camera>().GetComponent <GameScript>();

        trashDeck.Add(gameScript.getCardSelected());

        if (gameScript.getCardSelObjName().Contains("Card"))
        {
            CardScript cardScript = GameObject.Find(gameScript.getCardSelObjName()).GetComponent <CardScript>();
            if (gameScript.getCardSelObjName().Contains("1"))
            {
                DeckScript deckScript = GameObject.Find("P1 Deck").GetComponent <DeckScript>();
                deckScript.removeCard();
            }
            else if (gameScript.getCardSelObjName().Contains("2"))
            {
                DeckScript deckScript = GameObject.Find("P2 Deck").GetComponent <DeckScript>();
                deckScript.removeCard();
            }
            cardScript.setEnabled(false);
            cardScript.selectCard(); //To unselect it
        }

        else if (gameScript.getCardSelObjName().Contains("Trash"))
        {
            TrashScript trashScript = GameObject.Find(gameScript.getCardSelObjName()).GetComponent <TrashScript>();
            trashScript.removeCard();
            gameScript.setCardSelected(null);
            gameScript.setCardSelObjName(null);
        }

        else if (gameScript.getCardSelObjName().Contains("Main"))
        {
            HouseScript houseScript = GameObject.Find(gameScript.getCardSelObjName()).GetComponent <HouseScript>();
            houseScript.removeCard();
            gameScript.setCardSelected(null);
            gameScript.setCardSelObjName(null);
        }

        loadCard();
    }
Пример #5
0
    public void addToPile()
    {
        GameScript gameScript = FindObjectOfType <Camera>().GetComponent <GameScript>();

        pile.Add(gameScript.getCardSelected());
        if (pile.Count > 1)
        {
            GameObject newObj;
            GameObject createdObj;
            Transform  parent = gameObject.transform.parent;

            if (gameObject.name.Contains("LH"))
            {
                newObj = Resources.Load <GameObject>("LPiledCard");
                //parentName = "LHCanvas" + houseNum;
                createdObj      = Instantiate(newObj, parent);
                createdObj.name = "LH" + houseNum + "C" + (pile.Count - 1);
                createdObj.transform.localPosition = new Vector3((pile.Count - 2) * -15.0f, 0.0f, 0.0f);
            }
            else //if (gameObject.name.Contains("RH"))
            {
                newObj          = Resources.Load <GameObject>("RPiledCard");
                createdObj      = Instantiate(newObj, parent);
                createdObj.name = "RH" + houseNum + "C" + (pile.Count - 1);
                createdObj.transform.localPosition = new Vector3((pile.Count - 2) * 15.0f, 0.0f, 0.0f);
            }

            gameObject.transform.SetSiblingIndex(pile.Count - 1);
            PiledScript piledScript = createdObj.GetComponent <PiledScript>();
            piledScript.setCard(pile[pile.Count - 2]);
            piledScript.loadCard();
        }

        if (gameScript.getCardSelObjName().Contains("Card"))
        {
            CardScript  cardScript  = GameObject.Find(gameScript.getCardSelObjName()).GetComponent <CardScript>();
            DeckScript  deckScript  = GameObject.Find("P" + gameScript.getPlayer() + " Deck").GetComponent <DeckScript>();
            TrashScript trashScript = GameObject.Find("P" + gameScript.getPlayer() + " Trash").GetComponent <TrashScript>();

            deckScript.removeCard();

            cardScript.setEnabled(false);
            cardScript.selectCard(); //To unselect it

            if (trashScript.isEmpty() && deckScript.isEmpty())
            {
                Instantiate(Resources.Load <GameObject>("Winner"), GameObject.Find("Canvas").transform);
                GameObject.Find("Winner").GetComponent <Text>().text = "Player " + gameScript.getPlayer() + " wins!!";
            }
        }

        else if (gameScript.getCardSelObjName().Contains("Trash"))
        {
            TrashScript trashScript = GameObject.Find(gameScript.getCardSelObjName()).GetComponent <TrashScript>();
            trashScript.removeCard();
            gameScript.setCardSelected(null);
            gameScript.setCardSelObjName(null);

            DeckScript deckScript = GameObject.Find("P" + gameScript.getPlayer() + " Deck").GetComponent <DeckScript>();
            if (trashScript.isEmpty() && deckScript.isEmpty())
            {
                Instantiate(Resources.Load <GameObject>("Winner"), GameObject.Find("Canvas").transform);
                GameObject.Find("Winner(Clone)").GetComponent <Text>().text = "Player " + gameScript.getPlayer() + " wins!!";
            }
        }

        else if (gameScript.getCardSelObjName().Contains("Main"))
        {
            HouseScript houseScript = GameObject.Find(gameScript.getCardSelObjName()).GetComponent <HouseScript>();
            houseScript.removeCard();
            gameScript.setCardSelected(null);
            gameScript.setCardSelObjName(null);
        }

        loadCard();
    }
Пример #6
0
    public void Upgrade(int buildingNumber)
    {
        if (gameManager == null)
        {
            gameManager = GameObject.FindWithTag("GameManager");
        }

        if (moneyProduction == null)
        {
            moneyProduction = gameManager.GetComponent <MoneyProduction>();
        }

        if (buildingNumber == 0)
        {
            GameObject farmHouse = MouseControll.ChoosenBuilding.gameObject;
            choosenHouse = MouseControll.ChoosenBuilding.GetComponent <HouseScript>();

            if (choosenHouse.extensionMoney >= 6)
            {
                choosenHouse.extensionMoney++;
                farmHouse.transform.gameObject.tag = "BuildingMax";
            }
            else
            {
                farmHouse.transform.GetChild(choosenHouse.extensionMoney).GetComponent <MeshRenderer>().enabled = false;
                choosenHouse.extensionMoney++;
                farmHouse.transform.GetChild(choosenHouse.extensionMoney).GetComponent <MeshRenderer>().enabled = true;
            }
        }

        if (buildingNumber == 1)
        {
            GameObject farm = MouseControll.ChoosenBuilding.gameObject;
            choosenHouse = MouseControll.ChoosenBuilding.GetComponent <HouseScript>();

            if (choosenHouse.extensionWood >= 6)
            {
                choosenHouse.extensionWood++;
                farm.transform.gameObject.tag = "BuildingMax";
            }
            else
            {
                farm.transform.GetChild(choosenHouse.extensionWood).GetComponent <MeshRenderer>().enabled = false;
                choosenHouse.extensionWood++;
                farm.transform.GetChild(choosenHouse.extensionWood).GetComponent <MeshRenderer>().enabled = true;
            }
        }


        if (buildingNumber == 2)
        {
            GameObject house = MouseControll.ChoosenBuilding.gameObject;
            choosenHouse = MouseControll.ChoosenBuilding.GetComponent <HouseScript>();

            if (choosenHouse.extensionStone >= 6)
            {
                choosenHouse.extensionStone++;
                house.transform.gameObject.tag = "BuildingMax";
            }
            else
            {
                house.transform.GetChild(choosenHouse.extensionStone).GetComponent <MeshRenderer>().enabled = false;
                choosenHouse.extensionStone++;
                house.transform.GetChild(choosenHouse.extensionStone).GetComponent <MeshRenderer>().enabled = true;
            }
        }

        if (buildingNumber == 3)
        {
            GameObject tower = MouseControll.ChoosenBuilding.gameObject;
            choosenHouse = MouseControll.ChoosenBuilding.GetComponent <HouseScript>();

            if (choosenHouse.extensionHay >= 6)
            {
                choosenHouse.extensionHay++;
                tower.transform.gameObject.tag = "BuildingMax";
            }
            else
            {
                tower.transform.GetChild(choosenHouse.extensionHay).GetComponent <MeshRenderer>().enabled = false;
                choosenHouse.extensionHay++;
                tower.transform.GetChild(choosenHouse.extensionHay).GetComponent <MeshRenderer>().enabled = true;
            }
        }
    }
Пример #7
0
 private void Start()
 {
     Target = Waypoints.points[0];
     house  = (HouseScript)Target.GetComponent <HouseScript>();
 }