Пример #1
0
 private void ColProxy_CollisionEvent(CollisionProxy colA, CollisionProxy colB)
 {
     if (OnCollisionEvent != null && colA.collider.executing && colB.collider.executing)
     {
         OnCollisionEvent.Invoke(colA.collider, colB.collider);
     }
 }
Пример #2
0
 public Collider()
 {
     if (colliders == null)
     {
         colliders = new List <Collider>();
     }
     OnCollision = new OnCollisionEvent(OnCollisionBase);
 }
 private void OnCollisionEnter(Collision collision)
 {
     if (collider.enabled == true && !Collisioned)
     {
         Collisioned           = true;
         collider.enabled      = false;
         rigidbody.isKinematic = true;
         meshRenderer.enabled  = false;
         OnCollisionEvent?.Invoke(collision);
     }
 }
Пример #4
0
 public virtual void OnCollision(CollisionEventArgs e) =>
 OnCollisionEvent?.Invoke(this, e);
Пример #5
0
 public virtual void OnCollision(int id, Location robotLocation)
 {
     OnCollisionEvent?.Invoke(this, new CollisionEventArgs {
         RobotId = id, RobotRealPositionRefTerrain = robotLocation
     });
 }
Пример #6
0
 private void ColProxy_CollisionEvent(CollisionProxy colA, CollisionProxy colB)
 {
     OnCollisionEvent.Invoke(colA.collider, colB.collider);
 }
Пример #7
0
 public void RemoveColliderEvent(OnCollisionEvent action)
 {
     onColliderEnterEvent -= action;
 }
Пример #8
0
 public void AddColliderEvent(OnCollisionEvent action)
 {
     onColliderEnterEvent += action;
 }
Пример #9
0
 private void OnCollisionExit2D(Collision2D collision)
 {
     OnCollisionEvent?.Invoke(_pRigidbody, _pCollider, _eColliderShape, EPhysicsEvent.Exit, collision);
 }
        private void Update()
        {
            if (!isCollision)
            {
                if (Time.timeScale == 0f)
                {
                    return;
                }

                _deltaTime = Time.smoothDeltaTime / Time.timeScale;
                Vector3 gravityVelocity = (!StatMaster.GodTools.GravityDisabled) ? (bulletPropertise.GravityAcceleration) : Vector3.zero;
                Vector3 dragVelocity    = -(bulletPropertise.Velocity.normalized * bulletPropertise.Drag);
                bulletPropertise.Velocity += gravityVelocity + dragVelocity;
                ePoint = sPoint + bulletPropertise.Velocity * _deltaTime;

                lineRenderer.SetPosition(0, sPoint);

                if (Physics.Raycast(sPoint, bulletPropertise.Velocity, out hitInfo, (sPoint - ePoint).magnitude) && bulletPropertise.ColliderEnabled == true)
                {
                    if ((hitInfo.transform == gunbodyTransform && gunbodyTransform != null))
                    {
                        shootingNothing();
                    }
                    else
                    {
                        if (hasRigidbody(hitInfo, out rigidbody_Aim))
                        {
                            shootingSomething();
                        }
                        else if (hitInfo.collider.isTrigger == false)
                        {
                            shootingSomething();
                        }
                        else
                        {
                            shootingNothing();
                        }
                    }
                }
                else
                {
                    shootingNothing();
                }
            }
            else
            {
                lineRenderer.enabled = false;
                Destroy(gameObject);
            }

            bool hasRigidbody(RaycastHit hit, out Rigidbody rigidbody)
            {
                var value = false;

                rigidbody = null;

                if (hit.rigidbody != null && hit.rigidbody.isKinematic == false)
                {
                    value     = true;
                    rigidbody = hit.rigidbody;
                    return(value);
                }
                else if (hit.collider.attachedRigidbody != null && hit.collider.attachedRigidbody.isKinematic == false)
                {
                    value     = true;
                    rigidbody = hit.collider.attachedRigidbody;
                    return(value);
                }
                else
                {
                    var blockBehaviour = hit.transform.GetComponentInParent <BlockBehaviour>() ?? hit.transform.GetComponentInChildren <BlockBehaviour>();
                    if (blockBehaviour != null)
                    {
                        rigidbody = blockBehaviour.transform.GetComponent <Rigidbody>();
                        if (rigidbody != null && rigidbody.isKinematic == false)
                        {
                            value = true;
                            return(value);
                        }
                    }

                    var levelEntity = hit.transform.GetComponentInParent <LevelEntity>() ?? hit.transform.GetComponentInChildren <LevelEntity>();
                    if (levelEntity != null)
                    {
                        rigidbody = levelEntity.transform.GetComponent <Rigidbody>();
                        if (rigidbody != null && rigidbody.isKinematic == false)
                        {
                            value = true;
                            return(value);
                        }
                    }
                    return(value);
                }
            }

            void shootingSomething()
            {
                var targetType = "stone";

                lineRenderer.SetPosition(1, hitInfo.point);
                isCollision = true;

                if (!StatMaster.isClient)
                {
                    OnCollisionEvent?.Invoke(rigidbody_Aim);
                    targetType = createImpactEffect();

                    var message = ImpactMessage.CreateMessage(Guid.ToString(), targetType, hitInfo.point, hitInfo.normal);
                    ModNetworking.SendToAll(message);
                }
            }

            void shootingNothing()
            {
                lineRenderer.SetPosition(1, ePoint);
                sPoint = ePoint;
            }
        }
Пример #11
0
 public void RemoveWaitForBeforeKill(OnCollisionEvent behaviour)
 {
     _waitForThese.Remove(behaviour);
     tryToKillObjects();
 }
Пример #12
0
 public void AddWaitForBeforeKill(OnCollisionEvent behaviour)
 {
     _waitForThese.Add(behaviour);
 }
Пример #13
0
 private void OnCollisionEnter(Collision collision)
 {
     OnCollisionEvent?.Invoke(collision);
 }