public void match_body_to_body(FlatBodyObject aTarget)
 {
     foreach (var e in aTarget.mParts)
     {
         mParts[e.Key].transform.rotation = e.Value.transform.rotation;//Quaternion.Slerp(mParts[e.Key].transform.rotation,e.Value.transform.rotation,0.2f);
     }
 }
    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));
    }
Exemple #3
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);
        }
    }
Exemple #4
0
 public void unload()
 {
     if (mFlat != null)
     {
         mFlat.destroy();
         mFlat = null; //make sure mFlat was not in some other container
     }
 }
Exemple #5
0
    public PhysicsFlatBodyObject(FlatBodyObject aObject)
    {
        mFlat = aObject;

        mImportant[ZgJointId.Torso]         = new Stupid(new ZgJointId[] { ZgJointId.LeftShoulder, ZgJointId.RightShoulder, ZgJointId.Waist, ZgJointId.Neck });
        mImportant[ZgJointId.Waist]         = new Stupid(new ZgJointId[] { ZgJointId.LeftHip, ZgJointId.RightHip });
        mImportant[ZgJointId.LeftShoulder]  = new Stupid(ZgJointId.LeftElbow);
        mImportant[ZgJointId.LeftElbow]     = new Stupid(ZgJointId.LeftHand);
        mImportant[ZgJointId.LeftHip]       = new Stupid(ZgJointId.LeftKnee);
        mImportant[ZgJointId.LeftKnee]      = new Stupid(ZgJointId.LeftAnkle);
        mImportant[ZgJointId.RightShoulder] = new Stupid(ZgJointId.RightElbow);
        mImportant[ZgJointId.RightElbow]    = new Stupid(ZgJointId.RightHand);
        mImportant[ZgJointId.RightHip]      = new Stupid(ZgJointId.RightKnee);
        mImportant[ZgJointId.RightKnee]     = new Stupid(ZgJointId.RightAnkle);
        mImportant[ZgJointId.Neck]          = new Stupid(ZgJointId.Head);
        mImportant[ZgJointId.Head]          = new Stupid();
        mImportant[ZgJointId.LeftHand]      = new Stupid();
        mImportant[ZgJointId.RightHand]     = new Stupid();
        mImportant[ZgJointId.LeftAnkle]     = new Stupid();
        mImportant[ZgJointId.RightAnkle]    = new Stupid();
    }
    public ChoiceObjectPair(Texture2D aLeftTex, CharacterTextureBehaviour aChar, Pose aPose, int aDepth)
    {
        mSquare = new FlatElementImage(aLeftTex, aDepth);
        //NOTE these assets were removed since this class is no longer being used.
        //mDifficultyStars = new DifficultyObject(ManagerManager.Manager.mNewRef.uiPerfectStar, aDepth);
        //mDifficultyBalls = new DifficultyObject(ManagerManager.Manager.mNewRef.uiPerfectStar, aDepth);


        mElements.Add(new FlatElementMultiBase.ElementOffset(mSquare, new Vector3(mSide, 0, 0)));
        mElements.Add(new FlatElementMultiBase.ElementOffset(mDifficultyStars, new Vector3(-mSide, mRightBot, 0)));
        mElements.Add(new FlatElementMultiBase.ElementOffset(mDifficultyBalls, new Vector3(-mSide, mRightBot, 0)));

        mMeter            = new MeterImageObject(aLeftTex, null, MeterImageObject.FillStyle.DU, aDepth + 1);
        mMeter.Percentage = 0.0f;
        mBody             = new FlatBodyObject(aChar, aDepth + 2);
        mBody.set_target_pose(aPose);
        mElements.Add(new FlatElementMultiBase.ElementOffset(mMeter, new Vector3(mSide, 0, 0)));
        mElements.Add(new FlatElementMultiBase.ElementOffset(mBody, new Vector3(mSide + 24, -7, 0)));

        PrimaryGameObject = create_primary_from_elements();
    }
Exemple #7
0
    public void setup_with_body(FlatBodyObject aBody, bool aUseGravity = true)
    {
        mFlat = aBody;
        //construct the bodies
        foreach (var e in mImportant)
        {
            //note this will cerate 'dummy bodies' representing hand/ankle/head
            BodyGroup bg = new BodyGroup();
            bg.offset             = aBody.mParts[e.Key].transform.rotation.flat_rotation();
            bg.body               = BodyFactory.CreateBody(FSWorldComponent.PhysicsWorld, mFlat.mParts[e.Key].transform.position.toFV2());
            bg.body.Mass          = 25;
            bg.body.Friction      = .5f;
            bg.body.IgnoreGravity = !aUseGravity;
            bg.body.BodyType      = FarseerPhysics.Dynamics.BodyType.Dynamic;
            mBodies[e.Key]        = bg;

            //TODO why do I still have this? can probably delete
            //new GameObject(e.Key.ToString()).transform.position = mFlat.mParts[e.Key].transform.position;
        }

        //now create fixtures
        foreach (var e in mImportant)
        {
            if (e.Value.otherEnds.Count > 0)
            {
                List <FarseerPhysics.Common.Vertices> poly = new List <FarseerPhysics.Common.Vertices>();
                poly.Add(new FarseerPhysics.Common.Vertices());
                if (e.Key != ZgJointId.Torso || e.Value.otherEnds.Count == 1)                //torso does not need this point
                {
                    poly[0].Add(FVector2.Zero);
                }
                if (e.Value.otherEnds.Count == 1)
                {
                    //line version
                    //foreach(var f in e.Value.otherEnds)
                    //	poly[0].Add(mFlat.mParts[f].transform.position.toFV2()-mBodies[e.Key].body.Position);

                    //block version
                    FVector2 diff = mFlat.mParts[e.Value.otherEnds[0]].transform.position.toFV2() - mBodies[e.Key].body.Position;
                    FVector2 perp = new FVector2(diff.Y, -diff.X);
                    perp.Normalize();
                    float stretch = .03f;
                    poly[0].Add(perp * stretch);
                    poly[0].Add(diff + perp * stretch);
                    poly[0].Add(diff - perp * stretch);
                    poly[0].Add(-perp * stretch);
                }
                else
                {
                    foreach (var f in e.Value.otherEnds)
                    {
                        poly[0].Add(mFlat.mParts[f].transform.position.toFV2() - mBodies[e.Key].body.Position);
                    }
                }
                var fixture = FixtureFactory.AttachCompoundPolygon(poly, 1, mBodies[e.Key].body);
                fixture[0].CollisionGroup = -8; //negative indices never self collide
            }
        }

        //create joints
        foreach (var e in mImportant)
        {
            foreach (var f in e.Value.otherEnds)
            {
                if (mImportant[f].otherEnds.Count > 0)
                {
                    var joint = JointFactory.CreateRevoluteJoint(FSWorldComponent.PhysicsWorld, mBodies[e.Key].body, mBodies[f].body, FVector2.Zero);
                    mBodies[f].joint = joint;
                }
            }
        }

        //clean up the dummy bodies
        foreach (var e in mImportant)
        {
            if (e.Value.otherEnds.Count == 0)
            {
                FSWorldComponent.PhysicsWorld.RemoveBody(mBodies[e.Key].body);
                mBodies.Remove(e.Key);
            }
        }
    }
    //CharacterIndex[] mChoices = null;


    public void initialize()
    {
        mFlatCamera = new FlatCameraManager(new Vector3(24200, -3500, 0), 10);
        mFlatCamera.fit_camera_to_game();
        //mFlatCamera = mModeNormalPlay.mSunsetManager.mFlatCamera;


        var refs   = mManager.mReferences;
        var newRef = mManager.mNewRef;
        //BB choice nonsense
        var miniMan = ((GameObject)GameObject.Instantiate(refs.mMiniChar)).GetComponent <CharacterTextureBehaviour>();
        //mMiniMan = //TODO something like this: mManager.mCharacterBundleManager.get_mini_character(new CharacterIndex(0,1));
        Vector3 miniManScale = (new Vector3(1, 1, 1)) * 1.5f;

        for (int i = 0; i < BB_NUM_CHOICES; i++)
        {
            mBBChoices.Add(new NewChoiceObject(11));
            mBBChoiceBodies.Add(new FlatBodyObject(miniMan, 12));
            mBBChoiceBodies[i].HardShader = refs.mMiniCharacterShader;
            mBBChoiceBodies[i].HardScale  = miniManScale;
            mElement.Add(mBBChoices[i]);
            mElement.Add(mBBChoiceBodies[i]);
        }

        mBBChoosingBackground              = new FlatElementImage(null, mFlatCamera.Size, 0);
        mBBChoosingBackground.Enabled      = false;
        mBBChoosingBackground.HardPosition = mFlatCamera.get_point(Vector3.zero);
        mBBQuestionText       = new ColorTextObject(10);
        mBBQuestionTextPrefix = new FlatElementText(newRef.genericFont, 100, "", 10);
        //mBBQuestionText.HardPosition = mFlatCamera.get_point(0,0.6f) + new Vector3(0,-75,0);
        mBBQuestionText.HardPosition            = mFlatCamera.get_point(0, 0.72f);
        mBBQuestionTextPrefix.HardPosition      = mFlatCamera.get_point(0, 0.72f) + new Vector3(0, 75, 0);
        mBBQuestionText.SoftInterpolation       = 1;
        mBBQuestionTextPrefix.SoftInterpolation = 1;
        var bubbleImage = mManager.mCharacterBundleManager.get_image("SELECTION_BUBBLE");

        mBBQuestionBubble = new FlatElementImage(bubbleImage.Image, bubbleImage.Data.Size, 1);
        mBBQuestionBubble.HardPosition = mFlatCamera.get_point(0, 0.75f);
        mBBQuestionBubble.HardScale    = new Vector3(1.3f, 1.1f, 1);
        mBBQuestionBubble.HardColor    = GameConstants.UiPopupBubble;

        mBBMiniMans = new FlatBodyObject[BB_NUM_CHOICES];
        for (int i = 0; i < BB_NUM_CHOICES; i++)
        {
            mBBMiniMans[i]                   = new FlatBodyObject(miniMan, 20);
            mBBMiniMans[i].HardScale         = miniManScale;
            mBBMiniMans[i].HardColor         = GameConstants.UiPurpleTransparent;
            mBBMiniMans[i].SoftInterpolation = .13f;
            mElement.Add(mBBMiniMans[i]);
        }



        mElement.Add(mBBChoosingBackground);

        mElement.Add(mBBQuestionText);
        mElement.Add(mBBQuestionTextPrefix);
        mElement.Add(mBBQuestionBubble);

        GameObject.Destroy(miniMan.gameObject);

        set_for_choosing();
    }