public void load_character(CharacterLoader aLoader)
    {
        NGM.mManager.mBackgroundManager.load_character(aLoader);

        FlatBodyObject flatbody = new FlatBodyObject(aLoader, -1);

        flatbody.set_target_pose(NGM.CurrentPose, true);
        flatbody.HardPosition = new Vector3(10, 0, 0);
        flatbody.update(0);
        flatbody.set_layer(1 << 1);

        flatbody.PrimaryGameObject.name = "SIMIANBODY";


        //needed to make debugviewerthing work
        var cam = mManager.gameObject.AddComponent <Camera>();

        cam.transform.position = mManager.mCameraManager.MainBodyCamera.transform.position;
        cam.transform.rotation = mManager.mCameraManager.MainBodyCamera.transform.rotation;
        cam.fieldOfView        = mManager.mCameraManager.MainBodyCamera.fieldOfView;
        cam.orthographic       = mManager.mCameraManager.MainBodyCamera.orthographic;
        cam.orthographicSize   = mManager.mCameraManager.MainBodyCamera.orthographicSize;
        Debug.Log(mManager.mCameraManager.MainBodyCamera.orthographicSize);
        cam.depth       = 9999999;
        cam.clearFlags  = CameraClearFlags.Depth;
        cam.cullingMask = 0;

        mSimian = new FarseerSimian();
        mSimian.initialize(mManager.gameObject);
        mSimian.setup_with_body(flatbody);

        //this is stupid
        mSimian.add_environment(GameObject.FindObjectsOfType(typeof(Transform)).Where(e => e.name.StartsWith("FS_")).Select(e => ((Transform)e).gameObject));
    }
Example #2
0
    //TODO should call this directly and get rid of that stupid callback thing in events
    public void load_character(CharacterLoader aCharacter)
    {
        unload();

        if (aCharacter != null && aCharacter.Name != "999")
        {
            mFlat = new FlatBodyObject(aCharacter, -1);
            set_layer(mLayer);
            if (ManagerManager.Manager.mGameManager.CurrentLevel == 0)
            {
                mFlat.HardPosition = Random.insideUnitCircle.normalized * 30000;
            }
            else
            {
                mFlat.HardPosition = Random.insideUnitCircle.normalized * 1000;
            }
            mFlat.SoftPosition = Vector3.zero;
            mOffset            = (new Vector3(aCharacter.Sizes.mOffset.x, aCharacter.Sizes.mOffset.y, 0));
            mFlat.SoftPosition = mFlat.SoftPosition + mOffset;

            if (mMode == 0)
            {
                mFlat.SoftColor = new Color(0.5f, 0.5f, 0.5f, 0.5f);
            }
            else if (mMode == 1)
            {
                //mFlat.SoftColor = new Color(0.5f, 0.5f, 0.5f, 0.35f);
                mFlat.HardShader = mManager.mReferences.mTransparentCharacaterShader;
                mFlat.HardColor  = mManager.mCharacterBundleManager.get_character_stat(aCharacter.Character).CharacterInfo.CharacterOutlineColor;
            }

            mFlat.update(0);
        }
    }
Example #3
0
    public void update(ProjectionManager aManager)
    {
        //set desired position from projection manager
        foreach (KeyValuePair <ZgJointId, ProjectionManager.Stupid> e in aManager.mImportant)
        {
            if (mBodies.ContainsKey(e.Key))
            {
                //ManagerManager.Manager.mDebugString = mBodies[ZgJointId.Waist].body.Rotation.ToString();
                if (e.Key != ZgJointId.Waist)                //pretty sure this is because waist is controlled by torso, i.e. the degree of freedom we give up to allow the body to move around freely
                {
                    rotate_body_to(mBodies[e.Key].body, mBodies[ZgJointId.Waist].body.Rotation + (e.Value.smoothing.current - mBodies[e.Key].offset) * Mathf.PI / 180f);
                }
            }
        }

        //update the visual body to match the physics body
        mFlat.set_target_pose(physics_pose());
        mFlat.SoftInterpolation = .5f;
        mFlat.SoftPosition      = mBodies[ZgJointId.Torso].body.Position.toV3() / GameConstants.SCALE;
        //mFlat.HardPosition = mFlat.SoftPosition;
        mFlat.update(0);
    }