Example #1
0
    private void Awake()
    {
        GameObject GameManager = GameObject.Find("GameManager");

        instance      = this;
        agentsManager = GameManager.GetComponent <ThreeAgents>();
    }
Example #2
0
    private void Awake()
    {
        instance = this;
        player2  = GameObject.Find("Lumberjack2");
        player3  = GameObject.Find("Lumberjack3");
        player   = GameObject.Find("Agent");

        lostForestPlayer  = player.GetComponent <LostForest>();
        lostForestPlayer2 = player2.GetComponent <LostForest>();
        lostForestPlayer3 = player3.GetComponent <LostForest>();
        allMovableThings  = GameObject.FindGameObjectsWithTag("avoidSpawn");
    }
Example #3
0
    void Start()
    {
        playerMeet = new List <GameObject>();
        nbTrees    = GridWorld.instance.nbTrees;
        UnitRandom UnitRandomscript2 = player2.gameObject.AddComponent(typeof(UnitRandom)) as UnitRandom;

        UnitRandomscript2.enabled = true;
        LostForest CompLostForest2 = player2.gameObject.AddComponent(typeof(LostForest)) as LostForest;

        CompLostForest2.enabled = true;

        UnitRandom UnitRandomscript3 = player3.gameObject.AddComponent(typeof(UnitRandom)) as UnitRandom;

        UnitRandomscript3.enabled = true;
        LostForest CompLostForest3 = player3.gameObject.AddComponent(typeof(LostForest)) as LostForest;

        CompLostForest3.enabled = true;

        UnitSearchUnkCell UnitSearchscript = player.gameObject.AddComponent(typeof(UnitSearchUnkCell)) as UnitSearchUnkCell;

        UnitSearchscript.enabled = true;
        LostForest CompLostForest = player.gameObject.AddComponent(typeof(LostForest)) as LostForest;

        CompLostForest.enabled = true;

        Vector3 positionSawmill = new Vector3(Random.Range(-10.0f, 10.0f), 0, Random.Range(-10.0f, 10.0f));

        if (checkIfPosEmpty(positionSawmill))
        {
            GameObject sawmill = GameObject.Find("Sawmill");
            sawmill.transform.position = positionSawmill;
        }

        for (int i = 0; i < nbTrees; i++)
        {
            Vector3 positionTree = new Vector3(Random.Range(-10.0f, 10.0f), 0, Random.Range(-10.0f, 10.0f));
            if (checkIfPosEmpty(positionTree))
            {
                GameObject trees = GameObject.Find("Tree");
                Instantiate(trees, positionTree, Quaternion.identity);
            }
        }
    }
Example #4
0
    public bool foundAPlayer(GameObject Player1)
    {
        print("FUNCTION REACHED!!!!");
        playerMeet.Add(Player1);

        if (playerMeet.Count == 2)
        {
            GameObject lumberjack1;
            GameObject lumberjack2;

            lumberjack1 = playerMeet[0];
            lumberjack2 = playerMeet[1];

            lostForestPlayerFound1 = lumberjack1.GetComponent <LostForest>();
            lostForestPlayerFound2 = lumberjack2.GetComponent <LostForest>();

            if ((lostForestPlayerFound1.foundATree) && (!lostForestPlayerFound2.foundATree))
            {
                print("TREE SHARED!!!!");
                lostForestPlayerFound2.hereIsTheTree = lostForestPlayerFound1.hereIsTheTree;
                lostForestPlayerFound2.foundATree    = true;
                treeShared = lostForestPlayerFound2.hereIsTheTree;
            }
            if ((lostForestPlayerFound1.foundATree) && (lostForestPlayerFound2.foundATree))
            {
                print("TREE SHARED!!!!");
                lostForestPlayerFound2.hereIsTheTree = lostForestPlayerFound1.hereIsTheTree;
                lostForestPlayerFound2.foundATree    = true;
                treeShared = lostForestPlayerFound2.hereIsTheTree;
            }
            if ((!lostForestPlayerFound1.foundATree) && (lostForestPlayerFound2.foundATree))
            {
                print("TREE SHARED!!!!");
                lostForestPlayerFound1.hereIsTheTree = lostForestPlayerFound2.hereIsTheTree;
                lostForestPlayerFound1.foundATree    = true;
                treeShared = lostForestPlayerFound1.hereIsTheTree;
            }
            if ((lostForestPlayerFound1.foundTheSawmill) && (!lostForestPlayerFound2.foundTheSawmill))
            {
                print("TREE SHARED!!!!");
                lostForestPlayerFound2.hereIsTheSawmill = lostForestPlayerFound1.hereIsTheSawmill;
                lostForestPlayerFound2.foundTheSawmill  = true;
                sawmill = lostForestPlayerFound2.hereIsTheSawmill;
            }
            if ((!lostForestPlayerFound1.foundTheSawmill) && (lostForestPlayerFound2.foundTheSawmill))
            {
                print("SAWMILL SHARED!!!!");
                lostForestPlayerFound1.hereIsTheSawmill = lostForestPlayerFound2.hereIsTheSawmill;
                lostForestPlayerFound1.foundTheSawmill  = true;
                sawmill = lostForestPlayerFound2.hereIsTheSawmill;
            }

            if (lostForestPlayerFound1.foundATree && lostForestPlayerFound2.foundATree &&
                lostForestPlayerFound1.foundTheSawmill && lostForestPlayerFound2.foundTheSawmill)
            {
                print("ATTEINT!!!!");

                groupLumber(lumberjack1, lumberjack2, treeShared);
                return(true);
            }

            playerMeet.Clear();
            return(false);
        }
        return(false);
    }