public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (go != null)
            {
                _joint = go.GetComponent<SliderJoint2D>();

                if(_joint!=null)
                {
                    _motor = _joint.motor;
                    _limits = _joint.limits;
                }
            }

            SetProperties();

            if(!everyFrame)
            {
                Finish();
            }
        }
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.JointTranslationLimits2D o;
         o = new UnityEngine.JointTranslationLimits2D();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Ejemplo n.º 3
0
    static public int set_max(IntPtr l)
    {
        UnityEngine.JointTranslationLimits2D o = (UnityEngine.JointTranslationLimits2D)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.max = v;
        setBack(l, o);
        return(0);
    }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.JointTranslationLimits2D o;
			o=new UnityEngine.JointTranslationLimits2D();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.JointTranslationLimits2D o;
			o=new UnityEngine.JointTranslationLimits2D();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
Ejemplo n.º 6
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointTranslationLimits2D o;
         o = new UnityEngine.JointTranslationLimits2D();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointTranslationLimits2D o;
         o=new UnityEngine.JointTranslationLimits2D();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 static void SliderJoint2D_limits(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.SliderJoint2D _this = (UnityEngine.SliderJoint2D)vc.csObj;
         var result = _this.limits;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.JointTranslationLimits2D arg0  = (UnityEngine.JointTranslationLimits2D)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.SliderJoint2D            _this = (UnityEngine.SliderJoint2D)vc.csObj;
         _this.limits = arg0;
     }
 }
 static void JointTranslationLimits2D_max(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.JointTranslationLimits2D _this = (UnityEngine.JointTranslationLimits2D)vc.csObj;
         var result = _this.max;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.JointTranslationLimits2D _this = (UnityEngine.JointTranslationLimits2D)vc.csObj;
         _this.max = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
        /// <summary>
        /// Read the data using the reader.
        /// </summary>
        /// <param name="reader">Reader.</param>
        public override object Read(ISaveGameReader reader)
        {
            UnityEngine.JointTranslationLimits2D jointTranslationLimits2D = new UnityEngine.JointTranslationLimits2D();
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "min":
                    jointTranslationLimits2D.min = reader.ReadProperty <System.Single> ();
                    break;

                case "max":
                    jointTranslationLimits2D.max = reader.ReadProperty <System.Single> ();
                    break;
                }
            }
            return(jointTranslationLimits2D);
        }
Ejemplo n.º 11
0
    void loadJsonJoints(JSONNode jsonJoints)
    {
        int JointCount = 0;

        for (int i = 0, numberOfJoints = jsonJoints.Count; i < numberOfJoints; i++){
            JSONNode jsonJoint = jsonJoints[i];
            int jointType = jsonJoint["jointType"].AsInt;

            GameObject bodyA = loadedObjects[jsonJoint["bodyA"].AsInt];
            GameObject bodyB = loadedObjects[jsonJoint["bodyB"].AsInt];

            JSONNode localAnchorA = jsonJoint["localAnchorA"];
            Vector2 anchorA = new Vector2(localAnchorA[0].AsFloat / RATIO, -localAnchorA[1].AsFloat / RATIO);
            JSONNode localAnchorB = jsonJoint["localAnchorB"];
            Vector2 anchorB = new Vector2(localAnchorB[0].AsFloat / RATIO, -localAnchorB[1].AsFloat / RATIO);
            bool collideConnected = jsonJoint["collideConnected"].AsBool;
            string userData = jsonJoint["userData"].Value;

            if (jointType == (int) JointTypes.JOINT_DISTANCE || jointType == (int) JointTypes.JOINT_ROPE){
                DistanceJoint2D joint = bodyA.AddComponent<DistanceJoint2D>();
                joint.connectedBody = bodyB.GetComponent<Rigidbody2D>();
                joint.anchor = anchorA;
                joint.connectedAnchor = anchorB;

                // distance joint
                if (jsonJoint["length"] != null){
                    joint.distance = jsonJoint["length"].AsFloat / RATIO;
                    joint.maxDistanceOnly = true;
                }
                // rope joint
                else if (jsonJoint["maxLength"] != null){
                    joint.distance = jsonJoint["maxLength"].AsFloat / RATIO;
                }

                joint.enableCollision = collideConnected;
                joint.name += '_';
                joint.name += userData.Length > 0 ? userData : "joint" + JointCount++;
            }
            else if (jointType == (int) JointTypes.JOINT_REVOLUTE){
                HingeJoint2D joint = bodyA.AddComponent<HingeJoint2D>();
                joint.connectedBody = bodyB.GetComponent<Rigidbody2D>();
                joint.anchor = anchorA;
                joint.connectedAnchor = anchorB;
                joint.enableCollision = collideConnected;
                joint.name += '_';
                joint.name += userData.Length > 0 ? userData : "joint" + JointCount++;

                // limits are not working properly
                bool enableLimits = jsonJoint["enableLimit"].AsBool;
                float referenceAngle = -jsonJoint["referenceAngle"].AsFloat;
                float angleBetweenBodies = Mathf.Atan2(bodyB.transform.position.y - bodyA.transform.position.y,
                                                      bodyB.transform.position.x - bodyA.transform.position.x) * 180 / Mathf.PI;
                float upperAngle = -jsonJoint["lowerAngle"].AsFloat;
                float lowerAngle = -jsonJoint["upperAngle"].AsFloat;
                bool enableMotor = jsonJoint["enableMotor"].AsBool;
                float motorSpeed = -jsonJoint["motorSpeed"].AsFloat;
                float maxMotorTorque = jsonJoint["maxMotorTorque"].AsFloat;

                joint.useLimits = enableLimits;
                JointAngleLimits2D limits = new JointAngleLimits2D();
                limits.max = angleBetweenBodies + upperAngle;
                limits.min = angleBetweenBodies + lowerAngle;
                joint.limits = limits;
                joint.useMotor = enableMotor;
                JointMotor2D motor = new JointMotor2D();
                motor.maxMotorTorque = maxMotorTorque;
                motor.motorSpeed = motorSpeed;
                joint.motor = motor;
            }
            else if (jointType == (int) JointTypes.JOINT_WHEEL){
                WheelJoint2D joint = bodyA.AddComponent<WheelJoint2D>();
                joint.connectedBody = bodyB.GetComponent<Rigidbody2D>();
                joint.anchor = anchorA;
                joint.connectedAnchor = anchorB;
                joint.enableCollision = collideConnected;
                joint.name += '_';
                joint.name += userData.Length > 0 ? userData : "joint" + JointCount++;

                bool enableMotor = jsonJoint["enableMotor"].AsBool;
                float motorSpeed = -jsonJoint["motorSpeed"].AsFloat;
                float maxMotorTorque = jsonJoint["maxMotorTorque"].AsFloat;
                float dampingRatio = jsonJoint["dampingRatio"].AsFloat;
                float frequency = jsonJoint["frequencyHZ"].AsFloat;
                JSONNode localAxisA = jsonJoint["localAxisA"];
                float angle = Mathf.Atan2(-localAxisA[1].AsFloat, localAxisA[0].AsFloat) * 180 / Mathf.PI;

                joint.useMotor = enableMotor;
                JointMotor2D motor = new JointMotor2D();
                motor.maxMotorTorque = maxMotorTorque;
                motor.motorSpeed = motorSpeed;
                joint.motor = motor;

                JointSuspension2D suspension = new JointSuspension2D();
                suspension.dampingRatio = dampingRatio;
                suspension.frequency = frequency;
                suspension.angle = angle;
                joint.suspension = suspension;
            }
            else if (jointType == (int) JointTypes.JOINT_PRISMATIC){
                SliderJoint2D joint = bodyA.AddComponent<SliderJoint2D>();
                joint.connectedBody = bodyB.GetComponent<Rigidbody2D>();
                joint.anchor = anchorA;
                joint.connectedAnchor = anchorB;
                joint.enableCollision = collideConnected;
                joint.name += '_';
                joint.name += userData.Length > 0 ? userData : "joint" + JointCount++;

                bool enableLimits = jsonJoint["enableLimit"].AsBool;
                float referenceAngle = -jsonJoint["referenceAngle"].AsFloat;
                float upperTranslation = jsonJoint["upperTranslation"].AsFloat / RATIO;
                float lowerTranslation = jsonJoint["lowerTranslation"].AsFloat / RATIO;
                bool enableMotor = jsonJoint["enableMotor"].AsBool;
                float motorSpeed = -jsonJoint["motorSpeed"].AsFloat;
                float maxMotorTorque = jsonJoint["maxMotorTorque"].AsFloat;
                JSONNode localAxisA = jsonJoint["localAxisA"];
                float angle = Mathf.Atan2(-localAxisA[1].AsFloat, localAxisA[0].AsFloat) * 180 / Mathf.PI;

                joint.useLimits = enableLimits;
                JointTranslationLimits2D limits = new JointTranslationLimits2D();
                limits.max = upperTranslation;
                limits.min = lowerTranslation;
                joint.limits = limits;
                joint.useMotor = enableMotor;
                JointMotor2D motor = new JointMotor2D();
                motor.maxMotorTorque = maxMotorTorque;
                motor.motorSpeed = motorSpeed;
                joint.motor = motor;
                joint.angle = angle;
            }
        }
    }
Ejemplo n.º 12
0
		private extern void INTERNAL_set_limits(ref JointTranslationLimits2D value);
Ejemplo n.º 13
0
 private extern void set_limits_Injected(ref JointTranslationLimits2D value);
Ejemplo n.º 14
0
    //private Transform dummyCam;
    //private Vector3 oldMousePos = Vector3.zero;
    void Awake()
    {
        var wTransform = transform.Find ("weapon Transform");
        anim = GetComponent<Animator>();

        aud = wTransform.Find("Audio").GetComponent<AudioSource>();
        //aud.clip = hgSFX;
        ammoDisp = GameObject.Find("ammoClipTXT").GetComponent<Text>();
        // Setting up the references.

        playerT = GameObject.FindGameObjectWithTag("Player").transform;
        playerCtrl = playerT.GetComponent<PlayerControl>();
        playerHealth = playerT.GetComponent<PlayerHealth>();

        //print (playerT.name);

        playerCtrl.gunCS = this;
        playerAnim = playerT.GetComponent<Animator>();
        kickHit = playerT.Find ("kickHit").GetComponent<KickHit>();

        grabEnemyHitGO = playerT.Find ("grabEnemyHit").gameObject;
        //gehCS = grabEnemyHitGO.GetComponent<GrabEnemyHit> ();
        grabEnemyHitGO.GetComponent<GrabEnemyHit> ().gunCS = this;

        //yellSFX = playerCtrl.jumpFX;//make kick yell SFX same as jump from player control

        head = playerT.Find("head Transform");
        headSR = head.transform.Find ("head").GetComponent<SpriteRenderer>();

        psychoEye = head.Find("head").Find("psychoEye").gameObject;

        SliderJoint2D jnt = playerT.gameObject.AddComponent<SliderJoint2D>();
        jnt.connectedBody = GetComponent<Rigidbody2D>();
        jnt.anchor = new Vector2(0,0.6f);
        jnt.useLimits = true;
        jnt.angle = 90f;
        JointTranslationLimits2D l = new JointTranslationLimits2D();
        l.max = 1.2f;
        jnt.limits = l;

        //WEAPONS STUFF

        handGunWeapon = new Weapon(GunMode.HANDGUN,transform.Find("weapon Transform"));
        handGunWeapon.bulletShell = bulletShells [0];
        machineGunWeapon = new Weapon(GunMode.MACHINEGUN,transform.Find("weapon Transform"));
        machineGunWeapon.bulletShell = bulletShells [0];
        grenadeWeapon = new Weapon (GunMode.GRENADE,transform.Find("weapon Transform"));
        flameWeapon = new Weapon (GunMode.FLAME,transform.Find("weapon Transform"));
        rpgWeapon = new Weapon (GunMode.ROCKET,transform.Find("weapon Transform"));
        punchWeapon = new Weapon (GunMode.PUNCH,transform.Find("weapon Transform"));
        shotGunWeapon = new Weapon (GunMode.SHOTGUN,transform.Find("weapon Transform"));
        shotGunWeapon.bulletShell = bulletShells [1];
        stratWeapon = new Weapon (GunMode.STRAT,transform.Find("weapon Transform"));

        activeWeapon = handGunWeapon;

        weapons[0]=new Weapon(GunMode.UNARMED,transform.Find("weapon Transform"));
        weapons[1]=handGunWeapon;
        weapons[2]=machineGunWeapon;
        weapons[3]=grenadeWeapon;
        weapons[4]=flameWeapon;
        weapons[5]=rpgWeapon;
        weapons[6]=punchWeapon;
        weapons [7] = shotGunWeapon;
        weapons[8] = stratWeapon;

        weaponsForAmmo[0] = machineGunWeapon;
        weaponsForAmmo[1] = grenadeWeapon;
        weaponsForAmmo[2] = flameWeapon;
        weaponsForAmmo[3] = rpgWeapon;
        weaponsForAmmo[4] = punchWeapon;
        weaponsForAmmo [5] = shotGunWeapon;

        gunModes[0]=GunMode.UNARMED;
        gunModes[1]=GunMode.HANDGUN;
        gunModes[2]=GunMode.MACHINEGUN;
        gunModes[3]=GunMode.GRENADE;
        gunModes[4]=GunMode.FLAME;
        gunModes[5]=GunMode.ROCKET;
        gunModes[6]=GunMode.PUNCH;
        gunModes[7]=GunMode.SHOTGUN;
        gunModes[8]=GunMode.STRAT;

        //unarmLGO = playerT.Find ("body").Find("psycho bob_armL").gameObject;//unarmed arms, animated separately
        //unarmRGO = playerT.Find ("body").Find("psycho bob_armR").gameObject;

        handGunGO = wTransform.Find ("handGun3D").gameObject;
        bazookaGO = wTransform.Find ("bazooka3D").gameObject;
        machineGunGO = wTransform.Find ("machineGun3D").gameObject;
        flameThrowerGO = wTransform.Find ("flameThrower3D").gameObject;
        shotGunGO = wTransform.Find ("shotGun3D").gameObject;
        stratGO  = wTransform.Find ("stratGun3D").gameObject;
        rpgGO    = wTransform.Find("bazooka3D").Find("rocket3D").gameObject;
        punchGO  = wTransform.Find("bazooka3D").Find("punch3D").gameObject;

        weaponWheel = transform.Find("UIweaponWheel").gameObject;//GameObject.Find ("UI").transform.Find("UIweaponWheel").gameObject;//playerT.Find("weaponSelect").gameObject;
        weaponWheel.transform.SetParent (GameObject.Find ("UI").transform, false);

        bulletShell_ShotPos =wTransform. transform.Find ("bulletShell_spot");

        handGunFlare = wTransform.Find ("handGun3D").Find ("handGunFlare").GetComponent<ParticleSystem>();
        handGunFlareLight = wTransform.Find ("handGun3D").Find("handGunFlare light").GetComponent<Light>();
        //handGunFlareLight2 = wTransform.Find ("handGun3D").Find("handGunFlare light2").GetComponent<Light>();

        gunFlare = wTransform.Find ("machineGun3D").Find ("gunFlare").GetComponent<ParticleSystem>();
        gunFlareLight = wTransform.Find ("machineGun3D").Find("gunFlare light").GetComponent<Light>();
        //gunFlareLight2 = wTransform.Find ("machineGun3D").Find("gunFlare light2").GetComponent<Light>();

        shotGunFlare = wTransform.Find ("shotGun3D").Find ("gunFlare").GetComponent<ParticleSystem>();
        shotGunFlareLight = wTransform.Find ("shotGun3D").Find("gunFlare light").GetComponent<Light>();
        //shotGunFlareLight2 = wTransform.Find ("shotGun3D").Find("gunFlare light2").GetComponent<Light>();

        flame = wTransform.Find ("flameThrower3D").Find("flame").GetComponent<ParticleSystem>();
        smoke = wTransform.Find ("flameThrower3D").Find("flameSmoke").GetComponent<ParticleSystem>();
        flameLight =  wTransform.Find ("flameThrower3D").Find("flameFX").GetComponent<Light>();
        flameAud = flameLight.gameObject.GetComponent<AudioSource>();

        rpgSmoke = wTransform.Find ("bazooka3D").Find("rpgSmoke").GetComponent<ParticleSystem>();

        stratLightning = transform.Find ("lightning").gameObject;
        stratLightning.transform.parent = null;
        lightningCS = stratLightning.GetComponent<Lightning> ();
        stratLightning.SetActive(false);

        armIK[0] = playerT.Find ("body").Find ("psycho bob_armL").GetComponent<SimpleCCD>();
        armIK[1] = playerT.Find ("body").Find("psycho bob_armR").GetComponent<SimpleCCD>();

        armTargets[0]= transform.Find("weapon Transform").Find ("fArmB_L_IK");//for flipping when gun flips
        armTargets[1]= transform.Find("weapon Transform").Find ("fArmB_R_IK");
        armTargets[2]= playerT.Find ("handL_IK");//for unarmed IK targets
        armTargets[3]= playerT.Find ("handR_IK");
        armTargets[4]= stratGO.transform.Find("handLmg");//for strat
        armTargets[5]= stratGO.transform.Find ("handRmg");
        armTargets[6]= playerT.Find ("handL_IK_grab"); //for grabbing enemies;
        armTargets[7]= playerT.Find ("handR_IK_grab");

        fArmR_SR = armIK[1].transform.Find("psycho bob_fArmR").GetComponent<SpriteRenderer>();
        fArmL_SR = armIK[0].transform.Find("psycho bob_fArmL").GetComponent<SpriteRenderer>();
        armL_SR = armIK[0].transform.parent.Find("psycho bob_armL").GetComponent<SpriteRenderer>();

        //elbowTargets [0] = playerT.Find ("body").Find ("Skeleton").Find ("armB_L_IK");
        //elbowTargets [1] = playerT.Find ("body").Find ("Skeleton").Find ("armB_R_IK");

        armTargetPos[0] = armTargets[0].localPosition;//handgun machine gun L
        armTargetPos[1] = armTargets[1].localPosition;//R
        armTargetPos[2] = new Vector3(-0.8f,-0.4f,armTargets[0].localPosition.z);//flamethrower
        armTargetPos[3] = new Vector3(1.2f,-0.2f,armTargets[1].localPosition.z);
        armTargetPos[4] = new Vector3(-0.6f,-0.1f,armTargets[1].localPosition.z);//bazooka
        armTargetPos[5] = new Vector3(2f,1.57f,armTargets[0].localPosition.z);
        armTargetPos[6] = new Vector3(-.75f,-0.3f,armTargets[0].localPosition.z);//shotgun
        armTargetPos[7] = new Vector3(1.5f,0.5f,armTargets[0].localPosition.z);
        //armTargetPos[8] = new Vector3(-1f,0.8f,armTargets[0].localPosition.z);//strat
        //armTargetPos[9] = new Vector3(1.8f,-0.5f,armTargets[0].localPosition.z);

        hudGun =GameObject.FindGameObjectWithTag("HUD").transform.Find ("gunHUD").Find ("weaponIMG").GetComponent<UI_WeaponDisplay>();

        rightHands[0] = wTransform.Find("handGun3D").Find ("hands2").GetComponent<SpriteRenderer>();
        rightHands[1] = wTransform.Find("machineGun3D").Find ("handRmg").GetComponent<SpriteRenderer>();
        rightHands[2] = wTransform.Find("shotGun3D").Find ("shotgun_grip").Find ("handR").GetComponent<SpriteRenderer>();
        rightHands[3] = wTransform.Find("stratGun3D").Find ("handRmg").GetComponent<SpriteRenderer>();
        rightHands[4] = wTransform.Find("flameThrower3D").Find ("handR").GetComponent<SpriteRenderer>();
        rightHands[5] = wTransform.Find("bazooka3D").Find ("handRbz").GetComponent<SpriteRenderer>();
        //rightHands[6] = wTransform.Find("").Find ("handR").gameObject;
        //rightHands[7] = wTransform.Find("").Find ("handR").gameObject;
        //rightHands[8] = wTransform.Find("").Find ("handR").gameObject;
        //hero = transform.root.gameObject.transform;
        bazookaGO.SetActive(false);
        machineGunGO.SetActive(false);
        //flameThrowerGO.SetActive(false);
        //camera = Camera.main;
        var xhairGO = (GameObject)Instantiate (xhairRef,transform.position  , Quaternion.identity);
        xhair = xhairGO.transform;
        xhair.name = "xhair";
        Cursor.visible = false;

        xhairHUD =GameObject.FindGameObjectWithTag("HUD").transform.Find ("xhairHUD");

        gunMode = GunMode.UNARMED;

        SwitchWeapons();

        cameraXmaxMin = Camera.main.transform.GetComponent<CameraFollow>().GetCameraMaxMin();

        //dummyCam = Camera.main.transform.Find ("dummyCam");
    }
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.JointTranslationLimits2D jointTranslationLimits2D = (UnityEngine.JointTranslationLimits2D)value;
     writer.WriteProperty("min", jointTranslationLimits2D.min);
     writer.WriteProperty("max", jointTranslationLimits2D.max);
 }
Ejemplo n.º 16
0
 private extern void get_limits_Injected(out JointTranslationLimits2D ret);
Ejemplo n.º 17
0
 private extern void INTERNAL_get_limits(out JointTranslationLimits2D value);
Ejemplo n.º 18
0
		private extern void INTERNAL_get_limits(out JointTranslationLimits2D value);
Ejemplo n.º 19
0
 private extern void INTERNAL_set_limits(ref JointTranslationLimits2D value);
Ejemplo n.º 20
0
 private void INTERNAL_set_limits(ref JointTranslationLimits2D value)
 {
     throw new NotImplementedException("なにこれ");
 }
Ejemplo n.º 21
0
 static public int get_max(IntPtr l)
 {
     UnityEngine.JointTranslationLimits2D o = (UnityEngine.JointTranslationLimits2D)checkSelf(l);
     pushValue(l, o.max);
     return(1);
 }