Exemplo n.º 1
0
        static void DeployableTrap_OnReceiveArmTrap_Post(DeployableTrap __instance)
        {
            #region quit
            if (__instance.CurrentTrapType == DeployableTrap.TrapType.Runic)
            {
                return;
            }
            #endregion

            // Cache
            Collider collider = __instance.m_interactionToggle.m_interactionCollider;
            Material material = __instance.CurrentVisual.FindChild("TrapVisual").GetComponentInChildren <MeshRenderer>().material;

            // Disarm
            material.color   = TRAP_START_COLOR;
            collider.enabled = false;
            switch (__instance.CurrentTrapType)
            {
            case DeployableTrap.TrapType.TripWireTrap: collider.As <BoxCollider>().SetSizeZ(_wireTrapDepth); break;

            case DeployableTrap.TrapType.PressurePlateTrap: collider.As <SphereCollider>().radius = _pressureTrapRadius; break;
            }

            // Arm
            float setupTime = Time.time;
            __instance.ExecuteUntil
            (
                () => Time.time - setupTime >= _trapsArmDelay,
                () => material.color = Utility.Lerp3(TRAP_START_COLOR, TRAP_TRANSITION_COLOR, TRAP_ARMED_COLOR, (Time.time - setupTime) / _trapsArmDelay),
                () => { material.color = TRAP_ARMED_COLOR; collider.enabled = true; }
            );
        }
Exemplo n.º 2
0
 public void TopCollision(Collider other)
 {
     if (other is T)
     {
         Colliders.Add(other.As <T>());
     }
 }
Exemplo n.º 3
0
        public static void HandleHorizontalCollision(
            this Collider a
            , Collider b)
        {
            if (a.Disabled || b.Disabled)
            {
                return;
            }

            var collision = a.IsColliding(b);

            if (collision == CollisionResult.Nope)
            {
                return;
            }

            if (collision == CollisionResult.Left)
            {
                if (a is ICollisionHandler)
                {
                    a.As <ICollisionHandler>().LeftCollision(b);
                }

                if (b is ICollisionHandler)
                {
                    b.As <ICollisionHandler>().RightCollision(a);
                }
            }
            else if (collision == CollisionResult.Right)
            {
                if (a is ICollisionHandler)
                {
                    a.As <ICollisionHandler>().RightCollision(b);
                }

                if (b is ICollisionHandler)
                {
                    b.As <ICollisionHandler>().LeftCollision(a);
                }
            }
        }
Exemplo n.º 4
0
        public static void HandleVerticalCollision(
            this Collider a
            , Collider b)
        {
            if (a.Disabled || b.Disabled)
            {
                return;
            }

            var collision = a.IsColliding(b);

            if (collision == CollisionResult.Nope)
            {
                return;
            }

            if (collision == CollisionResult.Top)
            {
                if (a is ICollisionHandler)
                {
                    a.As <ICollisionHandler>().TopCollision(b);
                }

                if (b is ICollisionHandler)
                {
                    b.As <ICollisionHandler>().BotCollision(a);
                }
            }
            else if (collision == CollisionResult.Bottom)
            {
                if (a is ICollisionHandler)
                {
                    a.As <ICollisionHandler>().BotCollision(b);
                }

                if (b is ICollisionHandler)
                {
                    b.As <ICollisionHandler>().TopCollision(a);
                }
            }
        }
Exemplo n.º 5
0
        private void OnTriggerEnter(Collider other)
        {
            if (other.As <IUnitProperties>() == null)
            {
                return;
            }

            var unit = other.GetUnitFacade();

            if (unit == null)
            {
                return;
            }

            var grp = unit.transientGroup;

            if (grp == null)
            {
                return;
            }

            if (grp.currentWaypoints.count <= 1)
            {
                Vector3 lastPOI = _poiSource.GetPOI(this.transform.position);
                for (int i = 0; i < waypointIterations; i++)
                {
                    grp.MoveTo(lastPOI, true);
                    lastPOI = _poiSource.GetPOI(lastPOI);
                }
            }

            float lastChanged;

            if (_recentlyChanged.TryGetValue(grp, out lastChanged) && (Time.time - lastChanged) < 10f)
            {
                return;
            }

            _recentlyChanged[grp] = Time.time;

            var randomFormation = grp.currentFormation == null?GetFormation(Random.Range(0, 6)) : GetRandomFormation(grp.currentFormation);

            grp.SetFormation(randomFormation);
        }
Exemplo n.º 6
0
        private void OnTriggerEnter(Collider otherCollider)
        {
            if (otherCollider.As <IUnitProperties>() == null)
            {
                return;
            }

            var unit = otherCollider.GetUnitFacade();

            if (unit == null)
            {
                return;
            }

            var grp = unit.transientGroup as DefaultSteeringTransientUnitGroup;

            float currentTime = Time.time;

            if (currentTime - _startTime < this.groupCreationTime)
            {
                if (grp == null)
                {
                    if (_group == null)
                    {
                        _group = new DefaultSteeringTransientUnitGroup(1);
                    }

                    _group.Add(unit);
                    StartCoroutine(DelayedMove());
                }
            }
            else
            {
                if (grp != null)
                {
                    if (++_groupCount >= grp.count + 1)
                    {
                        grp.MoveTo(moveToTarget, false);
                        _groupCount = 0;
                    }
                }
            }
        }