示例#1
0
 void OnTriggerEnter(Collider col)
 {
     //not moving object and no object in hands
     if (!movingObj && !currentObj)
     {
         // isObject
         if (col.gameObject.layer == 8)
         {
             ObjectThrow objThrow = col.gameObject.GetComponent <ObjectThrow> ();
             if (!objThrow.touchingHand)
             {
                 // change color of object we are touching
                 ObjectStats objColor = col.gameObject.GetComponent <ObjectStats> ();
                 objColor.TouchingHands();
                 // now change values to indicate we are touching it
                 if (left)
                 {
                     objThrow.hand = 1;
                 }
                 else
                 {
                     objThrow.hand = 2;
                 }
                 currentObj = col.gameObject;
                 col.gameObject.GetComponent <ObjectThrow> ().touchingHand = true;
             }
         }
     }
 }
示例#2
0
    // When NPC collides with a cube
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Soul")
        {
            soul = col.gameObject;
            Debug.Log(soul);
            ObjectThrow obj = col.gameObject.GetComponent <ObjectThrow> ();

            // teleport to the NPC get hit if NPC I want to transfer is not myself
            // teleport to the NPC get hit if NPC I am transferring to is not myself
            // and also if obj is moving when it hits npc
            //Test
            //obj.npc = GameObject.Find ("Roy");

            if (obj.GetComponent <Rigidbody> ().velocity.magnitude > 0.01f && !obj.GetComponent <Rigidbody> ().isKinematic&& obj.npc && (obj.npc != NPC))
            {
                isCollide = true;
                end       = obj.npc.transform.position;

                /*
                 * obj.GetComponent<Rigidbody> ().velocity = Vector3.zero;
                 * pm.PossessNewNPC (NPC);
                 *
                 * col.gameObject.GetComponent<SoulMovement> ().followHead = true;
                 * col.gameObject.GetComponent<MeshRenderer> ().enabled = false;
                 */
            }
        }
    }
        //BOLT

        public override void OnEvent(ObjectThrow evnt)
        {
            if (entity == evnt.Entity)
            {
                var size = (Size)evnt.Size;
                InstantiateShockwave(evnt.Position, evnt.Rotation, size);
            }
        }
示例#4
0
 private void Start()
 {
     rb                  = GetComponent <Rigidbody>();
     instance            = this;
     powerCheck.maxValue = maxForce;
     slider.SetActive(true);
     launchForce = minForce;
     StartCoroutine(timeUpdate());
 }
示例#5
0
        private void SendObjectThrowEvent(Vector3 position, Quaternion rotation, Size objectSize)
        {
            var objectThrowEvent = ObjectThrow.Create(entity);

            objectThrowEvent.Position = position;
            objectThrowEvent.Rotation = rotation;
            objectThrowEvent.Size     = (int)objectSize;
            objectThrowEvent.Entity   = GetComponentInParent <BoltEntity>();
            objectThrowEvent.Send();
        }
示例#6
0
    //when throw object to attract NPC's attention
    private void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.layer == 8)
        {
            //wait for a while
            Wait();
            ObjectThrow obj = col.gameObject.GetComponent <ObjectThrow> ();
            if (obj.npc)
            {
                LookAtPlayer(obj.npc);
            }
        }

        //lookingAt.GetComponent<NPC> ().LookAtPlayer (currentNPC);
    }
示例#7
0
    private void Awake()
    {
        gun = GetComponentInChildren <Gun>();
        if (gun == null)
        {
            throw new System.Exception("Player Action - Need Gun !");
        }

        objectThrow = FindObjectOfType <ObjectThrow>();
        if (objectThrow == null)
        {
            throw new System.Exception("Player Action - Need Object Throw !");
        }

        if (health == null)
        {
            throw new System.Exception("Player Action - Need Health !");
        }
    }
示例#8
0
 void OnTriggerExit(Collider col)
 {
     if (col.gameObject.layer == 8)
     {
         ObjectThrow objThrow = col.gameObject.GetComponent <ObjectThrow> ();
         if (objThrow.touchingHand)
         {
             // change values to indicate we are not touching it
             if (left && objThrow.hand == 1)
             {
                 if (col.gameObject.GetComponent <Rigidbody> ().isKinematic)
                 {
                     return;
                 }
                 // change color of object we are not touching anymore
                 ObjectStats objColor = col.gameObject.GetComponent <ObjectStats> ();
                 objColor.NotTouchingHands();
                 objThrow.touchingHand = false;
                 objThrow.hand         = 0;
                 currentObj            = null;
                 movingObj             = false;
             }
             if (!left && objThrow.hand == 2)
             {
                 if (col.gameObject.GetComponent <Rigidbody> ().isKinematic)
                 {
                     return;
                 }
                 // change color of object we are not touching anymore
                 ObjectStats objColor = col.gameObject.GetComponent <ObjectStats> ();
                 objColor.NotTouchingHands();
                 objThrow.touchingHand = false;
                 objThrow.hand         = 0;
                 currentObj            = null;
                 movingObj             = false;
             }
         }
     }
 }
示例#9
0
    void Update()
    {
        if (isCollide)
        {
            soul.GetComponent <Rigidbody> ().AddForce(.1f * (end - soul.transform.position));
            float distance = Vector3.Distance(end, soul.transform.position);
            Debug.Log("enter");
            Debug.Log("distance" + distance);
            if (distance < 1f)
            {
                Debug.Log("lalalal");
                ObjectThrow obj = soul.GetComponent <ObjectThrow> ();
                obj.GetComponent <Rigidbody> ().velocity = Vector3.zero;
                pm.PossessNewNPC(NPC);


                isCollide = false;

                soul.GetComponent <SoulMovement> ().followHead = true;
                soul.GetComponent <MeshRenderer> ().enabled    = false;
            }
        }
    }
示例#10
0
 private void Start()
 {
     _anim              = GameObject.Find("Model").GetComponent <Animator>();
     _input             = GameObject.Find("GameManager").GetComponent <InputManager>();
     _objectThrowScript = this.gameObject.GetComponent <ObjectThrow>();
 }