Commit 36b53389 by Philipp Adolf

Change behavior of trap destroyers

Instead of acting as a bullet power up it now immediately destroys a trap on pickup. The trap closest to any player (excluding the player that picked up the destroyer) is destroyed.
parent 52ad2aa7
...@@ -237,7 +237,6 @@ public class PlayerControl : MonoBehaviour ...@@ -237,7 +237,6 @@ public class PlayerControl : MonoBehaviour
public const int POWERUP_NONE = 0; public const int POWERUP_NONE = 0;
public const int POWERUP_HEALINGBULLET = 1; public const int POWERUP_HEALINGBULLET = 1;
public const int POWERUP_TRAPDESTROYER = 2;
private int powerUpType = POWERUP_NONE; private int powerUpType = POWERUP_NONE;
...@@ -246,7 +245,6 @@ public class PlayerControl : MonoBehaviour ...@@ -246,7 +245,6 @@ public class PlayerControl : MonoBehaviour
public float coolDownTime = 2.0f; public float coolDownTime = 2.0f;
public GameObject healingBulletPrefab; public GameObject healingBulletPrefab;
public GameObject trapDestroyingBulletPrefab;
/// <summary> /// <summary>
/// Falls das im Editor falsch ist: Auf 0.2 setzen. /// Falls das im Editor falsch ist: Auf 0.2 setzen.
...@@ -269,10 +267,6 @@ public class PlayerControl : MonoBehaviour ...@@ -269,10 +267,6 @@ public class PlayerControl : MonoBehaviour
GameObject bullet = Instantiate(healingBulletPrefab, pos, transform.rotation) as GameObject; GameObject bullet = Instantiate(healingBulletPrefab, pos, transform.rotation) as GameObject;
bullet.GetComponent<Bullet>().shoot(new Vector2(dir, 0)); bullet.GetComponent<Bullet>().shoot(new Vector2(dir, 0));
break; break;
case POWERUP_TRAPDESTROYER:
GameObject trapbullet = Instantiate(trapDestroyingBulletPrefab, pos, transform.rotation) as GameObject;
trapbullet.GetComponent<Bullet>().shoot(new Vector2(dir, 0));
break;
default: default:
break; break;
} }
......
...@@ -8,7 +8,6 @@ public class PowerUpScript : MonoBehaviour ...@@ -8,7 +8,6 @@ public class PowerUpScript : MonoBehaviour
/// sollte übereinstimmen mit PlayerControl.POWERUP_XXX /// sollte übereinstimmen mit PlayerControl.POWERUP_XXX
/// 0 == none /// 0 == none
/// 1 == Heal /// 1 == Heal
/// 2 == destroyTrap
/// </summary> /// </summary>
public int type; public int type;
......
using UnityEngine;
using System.Collections;
public class TrapDestroyer : MonoBehaviour
{
public float respawnTime = 5.0f;
private Vector2 realPosition;
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player")
{
GameObject bestTrap = null;
float bestDistance = float.PositiveInfinity;
GameObject[] traps = GameObject.FindGameObjectsWithTag("Trap");
foreach (GameObject player in GameObject.FindGameObjectsWithTag("Player"))
{
if (player == other.gameObject)
continue;
foreach (GameObject trap in traps)
{
float distance = (player.transform.position - trap.transform.position).magnitude;
if (distance < bestDistance)
{
bestTrap = trap;
bestDistance = distance;
}
}
if (bestTrap != null)
{
bestTrap.GetComponent<Trap>().destroyTrap();
}
}
DestroyPowerUp();
}
}
void DestroyPowerUp()
{
realPosition = transform.position;
transform.position = new Vector2(1000, 1000);
Invoke("Activate", respawnTime);
}
void Activate()
{
transform.position = realPosition;
}
}
fileFormatVersion: 2 fileFormatVersion: 2
guid: 84f3fefc4de4fd24982fdd4f908396bb guid: cf4e7b5b5976d4f4fa88ca684f750e96
timeCreated: 1433440862 timeCreated: 1433541614
licenseType: Free licenseType: Free
NativeFormatImporter: MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment