Exemple #1
0
    override public void PickupHoldable(string HandString)
    {
        // drop other objects
        if (HandControllerLeft.GetComponent <RobustController>().HoldingObject == true)
        {
            HandControllerLeft.GetComponent <RobustController>().HoldableObject.GetComponent <Holdable>().InHandLeft = false;
            HandControllerLeft.GetComponent <RobustController>().HoldableObject.GetComponent <Holdable>().Dropped    = true;
            HandControllerLeft.GetComponent <RobustController>().HoldableObject.GetComponent <Holdable>().SendMessage("DropHoldable", "left");
            HandControllerLeft.GetComponent <RobustController>().HoldableObject = null;
            HandControllerLeft.GetComponent <RobustController>().HoldingObject  = false;
        }
        if (HandControllerRight.GetComponent <RobustController>().HoldingObject == true)
        {
            HandControllerRight.GetComponent <RobustController>().HoldableObject.GetComponent <Holdable>().InHandRight = false;
            HandControllerRight.GetComponent <RobustController>().HoldableObject.GetComponent <Holdable>().Dropped     = true;
            HandControllerRight.GetComponent <RobustController>().HoldableObject.GetComponent <Holdable>().SendMessage("DropHoldable", "right");
            HandControllerRight.GetComponent <RobustController>().HoldableObject = null;
            HandControllerRight.GetComponent <RobustController>().HoldingObject  = false;
        }

        // pick up this one
        InHandLeft = true;
        Dropped    = false;
        HandControllerLeft.GetComponent <RobustController>().HoldableObject = this.gameObject;
        HandControllerLeft.GetComponent <RobustController>().HoldingObject  = true;
        InHandRight = true;
        Dropped     = false;
        HandControllerRight.GetComponent <RobustController>().HoldableObject = this.gameObject;
        HandControllerRight.GetComponent <RobustController>().HoldingObject  = true;
        WeaponAnimationController.SetBool("Holding", true);
        Audio.PlayOneShot(WindUpSound);
    }
Exemple #2
0
    override public void PickupHoldable(string HandString)
    {
        // drop other objects
        if (HandControllerLeft.GetComponent <RobustController>().HoldingObject == true)
        {
            HandControllerLeft.GetComponent <RobustController>().HoldableObject.GetComponent <Holdable>().InHandLeft = false;
            HandControllerLeft.GetComponent <RobustController>().HoldableObject.GetComponent <Holdable>().Dropped    = true;
            HandControllerLeft.GetComponent <RobustController>().HoldableObject.GetComponent <Holdable>().SendMessage("DropHoldable", "left");
            HandControllerLeft.GetComponent <RobustController>().HoldableObject = null;
            HandControllerLeft.GetComponent <RobustController>().HoldingObject  = false;
        }
        if (HandControllerRight.GetComponent <RobustController>().HoldingObject == true)
        {
            HandControllerRight.GetComponent <RobustController>().HoldableObject.GetComponent <Holdable>().InHandRight = false;
            HandControllerRight.GetComponent <RobustController>().HoldableObject.GetComponent <Holdable>().Dropped     = true;
            HandControllerRight.GetComponent <RobustController>().HoldableObject.GetComponent <Holdable>().SendMessage("DropHoldable", "right");
            HandControllerRight.GetComponent <RobustController>().HoldableObject = null;
            HandControllerRight.GetComponent <RobustController>().HoldingObject  = false;
        }

        // pick up this one
        InHandLeft = true;
        Dropped    = false;
        HandControllerLeft.GetComponent <RobustController>().HoldableObject = this.gameObject;
        HandControllerLeft.GetComponent <RobustController>().HoldingObject  = true;
        InHandRight = true;
        Dropped     = false;
        HandControllerRight.GetComponent <RobustController>().HoldableObject = this.gameObject;
        HandControllerRight.GetComponent <RobustController>().HoldingObject  = true;
    }
Exemple #3
0
 void OnTriggerEnter(Collider other)
 {
     if (InHandLeft || InHandRight)
     {
         string HoldableObjectTag = other.tag;
         //print (HoldableObjectTag);
         if (HoldableObjectTag == "FlashLight")
         {
             //print("reload");
             other.GetComponent <FlashLight>().Power = Power;
             if (InHandLeft)
             {
                 HandControllerLeft.GetComponent <RobustController>().HoldableObject = null;
                 HandControllerLeft.GetComponent <RobustController>().HoldingObject  = false;
             }
             if (InHandRight)
             {
                 HandControllerRight.GetComponent <RobustController>().HoldableObject = null;
                 HandControllerRight.GetComponent <RobustController>().HoldingObject  = false;
             }
             Destroy(this.gameObject);
         }
         if (HoldableObjectTag == "GunWithLight")
         {
             //print("reload");
             other.GetComponent <GunWithLight>().Power = Power;
             if (InHandLeft)
             {
                 HandControllerLeft.GetComponent <RobustController>().HoldableObject = null;
                 HandControllerLeft.GetComponent <RobustController>().HoldingObject  = false;
             }
             if (InHandRight)
             {
                 HandControllerRight.GetComponent <RobustController>().HoldableObject = null;
                 HandControllerRight.GetComponent <RobustController>().HoldingObject  = false;
             }
             Destroy(this.gameObject);
         }
         if (HoldableObjectTag == "LightSword")
         {
             //print("reload");
             other.GetComponent <LightSword>().Power = Power;
             if (InHandLeft)
             {
                 HandControllerLeft.GetComponent <RobustController>().HoldableObject = null;
                 HandControllerLeft.GetComponent <RobustController>().HoldingObject  = false;
             }
             if (InHandRight)
             {
                 HandControllerRight.GetComponent <RobustController>().HoldableObject = null;
                 HandControllerRight.GetComponent <RobustController>().HoldingObject  = false;
             }
             Destroy(this.gameObject);
         }
     }
 }
Exemple #4
0
 void OnTriggerEnter(Collider other)
 {
     if (InHandLeft || InHandRight)
     {
         // make sure that its a hand gun
         string HoldableObjectTag = other.tag;
         //Debug.Log (HoldableObjectTag);
         if (HoldableObjectTag == "HandGun")
         {
             // make sure the gun is empty
             int GunAmmoLeft = other.GetComponent <Gun>().WeaponAnimationController.GetInteger("Ammo");
             if (GunAmmoLeft < 1)
             {
                 //print("reload");
                 MagModel.SetActive(false);
                 other.GetComponent <Gun>().WeaponAnimationController.SetInteger("Ammo", Ammo);
                 if (InHandLeft)
                 {
                     HandControllerLeft.GetComponent <RobustController>().HoldableObject = null;
                     HandControllerLeft.GetComponent <RobustController>().HoldingObject  = false;
                 }
                 if (InHandRight)
                 {
                     HandControllerRight.GetComponent <RobustController>().HoldableObject = null;
                     HandControllerRight.GetComponent <RobustController>().HoldingObject  = false;
                 }
                 Audio.PlayOneShot(ReloadSounds[(Random.Range(0, (ReloadSounds.Length - 1)))]);
                 Destroy(this.gameObject, 0f);
             }
         }
         if (HoldableObjectTag == "GunWithLight")
         {
             // make sure the gun is empty
             int GunAmmoLeft = other.GetComponent <GunWithLight>().WeaponAnimationController.GetInteger("Ammo");
             if (GunAmmoLeft < 1)
             {
                 //print("reload");
                 MagModel.SetActive(false);
                 other.GetComponent <GunWithLight>().WeaponAnimationController.SetInteger("Ammo", Ammo);
                 if (InHandLeft)
                 {
                     HandControllerLeft.GetComponent <RobustController>().HoldableObject = null;
                     HandControllerLeft.GetComponent <RobustController>().HoldingObject  = false;
                 }
                 if (InHandRight)
                 {
                     HandControllerRight.GetComponent <RobustController>().HoldableObject = null;
                     HandControllerRight.GetComponent <RobustController>().HoldingObject  = false;
                 }
                 Audio.PlayOneShot(ReloadSounds[(Random.Range(0, (ReloadSounds.Length - 1)))]);
                 Destroy(this.gameObject, 0f);
             }
         }
     }
 }
Exemple #5
0
 override public void DropHoldable(string HandString)
 {
     // drop
     InHandLeft = false;
     Dropped    = true;
     HandControllerLeft.GetComponent <RobustController>().HoldableObject = null;
     HandControllerLeft.GetComponent <RobustController>().HoldingObject  = false;
     InHandRight = false;
     Dropped     = true;
     HandControllerRight.GetComponent <RobustController>().HoldableObject = null;
     HandControllerRight.GetComponent <RobustController>().HoldingObject  = false;
 }
Exemple #6
0
 override public void DropHoldable(string HandString)
 {
     // drop
     InHandLeft = false;
     Dropped    = true;
     HandControllerLeft.GetComponent <RobustController>().HoldableObject = null;
     HandControllerLeft.GetComponent <RobustController>().HoldingObject  = false;
     InHandRight = false;
     Dropped     = true;
     HandControllerRight.GetComponent <RobustController>().HoldableObject = null;
     HandControllerRight.GetComponent <RobustController>().HoldingObject  = false;
     WeaponAnimationController.SetBool("Holding", false);
     Audio.PlayOneShot(WindDownSound);
 }
Exemple #7
0
    override public void TriggerPressedDown(string HandString)
    {
        string Hand = "";

        if (HandString.Contains("left"))
        {
            Hand = "left";
        }
        if (HandString.Contains("right"))
        {
            Hand = "right";
        }

        if (InHandLeft && Hand == "left")
        {
            // drop
            InHandLeft = false;
            //Dropped = true;
            HandControllerLeft.GetComponent <RobustController>().HoldableObject = null;
            HandControllerLeft.GetComponent <RobustController>().HoldingObject  = false;
            //Eat and give health
            Player.GetComponent <Player>().HitPoints += Health;
            Destroy(this.gameObject);
            return;
        }
        if (InHandRight && Hand == "right")
        {
            // drop
            InHandRight = false;
            //Dropped = true;
            HandControllerRight.GetComponent <RobustController>().HoldableObject = null;
            HandControllerRight.GetComponent <RobustController>().HoldingObject  = false;
            //Eat and give health
            Player.GetComponent <Player>().HitPoints += Health;
            Destroy(this.gameObject);
            return;
        }
    }
Exemple #8
0
    override public void FixedUpdate()
    {
        if (InHandLeft)
        {
            if (LeftHandModel != null)
            {
                LeftHandModel.SetActive(true);
            }
            if (RightHandModel != null)
            {
                RightHandModel.SetActive(false);
            }
            this.GetComponent <Rigidbody>().isKinematic = true;
            this.gameObject.layer = 9;             // change layer to InHand for physics collisions
            // slave to controller
            transform.position = HandControllerLeft.transform.position;
            transform.rotation = HandControllerLeft.transform.rotation;
            HandControllerLeft.GetComponent <RobustController>().HoldableObject = this.gameObject;

            // play whoosh sound
            float WhooshDist = Vector3.Distance(PreviousPosition, transform.position);
            if (WhooshDist > 0.04f)
            {
                //if(AudioWhoosh.isPlaying == false) AudioWhoosh.PlayOneShot(WhooshSounds[(Random.Range(0,(WhooshSounds.Length-1)))]);
            }
        }
        if (InHandRight)
        {
            if (LeftHandModel != null)
            {
                LeftHandModel.SetActive(false);
            }
            if (RightHandModel != null)
            {
                RightHandModel.SetActive(true);
            }
            this.GetComponent <Rigidbody>().isKinematic = true;
            this.gameObject.layer = 9;             // change layer to InHand for physics collisions
            // slave to controller
            transform.position = HandControllerRight.transform.position;
            transform.rotation = HandControllerRight.transform.rotation;
            HandControllerRight.GetComponent <RobustController>().HoldableObject = this.gameObject;

            // play whoosh sound
            float WhooshDist = Vector3.Distance(PreviousPosition, transform.position);
            if (WhooshDist > 0.04f)
            {
                //if(AudioWhoosh.isPlaying == false) AudioWhoosh.PlayOneShot(WhooshSounds[(Random.Range(0,(WhooshSounds.Length-1)))]);
            }
        }

        if (!InHandLeft && !InHandRight)
        {
            this.gameObject.layer = 0;             // change layer to Default for physics collisions
            if (LeftHandModel != null)
            {
                LeftHandModel.SetActive(false);
            }
            if (RightHandModel != null)
            {
                RightHandModel.SetActive(false);
            }
            if (Dropped)
            {
                this.GetComponent <Rigidbody>().isKinematic = false;
                if (UseMomentum)
                {
                    transform.root.GetComponent <Rigidbody>().velocity        = Velocity;
                    transform.root.GetComponent <Rigidbody>().angularVelocity = AngularVelocity;
                }
                Dropped = false;
            }
        }

        if (!Audio.isPlaying && TurnedOn)
        {
            Audio.PlayOneShot(IdleSound);
        }

        Velocity         = (transform.position - PreviousPosition) * (1f / Time.deltaTime);
        AngularVelocity  = ((transform.rotation * Vector3.forward) - PreviousRotation) * (1f / Time.deltaTime);
        PreviousPosition = transform.position;
        PreviousRotation = (transform.rotation * Vector3.forward);
    }
Exemple #9
0
    override public void FixedUpdate()
    {
        if (MuzzleFlash != null)
        {
            MuzzleFlash.SetActive(false);
        }
        if (FireGunStart)
        {
            FireGun();
            if (MuzzleFlash != null)
            {
                if (WeaponAnimationController.GetInteger("Ammo") > 0)
                {
                    MuzzleFlash.SetActive(true);
                }
            }
        }


        if (InHandLeft || InHandRight)
        {
            if (LeftHandModel != null)
            {
                LeftHandModel.SetActive(true);
            }
            if (RightHandModel != null)
            {
                RightHandModel.SetActive(true);
            }
            this.GetComponent <Rigidbody>().isKinematic = true;
            this.gameObject.layer = 9;             // change layer to InHand for physics collisions
            // slave to controller
            transform.position = HandControllerLeft.transform.position;

            //transform.rotation = HandControllerLeft.transform.rotation;
            Vector3 targetDir = HandControllerLeft.transform.position - HandControllerRight.transform.position;
            transform.rotation = Quaternion.LookRotation(targetDir);

            HandControllerRight.GetComponent <RobustController>().HoldableObject = this.gameObject;
            HandControllerLeft.GetComponent <RobustController>().HoldableObject  = this.gameObject;
        }

        if (!InHandLeft && !InHandRight)
        {
            this.gameObject.layer = 0;             // change layer to Default for physics collisions
            if (LeftHandModel != null)
            {
                LeftHandModel.SetActive(false);
            }
            if (RightHandModel != null)
            {
                RightHandModel.SetActive(false);
            }
            if (Dropped)
            {
                this.GetComponent <Rigidbody>().isKinematic = false;
                if (UseMomentum)
                {
                    transform.root.GetComponent <Rigidbody>().velocity        = Velocity;
                    transform.root.GetComponent <Rigidbody>().angularVelocity = AngularVelocity;
                }
                Dropped = false;
            }
        }

        Velocity         = (transform.position - PreviousPosition) * (1f / Time.deltaTime);
        AngularVelocity  = ((transform.rotation * Vector3.forward) - PreviousRotation) * (1f / Time.deltaTime);
        PreviousPosition = transform.position;
        PreviousRotation = (transform.rotation * Vector3.forward);
    }
Exemple #10
0
    override public void FixedUpdate()
    {
        if (FlameOn)
        {
            // does the gun have any ammo?
            if (Ammo > 0)
            {
                Ammo -= Time.deltaTime;
                if (!Audio.isPlaying)
                {
                    Audio.Play();
                }
                LightFire.GetComponent <Light>().enabled = true;
                Flames.SetActive(true);
                //Debug.Log("Flame On !");
                if (TriggerCollisionObject != null)
                {
                    if (TriggerCollisionObject.transform.root.tag == "Baddie")
                    {
                        //Debug.Log("hit baddie");
                        TriggerCollisionObject.transform.root.GetComponent <Baddie>().SendMessage("TakeDamage", DamagePerFrame);
                    }
                }
            }
            else
            {
                Audio.Pause();
                FlameOn = false;
                LightFire.GetComponent <Light>().enabled = false;
                Flames.SetActive(false);
            }
        }
        else
        {
            Audio.Pause();
            LightFire.GetComponent <Light>().enabled = false;
            Flames.SetActive(false);
        }

        if (InHandLeft && InHandRight)
        {
            if (LeftHandModel != null)
            {
                LeftHandModel.SetActive(true);
            }
            if (RightHandModel != null)
            {
                RightHandModel.SetActive(true);
            }
            this.GetComponent <Rigidbody>().isKinematic = true;
            //GunRigidBody.GetComponent<Rigidbody>().isKinematic = true;
            //GunRigidBody.transform.localPosition = Vector3.zero;
            //GunRigidBody.transform.localRotation = Quaternion.identity;
            this.gameObject.layer = 9;             // change layer to InHand for physics collisions
            // slave to controller
            transform.position = HandControllerLeft.transform.position;

            //transform.rotation = HandControllerLeft.transform.rotation;
            Vector3 targetDir = HandControllerLeft.transform.position - HandControllerRight.transform.position;
            transform.rotation = Quaternion.LookRotation(targetDir);

            HandControllerRight.GetComponent <RobustController>().HoldableObject = this.gameObject;
            HandControllerLeft.GetComponent <RobustController>().HoldableObject  = this.gameObject;
        }

        if (!InHandLeft && !InHandRight)
        {
            this.gameObject.layer = 0;             // change layer to Default for physics collisions
            if (LeftHandModel != null)
            {
                LeftHandModel.SetActive(false);
            }
            if (RightHandModel != null)
            {
                RightHandModel.SetActive(false);
            }
            if (Dropped)
            {
                this.GetComponent <Rigidbody>().isKinematic = false;
                //GunRigidBody.GetComponent<Rigidbody>().isKinematic = false;
                if (UseMomentum)
                {
                    transform.root.GetComponent <Rigidbody>().velocity        = Velocity;
                    transform.root.GetComponent <Rigidbody>().angularVelocity = AngularVelocity;
                }
                Dropped = false;
            }
        }

        if (InHandLeft && !InHandRight)
        {
            if (LeftHandModel != null)
            {
                LeftHandModel.SetActive(true);
            }
            if (RightHandModel != null)
            {
                RightHandModel.SetActive(false);
            }
            this.GetComponent <Rigidbody>().isKinematic = true;
            //GunRigidBody.GetComponent<Rigidbody>().isKinematic = false;
            this.gameObject.layer = 9;             // change layer to InHand for physics collisions
            // slave to controller
            transform.position = HandControllerLeft.transform.position;
            transform.rotation = HandControllerLeft.transform.rotation;
            HandControllerLeft.GetComponent <RobustController>().HoldableObject = this.gameObject;
        }

        if (InHandRight && !InHandLeft)
        {
            if (LeftHandModel != null)
            {
                LeftHandModel.SetActive(false);
            }
            if (RightHandModel != null)
            {
                RightHandModel.SetActive(true);
            }
            this.GetComponent <Rigidbody>().isKinematic = true;
            //GunRigidBody.GetComponent<Rigidbody>().isKinematic = false;
            this.gameObject.layer = 9;             // change layer to InHand for physics collisions
            // slave to controller
            transform.position = HandControllerRight.transform.position;
            transform.rotation = HandControllerRight.transform.rotation;
            HandControllerRight.GetComponent <RobustController>().HoldableObject = this.gameObject;
        }

        Velocity         = (transform.position - PreviousPosition) * (1f / Time.deltaTime);
        AngularVelocity  = ((transform.rotation * Vector3.forward) - PreviousRotation) * (1f / Time.deltaTime);
        PreviousPosition = transform.position;
        PreviousRotation = (transform.rotation * Vector3.forward);
    }
Exemple #11
0
    override public void FixedUpdate()
    {
        if (InHandLeft)
        {
            if (LeftHandModel != null)
            {
                LeftHandModel.SetActive(true);
            }
            if (RightHandModel != null)
            {
                RightHandModel.SetActive(false);
            }
            this.GetComponent <Rigidbody>().isKinematic = true;
            this.gameObject.layer = 9;             // change layer to InHand for physics collisions
            // slave to controller
            transform.position = HandControllerLeft.transform.position;
            transform.rotation = HandControllerLeft.transform.rotation;
            HandControllerLeft.GetComponent <RobustController>().HoldableObject = this.gameObject;
        }
        if (InHandRight)
        {
            if (LeftHandModel != null)
            {
                LeftHandModel.SetActive(false);
            }
            if (RightHandModel != null)
            {
                RightHandModel.SetActive(true);
            }
            this.GetComponent <Rigidbody>().isKinematic = true;
            this.gameObject.layer = 9;             // change layer to InHand for physics collisions
            // slave to controller
            transform.position = HandControllerRight.transform.position;
            transform.rotation = HandControllerRight.transform.rotation;
            HandControllerRight.GetComponent <RobustController>().HoldableObject = this.gameObject;
        }

        if (!InHandLeft && !InHandRight)
        {
            this.gameObject.layer = 0;             // change layer to Default for physics collisions
            if (LeftHandModel != null)
            {
                LeftHandModel.SetActive(false);
            }
            if (RightHandModel != null)
            {
                RightHandModel.SetActive(false);
            }
            if (Dropped)
            {
                this.GetComponent <Rigidbody>().isKinematic = false;
                if (UseMomentum)
                {
                    transform.root.GetComponent <Rigidbody>().velocity        = Velocity;
                    transform.root.GetComponent <Rigidbody>().angularVelocity = AngularVelocity;
                }
                Dropped = false;
            }
        }

        Velocity         = (transform.position - PreviousPosition) * (1f / Time.deltaTime);
        AngularVelocity  = ((transform.rotation * Vector3.forward) - PreviousRotation) * (1f / Time.deltaTime);
        PreviousPosition = transform.position;
        PreviousRotation = (transform.rotation * Vector3.forward);

        // cast ray to intersect objects
        RaycastHit hit;
        Vector3    dir      = transform.rotation * Vector3.forward;
        Ray        ClickRay = new Ray(transform.position, dir);

        if (Physics.Raycast(ClickRay, out hit))
        {
            //Debug.Log (hit.collider.name + " - " + hit.point);
            Vector3 targetDir = (hit.point - transform.position);
            //Debug.Log (targetDir.magnitude);
            Vector3 newScale = new Vector3(1, targetDir.magnitude, 1);
            LaserPointer.transform.localScale = newScale;
            LaserDot.SetActive(true);
            LaserDot.transform.localScale = newScale;

            // change size of the button
            if (hit.collider != PreviousCollider && PreviousCollider != null)
            {
                PreviousCollider.transform.localScale = Vector3.one;
                PreviousCollider = null;
            }

            if (hit.collider.tag == "UIButton")
            {
                //Debug.Log(hit.collider);
                if (PreviousCollider != hit.collider)
                {
                    Audio.PlayOneShot(SoundButtonHover);
                }
                hit.collider.transform.localScale = new Vector3(ButtonScaleAmount, ButtonScaleAmount, ButtonScaleAmount);
                PreviousCollider = hit.collider;
            }
        }
        else
        {
            LaserPointer.transform.localScale = new Vector3(1, 30, 1);
            LaserDot.SetActive(false);
        }
    }