Esempio n. 1
0
 get => new float4(InverseInertia, InverseMass);
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        /*
         *      if (Input.GetKeyDown("b")) _key_press = "b";
         *      if (Input.GetKeyDown("f")) _key_press = "f";
         *      if (Input.GetKeyDown("g")) _key_press = "g";
         */

        switch (enabledSkill)
        {
        case SkillTypes.blackHole:
            if (Input.GetMouseButtonDown(0))
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit, 100))
                {
                    _object = new GameObject("BlackHole");
                    _object.AddComponent("Blackhole");
                    _object.transform.position = hit.point + new Vector3(0, 0.5f, 0);
                }
                //_key_press = "";
                enabledSkill = SkillTypes.noSkill;
            }
            break;

        case SkillTypes.tractionBeam:
            //vamos a iluminar todos los objetos a mi alrededor
            //Iluminate (Color.blue,"Beamer");
            //Iluminate (Color.black,"Tractor");
            if (!_beam)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    //Iluminate (Color.black,"Beamer");
                    Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit, 100))                   //,(1<<LayerMask.NameToLayer("Beamer"))))
                    {
                        if (hit.collider.gameObject.tag == "Beamer")
                        {
                            if (hit.collider.gameObject.GetComponent <Intertia>() == null)
                            {
                                _horizontal = 10f;
                                _lateral    = 7f;
                                _beamobject = hit.collider.gameObject;
                                _beamobject.AddComponent("Intertia");
                                Intertia inertiascript = _beamobject.GetComponent("Intertia") as Intertia;
                                inertiascript.player = player;
                                //GameObject hand = GameObject.Find("Beta:RightHand");
                                LightningBolt script = righthand.GetComponent("LightningBolt") as LightningBolt;
                                script.target = hit.collider.gameObject.transform.position;
                                script.active = true;
                                _beam         = true;
                            }
                        }
                    }
                    enabledSkill = SkillTypes.noSkill;
                }
            }
            else
            {
                //retiramos la inercia y el rayo del objecto
                //Iluminate (Color.black,"Beamer");
                //Iluminate (Color.black,"Tractor");
                Destroy(_beamobject.GetComponent("Intertia"));
                //GameObject hand = GameObject.Find("Beta:RightHand");
                LightningBolt script = righthand.GetComponent("LightningBolt") as LightningBolt;
                script.active = false;
                _beam         = false;
                _lateral      = 0;
                _horizontal   = 0;
                enabledSkill  = SkillTypes.noSkill;
            }
            break;

        case SkillTypes.liftingHook:
            //Iluminate (Color.red,"Tractor");
            //Iluminate (Color.black,"Beamer");
            if (!_tractor)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    //Iluminate (Color.black,"Tractor");
                    Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit, 100))
                    {
                        if (hit.collider.gameObject.tag == "Tractor")
                        {
                            if (hit.collider.gameObject.GetComponent <InverseInertia>() == null)
                            {
                                //GameObject Beta = GameObject.Find("Beta");
                                player.AddComponent("InverseInertia");
                                InverseInertia script = player.GetComponent("InverseInertia") as InverseInertia;
                                script.hitpoint = hit.point;
                                _hitpoint       = hit.point;
                                _tractorobject  = hit.collider.gameObject;
                                _tractor        = true;
                                ///
                                //GameObject hand = GameObject.Find("Beta:LeftHand");
                                LightningBolt script2 = lefthand.GetComponent("LightningBolt") as LightningBolt;
                                //Transform test=c
                                //test.position=hit.point;
                                script2.target = hit.point;
                                script2.active = true;
                            }
                        }
                    }
                    enabledSkill = SkillTypes.noSkill;
                }
            }
            else
            {
                //Iluminate (Color.black,"Tractor");
                //Iluminate (Color.black,"Beamer");
                _tractor = false;
                //GameObject Beta = GameObject.Find("Beta");
                InverseInertia script = player.GetComponent("InverseInertia") as InverseInertia;
                Destroy(script);
                //GameObject hand = GameObject.Find("Beta:LeftHand");
                LightningBolt script2 = lefthand.GetComponent("LightningBolt") as LightningBolt;
                script2.active = false;
                enabledSkill   = SkillTypes.noSkill;
            }
            break;

        default: break;
        }
    }