Exemple #1
0
    protected override void UseShooting()
    {
        RaycastHit hit;

        if (Physics.Raycast(new Ray(this.cameraTransform.position, this.cameraTransform.TransformDirection(Vector3.forward)), out hit, this.distance))
        {
            if (hit.transform.root == this.cameraTransform.root)
            {
                return;
            }
            Rigidbody rigidbody = hit.transform.GetComponent <Rigidbody>();
            if (rigidbody != null)
            {
                rigidbody.AddForce((hit.point - this.cameraTransform.position).normalized * this.force);
            }
            Terminatable terminatable = hit.transform.GetComponent <Terminatable>();
            if (terminatable != null)
            {
                terminatable.Hit(this.damage, hit, this.cameraTransform.root);
            }
            else
            {
                Destroyable destroyable = hit.transform.GetComponent <Destroyable>();
                if (destroyable != null)
                {
                    destroyable.Explode(hit.point);
                }
            }
        }
    }
Exemple #2
0
 protected void Attack()
 {
     if (Time.fixedTime < this.allowAttackTime)
     {
         return;
     }
     if (this.TargetReachable())
     {
         if (this.targetT.position != transform.position)
         {
             Quaternion targetRotation = Quaternion.LookRotation(this.targetT.position - transform.position, Vector3.up);
             this.transform.rotation = Quaternion.Slerp(this.transform.rotation, targetRotation, Time.deltaTime * 4.0f);
         }
         RaycastHit hit;
         foreach (NPCAttack attack in this.settings.attack)
         {
             Vector3 attackOffset = this.transform.TransformPoint(attack.offset);
             if (Physics.Raycast(attackOffset, this.transform.forward, out hit))
             {
                 Debug.DrawLine(attackOffset, hit.point, Color.red);
                 if (attack.distance >= Vector3.Distance(attackOffset, hit.point))
                 {
                     Terminatable terminatable = hit.transform.root.GetComponentInChildren <Terminatable>();
                     if (terminatable)
                     {
                         terminatable.Hit(UnityEngine.Random.Range(attack.minDamage, attack.maxDamage), hit, this.transform.root);
                     }
                     this.allowAttackTime = Time.fixedTime + attack.delay;
                     return;
                 }
             }
         }
     }
 }
Exemple #3
0
    private void OnCollisionEnter(Collision collision)
    {
        Terminatable terminatable = collision.transform.GetComponent <Terminatable>();

        if (terminatable != null)
        {
            terminatable.Hit(this.damage, this.cameraTransform.root);
        }
    }
Exemple #4
0
 private void Start()
 {
     this.strength           = 4000;
     this.playerTerminatable = this.GetComponent <Terminatable>();
     this.cameraTransform    = this.transform.GetComponentInChildren <Camera>().transform;
     this.currentItem.player = this;
     this.items.Add(this.currentItem);
     this.CurrentItem = this.currentItem;
 }
Exemple #5
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         RaycastHit hit;
         if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit))
         {
             Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red);
             Actable actable = hit.transform.GetComponentInChildren <Actable>();
             if (actable)
             {
                 actable.Act(new string[] { "Foo" });
             }
             Deformable deformable = hit.transform.GetComponentInChildren <Deformable>();
             if (deformable)
             {
                 deformable.Hit(hit, Camera.main.transform.forward * 4.0f);
             }
             Destroyable destroyable = hit.transform.GetComponentInChildren <Destroyable>();
             if (destroyable)
             {
                 destroyable.Explode(hit.point);
             }
             Terminatable terminatable = hit.transform.GetComponentInChildren <Terminatable>();
             if (terminatable)
             {
                 terminatable.Hit(Random.Range(0, 47), this.transform);
             }
             Damageable damageable;
             if ((damageable = hit.transform.GetComponent <Damageable>()) != null || (damageable = hit.transform.root.GetComponent <Damageable>()) != null)
             {
                 damageable.Damage(hit);
             }
             Rigidbody rigidbody = hit.transform.GetComponentInChildren <Rigidbody>();
             if (rigidbody)
             {
                 rigidbody.AddForceAtPosition(Camera.main.transform.forward * 100.0f, hit.point);
             }
         }
     }
 }
Exemple #6
0
	private void OnTriggerEnter(Collider collider)
	{
		if (this.player == null)
			return;
		if (collider.transform.root.gameObject.isStatic)
		{
			this.GetComponent<Rigidbody>().isKinematic = true;
			this.transform.parent = collider.transform;
			this.player = null;
		}
		else
		{
			if (this.player.transform.root == collider.transform.root)
				return;
			Terminatable terminatable = collider.transform.GetComponentInChildren<Terminatable>();
			if (terminatable == null)
				terminatable = collider.transform.root.GetComponentInChildren<Terminatable>();
			if (terminatable != null)
				terminatable.Hit(this.damage, this.player.cameraTransform.root);
		}
	}