コード例 #1
0
        public override void Merge(bool active)
        {
            base.Merge(active);
            if (active)
            {
                if (cloudEffectInstance != null)
                {
                    cloudEffectInstance.Despawn();
                }

                cloudEffectInstance = stormStartEffectData.Spawn(Player.currentCreature.transform.position, Quaternion.identity);
                cloudEffectInstance.Play();

                return;
            }
            Vector3 from  = Player.local.transform.rotation * PlayerControl.GetHand(Side.Left).GetHandVelocity();
            Vector3 from2 = Player.local.transform.rotation * PlayerControl.GetHand(Side.Right).GetHandVelocity();

            if (from.magnitude > SpellCaster.throwMinHandVelocity && from2.magnitude > SpellCaster.throwMinHandVelocity)
            {
                if (Vector3.Angle(from, mana.casterLeft.magicSource.position - mana.mergePoint.position) < 45f || Vector3.Angle(from2, mana.casterRight.magicSource.position - mana.mergePoint.position) < 45f)
                {
                    if (currentCharge > stormMinCharge && !EarthBendingController.LightningActive)
                    {
                        EarthBendingController.LightningActive = true;
                        mana.StartCoroutine(StormCoroutine());
                        mana.StartCoroutine(DespawnEffectDelay(cloudEffectInstance, 15f));
                        currentCharge = 0;
                        return;
                    }
                }
            }

            mana.StartCoroutine(DespawnEffectDelay(cloudEffectInstance, 1f));
        }
コード例 #2
0
        private void OnParticleCollision(GameObject other)
        {
            int numCollisionEvents = part.GetCollisionEvents(other, collisionEvents);

            foreach (ParticleCollisionEvent particleCollisionEvent in collisionEvents)
            {
                EffectInstance effectInstance = spikesCollisionEffectData.Spawn(particleCollisionEvent.intersection, Quaternion.identity);
                effectInstance.Play();

                foreach (Collider collider in Physics.OverlapSphere(particleCollisionEvent.intersection, 1f))
                {
                    if (collider.attachedRigidbody)
                    {
                        if (collider.GetComponentInParent <Creature>())
                        {
                            Creature creature = collider.GetComponentInParent <Creature>();
                            if (creature != Player.currentCreature)
                            {
                                if (creature.state != Creature.State.Dead)
                                {
                                    creature.brain.TryAction(new ActionShock(10, 12), true);
                                    creature.Damage(new CollisionInstance(new DamageStruct(DamageType.Energy, 5f)));
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
 public override void Merge(bool active)
 {
     base.Merge(active);
     if (active)
     {
         effectShown = true;
         textObject.transform.position = Player.currentCreature.mana.mergePoint.transform.position + new Vector3(0, 0.2f, 0);
         ringEffect = ringEffectData.Spawn(Player.currentCreature.mana.mergePoint.transform);
         ringEffect.Play();
         lineEffect = lineEffectData.Spawn(Player.currentCreature.mana.mergePoint.transform.position, Player.currentCreature.mana.mergePoint.transform.rotation);
         lineEffect.Play();
     }
     else
     {
         effectShown = false;
         ringEffect.Stop();
         ringEffect.Despawn();
         lineEffect.Stop();
         lineEffect.Despawn();
         textObject.SetActive(false);
         if (currentCharge == 1)
         {
             Physics.gravity = GetHandsPointingQuaternion() * Vector3.forward * 9.8f * GetHandDistanceInGs();
         }
     }
 }
コード例 #4
0
        IEnumerator IceSpikesCoroutine()
        {
            Vector3 pos = Player.currentCreature.transform.position;

            EffectInstance frostEffectInstance = frostEffectData.Spawn(pos, Quaternion.identity);

            frostEffectInstance.Play();

            foreach (Creature creature in Creature.list)
            {
                if (creature != Player.currentCreature && !creature.isKilled)
                {
                    float dist = Vector3.Distance(creature.transform.position, pos);
                    if (dist < frostRadius)
                    {
                        mana.StartCoroutine(FreezeCreature(creature, frozenDuration));
                    }
                }
            }

            yield return(new WaitForSeconds(6f));

            //stop
            frostEffectInstance.Stop();
            EarthBendingController.IceActive = false;
        }
コード例 #5
0
 public override void OnCrystalUse(Side side, bool active)
 {
     staffActive = active;
     if (active)
     {
         staffEffect = chargeEffectData.Spawn(imbue.colliderGroup.imbueShoot.position, Quaternion.identity);
         staffEffect.SetSource(imbue.colliderGroup.imbueShoot);
         staffEffect.SetParent(imbue.colliderGroup.collisionHandler.item.transform);
         ((EffectVfx)staffEffect.effects.Find(effect => effect is EffectVfx)).vfx.SetInt("State", 1);
         staffEffect.Play();
         Player.currentCreature.mana.StartCoroutine(StaffCoroutine());
     }
     else
     {
         if (previousItems != null)
         {
             previousItems.ForEach(item => item?.HeldItem().Reset(CastSource.Staff));
         }
         if (items != null)
         {
             items.ForEach(item => item?.HeldItem()?.Reset(CastSource.Staff));
         }
         staffEffect?.Stop();
         Throw(imbue.colliderGroup.collisionHandler.item.rb.GetPointVelocity(imbue.colliderGroup.imbueShoot.position), CastSource.Staff);
     }
     base.OnCrystalUse(side, active);
 }
コード例 #6
0
        public IEnumerator StormCoroutine()
        {
            Vector3 playerPos = Player.currentCreature.transform.position;

            //Get all creatures in range
            foreach (Creature creature in Creature.list)
            {
                if (creature != Player.currentCreature)
                {
                    if (creature.state != Creature.State.Dead)
                    {
                        float dist = Vector3.Distance(playerPos, creature.transform.position);
                        if (dist < stormRadius)
                        {
                            EffectInstance stormInst = stormEffectData.Spawn(creature.transform.position, Quaternion.identity);
                            stormInst.Play();


                            foreach (ParticleSystem particleSystem in stormInst.effects[0].gameObject.GetComponentsInChildren <ParticleSystem>())
                            {
                                if (particleSystem.gameObject.name == "CollisionDetector")
                                {
                                    ElectricSpikeCollision scr = particleSystem.gameObject.AddComponent <ElectricSpikeCollision>();
                                    scr.part = particleSystem;
                                    scr.spikesCollisionEffectData = spikesCollisionEffectData;
                                }
                            }

                            mana.StartCoroutine(DespawnEffectDelay(stormInst, 15f));

                            yield return(new WaitForSeconds(UnityEngine.Random.Range(0.1f, 0.4f)));
                        }
                    }
                }
                else
                {
                    EffectInstance stormInst = stormEffectData.Spawn(creature.transform.position + creature.transform.forward * 2, Quaternion.identity);
                    stormInst.Play();


                    foreach (ParticleSystem particleSystem in stormInst.effects[0].gameObject.GetComponentsInChildren <ParticleSystem>())
                    {
                        if (particleSystem.gameObject.name == "CollisionDetector")
                        {
                            ElectricSpikeCollision scr = particleSystem.gameObject.AddComponent <ElectricSpikeCollision>();
                            scr.part = particleSystem;
                            scr.spikesCollisionEffectData = spikesCollisionEffectData;
                        }
                    }

                    mana.StartCoroutine(DespawnEffectDelay(stormInst, 15f));
                }
            }

            yield return(new WaitForSeconds(10f));

            EarthBendingController.LightningActive = false;
        }
コード例 #7
0
 public override void Enter(DaggerBehaviour dagger, DaggerController controller)
 {
     base.Enter(dagger, controller);
     whooshEffect = Catalog.GetData <EffectData>("ClawsWhoosh").Spawn(dagger.transform);
     whooshEffect.Play();
     dagger.SetPhysics(0);
     dagger.CreateJoint();
     dagger.IgnoreDaggerCollisions();
     dagger.item.mainCollisionHandler.OnCollisionStartEvent += CollisionEvent;
 }
コード例 #8
0
ファイル: ItemThrust.cs プロジェクト: Kingo64/BasSDK
        protected void Awake()
        {
            item = this.GetComponent <Item>();
            item.OnHeldActionEvent += OnHeldAction;
            thrustTransform         = item.GetCustomReference("Thrust");
            module = item.data.GetModule <ItemModuleThrust>();
            EffectData effectData = Catalog.GetData <EffectData>(module.effectId);

            effectInstance = effectData.Spawn(this.transform, false);
            effectInstance.Play();
            effectInstance.SetIntensity(0);
        }
コード例 #9
0
 public virtual void Load(ItemPhysic.EffectHinge effectHingeData)
 {
     if (effectHingeData != null && hingeJoint != null)
     {
         data = effectHingeData;
         EffectData effectData = Catalog.GetData <EffectData>(effectHingeData.effectId);
         effectInstance = effectData.Spawn(this.transform.position, this.transform.rotation, this.transform, pooled: false);
         effectInstance.SetIntensity(0);
         effectInstance.Play();
         jointRb = hingeJoint.GetComponent <Rigidbody>();
         loaded  = true;
     }
 }
コード例 #10
0
 public void UpdateTrap(Vector3 position, bool armed)
 {
     if (this.armed)
     {
         return;
     }
     this.position = position;
     if (!this.armed && armed)
     {
         trapEffect.SetIntensity(1);
         trapEffect.Play();
     }
     this.armed = armed;
 }
コード例 #11
0
        public IEnumerator PlayEffectSound(float delay, EffectData effectData, Vector3 position, float despawnDelay = 0)
        {
            yield return(new WaitForSeconds(delay));

            EffectInstance effectInstance = effectData.Spawn(position, Quaternion.identity);

            effectInstance.Play();
            if (despawnDelay != 0)
            {
                yield return(new WaitForSeconds(despawnDelay));

                effectInstance.Stop();
            }
        }
コード例 #12
0
        private void OnParticleCollision(GameObject other)
        {
            int numCollisionEvents = part.GetCollisionEvents(other, collisionEvents);

            foreach (ParticleCollisionEvent particleCollisionEvent in collisionEvents)
            {
                EffectInstance effectInstance = rockCollisionEffectData.Spawn(particleCollisionEvent.intersection, Quaternion.identity);
                effectInstance.Play();

                foreach (Collider collider in Physics.OverlapSphere(particleCollisionEvent.intersection, rockExplosionRadius))
                {
                    if (collider.attachedRigidbody)
                    {
                        if (collider.GetComponentInParent <Creature>())
                        {
                            Creature creature = collider.GetComponentInParent <Creature>();
                            if (creature != Player.currentCreature)
                            {
                                if (creature.state == Creature.State.Alive)
                                {
                                    creature.ragdoll.SetState(Ragdoll.State.Destabilized);
                                }
                                StartCoroutine(AddForceCoroutine(collider.attachedRigidbody, particleCollisionEvent.intersection));
                            }
                        }
                        else if (collider.GetComponentInParent <Item>())
                        {
                            Item item = collider.GetComponentInParent <Item>();

                            if (item.mainHandler)
                            {
                                if (item.mainHandler.creature != Player.currentCreature)
                                {
                                    StartCoroutine(AddForceCoroutine(collider.attachedRigidbody, particleCollisionEvent.intersection));
                                }
                            }
                        }
                    }
                }
            }

            IEnumerator AddForceCoroutine(Rigidbody rb, Vector3 expPos)
            {
                yield return(new WaitForEndOfFrame());

                rb.AddExplosionForce(rockExplosionForce, expPos, rockExplosionForce, 1f, ForceMode.Impulse);
            }
        }
コード例 #13
0
        private void CollisionPlayerHolding(ref CollisionStruct collisionInstance)
        {
            if (collisionInstance.impactVelocity.magnitude > 2)
            {
                if (!collisionInstance.targetCollider.attachedRigidbody)
                {
                    if (Time.time - lastColTime > 1f)
                    {
                        lastColTime = Time.time;

                        if (aoeEffectData != null)
                        {
                            EffectInstance effect = aoeEffectData.Spawn(collisionInstance.contactPoint, Quaternion.LookRotation(collisionInstance.contactNormal));
                            effect.Play();
                        }

                        foreach (Creature creature in Creature.list)
                        {
                            if (Vector3.Distance(creature.body.transform.position, collisionInstance.contactPoint) < aoeRange)
                            {
                                if (creature == Creature.player)
                                {
                                    continue;
                                }
                                if (!creature.health.isKilled)
                                {
                                    if (IsBoss(creature))
                                    {
                                        Debug.Log("Ram is boss");
                                        creature.TryAction(new ActionStagger((creature.body.transform.position - collisionInstance.contactPoint).normalized, 10f, ActionStagger.Type.FallGround), true);
                                        continue;
                                    }
                                    else
                                    {
                                        creature.ragdoll.SetState(Creature.State.Destabilized);
                                    }
                                }

                                foreach (RagdollPart part in creature.ragdoll.parts)
                                {
                                    part.rb.AddExplosionForce(aoeForce * part.rb.mass, collisionInstance.contactPoint, aoeRange, 2f, ForceMode.Impulse);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #14
0
ファイル: Animals.cs プロジェクト: mattieshadow/Amnesia-RPG
 void Update()
 {
     foreach (Creature creature in Creature.list)
     {
         if (creature.gameObject.GetComponent <VampirismBoth>())
         {
             if (Vector3.Distance(creature.ragdoll.GetPart(RagdollPart.Type.Head).transform.position, transform.position) < 0.3f && !attacker)
             {
                 attacker = creature;
                 bleedEffect.Play();
             }
             else
             {
                 bleedEffect.Stop();
             }
         }
     }
     if (Vector3.Distance(Player.currentCreature.transform.position, transform.position) < 1)
     {
         scared      = true;
         scaredTimer = Time.time;
     }
     if (Time.time - scaredTimer > 10 && scared)
     {
         scared = false;
     }
     if (scared)
     {
         if (!animation.isPlaying)
         {
             animation.Play("Armature_Jump");
         }
         itemSheep.transform.position = itemSheep.transform.position + (gameObject.transform.forward * movementSpeed * Time.deltaTime);
         if (Physics.Raycast(itemSheep.transform.position + (itemSheep.transform.up * 0.1f), itemSheep.transform.forward, out RaycastHit hit, 999))
         {
             Debug.Log(Vector3.Distance(hit.point, itemSheep.transform.position));
         }
     }
     if (health <= 0)
     {
         itemSheep.Despawn();
     }
     if (Time.time - rotationTimer > 1)
     {
         rotationTimer = Time.time;
         itemSheep.transform.LookAt(transform);
     }
 }
コード例 #15
0
ファイル: DaggerSpell.cs プロジェクト: lyneca/DaggerSpell
 public override void Throw(Vector3 velocity)
 {
     if (summonedDagger && daggerActive)
     {
         base.Throw(velocity);
         EnableDagger();
         Rigidbody rb = summonedDagger.GetComponent <Rigidbody>();
         PointItemFlyRefAtTarget(summonedDagger, velocity, 1.0f);
         rb.AddForce(velocity * 5, ForceMode.Impulse);
         throwEffectInstance = throwEffect.Spawn(spellCaster.magicSource);
         throwEffectInstance.SetTarget(summonedDagger.transform);
         throwEffectInstance.Play();
         summonedDagger.Throw();
         daggerActive = false;
     }
 }
コード例 #16
0
        public void Init(HandleRagdoll handleRagdoll)
        {
            _ragdollGripEffectData = Catalog.GetData <EffectData>("SpellGravityGrab");
            //remove audio
            _ragdollGripEffect = _ragdollGripEffectData.Spawn(handleRagdoll.transform);
            foreach (var effect in _ragdollGripEffect.effects)
            {
                if (effect is EffectAudio)
                {
                    //mute
                    (effect as EffectAudio).audioSource.volume = 0;
                }
            }

            _ragdollGripEffect.Play();
        }
コード例 #17
0
        private void SpawnBulletInstance()
        {
            rotatingMergePoint = new GameObject("rotmpoint");

            bulletInstance = bulletEffectData.Spawn(rotatingMergePoint.transform);
            bulletInstance.Play();
            bulletInstance.SetIntensity(1f);

            foreach (ParticleSystem child in bulletInstance.effects[0].GetComponentsInChildren <ParticleSystem>())
            {
                if (child.gameObject.name == "Bullets")
                {
                    BulletCollisionClass scr = child.gameObject.AddComponent <BulletCollisionClass>();
                    scr.part          = child;
                    scr.bulletColData = bulletCollisionEffectData;
                }
            }
        }
コード例 #18
0
        protected IEnumerator BubbleCoroutine(float duration)
        {
            bubbleActive = true;
            StopCapture();
            EffectInstance bubbleEffect = null;

            if (bubbleEffectData != null)
            {
                bubbleEffect = bubbleEffectData.Spawn(captureTrigger.transform.position, Quaternion.identity, null, null, true, Array.Empty <Type>());
                bubbleEffect.SetIntensity(0f);
                bubbleEffect.Play(0);
            }
            yield return(new WaitForFixedUpdate());

            StartCapture(0f);
            captureTrigger.transform.SetParent(null);
            float startTime = Time.time;

            while (Time.time - startTime < duration)
            {
                if (!captureTrigger)
                {
                    yield break;
                }
                float num = bubbleScaleCurveOverTime.Evaluate((Time.time - startTime) / duration);
                captureTrigger.SetRadius(num * bubbleEffectMaxScale * 0.5f);
                if (bubbleEffect != null)
                {
                    bubbleEffect.SetIntensity(num);
                }
                yield return(null);
            }
            if (bubbleEffect != null)
            {
                bubbleEffect.End(false, -1f);
            }
            StopCapture();
            bubbleActive = false;
            yield break;
        }
コード例 #19
0
        public async void Fire()
        {
            playing        = true;
            effectInstance = effectData.Spawn(mana.mergePoint.position, mana.mergePoint.rotation);
            effectInstance.Play();

            await Task.Delay(2300);

            Collider[] hit = Physics.OverlapCapsule(mana.mergePoint.position, mana.mergePoint.position + (mana.mergePoint.forward * 8f), 0.7f);

            foreach (Collider collider in hit)
            {
                if (collider.attachedRigidbody)
                {
                    if (collider.GetComponentInParent <Creature>())
                    {
                        Creature creature = collider.GetComponentInParent <Creature>();

                        if (!creature.isPlayer)
                        {
                            if (!creature.isKilled)
                            {
                                creature.ragdoll.SetState(Ragdoll.State.Frozen);
                                collider.attachedRigidbody.AddForce(mana.mergePoint.forward * 30, ForceMode.Impulse);

                                CollisionInstance l_Dmg = new CollisionInstance(new DamageStruct(DamageType.Energy, damage));
                                creature.Damage(l_Dmg);
                            }
                        }
                    }
                }
            }

            await Task.Delay(2300);

            effectInstance.Stop();
            playing = false;
        }
コード例 #20
0
        IEnumerator FreezeCreature(Creature targetCreature, float duration)
        {
            EffectInstance effectInstance = frozenEffectData.Spawn(targetCreature.transform.position, Quaternion.identity, targetCreature.transform);

            effectInstance.Play();

            targetCreature.ragdoll.SetState(Ragdoll.State.Frozen);
            targetCreature.ragdoll.AddNoStandUpModifier(this);

            targetCreature.brain.Stop();

            yield return(new WaitForSeconds(duration));

            if (!targetCreature.isKilled)
            {
                targetCreature.ragdoll.SetState(Ragdoll.State.Destabilized);
                targetCreature.ragdoll.RemoveNoStandUpModifier(this);

                targetCreature.brain.Load(targetCreature.brain.instance.id);
            }

            effectInstance.Despawn();
        }
コード例 #21
0
        public void Begin(HoleType type, ref Item otherHole, CosmicSelfMerge spellData)
        {
            nomEffect     = nomEffect ?? Catalog.GetData <EffectData>("HoleAbsorb");
            pewEffect     = pewEffect ?? Catalog.GetData <EffectData>("HoleFire");
            ambientEffect = ambientEffect ?? Catalog.GetData <EffectData>((type == Black) ? "BlackHoleAmbient" : "WhiteHoleAmbient");

            itemSpamDelay   = spellData.itemSpamDelay;
            friction        = spellData.friction;
            throwTrackRange = spellData.throwTrackRange;
            throwTrackForce = spellData.throwTrackForce;
            throwForce      = spellData.throwForce;
            pushForce       = spellData.pushForce;
            pullForce       = spellData.pullForce;

            if (active)
            {
                return;
            }
            this.otherHole = otherHole;
            item           = GetComponent <Item>();
            effect         = ambientEffect.Spawn(transform);
            effect.Play();
            this.type = type;
        }
コード例 #22
0
        public IEnumerator BubbleCoroutine()
        {
            Vector3 centerPoint = mana.mergePoint.transform.position;


            EffectInstance bubbleEffect = null;

            bubbleEffect = bubbleEffectData.Spawn(centerPoint, Quaternion.identity);
            bubbleEffect.SetIntensity(0f);
            bubbleEffect.Play(0);

            ParticleSystem parentParticleSystem = bubbleEffect.effects[0].gameObject.GetComponent <ParticleSystem>();


            foreach (ParticleSystem particleSystem in parentParticleSystem.gameObject.GetComponentsInChildren <ParticleSystem>())
            {
                if (particleSystem.gameObject.name == "Portal")
                {
                    float startDelay = particleSystem.main.startDelay.constant;
                    Player.currentCreature.mana.StartCoroutine(PlayEffectSound(startDelay, portalEffectData, particleSystem.transform.position, 3f));
                }

                if (particleSystem.gameObject.name == "Rock")
                {
                    RockCollision scr = particleSystem.gameObject.AddComponent <RockCollision>();
                    scr.rockCollisionEffectData = rockCollisionEffectData;
                    scr.rockExplosionForce      = rockExplosionForce;
                    scr.rockExplosionRadius     = rockExplosionRadius;
                    scr.part = particleSystem;
                }
            }
            yield return(new WaitForSeconds(4.5f));

            bubbleEffect.Stop();
            EarthBendingController.GravActive = false;
        }
コード例 #23
0
        IEnumerator SlowCoroutine(Creature targetCreature, float energy, float maxSlow, float minSlow, float duration)
        {
            EffectData imbueHitRagdollEffectData = Catalog.GetData <EffectData>("ImbueIceRagdoll", true);

            effectInstance = imbueHitRagdollEffectData.Spawn(targetCreature.ragdoll.rootPart.transform, true, Array.Empty <Type>());
            effectInstance.SetRenderer(targetCreature.GetRendererForVFX(), false);
            effectInstance.Play(0);
            effectInstance.SetIntensity(1f);

            float animSpeed = Mathf.Lerp(minSlow, maxSlow, energy / 100);

            if (animSpeed != 0)
            {
                targetCreature.animator.speed   *= (animSpeed / 100);
                targetCreature.locomotion.speed *= (animSpeed / 100);
            }
            else
            {
                targetCreature.ragdoll.SetState(Ragdoll.State.Frozen);
                targetCreature.ragdoll.AddNoStandUpModifier(this);

                targetCreature.brain.Stop();
            }


            /*
             * targetCreature.animator.speed *= (animSpeed / 100);
             * targetCreature.locomotion.speed *= (animSpeed / 100);
             */



            yield return(new WaitForSeconds(duration));

            /*
             * targetCreature.animator.speed = 1;
             * targetCreature.locomotion.speed = targetCreature.data.locomotionSpeed;
             *
             *
             *
             * if (!targetCreature.brain.instance.isActive)
             * {
             *  targetCreature.brain.instance.Start();
             * }*/


            if (animSpeed != 0)
            {
                targetCreature.animator.speed   = 1;
                targetCreature.locomotion.speed = targetCreature.data.locomotionSpeed;
            }
            else
            {
                if (!targetCreature.isKilled)
                {
                    targetCreature.ragdoll.SetState(Ragdoll.State.Destabilized);
                    targetCreature.ragdoll.RemoveNoStandUpModifier(this);

                    targetCreature.brain.Load(targetCreature.brain.instance.id);
                }
            }



            effectInstance.Despawn();

            /*
             * targetCreature.umaCharacter.umaDCS.SetColor("Skin", defaultSkinColor, default(Color), 0, true);
             */
        }
コード例 #24
0
 public void Start()
 {
     item = GetComponent <Item>();
     rb   = item.rb;
     //item.mainCollisionHandler.damagers.ForEach(damager => damager.penetrationExitOnMaxDepth = true);
     controller = Player.currentCreature.mana.gameObject.GetComponent <DaggerController>();
     Catalog.GetData <EffectData>("SlingshotGrabPoint").Spawn(transform).Play();
     trailEffect = Catalog.GetData <EffectData>("ShiftTrail").Spawn(transform);
     trailEffect.SetIntensity(0);
     trailEffect.Play();
     item.OnSnapEvent += holder => {
         // item.lastHandler?.ClearTouch();
         // item.lastHandler = null;
         IntoState <DefaultState>();
         if (item.transform.parent.GetComponentsInChildren <Item>() is Item[] items && items.Count() > 1)
         {
             var slotToUse = holder.slots.FirstOrDefault(slot => slot.GetComponentsInChildren <Item>().Count() == 0);
             if (slotToUse == null)
             {
                 return;
             }
             var holderPoint = item.GetHolderPoint(holder.data.targetAnchor);
             item.transform.MoveAlign(holderPoint.anchor, slotToUse.transform, slotToUse.transform);
         }
         if (holder.GetComponentInParent <Item>() is Item holderItem)
         {
             item.IgnoreObjectCollision(holderItem);
         }
     };
     item.OnUnSnapEvent += holder => {
         if (holder.GetComponentInParent <Item>() is Item holderItem)
         {
             item.IgnoreObjectCollision(holderItem);
             item.RunNextFrame(() => item.IgnoreObjectCollision(holderItem));
         }
     };
     item.OnTelekinesisGrabEvent += (handle, grabber) => {
         if (!state.Grabbable())
         {
             IntoState <DefaultState>();
         }
     };
     item.OnGrabEvent += (handle, hand) => {
         IntoState <DefaultState>();
         foreach (var collider in hand.colliderGroup.colliders)
         {
             foreach (var group in item.colliderGroups)
             {
                 foreach (var otherCollider in group.colliders)
                 {
                     Physics.IgnoreCollision(collider, otherCollider);
                 }
             }
         }
         controller.RunAfter(() => {
             if (hand.caster?.spellInstance is SpellCastCharge spell)
             {
                 spell.imbueEnabled = true;
             }
         }, 0.5f);
     };
     item.OnUngrabEvent += (handle, hand, throwing) => {
         var velocity = Player.local.transform.rotation * PlayerControl.GetHand(hand.side).GetHandVelocity();
         if (throwing && velocity.magnitude > 3)
         {
             lastNoOrbitTime = Time.time;
             IntoState <DefaultState>();
         }
     };
     pidController = new PIDRigidbodyHelper(rb, 5, 1);
     if (state == null)
     {
         IntoState <DefaultState>();
     }
 }
コード例 #25
0
 void Update()
 {
     if (isPlayer)
     {
         if (Time.time - timer > RPGManager.statInfo.updateLevelTime)
         {
             timer             = Time.time;
             VampireSave.blood = blood;
             File.WriteAllText(Path.Combine(Application.streamingAssetsPath, "Mods/Amnesia RPG/Saves/vampiresave.json"), JsonConvert.SerializeObject(new VampireSave(), Formatting.Indented));
         }
     }
     foreach (Item item in Item.list)
     {
         if (Vector3.Distance(item.transform.position, vampire.ragdoll.GetPart(RagdollPart.Type.Head).transform.position + (vampire.ragdoll.GetPart(RagdollPart.Type.Head).transform.up * 0.1f)) < 0.25f)
         {
             foreach (Paintable paintable in item.paintables)
             {
                 if (Vector3.Distance(paintable.transform.position, vampire.ragdoll.GetPart(RagdollPart.Type.Head).transform.position + (vampire.ragdoll.GetPart(RagdollPart.Type.Head).transform.up * 0.1f)) < 0.10f)
                 {
                     paintable.Clear();
                 }
             }
         }
     }
     if (isPlayer && blood > 1 && vampire.currentHealth < vampire.maxHealth)
     {
         blood -= 0.01f * Time.deltaTime;
         vampire.currentHealth += 0.05f * Time.deltaTime;
     }
     blood -= 0.0025f * Time.deltaTime;
     foreach (Creature creature in Creature.list)
     {
         if (Vector3.Distance(vampire.ragdoll.GetPart(RagdollPart.Type.Head).transform.position, creature.ragdoll.GetPart(RagdollPart.Type.Neck).transform.position) < 0.3f && creature != vampire && !biteVictim)
         {
             biteVictim = creature;
         }
     }
     if (biteVictim)
     {
         if (biteEffect is null)
         {
             biteEffect = Catalog.GetData <EffectData>("Bleeding").Spawn(biteVictim.ragdoll.GetPart(RagdollPart.Type.Neck).transform.position, Quaternion.identity, biteVictim.ragdoll.GetPart(RagdollPart.Type.Neck).transform);
         }
         biteEffect.Play();
         if (isPlayer)
         {
             damage = TraitsManager.vampirismLvl * Time.deltaTime;
         }
         else
         {
             damage = Random.Range(1 * Time.deltaTime, 3 * Time.deltaTime);
         }
         if (biteVictim.currentHealth > damage)
         {
             biteVictim.currentHealth -= damage;
             vampire.currentHealth    += damage;
         }
         else
         {
             biteVictim.Kill();
             if (isPlayer)
             {
                 TraitsManager.vampirismExp += damage;
             }
         }
         if (isPlayer)
         {
             int divider;
             if (biteVictim.isKilled)
             {
                 divider = 100;
             }
             else
             {
                 divider = 50;
             }
             TraitsManager.vampirismExp += damage / divider;
             if (blood < 100)
             {
                 blood += damage / divider;
             }
         }
         if (Vector3.Distance(vampire.ragdoll.GetPart(RagdollPart.Type.Head).transform.position, biteVictim.ragdoll.GetPart(RagdollPart.Type.Neck).transform.position) > 0.3f)
         {
             biteVictim = null;
             biteEffect.Despawn();
             biteEffect = null;
         }
     }
 }
コード例 #26
0
        private void ReforgedCaestusItem_OnCollisionCreaturePlayerHoldingEvent(ref CollisionStruct collisionInstance, Creature hitCreature)
        {
            Debug.Log("HitCreature");
            if (hitCreature != Creature.player)
            {
                Debug.Log("HitCreature no player");
                if (Time.time - lastColTime > 0.8f)
                {
                    Debug.Log("HitCreature last time");
                    lastColTime = Time.time;

                    //spawn effect
                    if (coneEffectData != null)
                    {
                        EffectInstance effectInstance = coneEffectData.Spawn(item.transform.position, item.transform.rotation);
                        effectInstance.Play();
                    }

                    Vector3 forwards = item.transform.forward;

                    //Want to make sure it is punching forwards
                    if (Vector3.Dot(collisionInstance.impactVelocity.normalized, forwards) > 0.4f)
                    {
                        Debug.Log("HitCreature is punching forwards");
                        //get creatures in front
                        foreach (Creature creature in Creature.list)
                        {
                            if (creature != Creature.player)
                            {
                                if (!IsBoss(creature))
                                {
                                    float   distance  = Vector3.Distance(creature.transform.position, item.transform.position);
                                    Vector3 direction = (Vector3.ProjectOnPlane(creature.transform.position, Vector3.up) - Vector3.ProjectOnPlane(collisionInstance.contactPoint, Vector3.up)).normalized;

                                    if (distance < coneLength)
                                    {
                                        Debug.Log("HitCreature is in range");
                                        if (Vector3.Dot(direction, forwards) > coneAngle)
                                        {
                                            Debug.Log("HitCreature in in angle");
                                            if (!creature.health.isKilled)
                                            {
                                                creature.ragdoll.SetState(Creature.State.Destabilized);
                                            }

                                            foreach (RagdollPart part in creature.ragdoll.parts)
                                            {
                                                Vector3 force = direction;
                                                part.rb.AddForce(force * coneForce * part.rb.mass, ForceMode.Impulse);
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        if (!IsBoss(hitCreature))
                        {
                            //add force to the hit creature
                            if (!hitCreature.health.isKilled)
                            {
                                hitCreature.ragdoll.SetState(Creature.State.Destabilized);
                            }

                            foreach (RagdollPart part in hitCreature.ragdoll.parts)
                            {
                                Vector3 force = item.transform.forward;
                                part.rb.AddForce(force * coneForce * part.rb.mass, ForceMode.Impulse);
                            }
                        }
                    }
                }
            }
        }