Exemple #1
0
    void OnCollisionEnter(Collision collision)
    {
        // 		Debug.Log(collision.gameObject.transform.name);
        rigidbody = collision.gameObject.GetComponent<Rigidbody>();

        audio.PlayOneShot(effect_sound);

        rigidbody.AddExplosionForce(power, collision.gameObject.transform.position, radius);

        PlayerControl.ComboCount += 1;
        PlayerControl.Count += 1;
        if(PlayerControl.ComboCount >= 3)
        {
            if(PlayerControl.Rezentime <=3)
            {
                if (PlayerControl.RezenMaxdistance >= PlayerControl.RezenMindistance)
                    PlayerControl.RezenMaxdistance -= 1;
            }
            else
                PlayerControl.Rezentime -= 1;
        }

        if(PlayerControl.ComboCount >=2)
        {
            StartCoroutine("TextEffect");
        }

        Debug.Log("Count : " + PlayerControl.ComboCount);
        Debug.Log("RezenTime : " + PlayerControl.Rezentime);
        Debug.Log("RezenMaxdistance : " + PlayerControl.RezenMaxdistance);

        countText.text = PlayerControl.Count.ToString("00");
    }
    void Awake()
    {
        //If it has Children also turn children into Debris (Used for sails and bigger objects)
        if (transform.childCount > 0)
        {
            for (int i = 0; i < transform.childCount; i++)
            {
                if (transform.GetChild(i).name == "Small")
                {
                    smallChildren.Add(transform.GetChild(i));
                }
            }
            foreach (Transform child in smallChildren)
            {
                child.gameObject.AddComponent<SmallDebrisScript>();
            }
        }

        if (GetComponent<Rigidbody>() == null)
        {
            debrisBody = gameObject.AddComponent<Rigidbody>();
        }
        debrisBody = gameObject.GetComponent<Rigidbody>();
        debrisBody.useGravity = true;
        debrisBody.isKinematic = false;
        //debrisBody.AddForce(((transform.up + transform.position) * 2) * debrisBody.mass);
        debrisBody.AddExplosionForce(250, transform.position, 50, 25);
        transform.parent = null;
        name = "Debris";
        Destroy(this);
    }
 public override void OnFixedUpdate()
 {
     if (rigidbody != null)
     {
         rigidbody.AddExplosionForce(owner.GetValue(force), owner.GetValue(position), owner.GetValue(radius), owner.GetValue(upwardsModifier), forceMode);
     }
     Finish();
 }
 static public int AddExplosionForce(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 6)
         {
             UnityEngine.Rigidbody self = (UnityEngine.Rigidbody)checkSelf(l);
             System.Single         a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector3 a2;
             checkType(l, 3, out a2);
             System.Single a3;
             checkType(l, 4, out a3);
             System.Single a4;
             checkType(l, 5, out a4);
             UnityEngine.ForceMode a5;
             checkEnum(l, 6, out a5);
             self.AddExplosionForce(a1, a2, a3, a4, a5);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 5)
         {
             UnityEngine.Rigidbody self = (UnityEngine.Rigidbody)checkSelf(l);
             System.Single         a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector3 a2;
             checkType(l, 3, out a2);
             System.Single a3;
             checkType(l, 4, out a3);
             System.Single a4;
             checkType(l, 5, out a4);
             self.AddExplosionForce(a1, a2, a3, a4);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 4)
         {
             UnityEngine.Rigidbody self = (UnityEngine.Rigidbody)checkSelf(l);
             System.Single         a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector3 a2;
             checkType(l, 3, out a2);
             System.Single a3;
             checkType(l, 4, out a3);
             self.AddExplosionForce(a1, a2, a3);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #5
0
 static public int AddExplosionForce(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(System.Single), typeof(UnityEngine.Vector3), typeof(System.Single), typeof(System.Single), typeof(UnityEngine.ForceMode)))
         {
             UnityEngine.Rigidbody self = (UnityEngine.Rigidbody)checkSelf(l);
             System.Single         a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector3 a2;
             checkType(l, 3, out a2);
             System.Single a3;
             checkType(l, 4, out a3);
             System.Single a4;
             checkType(l, 5, out a4);
             UnityEngine.ForceMode a5;
             checkEnum(l, 6, out a5);
             self.AddExplosionForce(a1, a2, a3, a4, a5);
             return(0);
         }
         else if (matchType(l, 2, typeof(System.Single), typeof(UnityEngine.Vector3), typeof(System.Single), typeof(System.Single)))
         {
             UnityEngine.Rigidbody self = (UnityEngine.Rigidbody)checkSelf(l);
             System.Single         a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector3 a2;
             checkType(l, 3, out a2);
             System.Single a3;
             checkType(l, 4, out a3);
             System.Single a4;
             checkType(l, 5, out a4);
             self.AddExplosionForce(a1, a2, a3, a4);
             return(0);
         }
         else if (matchType(l, 2, typeof(System.Single), typeof(UnityEngine.Vector3), typeof(System.Single)))
         {
             UnityEngine.Rigidbody self = (UnityEngine.Rigidbody)checkSelf(l);
             System.Single         a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector3 a2;
             checkType(l, 3, out a2);
             System.Single a3;
             checkType(l, 4, out a3);
             self.AddExplosionForce(a1, a2, a3);
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
	public void EntityBetween(Vector3 newOrigin, Rigidbody oldTarget){
		float rayDis = Vector3.Distance (newOrigin, oldTarget.transform.position);
		Vector3 rayDir = (oldTarget.transform.position - newOrigin);
		if(Physics.Raycast (newOrigin, rayDir, out rayHit, rayDis)){
			timesHit++;
			if(rayHit.transform.gameObject != oldTarget.gameObject){
				if(rayHit.transform.tag != "Wall" && rayHit.transform.tag != "Cover" && rayHit.transform.tag != "Ground"){
					EntityBetween(rayHit.transform.position, oldTarget);
				}
			}
			else if(rayHit.transform.gameObject == oldTarget.gameObject) {
				GrenadeEffect (oldTarget.gameObject);
				oldTarget.AddExplosionForce (power, explosionPos, radius);
			}
		}
	}
Exemple #7
0
    static int AddExplosionForce(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 4)
            {
                UnityEngine.Rigidbody obj = (UnityEngine.Rigidbody)ToLua.CheckObject(L, 1, typeof(UnityEngine.Rigidbody));
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.Vector3 arg1 = ToLua.ToVector3(L, 3);
                float arg2 = (float)LuaDLL.luaL_checknumber(L, 4);
                obj.AddExplosionForce(arg0, arg1, arg2);
                return(0);
            }
            else if (count == 5)
            {
                UnityEngine.Rigidbody obj = (UnityEngine.Rigidbody)ToLua.CheckObject(L, 1, typeof(UnityEngine.Rigidbody));
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.Vector3 arg1 = ToLua.ToVector3(L, 3);
                float arg2 = (float)LuaDLL.luaL_checknumber(L, 4);
                float arg3 = (float)LuaDLL.luaL_checknumber(L, 5);
                obj.AddExplosionForce(arg0, arg1, arg2, arg3);
                return(0);
            }
            else if (count == 6)
            {
                UnityEngine.Rigidbody obj = (UnityEngine.Rigidbody)ToLua.CheckObject(L, 1, typeof(UnityEngine.Rigidbody));
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.Vector3 arg1 = ToLua.ToVector3(L, 3);
                float arg2 = (float)LuaDLL.luaL_checknumber(L, 4);
                float arg3 = (float)LuaDLL.luaL_checknumber(L, 5);
                UnityEngine.ForceMode arg4 = (UnityEngine.ForceMode)ToLua.CheckObject(L, 6, typeof(UnityEngine.ForceMode));
                obj.AddExplosionForce(arg0, arg1, arg2, arg3, arg4);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Rigidbody.AddExplosionForce"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
        void ApplyForceToTarget(Vector3 contactPoint, Rigidbody rb)
        {

            if ( rb.GetComponent<NavMeshAgent>() != null)
                rb.GetComponent<NavMeshAgent>().enabled = false;

            rb.isKinematic = false;

            if ( rb.CompareTag("Enemy") )
            {
                //rb.GetComponent<Rigidbody>().isKinematic = false;
                explosionPower = explosionPower * 10;
            }
              
            rb.AddExplosionForce(explosionPower, contactPoint, blastRadius, .5f, ForceMode.Impulse);
            //Vector3 direction = rb.transform.position - transform.position;
            //rb.AddForceAtPosition(direction.normalized, contactPoint, ForceMode.Impulse);

            if ( rb.CompareTag("Enemy") )
            {
                Destroy(rb.gameObject, destroyTime);
            }
        }
Exemple #9
0
    void OnCollisionEnter(Collision other)
    {
        if(other.gameObject.tag == "Ball")
        {
            score.AddScore(50);
        }
        else if (other.gameObject.tag == "MultiBall")
        {
            score.AddScore(50);
        }

        foreach (Collider col in Physics.OverlapSphere(transform.position, _forceRadius))
        {
            if (col.name == "PlayerBall")
            {
                _colRigid = col.GetComponent<Rigidbody>();
                _colRigid.AddExplosionForce(force, transform.position, _forceRadius);
            }
        }

        Instantiate(explosion, other.transform.position, other.transform.rotation);
        RemoveParticle();
    }
 /// <summary>
 /// Applies the force to the specified rigidbody
 /// </summary>
 /// <param name="body">Body receiving the force</param>
 public override void ApplyForce(Rigidbody body) {
   body.AddExplosionForce(Amount, ExplosionOrigin.position, ExplosionRadius, UpwardsModifier,
                          ForceMode.Impulse);
 }
Exemple #11
0
 // The AoE effect on game objects
 protected override void AoEHit(Rigidbody obj)
 {
     obj.AddExplosionForce(400f, position, radius);
 }
 public void addForce(Rigidbody rbody)
 {
     rbody.AddExplosionForce(Force,Position,Radius);
 }
 public void Add(Rigidbody target, Vector3 pos)
 {
     target.AddExplosionForce(force, pos, radius, upwardsModifier, mode);
 }
    /// <summary>
    /// Metodo responsavel por verificar se é necessário explodir e executar a explosao
    /// </summary>
    public virtual void Explode(bool forceExplosion)
    {
        if (_armed && _timeToExplode < Time.time || forceExplosion)
        {
            // Toca o som de explosao

            // Apresenta particulas de explosao
            if (ExplosionParticlePrefab != null)
            {
                GameObject explosionParticle = GameObject.Instantiate(ExplosionParticlePrefab);
                explosionParticle.transform.position = transform.position;
                GameObject.Destroy(explosionParticle, 5f);
            }

            ApplicationModel.Instance.ShakeCamera();

            // Verifica as colisoes
            int _hits = Physics.OverlapSphereNonAlloc(transform.position, ExplosionRadius, _colliders, AffectedLayer);

            if (_hits > 0)
            {
                for (int i = 0; i < _hits; i++)
                {
                    // Recupera os componentes
                    _affectedCharacter = _colliders[i].GetComponent<BaseEnemy>();
                    _affectedRigidBody = _colliders[i].attachedRigidbody;

                    if (_affectedCharacter != null)
                    {
                        // Aplica dano se for personagem
						_affectedCharacter.ApplyDamage(ThrownByCharacter, ENUMERATORS.Combat.DamageType.Melee, ENUMERATORS.Player.PlayerClass.UNDEFINED ,ExplosionDamage);
                    }

                    if (_affectedRigidBody != null)
                    {
                        // Aplica a forca de explosao nos rigidbodys
                        _affectedRigidBody.AddExplosionForce(ExplosionForce, transform.position + Vector3.up * ExplosionYOffSet, ExplosionRadius);
                        _affectedRigidBody.AddForce(Vector3.up * ExplosionForce);
                    }
                }
            }

            ReturnToPool();
        }
    }
 public override void ApplyKillForce(Rigidbody rigidbody)
 {
     rigidbody.AddExplosionForce(Force, Position, Radius, 1f, ForceMode.Impulse);
 }