public void OnTriggerEnter(Collider collider)
 {
     print (collider.name + " " +gameObject.name);
     if (collider.name == "Player1" || collider.name == "Player2")
     {
         switch (BridgePuzzle.triggered)
         {
         case 1:
             BridgePuzzle.CreateRopeAndAxe();
             break;
         case 2:
             if(gameObject.name == "Axe")
                 BridgePuzzle.GetAxe(collider.name);
             else if (gameObject.name == "Rope")
                 BridgePuzzle.GetRope(collider.name);
             break;
         case 3:
             break;
         case 5:
             BridgePuzzle.GameOver();
             break;
         default:
             break;
         }
             
     }
 }
    public void OnTriggerStay(Collider collider)
    {
        if(gameObject.name == "bridge1" || gameObject.name == "bridge2")
        {
            if(BridgePuzzle.bridgeKeys % 2 == 0 && collider.name == "Player1")
            {
                Move1.P2Tips = "";
                Move1.P1Tips = "Press E";
  
                if(Input.GetKeyDown(KeyCode.E))
                    BridgePuzzle.P1Pressed();
                
            }
            else if (BridgePuzzle.bridgeKeys % 2 == 1 && collider.name == "Player2")
            {
                Move1.P2Tips = "Press I";
                Move1.P1Tips = "";

                if(Input.GetKeyDown(KeyCode.I))
                    BridgePuzzle.P2Pressed();
            }
            
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (isActive)
        {
            if (objects.Count == 0 && picked == 0)
            {
                //Destroy(GameObject.Find("BearTrapStart"));
                CreateObject("Rope", 351F, 32F, 49F);
                BridgePuzzle.CreateGameObject("Rope", "RopeMesh", 353F, 32F, 51F);
                CreateObject("Rope2", 307F, 40F, 67F);
                BridgePuzzle.CreateGameObject("Rope", "RopeMesh2", 309F, 40F, 69F);
                CreateObject("Axe", 447F, 30F, 99F);
                var goChild = BridgePuzzle.CreateGameObject("Axe", "AxeMesh", 448F, 30F, 99F);
                goChild.transform.Rotate(52.1f, 232, 319.78f);
                goChild.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
                picked = 1;
            }
            else if (objects.Count == 0 && picked == 1)
            {
                if (BearPuzzleScript.gotTheAxe == 0)
                {
                    Move1.AddDialog(1, "I managed to find a lot of rope.");
                    Move1.AddDialog(2, "Great! and I found an axe. Let's meet back at the Bear trap and make the slingshot.");
                    SavedVars.Instance.StartCoroutine(Move1.Talk());
                }
                else
                {
                    Move1.AddDialog(2, "I managed to find a lot of rope.");
                    Move1.AddDialog(1, "Great! and I found an axe. Let's meet back at the Bear trap and make the slingshot.");
                    SavedVars.Instance.StartCoroutine(Move1.Talk());
                }

                var position = gameObject.transform.position;
                position.x = 457F;
                position.y = 35F;
                position.z = 190F;
                var newObject = (GameObject)Instantiate(Resources.Load("BearTrapTrigger"), position, Quaternion.identity);
                newObject.name = "SlingShot";
                newObject.tag  = "TriggerPosition";
                objects.Add(newObject);
                picked = 2;
            }
            else if (objects.Count == 0 && picked == 2)
            {
                Move1.AddDialog(2, "Alright. Get into a position and i'll launch you from here. ");
                Move1.AddDialog(2, "Be careful we don't want you to launch too close to the trap or too far.");
                Move1.AddDialog(2, "Also we should remember what position we launched in so that we can use it to pull the rock.");
                Move1.AddDialog(1, "Right. The ground looks a little weak under the trap. ");
                Move1.AddDialog(1, "Standing in the wrong position could cause us to pull the rock with too much force and break the ground.");
                SavedVars.Instance.StartCoroutine(Move1.Talk());
                var position = gameObject.transform.position;
                position.x = 457F;
                position.y = 35;
                position.z = 190F;
                var newObject = (GameObject)Instantiate(Resources.Load("LaunchPrefab"), position, Quaternion.identity);
                newObject.name = "Launch";
                newObject.tag  = "LaunchTrigger";
                picked         = 3;

                CreateLaunchPositions("Position1", 437F, 177F);
                CreateLaunchPositions("Position2", 444F, 177F);
                CreateLaunchPositions("Position3", 450F, 178F);
                CreateLaunchPositions("Position4", 456F, 177F);
            }

            if (BearPuzzleScript.launchedCorrectly && picked == 3)
            {
                Move1.AddDialog(1, "Ah. Ahhhhhhhhhhhhhhhh");
                Move1.AddDialog(1, ".....................");
                Move1.AddDialog(1, "That went well. Now lets stand in the same position we launched in to pull the rock.");
                Move1.AddDialog(2, "Ok.");
                SavedVars.Instance.StartCoroutine(Move1.Talk());

                CreatePullPositions("Position1", 437F, 177F);
                CreatePullPositions("Position2", 444F, 177F);
                CreatePullPositions("Position3", 450F, 178F);
                CreatePullPositions("Position4", 456F, 177F);

                CreatePullPositions("Position5", 381F, 178F);
                CreatePullPositions("Position6", 376F, 180F);
                CreatePullPositions("Position7", 374F, 184F);
                CreatePullPositions("Position8", 373F, 189F);
                picked = 4;
            }
        }
    }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        LevelTime += Time.deltaTime;

        if (gameObject.tag == "RockPullPosition" && count < 4)
        {
            if (Input.GetKeyDown(KeyCode.P) && p2turn)
            {
                p2turn       = false;
                p1turn       = true;
                Move1.P2Tips = "";
                count++;
            }

            else if (Input.GetKeyDown(KeyCode.R) && p1turn)
            {
                p2turn       = true;
                p1turn       = false;
                Move1.P1Tips = "";
                count++;
            }
        }

        if (count == 4 && gameObject.name == "Rock01")
        {
            if (pullPosition == BearPuzzleScript.chosenPosition)
            {
                correctPosition = true;
            }

            Move1.P1Tips = "";
            Move1.P2Tips = "";
            GameObject[] lt = GameObject.FindGameObjectsWithTag("RockPullPosition");
            foreach (GameObject go in lt)
            {
                Destroy(go);
            }
            rigidbody.AddForce(Vector3.back * 1000f);
            count = 5;
            if (!correctPosition)
            {
                var position = gameObject.transform.position;
                position.x = 420F;
                position.y = 36F;
                position.z = 170F;
                var newObject = (GameObject)Instantiate(Resources.Load("HoleTrigger"), position, Quaternion.identity);
                newObject.name = "EnterHole";
                newObject.tag  = "TriggerPosition";
                newObject.transform.localScale        = new Vector3(4.4f, 1f, 35f);
                invisibleCollider.collider.isTrigger  = false;
                invisibleCollider2.collider.isTrigger = false;
                Move1.AddDialog(1, "......  ");
                Move1.AddDialog(1, ".......");
                Move1.AddDialog(1, "Oh no. We broke the ground.");
                Move1.AddDialog(2, "Perfect. Now we have to waste time getting me in and out. Let's Hurry.");
                SavedVars.Instance.StartCoroutine(Move1.Talk());
            }
            else
            {
                Move1.AddDialog(1, "......  ");
                Move1.AddDialog(1, ".......");
                Move1.AddDialog(1, "Whew. we didn't break the ground.");
                Move1.AddDialog(2, "Good. let's go.");
                SavedVars.Instance.StartCoroutine(Move1.Talk());
            }
        }
        if (count == 6 && gameObject.name == "EnterHole")
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Move1.P2Tips = "";
                Destroy(GameObject.Find("EnterHole"));
                BearPuzzleScript.player2.transform.position = new Vector3(408F, 31F, 168F);
                count = 7;
                var position = gameObject.transform.position;
                position.x = 393F;
                position.y = 36F;
                position.z = 165F;
                var newObject = (GameObject)Instantiate(Resources.Load("HoleTrigger"), position, Quaternion.identity);
                newObject.name = "DropRope";
                newObject.tag  = "TriggerPosition";
                newObject.transform.localScale = new Vector3(4.4f, 1f, 40f);
                //BridgePuzzle.CreateGameObject("Rope","RopeMesh",355F,36F,167F);
                Move1.AddDialog(2, "Hey, Buddy lend me some rope.");
                Move1.AddDialog(1, "Right.");
                SavedVars.Instance.StartCoroutine(Move1.Talk());
            }
        }
        if (count == 7 && gameObject.name == "DropRope")
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                print("drop");
                Move1.P1Tips = "";
                Destroy(GameObject.Find("DropRope"));
                var position = gameObject.transform.position;
                position.x = 402F;
                position.y = 29F;
                position.z = 168F;

                var newObject = (GameObject)Instantiate(Resources.Load("PullPosition"), position, Quaternion.identity);
                newObject.name = "Rope";
                newObject.tag  = "TriggerPosition";
                BridgePuzzle.CreateGameObject("Rope", "RopeMesh", 403F, 29F, 169F);
                count = 8;
            }
        }
        if (count == 8 && gameObject.name == "Rope")
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Move1.P2Tips = "";
                Destroy(GameObject.Find("Rope"));
                Destroy(GameObject.Find("RopeMesh"));
                BearPuzzleScript.player2.transform.position = new Vector3(390F, 37F, 165F);
                count = 9;
                Move1.AddDialog(1, "Lets go.");
                SavedVars.Instance.StartCoroutine(Move1.Talk());
            }
        }
        if (count == 9)
        {
        }
    }