public void OnEnterHandler(JCollider thisBody, JCollider otherBody) { Debug.Log("OnEnterHandler for WeaponPickup: " + gameObject.name); var weaponSlot = otherBody.GetComponent <WeaponSlot>(); if (weaponSlot == null || !weaponSlot.enabled) { return; } string name = weaponSlot.ActiveWeaponName; var index = -1; for (var i = 0; i < WeaponsUpgradesNames.Length; i++) { if (WeaponsUpgradesNames[i].Equals(weaponSlot.ActiveWeaponName)) { index = i; break; } } var nextWeaponIndex = (index + 1) % WeaponsUpgrades.Length; var upgradeColor = GetComponentInChildren <Renderer>().material.color; // nextWeaponIndex + 1 since WeaponUpgradePath.CurrentUpgradeNumber is 1-indexed and nextWeaponIndex is 0-indexed weaponSlot.AttachWeapon(WeaponsUpgrades[nextWeaponIndex], new WeaponUpgradePath(upgradeColor, WeaponsUpgrades.Length, nextWeaponIndex + 1)); thisBody.NotifyDestroyCollider(); Destroy(gameObject); }
void Start() { jCollider = GetComponent <JCollider>(); jCollider.SetOnJCollisionEnterHandler(OnEnterHandler); jCollider.SetOnJCollisionStayHandler(OnStayHandler); Debug.Log("WeaponPickup.Start(). colliderId: " + jCollider.IdGenerated); }
void Awake() { col = GetComponent<JCollider>(); col.TriggerEnter += EnterToTrigger; col.TriggerStay += StayInTrigger; col.TriggerExit += ExitFromTrigger; }
void Awake() { col = GetComponent <JCollider>(); col.TriggerEnter += EnterToTrigger; col.TriggerStay += StayInTrigger; col.TriggerExit += ExitFromTrigger; }
private void CollisionHandler(JCollider thisBody, JCollider otherBody) { var playerHealth = otherBody.GetComponent <PlayerHealth>(); var otherColor = settings.color; if (playerHealth != null) { var playerSettings = otherBody.GetComponent <PlayerSettings>(); otherColor = playerSettings.color; if (playerHealth.DoDamage(settings.Damage)) { AFEventManager.INSTANCE.PostEvent(AFEvents.Kill(settings.PlayerOwnerNumber, playerSettings.playerNumber)); } } else { Debug.Log("Bullet hit something else.."); } if (playerHealth != null || settings.DestroyOnAnyOverlap) { Debug.Log("Time to destroy bullet"); var hitParticles = Instantiate(settings.hitParticlesPrefab, transform.position, transform.rotation); var colorModule = hitParticles.colorOverLifetime; colorModule.enabled = true; ParticleSystem.MinMaxGradient gradient = new ParticleSystem.MinMaxGradient(settings.color, otherColor); var mainModule = hitParticles.main; mainModule.startColor = gradient; Destroy(gameObject); } }
void Start() { colliderManager = GameObject.FindObjectOfType <JColliderManager>(); collider = GetComponent <JCollider>(); settings = GetComponent <BombSettings>(); AFEventManager.INSTANCE.AddListener(this); Invoke("TriggerExplosionDueToLifeTime", settings.MaxLifeTimeWithoutExploding); }
public JCollision(List <Vector3> points, Vector3 normal, float depth, JCollider colliderA, JCollider colliderB) { valid = true; collisionPoints = points; collisionNormal = normal; collisionDepth = depth; this.colliderA = colliderA; this.colliderB = colliderB; }
private const long IdMultiplierFactor = 10000000; // Number chosen slightly at random public JCollisionPair(JCollider body1, JCollider body2) { this.body1 = body1; this.body2 = body2; if (body1.IdGenerated < body2.IdGenerated) { IdHashCode = (body1.IdGenerated + IdMultiplierFactor * body2.IdGenerated).GetHashCode(); } else { IdHashCode = (body2.IdGenerated + IdMultiplierFactor * body1.IdGenerated).GetHashCode(); } }
protected override bool CheckCollision(JCollider colliderA, JCollider colliderB, out JCollision collision) { collision = null; if (colliderA is T1 && colliderB is T2) { collision = new JCollision(colliderA, colliderB); return(CheckCollision(colliderA as T1, colliderB as T2, out collision)); } else if (colliderB is T1 && colliderA is T2) { collision = new JCollision(colliderB, colliderA); return(CheckCollision(colliderB as T1, colliderA as T2, out collision)); } return(false); }
void Awake() { col = GetComponent <JCollider>(); }
void Awake() { col = GetComponent<JCollider>(); }
public void OnStayHandler(JCollider thisBody, JCollider otherBody) { Debug.Log("OnStayHandler for weaponPickup: " + gameObject.name); }
public JCollision(JCollider colliderA, JCollider colliderB) { valid = false; this.colliderA = colliderA; this.colliderB = colliderB; }
public JCollisionPushPair(JCollider collider, JCollider pushingFrom, Push push) { this.pushable = collider; this.pushingFrom = pushingFrom; this.push = push; }
// Start is called before the first frame update void Start() { settings = GetComponent <BulletSettings>(); collision = GetComponent <JCollider>(); collision.SetOnJCollisionEnterHandler(CollisionHandler); }