void OnCollisionEnter(Collision theObject)
 {
     if(beenHit == false && theObject.gameObject.name == "coconut")
     {
         StartCoroutine("targetHit");
     }
 }
 void OnCollisionEnter(Collision collision)
 {
     if(runnerController!=null)
     {
         runnerController.Runnercollision(collision);
     }
 }
Example #3
0
 void OnCollisionEnter(Collision collision)
 {
     _jukebox.SendMessage("PlayBreak");	//play our sound
     _camera.SendMessage("score",1);
     Destroy(transform.parent.gameObject);
     Destroy(gameObject);
 }
	void OnCollisionEnter(Collision col)
	{
		if(side==BulletSide.FRIENDLY)
		{
			if(col.gameObject.tag==TagsStorage.ABIL_SHIELD)
				deactivate();
			
			if(col.gameObject.tag==TagsStorage.ENEMY_TAG)
			{
				col.gameObject.GetComponent<EnemySpaceship>().Attacked(damage);
				deactivate();
			}
		}
		
		if(side==BulletSide.ENEMY)
		{
			if(col.gameObject.tag==TagsStorage.FRIENDLY_TAG)
			{
				col.gameObject.GetComponent<FriendlySpaceship>().Attacked(damage);
				deactivate();
			}
			if(col.gameObject.tag==TagsStorage.ABIL_SHIELD)
				deactivate();
		}
		
		if(col.gameObject.tag==TagsStorage.ASTEROID_TAG)
			deactivate();
	}
    void OnCollisionEnter(Collision collision)
    {
        AudioSource audio = GetComponent<AudioSource>();

        audio.Play();
            Debug.Log("Bim");
    }
 private void OnCollisionEnter(Collision collision)
 {
     var weapon_backpack = collision.collider.GetComponent<WeaponBackpackController>();
     GameObject nlog = GameObject.FindWithTag("Log");
     string message = "";
     LogScript log = nlog.GetComponent<LogScript>();
     if(weapon_backpack != null) {
         if (pickup_sound != null)
         {
             AudioSource.PlayClipAtPoint(pickup_sound, transform.position);
         }
         var found_ammo = Random.Range(0, max_ammo + 1);
         weapon_backpack.ChangeAmmo(found_ammo);
         var player = GameObject.FindGameObjectWithTag("StartingWeapons");
         string pickupMessage = player.GetComponent<StartingWeapons>().PickupAll();
         Destroy(gameObject);
     }
     var health = collision.collider.GetComponent<HealthController>();
     if (health != null)
     {
         var collected_health = Random.Range(50, 76);
         health.ChangeHealth(collected_health);
         Destroy(gameObject);
     }
     log.PassMessage("You just picked up guns.\nPress r to toggle through\n");
 }
    public override void OnCollisionEnter(Collision col)
    {
        if (GameManager.Rules.State == GlobalState.DRAG_WHITEBALL)
            return;

        if (col.gameObject.name.Contains("Rail"))
        {
            HOAudioManager.BallhitRail(m_rigidbody.velocity);
            GameManager.Rules.CueBallHitRail();
            GameManager.Rules.BallHitRail();
            GameStatistics.MarkCueballHitRail(1);
        }
        if (col.transform.CompareTag("Ball"))
        {
            HOAudioManager.BallhitBall(m_rigidbody.velocity);
            GameStatistics.MarkCueballHitBall(1);
            PoolBall ball = col.gameObject.GetComponent<PoolBall>();
            GameManager.Rules.WhiteBallHitBall(ball);
            if (ball && ball == m_targetBall)
            {
                m_targetBall.PointAtTarget(m_targetPos);
                m_targetBall = null;
            }
        }
    }
Example #8
0
	void OnCollisionEnter (Collision collision)
	{
		if(collision.gameObject.tag == "FriendlyFire")
		{
			// Add explosion
			var explosion = GameObject.Instantiate(explosionPrefab);
			explosion.transform.position = collision.gameObject.transform.position;
			AudioSource.PlayClipAtPoint(explosionSound, explosion.transform.position);

      // Remove fireball
      Destroy(collision.gameObject);

			// Subtract health
			int healthLost = getHealthCost(collision.gameObject.name);
			currentHealth -= healthLost;
            Debug.Log(currentHealth);

			// Check for death
			if (currentHealth <= 0) {
				var samuraiExplosion = GameObject.Instantiate(explosionPrefab);
				samuraiExplosion.transform.position = gameObject.transform.position;
				AudioSource.PlayClipAtPoint(deathSound, samuraiExplosion.transform.position);
				Destroy(gameObject);
			}
		}
	}
 void OnCollisionEnter(Collision collision)
 {
     if(collision.gameObject.layer == target.layer)
     {
         GameManager.Instance.Endgame();
     }
 }
 void OnCollisionExit(Collision other)
 {
     if (other.gameObject.tag == "Trap")
     {
         traps.Remove(other.gameObject);
     }
 }
Example #11
0
	void OnCollisionEnter(Collision collision)
	{
		if(collision.gameObject.tag == "Bullets" ) // bumped bullets
		{
			health -= collision.gameObject.GetComponent<BulletsStats>().damage; // get damage
		}
	}
Example #12
0
	public void OnCollisionEnter(Collision col)
	{
		if(col.gameObject.transform.position.x < transform.position.x)
			SendMessageUpwards("RotateDoorClock");//, col.gameObject.rigidbody.velocity.magnitude);
		else
			SendMessageUpwards("RotateDoorUnClock");
	}
 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag == "Projectile")
     {
         explode = true;
     }
 }
Example #14
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.gameObject.tag.Equals("Player"))
     {
         collision.collider.rigidbody.AddForce(Vector3.forward * 100);
     }
 }
    void OnCollisionEnter(Collision theCollision)
    {
        CarDriver otherObjectsScript = theCollision.gameObject.GetComponent<CarDriver> ();

        if(otherObjectsScript != null)
            otherObjectsScript.Respawn();
    }
Example #16
0
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.tag == "Ammo")
        {
            vie--;
            if (vie <= 0)
            {
                isDead = true;
                anim.SetBool("isWalking", false);
                anim.SetBool("weapon", false);
                anim.SetBool("isDead", true);
                Player.score++;
                if (!isDead)
                {
                    GameObject.Find("score").GetComponent<Text>().text = "Score : " + Player.score;
                }
                isDead = true;

                if (Application.loadedLevelName == "Jeu1")
                {
                    Application.LoadLevel("Jeu2");
                }
            }
        }
    }
Example #17
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.name == "Player")
     {
         clearText.SetActive(true);
     }
 }
 void OnCollisionEnter(Collision collision)
 {
     if(collision.gameObject.tag == "BallTag")
     {
         GameOver(collision);
     }
 }
Example #19
0
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.name == "Wall")
        {
            Destroy (gameObject);

        }
        else if (col.gameObject.name == "BlueVirus"){
            bVirus = col.gameObject.GetComponent<BlueVirus>();
            bVirus.takeDamage (1,1);
            Destroy (gameObject);
        }
        else if (col.gameObject.name == "RedVirus"){
            Destroy (gameObject);
        }
        else if (col.gameObject.name == "GreenVirus"){
            gVirus = col.gameObject.GetComponent<GreenVirus>();
            gVirus.takeDamage (1,1);
            Destroy (gameObject);
        }else if(col.gameObject.name == "Boss"){
            boss = col.gameObject.GetComponent<BossScript>();
            boss.takeDamage(1, 1);
            Destroy(gameObject);
        }
    }
Example #20
0
 void OnCollisionEnter(Collision collision)
 {
     if(collision.gameObject.tag == "Bullet")
     {
         GetComponent<NavMeshAgent>().Warp(begin);
     }
 }
Example #21
0
    // Handle all collisions
    void OnCollisionEnter(Collision collision)
    {
        if (gameObject.name == "1_Player_East")
        {
            PlayerPrefs.SetInt("NumPlayers", 1);
            Application.LoadLevel(2);
        }
        if (gameObject.name == "1_Player_West")
        {
            PlayerPrefs.SetInt("NumPlayers", 1);
            Application.LoadLevel(3);
        }
        if (gameObject.name == "2_Player_East")
        {
            PlayerPrefs.SetInt("NumPlayers", 2);
            Application.LoadLevel(2);
        }
        if (gameObject.name == "2_Player_West")
        {
            PlayerPrefs.SetInt("NumPlayers", 2);
            Application.LoadLevel(3);
        }

        if (collision.gameObject.GetComponent(typeof(SnowBall)) != null )
        {
            if( (collision.gameObject.GetComponent(typeof(SnowBall)) as SnowBall).BallLauncher == SnowBall.Launcher.Enemy)
            {
                GUIManager.currentScore = GUIManager.currentScore - HitPenalty;
                if (PlayerPrefs.GetString("SelectedGameMode").Equals("HardMode"))
                {
                    GameController.lives--;
                }
            }
        }
    }
    void OnCollisionEnter(Collision col)
    {
        if(particule)
            GameObject.Instantiate(particule, transform.position, Quaternion.identity);

        //on inflige des degas au ennemis si il sont dans la zone
        EnemyController[] targets = FindObjectsOfType(System.Type.GetType("EnemyController")) as EnemyController[];
        for (int i=0; i<targets.Length; i++)
        {
            Vector3 distance = transform.position-targets[i].transform.position;
            if(distance.magnitude <= m_distance)
            {
                float damage = -m_damage + (-m_damage)/100 * targets[i].getSkillManager().getMagicResistance();
                //gestion de la furie
                if(m_furie)
                    damage += damage/100 * m_damageFurie;
                //gestion des critique
                if(m_factorCritique/100 < Random.value)
                    damage *= 2;
                targets[i].healthUpdate(damage);
            }
        }

        Destroy(this.gameObject);
    }
Example #23
0
 void OnCollisionEnter(Collision col)
 {
     if (col.collider.CompareTag("Player") || col.collider.CompareTag("Item"))
     {
         isHurt = true;
     }
 }
Example #24
0
 void OnCollisionEnter(Collision c)
 {
     if (c.gameObject == GameObject.FindWithTag ("Boss"))
         SetPv (5);
     if (c.gameObject.tag == "fireennemy")
         SetPv (1);
 }
Example #25
0
    void OnCollisionEnter(Collision col)
    {
        if (!roadcols.Contains(col.collider.name))
        {

            if (col.collider.name.Equals("Road_Coll02_Side") && TriggerTimer.roundNo > rc2s)
            {
                Debug.Log("triggered");
                rc2s++;
            }
            else
            {

                if (col.collider.name.Equals("Road_Coll_Side") && RoadCollHelper.inTrigger)
                {
                    //do nothing
                }
                else
                {
                    Debug.Log(col.collider.name);
                    Debug.Log(col.relativeVelocity.magnitude);
                    velo.Add(col.relativeVelocity.magnitude);
                    TriggerTimer.collisions++;
                }
            }
        }
    }
Example #26
0
 void OnCollisionEnter(Collision collision)
 {
     if(collision.collider.tag == "KillBox") {
         Destroy(gameObject);
         MultiManager.Instance.Board.DropHealth();
     }
 }
	virtual protected void OnCollide( Collision collision )
	{
		if ( collision.gameObject.CompareTag( "Player" ) ) return;

		// Kill enemy
		if ( ( !HasHitUnit ) && ( collision != null ) && ( collision.transform.gameObject.layer == LayerMask.NameToLayer( "Enemy" ) ) )
		{
			EnemyUnitBaseScript enemyunit = collision.transform.GetComponent<EnemyUnitBaseScript>();
			if ( enemyunit )
			{
				enemyunit.Die_Killed();
            }

			Destroy( collision.transform.gameObject );

			// Flag as hit so no other units are destroyed this frame
			HasHitUnit = true;

			// Virtual override for child classes
			OnUnitHit( collision );
        }

		// Kill protectile
		Destroy( transform.parent.gameObject );

		// Spawn projectile death effect
		GameObject effect = (GameObject) Instantiate( DeathEffectPrefab, transform.position, Quaternion.Euler( Vector3.zero ) );
		effect.transform.SetParent( GameObject.Find( "GameObjectContainer" ).transform );
	}
Example #28
0
    void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("TrackWall"))
        {
            // Get Collision impact
            float impact = Vector3.Dot(other.contacts[0].normal, other.relativeVelocity);
            float hitDot = Vector3.Dot(other.contacts[0].normal, transform.forward);

            if (Mathf.Abs(impact) > 1 && hitDot < 0.1f)
            {
                // Zero out relative Z velocity
                r.PlayOneShot(r.settings.SFX_WALLHIT);
                Vector3 lv = transform.InverseTransformDirection(r.body.velocity);
                lv.y = 0;
                lv.z = 0;
                Vector3 wv = transform.TransformDirection(lv);
                r.body.velocity = wv;

                // Reduce engine power and thrust
                enginePower *= 0.2f;
                engineThrust *= 0.2f;

                // Push ship away from wall
                Vector3 dir = other.contacts[0].normal;
                dir.y = 0;
                r.body.AddForce(dir * Mathf.Abs(impact), ForceMode.Impulse);

                // Spawn hit particle
                GameObject particle = Instantiate(Resources.Load("Particles/CollisionHit") as GameObject) as GameObject;
                particle.transform.position = other.contacts[0].point;
                particle.transform.forward = -transform.forward;

                // Ship take damage
                r.shield -= Mathf.Abs(impact * 2);

            }
        }

        if (other.gameObject.tag == "Ship")
        {

            //r.PlayOneShot(SHIP2SHIP SOUND);

            // Stop Bounce
            Vector3 lv = transform.InverseTransformDirection(r.body.velocity);
            lv.y = 0;
            Vector3 wv = transform.TransformDirection(lv);
            if (!isShipGrounded)
                r.body.velocity = wv;

            // Slow ship down slightly
            enginePower *= 0.8f;
            engineThrust *= 0.8f;

            // Push away from other ship
            Vector3 dir = other.contacts[0].normal;
            dir.y = 0;
            r.body.AddForce(dir * 4, ForceMode.Impulse);
        }
    }
Example #29
0
 void OnCollisionEnter(Collision collision)
 {
     //Debug.Log(collision.relativeVelocity.magnitude);
     if (collision.relativeVelocity.magnitude > 2){
         audio.Play();
     }
 }
Example #30
0
    /*
	// Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }*/
	void onCollisionEnter(Collision col){
		Debug.Log("Collision Detetected");
	}
Example #31
0
        // localai0 : 0 when spawned, 1 when otherNPC spawned.
        // ai0 = npc number of other NPC
        // ai1 = charge time for gun.
        // ai2 = used for frame??
        // ai3 =
        public override void AI()
        {
            int     otherNPC           = -1;
            Vector2 offsetFromOtherNPC = Vector2.Zero;

            if (npc.localAI[0] == 0f && Main.netMode != 1)
            {
                npc.localAI[0] = 1f;
                int newNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("GreenFinTrapper"), npc.whoAmI, 0f, 0f, 0f, 0f, 255);
                npc.ai[0]     = (float)newNPC;
                npc.netUpdate = true;
            }
            int otherNPCCheck = (int)npc.ai[0];

            if (Main.npc[otherNPCCheck].active && Main.npc[otherNPCCheck].type == mod.NPCType("GreenFinTrapper"))
            {
                if (npc.timeLeft < 60)
                {
                    npc.timeLeft = 60;
                }
                otherNPC           = otherNPCCheck;
                offsetFromOtherNPC = Vector2.UnitY * -10f;
            }

            // If otherNPC exists, do this
            if (otherNPC != -1)
            {
                NPC nPC7 = Main.npc[otherNPC];
                npc.velocity        = Vector2.Zero;
                npc.position        = nPC7.Center;
                npc.position.X      = npc.position.X - (float)(npc.width / 2);
                npc.position.Y      = npc.position.Y - (float)(npc.height / 2);
                npc.position       += offsetFromOtherNPC;
                npc.gfxOffY         = nPC7.gfxOffY;
                npc.direction       = nPC7.direction;
                npc.spriteDirection = nPC7.spriteDirection;
                npc.timeLeft        = nPC7.timeLeft;
                npc.velocity        = nPC7.velocity;
                npc.target          = nPC7.target;
                if (npc.ai[1] < 60f)
                {
                    npc.ai[1] += 1f;
                }
                if (npc.justHit)
                {
                    npc.ai[1] = -30f;
                }
                int   projectileType   = Terraria.ID.ProjectileID.RayGunnerLaser;// 438;
                int   projectileDamage = 30;
                float scaleFactor20    = 7f;
                if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
                {
                    Vector2 vectorToPlayer           = Main.player[npc.target].Center - npc.Center;
                    Vector2 vectorToPlayerNormalized = Vector2.Normalize(vectorToPlayer);
                    float   num1547 = vectorToPlayer.Length();
                    float   num1548 = 700f;

                    if (num1547 < num1548)
                    {
                        if (npc.ai[1] == 60f && Math.Sign(vectorToPlayer.X) == npc.direction)
                        {
                            npc.ai[1] = -60f;
                            Vector2 center12  = Main.player[npc.target].Center;
                            Vector2 value26   = npc.Center - Vector2.UnitY * 4f;
                            Vector2 vector188 = center12 - value26;
                            vector188.X += (float)Main.rand.Next(-50, 51);
                            vector188.Y += (float)Main.rand.Next(-50, 51);
                            vector188.X *= (float)Main.rand.Next(80, 121) * 0.01f;
                            vector188.Y *= (float)Main.rand.Next(80, 121) * 0.01f;
                            vector188.Normalize();
                            if (float.IsNaN(vector188.X) || float.IsNaN(vector188.Y))
                            {
                                vector188 = -Vector2.UnitY;
                            }
                            vector188 *= scaleFactor20;
                            Projectile.NewProjectile(value26.X, value26.Y, vector188.X, vector188.Y, projectileType, projectileDamage, 0f, Main.myPlayer, 0f, 0f);
                            npc.netUpdate = true;
                        }
                        else
                        {
                            float oldAI2 = npc.ai[2];
                            npc.velocity.X = npc.velocity.X * 0.5f;
                            npc.ai[2]      = 3f;
                            if (Math.Abs(vectorToPlayerNormalized.Y) > Math.Abs(vectorToPlayerNormalized.X) * 2f)
                            {
                                if (vectorToPlayerNormalized.Y > 0f)
                                {
                                    npc.ai[2] = 1f;
                                }
                                else
                                {
                                    npc.ai[2] = 5f;
                                }
                            }
                            else if (Math.Abs(vectorToPlayerNormalized.X) > Math.Abs(vectorToPlayerNormalized.Y) * 2f)
                            {
                                npc.ai[2] = 3f;
                            }
                            else if (vectorToPlayerNormalized.Y > 0f)
                            {
                                npc.ai[2] = 2f;
                            }
                            else
                            {
                                npc.ai[2] = 4f;
                            }
                            if (npc.ai[2] != oldAI2)
                            {
                                npc.netUpdate = true;
                            }
                        }
                    }
                }
            }
            else
            {
                // This code is called when Bottom is dead. Top is transformed into a new NPC.
                npc.Transform(mod.NPCType("Kakamora2"));
                return;
            }
        }
Example #32
0
 public void OnCollisionEnter(Collision collision)
 {
     DoDamage(collision.collider.gameObject, collision.contacts[0].normal);
 }
Example #33
0
        public override void AI()
        {
            if (body == -1)
            {
                int npcID = BaseAI.GetNPC(npc.Center, mod.NPCType("Zero"), 1000, null);
                if (npcID >= 0)
                {
                    body = npcID;
                }
            }

            if (body == -1)
            {
                return;
            }

            NPC zero = Main.npc[body];

            if (zero == null || zero.life <= 0 || !zero.active || zero.type != mod.NPCType("Zero"))
            {
                npc.active = false; return;
            }

            for (int m = npc.oldPos.Length - 1; m > 0; m--)
            {
                npc.oldPos[m] = npc.oldPos[m - 1];
            }
            npc.oldPos[0] = npc.position;

            int probeNumber = ((Zero)zero.modNPC).WeaponCount;

            if (rotValue == -1f)
            {
                rotValue = npc.ai[0] % probeNumber * ((float)Math.PI * 2f / probeNumber);
            }
            rotValue += Main.expertMode ? .05f : 0f;
            while (rotValue > (float)Math.PI * 2f)
            {
                rotValue -= (float)Math.PI * 2f;
            }
            npc.Center = BaseUtility.RotateVector(zero.Center, zero.Center + new Vector2(((Zero)zero.modNPC).Distance, 0f), rotValue);

            if (Main.netMode != 1)
            {
                npc.ai[2]++;
            }

            Player player = Main.player[zero.target];

            int aiTimerFire = Main.expertMode ? 120 : 180;

            if (zero.ai[0] > 0 && Main.netMode != 1)
            {
                npc.active    = false;
                npc.netUpdate = true;
            }

            if (Main.netMode != 1)
            {
                npc.ai[2]++;
            }

            if (npc.ai[2] == aiTimerFire)
            {
                npc.ai[2] = 0;
                if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, player.width, player.height))
                {
                    float   spread = 45f * 0.0174f;
                    Vector2 dir    = Vector2.Normalize(player.Center - npc.Center);
                    dir *= 14f;
                    float  baseSpeed  = (float)Math.Sqrt((dir.X * dir.X) + (dir.Y * dir.Y));
                    double startAngle = Math.Atan2(dir.X, dir.Y) - .1d;
                    double deltaAngle = spread / 6f;
                    for (int i = 0; i < Main.rand.Next(4); i++)
                    {
                        double offsetAngle = startAngle + (deltaAngle * i);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), mod.ProjType("Static"), (int)(npc.damage / 1.5f), 5, Main.myPlayer);
                    }
                }
            }

            Vector2 vector2     = new Vector2(npc.position.X + (npc.width * 0.5f), npc.position.Y + (npc.height * 0.5f));
            float   num1        = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector2.X;
            float   num2        = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector2.Y;
            float   NewRotation = (float)Math.Atan2(num2, num1) - 1.57f;

            npc.rotation = MathHelper.Lerp(npc.rotation, NewRotation, 1f / 30f);
        }
 void OnCollisionEnter(Collision other)
 {
     Debug.Log("Trigger :" + other.gameObject.name);
 }
Example #35
0
 private void OnCollisionEnter(Collision collision)
 {
     Debug.Log("Cat hit the ground");
     jumping = false;
 }
Example #36
0
 void OnCollisionEnter(Collision collision)
 {
     rb.velocity = Vector3.Reflect(collision.relativeVelocity * -1 / rb.mass, collision.contacts[0].normal);
 }
Example #37
0
        public override void AI()
        {
            if (projectile.timeLeft < 30)
            {
                projectile.alpha += 10;
            }
            // 核心代码部分

            // 如果玩家仍然在控制弹幕
            if (Main.player[projectile.owner].channel)
            {
                // 获取弹幕持有者
                Player player = Main.player[projectile.owner];

                // 从玩家到达鼠标位置的单位向量
                Vector2 unit = Vector2.Normalize(Main.MouseWorld - player.Center);
                // 随机角度
                float rotaion = unit.ToRotation();
                // 调整玩家转向以及手持物品的转动方向
                player.direction    = Main.MouseWorld.X < player.Center.X ? -1 : 1;
                player.itemRotation = (float)Math.Atan2(rotaion.ToRotationVector2().Y *player.direction,
                                                        rotaion.ToRotationVector2().X *player.direction);
                player.itemTime      = 2;
                player.itemAnimation = 2;
                // 从弹幕到达鼠标位置的单位向量
                Vector2 unit2 = Vector2.Normalize(Main.MouseWorld - projectile.Center);
                // 让弹幕缓慢朝鼠标方向移动
                if (Vector2.Distance(projectile.Center, Main.MouseWorld) < 5)
                {
                    projectile.velocity *= 0;
                    projectile.Center    = Main.MouseWorld;
                }
                else
                {
                    projectile.velocity = unit2 * 5;
                }
            }
            else
            {
                // 如果玩家放弃吟唱就慢慢消失
                if (projectile.timeLeft > 30)
                {
                    projectile.timeLeft = 30;
                }
                // 返回函数这样就不会执行下面的攻击代码
                return;
            }

            // 累加帧计时器
            projectile.frameCounter++;
            // 当计时器经过了7帧
            if (projectile.frameCounter % 7 == 0)
            {
                // 重置计时器
                projectile.frameCounter = 0;
                // 选择下一帧动画
                // 让弹幕的帧与等于与5进行模运算,也就是除以5的余数
                projectile.frame++;
                projectile.frame %= 5;
            }

            NPC target = null;
            // 最大寻敌距离
            float distanceMax = 400f;

            foreach (NPC npc in Main.npc)
            {
                // 如果npc活着且敌对
                if (npc.active && !npc.friendly && npc.type != NPCID.TargetDummy &&
                    Collision.CanHit(projectile.Center, 1, 1, npc.position, npc.width, npc.height))
                {
                    // 计算距离
                    float currentDistance = Vector2.Distance(npc.Center, projectile.Center);
                    // 如果npc距离比当前最大距离小
                    if (currentDistance < distanceMax)
                    {
                        // 就把最大距离设置为npc和玩家的距离
                        // 并且暂时选取这个npc为距离最近npc
                        distanceMax = currentDistance;
                        target      = npc;
                    }
                }
            }
            baseRot += 0.15f;
            // 如果找到符合条件的npc, 并且符合开火间隔(一秒6次)
            if (target != null && projectile.timeLeft % 10 < 1)
            {
                Vector2 toTarget = target.Center - projectile.Center;
                toTarget.Normalize();
                toTarget *= 6f;

                toTarget = toTarget.RotatedBy(baseRot);
                for (int i = 0; i < 3; i++)
                {
                    toTarget = toTarget.RotatedBy(MathHelper.Pi / 1.5f);
                    // 我调整了一下发射位置,这样射线看起来更像从磁球中间射出来的
                    Projectile.NewProjectile(projectile.Center + projectile.velocity * 4f,
                                             toTarget, ProjectileID.LightBeam, 100, 5f, projectile.owner, target.whoAmI);
                }
            }
        }
Example #38
0
 private void OnCollisionStay(Collision collision)
 {
     colliding = true;
     timer     = 2.0f;
 }
Example #39
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.tag == "food")
     {
     }
 }
Example #40
0
 private void OnCollisionEnter(Collision coll)
 {
     CheckCollision(coll);
 }
Example #41
0
            // ...

            protected virtual void onBulletCollisionEnterEvent(Bullet bullet, Collision collision)
            {
            }
Example #42
0
        private void Thorium(Player player)
        {
            ThoriumPlayer thoriumPlayer = player.GetModPlayer <ThoriumPlayer>(thorium);

            //terrarium particle sprinters dust
            if (Collision.SolidCollision(player.position, player.width, player.height + 4) && Math.Abs(player.velocity.X) >= 2)
            {
                for (int i = 0; i < 1; i++)
                {
                    int num = Dust.NewDust(new Vector2(player.position.X - 2f, player.position.Y + (float)player.height - 2f), player.width + 4, 4, 57, 0f, 0f, 100, default(Color), 1.4f);
                    Main.dust[num].noGravity = true;
                    Main.dust[num].noLight   = true;
                    Dust dust = Main.dust[num];
                    dust.velocity *= 0f;
                }
                for (int j = 0; j < 1; j++)
                {
                    int num2 = Dust.NewDust(new Vector2(player.position.X - 2f, player.position.Y + (float)player.height - 2f), player.width + 4, 4, 61, 0f, 0f, 100, default(Color), 1.35f);
                    Main.dust[num2].noGravity = true;
                    Main.dust[num2].noLight   = true;
                    Dust dust2 = Main.dust[num2];
                    dust2.velocity *= 0f;
                }
                for (int k = 0; k < 1; k++)
                {
                    int num3 = Dust.NewDust(new Vector2(player.position.X - 2f, player.position.Y + (float)player.height - 2f), player.width + 4, 4, 229, 0f, 0f, 100, default(Color), 1.15f);
                    Main.dust[num3].noGravity = true;
                    Main.dust[num3].noLight   = true;
                    Dust dust3 = Main.dust[num3];
                    dust3.velocity *= 0f;
                }
                for (int l = 0; l < 1; l++)
                {
                    int num4 = Dust.NewDust(new Vector2(player.position.X - 2f, player.position.Y + (float)player.height - 2f), player.width + 4, 4, 60, 0f, 0f, 100, default(Color), 1.5f);
                    Main.dust[num4].noGravity = true;
                    Main.dust[num4].noLight   = true;
                    Dust dust4 = Main.dust[num4];
                    dust4.velocity *= 0f;
                }
                for (int m = 0; m < 1; m++)
                {
                    int num5 = Dust.NewDust(new Vector2(player.position.X - 2f, player.position.Y + (float)player.height - 2f), player.width + 4, 4, 127, 0f, 0f, 100, default(Color), 1.75f);
                    Main.dust[num5].noGravity = true;
                    Main.dust[num5].noLight   = true;
                    Dust dust5 = Main.dust[num5];
                    dust5.velocity *= 0f;
                }
                for (int n = 0; n < 1; n++)
                {
                    int num6 = Dust.NewDust(new Vector2(player.position.X - 2f, player.position.Y + (float)player.height - 2f), player.width + 4, 4, 59, 0f, 0f, 100, default(Color), 1.4f);
                    Main.dust[num6].noGravity = true;
                    Main.dust[num6].noLight   = true;
                    Dust dust6 = Main.dust[num6];
                    dust6.velocity *= 0f;
                }
                for (int num7 = 0; num7 < 1; num7++)
                {
                    int num8 = Dust.NewDust(new Vector2(player.position.X - 2f, player.position.Y + (float)player.height - 2f), player.width + 4, 4, 62, 0f, 0f, 100, default(Color), 1.35f);
                    Main.dust[num8].noGravity = true;
                    Main.dust[num8].noLight   = true;
                    Dust dust7 = Main.dust[num8];
                    dust7.velocity *= 0f;
                }
            }
            //air walkers
            if (Soulcheck.GetValue("Air Walkers"))
            {
                if (player.controlDown)
                {
                    jumped = true;
                }
                else
                {
                    jumped = false;
                }
                if (!Collision.SolidCollision(player.position, player.width, player.height + 4))
                {
                    hoverTimer++;
                }
                else
                {
                    hoverTimer = 0;
                }
                if (hoverTimer >= 250)
                {
                    canHover = false;
                }
                else
                {
                    canHover = true;
                }
                if (canHover && !jumped && !Collision.SolidCollision(player.position, player.width, player.height + 4))
                {
                    player.maxFallSpeed = 0f;
                    player.fallStart    = (int)(player.position.Y / 16f);
                    int num = Dust.NewDust(new Vector2(player.position.X - 2f, player.position.Y + (float)player.height - 2f), player.width + 4, 4, 229, 0f, 0f, 100, default(Color), 1.25f);
                    Main.dust[num].noGravity = true;
                    Main.dust[num].noLight   = true;
                    Dust dust = Main.dust[num];
                    dust.velocity *= 0f;
                }
            }
            //survivalist boots
            if (Math.Abs(player.velocity.X) > 2f)
            {
                player.lifeRegen += 2;
                player.lifeRegenTime++;
                player.manaRegenBonus += 2;
                player.manaRegenDelayBonus++;
                thoriumPlayer.bardResourceRecharge += 2;
            }
            //weighted winglets
            if (player.controlDown && !player.controlUp)
            {
                player.maxFallSpeed *= (player.wet ? 2.4f : 1.6f);
            }
            if (player.controlUp && !player.controlDown)
            {
                player.maxFallSpeed *= 0.4f;
                player.fallStart     = (int)(player.position.Y / 16f);
            }
        }
Example #43
0
 private void OnCollisionExit(Collision collision)
 {
     colliding = false;
 }
Example #44
0
 void OnCollisionExit(Collision collisionInfo)
 {
     callIfExist(idOnCollisionExit, collisionInfo);
 }
Example #45
0
 private void OnCollisionEnter(Collision other)
 {
     Destroy(this.gameObject);
 }
Example #46
0
 void OnCollisionEnter(Collision collision)
 {
     print("plataforma1");
 }
Example #47
0
 void OnCollisionStay(Collision collisionInfo)
 {
     callIfExist(idOnCollisionStay, collisionInfo);
 }
Example #48
0
    private void OnCollisionEnter(Collision collision)
    {
        transform.position = new Vector3(transform.localPosition.x, transform.localPosition.y, 0);

        BallInitialSpeed = 700f;
    }
Example #49
0
 void OnCollisionEnter(Collision collisionInfo)
 {
     callIfExist(idOnCollisionEnter, collisionInfo);
 }
Example #50
0
	void OnCollisionStay (Collision col) {
		if (col.gameObject.tag == "Building" && playerRigidBody.velocity.magnitude == 0f) {
			playerJumping = false;
			playerOnGround = true;
		}
	}
Example #51
0
        public override void AI()
        {
            npc.position += npc.velocity * 1.7f;
            if (Main.rand.Next(500) == 0 && Main.expertMode)
            {
                for (int i = 0; i < 50; i++)
                {
                    int dust = Dust.NewDust(npc.position, npc.width, npc.height, 5);
                    Main.dust[dust].scale     = 1.5f;
                    Main.dust[dust].noGravity = true;
                    Main.dust[dust].velocity *= 0f;
                    Main.dust[dust].velocity *= 0f;
                }
                npc.position.X = (Main.player[npc.target].position.X - 250) + Main.rand.Next(500);
                npc.position.Y = (Main.player[npc.target].position.Y - 250) + Main.rand.Next(500);
            }

            if (Main.rand.Next(500) == 0 && !Main.expertMode)
            {
                npc.TargetClosest(true);
                Vector2 vector142 = new Vector2(npc.Center.X, npc.Center.Y);
                float   num1243   = Main.player[npc.target].Center.X - vector142.X;
                float   num1244   = Main.player[npc.target].Center.Y - vector142.Y;
                float   num1245   = (float)Math.Sqrt(num1243 * num1243 + num1244 * num1244);
                if (npc.ai[1] == 0f)
                {
                    if (Main.netMode != 1)
                    {
                        npc.localAI[1] += 1f;
                        if (npc.localAI[1] >= 120 + Main.rand.Next(200))
                        {
                            npc.localAI[1] = 0f;
                            npc.TargetClosest(true);
                            int num1249 = 0;
                            int num1250;
                            int num1251;
                            while (true)
                            {
                                num1249++;
                                num1250  = (int)Main.player[npc.target].Center.X / 16;
                                num1251  = (int)Main.player[npc.target].Center.Y / 16;
                                num1250 += Main.rand.Next(-50, 51);
                                num1251 += Main.rand.Next(-50, 51);
                                if (!WorldGen.SolidTile(num1250, num1251) && Collision.CanHit(new Vector2(num1250 * 16, num1251 * 16), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
                                {
                                    break;
                                }
                                if (num1249 > 100)
                                {
                                    //return;
                                }
                            }
                            npc.ai[1]     = 1f;
                            npc.ai[2]     = num1250;
                            npc.ai[3]     = num1251;
                            npc.netUpdate = true;
                            //return;
                        }
                    }
                }
                else if (npc.ai[1] == 1f)
                {
                    npc.alpha += 3;
                    if (npc.alpha >= 255)
                    {
                        npc.alpha      = 255;
                        npc.position.X = npc.ai[2] * 16f - npc.width / 2;
                        npc.position.Y = npc.ai[3] * 16f - npc.height / 2;
                        npc.ai[1]      = 2f;
                        //return;
                    }
                }
                else if (npc.ai[1] == 2f)
                {
                    npc.alpha -= 3;
                    if (npc.alpha <= 0)
                    {
                        npc.alpha = 0;
                        npc.ai[1] = 0f;
                        //return;
                    }
                }
            }

            if (Main.expertMode && Main.rand.Next(7500) == 0)
            {
                NPC.NewNPC((int)npc.position.X - 150, (int)npc.position.Y - 150, 421);
                NPC.NewNPC((int)npc.position.X + 150, (int)npc.position.Y - 150, 421);
                NPC.NewNPC((int)npc.position.X - 150, (int)npc.position.Y + 150, 421);
                NPC.NewNPC((int)npc.position.X + 150, (int)npc.position.Y + 150, 421);
            }

            if (npc.target != -1 && !RunAway)
            {
                if (!Main.player[npc.target].active)
                {
                    if (Helper.GetNearestAlivePlayer(npc) == -1)
                    {
                        RunAway = true;
                    }
                    else
                    {
                        if (Main.player[Helper.GetNearestAlivePlayer(npc)].Distance(npc.Center) > 2500f)
                        {
                            RunAway = true;
                        }
                        else
                        {
                            npc.target = Helper.GetNearestAlivePlayer(npc);
                        }
                    }
                }
            }
            if (Main.dayTime || RunAway || npc.localAI[3] == 1)
            {
                npc.localAI[3] = 1;
                if (Main.npc[(int)npc.ai[2]].type == mod.NPCType("SoulofTrust") && Main.npc[(int)npc.ai[2]].active)
                {
                    Main.npc[(int)npc.ai[2]].localAI[3] = 1;
                }
                if (Main.npc[(int)npc.ai[3]].type == mod.NPCType("SoulofTruth") && Main.npc[(int)npc.ai[3]].active)
                {
                    Main.npc[(int)npc.ai[3]].localAI[3] = 1;
                }
                npc.life    += 11;
                npc.aiStyle  = 0;
                npc.rotation = 0;
                npc.velocity = Helper.VelocityFPTP(npc.Center, new Vector2(npc.Center.X, npc.Center.Y - 4815162342), 30.0f);
                CreateDust();
                return;
            }
            if (StateFlag)
            {
                if (
                    !((Main.npc[(int)npc.ai[2]].type == mod.NPCType("SoulofHope") && Main.npc[(int)npc.ai[2]].active)) ||
                    !((Main.npc[(int)npc.ai[3]].type == mod.NPCType("SoulofTrust") && Main.npc[(int)npc.ai[3]].active))
                    )
                {
                    StateFlag = false;
                    OnlyPower = true;
                }
            }
            if (!OnlyPower)
            {
                SetStage(!(Main.player[npc.GetNearestPlayer()].Distance(npc.Center) <= DistantionToPower));
            }
            else
            {
                SetStage(true);
            }
            SetRotation();
            CreateDust();
            if (Power && rnd.Next(5) == 0)
            {
                Shoot();
            }
        }
Example #52
0
    private void Update() {
      //var isInteractingWithAButton = hingeButtons.Query().Any(b => b.isInteracting);
      
      // Determine whether to begin or end the held state this frame.
      var shouldBeginHolding = false;
      var interactingHand = intObj.closestHoveringHand;
      if (interactingHand != null) {
        if (pinchGesture.wasActivated) {
          var pinchPos = pinchGesture.pose.position;
          Vector3 barSegmentA, barSegmentB;
          barCapsule.GetCapsulePoints(out barSegmentA, out barSegmentB);
          var barPinchSqrDist = Geometry.Collision.SqrDistPointSegment(barSegmentA,
            barSegmentB, pinchPos);
          if (barPinchSqrDist < beginHoldDist * beginHoldDist) {
            shouldBeginHolding = true;
          }
        }
      }
      var shouldStopHolding = !pinchGesture.isActive;

      // Update grasped or released state of the slide.
      if (!_isHeld && shouldBeginHolding) {
        // Just grasped.
        _isHeld = true;

        var slidePos_slide = slideMatrixInv.MultiplyPoint3x4(this.transform.position);
        var holdPos_slide = slideMatrixInv.MultiplyPoint3x4(pinchGesture.pose.position);
        holdOffset_slide = slidePos_slide - holdPos_slide;
      }
      if (_isHeld && shouldStopHolding) {
        // Just released.
        _isHeld = false;

        // Lock the slide open if released while fully open.
        var pos = this.transform.position;
        var pos_slide = slideMatrixInv.MultiplyPoint3x4(pos);
        float slideT;
        var clampedPos_slide
          = Collision.ClosestPtPointSegment(slideSegment_slide, pos_slide, out slideT);
        var slideDistance_slide = clampedPos_slide.Dot(slideAxis_slide);
        _isLockedOpen = slideDistance_slide >= stayOpenDistance_slide;
      }

      // Slide the pull bar to match the held position or its target rest position.
      if (_isHeld) {
        var pinchPos = pinchGesture.pose.position;
        var heldPosition_slide = slideMatrixInv.MultiplyPoint3x4(pinchPos);
        heldPosition_slide += holdOffset_slide;
        var clampedPosition_slide
          = Collision.ClosestPtPointSegment(slideSegment_slide, heldPosition_slide);

        var targetPos = slideMatrix.MultiplyPoint3x4(clampedPosition_slide);
        this.transform.position = Vector3.Lerp(this.transform.position, targetPos,
          (_slideHeldSpeed * Time.deltaTime));
      }
      else {
        var targetPosition = slideTransform.position;

        if (_isLockedOpen) {
          targetPosition = slideMatrix.MultiplyPoint3x4(maxSlidePos_slide);
        }

        this.transform.position = Vector3.Lerp(this.transform.position, targetPosition,
          slideBackSpeed * Time.deltaTime);
      }
    }
Example #53
0
	void OnCollisionExit (Collision col) {
		playerNumberOfCollisions -=1;
		if (playerNumberOfCollisions <= 0) {
			playerOnGround = false;
		}
	}
Example #54
0
 private void OnCollisionStay(Collision other)
 {
     _isAirbone = false;
 }
    void OnCollisionEnter(Collision hit)
    {
        if (!hasCollided)
        {
            hasCollided = true;
            //transform.DetachChildren();
            impactParticle = Instantiate(impactParticle, transform.position, Quaternion.FromToRotation(Vector3.up, impactNormal)) as GameObject;
            //Debug.DrawRay(hit.contacts[0].point, hit.contacts[0].normal * 1, Color.yellow);

            if (hit.gameObject.tag == "Destructible") // Projectile will destroy objects tagged as Destructible
            {
                Destroy(hit.gameObject);
            }


            //////////////////////////////////////////////////////////////////
            /// My Code
            //////////////////////////////////////////////////////////////////

            //If the object that the particle collided with
            if (hit.gameObject.GetComponent <Player>())
            {
                Debug.Log("HIT THE PLAYER!!!!");

                Player scriptComp = hit.gameObject.GetComponent <Player>();
                scriptComp.GetHit(projectileDamage);
            }
            else
            {
                Debug.Log("HIT OBJECT!!!!");
            }

            //////////////////////////////////////////////////////////////////
            /// End My Code
            //////////////////////////////////////////////////////////////////

            //yield WaitForSeconds (0.05);
            foreach (GameObject trail in trailParticles)
            {
                GameObject curTrail = transform.Find(projectileParticle.name + "/" + trail.name).gameObject;
                curTrail.transform.parent = null;
                Destroy(curTrail, 3f);
            }
            Destroy(projectileParticle, 3f);
            Destroy(impactParticle, 5f);
            Destroy(gameObject);
            //projectileParticle.Stop();

            ParticleSystem[] trails = GetComponentsInChildren <ParticleSystem>();
            //Component at [0] is that of the parent i.e. this object (if there is any)
            for (int i = 1; i < trails.Length; i++)
            {
                ParticleSystem trail = trails[i];
                if (!trail.gameObject.name.Contains("Trail"))
                {
                    continue;
                }

                trail.transform.SetParent(null);
                Destroy(trail.gameObject, 2);
            }
        }
    }
Example #56
0
 void OnCollisionEnter(Collision collision)
 {
     Debug.LogWarning("Object:" + collision.gameObject.ToString() + ", destroyed because it fell off the world.");
     Destroy(collision.gameObject);
 }
 private void OnCollisionStay(Collision collision)
 {
 }
Example #58
0
 public override bool OnTileCollide(Vector2 oldVelocity)
 {
     Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height);
     Main.PlaySound(SoundID.Item10, projectile.position);
     return(true);
 }
Example #59
0
 private void OnCollisionExit(Collision other)
 {
     _isAirbone = true;
 }
Example #60
-1
	public void OnCollisionStay(Collision col)
	{
		if(col.gameObject.transform.position.x < transform.position.x)
			SendMessageUpwards("RotateDoorClock");
		else
			SendMessageUpwards("RotateDoorUnClock");
	}