Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        mRandomReverter = new RandomReverter();

        GameObject ArrowIndicator = GameObject.Find("ArrowIndicator");
        ElevatorArrow ArrowScript = null;

        if (ScenarioManager.Instance.GetDifficultyInfo().name == "Easy") {
            if (ArrowIndicator != null) {
                ArrowScript = ArrowIndicator.GetComponent<ElevatorArrow>() as ElevatorArrow;
            }
        }

        Dictionary<int, string> floorMap = new Dictionary<int, string>();
        int heavenFloor = Random.Range(1, 4);
        floorMap.Add(heavenFloor, "heaven");
        string team_instructions = "";
        switch(heavenFloor)
        {
        case 1:
            floorMap.Add(2, "hell");
            floorMap.Add(3, "bathroom");
            team_instructions = "Ground floor exit!\nGo!";
            if (ArrowScript != null) {
                ArrowScript.m_FloorGArrow.SetActive(true);
            }
            break;
        case 2:
            floorMap.Add(1, "hell");
            floorMap.Add(3, "bathroom");
            team_instructions = "1st floor exit!\nGo!";
            if (ArrowScript != null) {
                ArrowScript.m_Floor1Arrow.SetActive(true);
            }
            break;
        case 3:
            floorMap.Add(2, "hell");
            floorMap.Add(1, "bathroom");
            team_instructions = "2nd floor exit!\nGo!";
            if (ArrowScript != null) {
                ArrowScript.m_Floor2Arrow.SetActive(true);
            }
            break;
        }

        GameObject instructions = GameObject.Find("team instructions");
        Text text = instructions.GetComponent<Text>() as Text;
        text.text =  team_instructions;

        GameObject leftDoor = GameObject.Find("left door");
        GameObject rightDoor = GameObject.Find("right door");

        // find key game objects
        mHand = GameObject.Find("IK_fingertip");
        //Debug.Log("hand obj name: " + mHand.name);
        mElevateKeyPad = GameObject.Find("elevator button keypad");
        //Debug.Log("mElevateKeyPad name: " + mElevateKeyPad.name);
        mCorrectButton = GameObject.Find("button.001");
        mWrongButton = GameObject.Find("button.002");
        mGameCamera = GameObject.Find("Main Camera");
        mElevatorFloor = GameObject.Find("big ground");
        GameObject elevatorWall = GameObject.Find("elevator walls");
        mHellBackground = GameObject.Find("outside environment_hell");
        mHeavenBackground = GameObject.Find("outside environment_heaven");
        mBathroomBackground = GameObject.Find("outside environment_bathroom");

        // find IK objects
        mGameObject_IK_Control   = GameObject.Find("IK_Control");
        mGameObject_RightArm     = GameObject.Find("mixamorig:RightArm");
        mGameObject_RightForeArm = GameObject.Find("mixamorig:RightForeArm");
        mGameObject_RightHand    = GameObject.Find("mixamorig:RightHand");
        mGameObject_IK_fingertip = GameObject.Find("IK_fingertip");
        mGameObject_IK_elbow     = GameObject.Find("IK_elbow");

        // sample initial state first-time through
        mRememberedTransform_IK_Control.Read  (mGameObject_IK_Control.transform);
        mRememberedTransform_RightArm.Read    (mGameObject_RightArm.transform);
        mRememberedTransform_RightForeArm.Read(mGameObject_RightForeArm.transform);
        mRememberedTransform_RightHand.Read   (mGameObject_RightHand.transform);
        mRememberedTransform_IK_fingertip.Read(mGameObject_IK_fingertip.transform);
        mRememberedTransform_IK_elbow.Read    (mGameObject_IK_elbow.transform);

        // initialize state
        Reset();

        ElevatorMoveBehavior elevatorMover = new ElevatorMoveBehavior("elevator move", mElevatorFloor, floorMap, leftDoor, rightDoor, this, mHellBackground, mHeavenBackground, mBathroomBackground, elevator_bell);
        for(int i = 0; i < mFloorSignals.Count; ++i)
        {
            mIndirectControls.AddControl(mFloorSignals[i],          elevatorMover);
            GameObject obj = GameObject.Find("button.00" + (i+1).ToString());
            //Debug.Log(obj.name);
            mIndirectControls.AddControl(mButtonPushSignals[i],          new CorrectButtonBehavior("correct button push", obj, mHand, i));
            /*
            ButtonPushBehavior pushBehavior;
            if (i == 0)
            {
                pushBehavior = new CorrectButtonBehavior("correct button push", obj, mHand, i, this);
            }
            else
            {
                pushBehavior = new WrongButtonBehavior("wrong button push", obj, mHand, i);
            }
            mIndirectControls.AddControl(mButtonPushSignals[i], pushBehavior);
            //*/
        }

        // these are not presently actually used
        //List<ButtonPushBehavior> buttonBehaviorList = new List<ButtonPushBehavior>();
        //buttonBehaviorList.Add(new CorrectButtonBehavior("correct button push", mCorrectButton, mHand, 1));
        //buttonBehaviorList.Add(new WrongButtonBehavior("wrong button push", mWrongButton, mHand, 2));

        float speed = 0.01f;
        // automatic controls
        mControls.AddControl(new TrueSignal(),          					new UnstableBehavior("unstable hand", mHand));

        // first player
        Behavior p1Up    = new TranslateBehavior("player1 move up",    mHand, new Vector3( 0,  1, 0) * speed);
        Behavior p1Down  = new TranslateBehavior("player1 move down",  mHand, new Vector3( 0, -1, 0) * speed);
        Behavior p1Left  = new TranslateBehavior("player1 move left",  mHand, new Vector3( 1,  0, 0) * speed);
        Behavior p1Right = new TranslateBehavior("player1 move right", mHand, new Vector3(-1,  0, 0) * speed);
        SetControlScheme(0, p1Up, p1Down, p1Left, p1Right);

        // second player
        mHandPushBehavior = new PushBehavior("finger push", mHand, mElevateKeyPad);
        SetControlScheme(1, mHandPushBehavior, null, null, null);

        //mControls.AddControl(new TrueSignal(),          scenario.GetBehavior("unstable hand"));
        //mControls.AddControl(new TrueSignal(),          new CorrectButtonBehavior("correct button push", mCorrectButton, mHand, 1));
        //mControls.AddControl(new TrueSignal(),          new CorrectButtonBehavior("wrong button push", mWrongButton, mHand, 2));
    }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     _random = new RandomReverter ();
     Reset();
 }
Exemplo n.º 3
0
    void Start()
    {
        _reverter = new GameObjectReverter(this.gameObject);
        _random = new RandomReverter();
        _bounder = new Bounder(bounds);

        Behavior p2Wind  = new DynamicWindBehavior("player2 wind", 			  this.gameObject, WindChanged);
        Behavior p2Up    = new MovementCallbackBehavior("player2 move up",    this.gameObject, new Vector3( 0,  0, -1) * speed * Time.fixedDeltaTime, Move);
        Behavior p2Down  = new MovementCallbackBehavior("player2 move down",  this.gameObject, new Vector3( 0,  0,  1) * speed * Time.fixedDeltaTime, Move);
        Behavior p2Left  = new MovementCallbackBehavior("player2 move left",  this.gameObject, new Vector3( 1,  0,  0) * speed * Time.fixedDeltaTime, Move);
        Behavior p2Right = new MovementCallbackBehavior("player2 move right", this.gameObject, new Vector3(-1,  0,  0) * speed * Time.fixedDeltaTime, Move);

        // rig control scheme
        mControls.AddControl(new TrueSignal(), 							   p2Wind );
        //   for buttons

        SetControlScheme(1, p2Up, p2Down, p2Left, p2Right);

        Reset();
    }