Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 void Start()
 {
     jCollider = GetComponent <JCollider>();
     jCollider.SetOnJCollisionEnterHandler(OnEnterHandler);
     jCollider.SetOnJCollisionStayHandler(OnStayHandler);
     Debug.Log("WeaponPickup.Start(). colliderId: " + jCollider.IdGenerated);
 }
Ejemplo n.º 3
0
 void Awake()
 {
     col = GetComponent<JCollider>();
     col.TriggerEnter += EnterToTrigger;
     col.TriggerStay += StayInTrigger;
     col.TriggerExit += ExitFromTrigger;
 }
Ejemplo n.º 4
0
 void Awake()
 {
     col = GetComponent <JCollider>();
     col.TriggerEnter += EnterToTrigger;
     col.TriggerStay  += StayInTrigger;
     col.TriggerExit  += ExitFromTrigger;
 }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
 void Start()
 {
     colliderManager = GameObject.FindObjectOfType <JColliderManager>();
     collider        = GetComponent <JCollider>();
     settings        = GetComponent <BombSettings>();
     AFEventManager.INSTANCE.AddListener(this);
     Invoke("TriggerExplosionDueToLifeTime", settings.MaxLifeTimeWithoutExploding);
 }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 8
0
        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();
            }
        }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
 void Awake()
 {
     col = GetComponent <JCollider>();
 }
Ejemplo n.º 11
0
 void Awake()
 {
     col = GetComponent<JCollider>();
 }
Ejemplo n.º 12
0
 public void OnStayHandler(JCollider thisBody, JCollider otherBody)
 {
     Debug.Log("OnStayHandler for weaponPickup: " + gameObject.name);
 }
Ejemplo n.º 13
0
 public JCollision(JCollider colliderA, JCollider colliderB)
 {
     valid          = false;
     this.colliderA = colliderA;
     this.colliderB = colliderB;
 }
Ejemplo n.º 14
0
 public JCollisionPushPair(JCollider collider, JCollider pushingFrom, Push push)
 {
     this.pushable    = collider;
     this.pushingFrom = pushingFrom;
     this.push        = push;
 }
Ejemplo n.º 15
0
 // Start is called before the first frame update
 void Start()
 {
     settings  = GetComponent <BulletSettings>();
     collision = GetComponent <JCollider>();
     collision.SetOnJCollisionEnterHandler(CollisionHandler);
 }