コード例 #1
0
ファイル: lv3Dialogues.cs プロジェクト: shujiank/gbl_g1
 void OnTriggerEnter(Collider other)
 {
     Debug.Log(other.gameObject.name);
     Debug.Log("collision happened");
     if (this.gameObject.name == "NPC1")
     {
         curContent = GameInfo.R_SContent;
     }
     if (this.gameObject.name == "NPC2")
     {
         curContent = GameInfo.Stretch_shearContent;
     }
     if (this.gameObject.name == "NPC3")
     {
         curContent = GameInfo.StretchOnLineContent;
     }
     if (this.gameObject.name == "NPC4")
     {
         curContent = GameInfo.RotationContent;
     }
     FrameworkCore.setContent(curContent);
     sword.showBox();
 }
        private void NPCshoot()
        {
            if (thisNPC != null && thisNPCBrain != null && thisNPC.brain.currentTarget != null)
            {
                var npcAimAngle = NpcAimingAngle(BrainBow, npcRayCastPoint.TransformDirection(Vector3.forward), module.npcDistanceToFire);
                if (Physics.Raycast(npcRayCastPoint.position, npcAimAngle, out RaycastHit hit, module.npcDetectionRadius))
                {
                    Creature target = null;
                    if (hit.collider.transform.root.name.Contains("Player") || hit.collider.transform.root.name.Contains("Pool_Human"))
                    {
                        target = hit.collider.transform.root.GetComponentInChildren <Creature>();
                    }

                    if (target != null && thisNPC != target &&
                        thisNPC.faction.attackBehaviour != GameData.Faction.AttackBehaviour.Ignored && thisNPC.faction.attackBehaviour != GameData.Faction.AttackBehaviour.Passive &&
                        target.faction.attackBehaviour != GameData.Faction.AttackBehaviour.Ignored && (thisNPC.faction.attackBehaviour == GameData.Faction.AttackBehaviour.Agressive || thisNPC.factionId != target.factionId))
                    {
                        Fire(true);
                        FrameworkCore.DamageCreatureCustom(target, module.npcDamageToPlayer, hit.point);
                        npcShootDelay = UnityEngine.Random.Range(BrainBow.bowAimMinMaxDelay.x, BrainBow.bowAimMinMaxDelay.y);
                    }
                }
            }
        }
コード例 #3
0
 public void hitContentTwo()
 {
     FrameworkCore.setContent(contentTwo);
     updateDisplay();
 }
コード例 #4
0
        public void OnHeldAction(RagdollHand interactor, Handle handle, Interactable.Action action)
        {
            if (handle.Equals(mainHandle))
            {
                // Trigger Action
                if (action == Interactable.Action.UseStart)
                {
                    // Begin Firing
                    triggerPressed = true;
                    if (!isFiring)
                    {
                        StartCoroutine(FrameworkCore.GeneralFire(TrackedFire, TriggerIsPressed, fireModeSelection, module.fireRate, module.burstNumber, emptySound, SetFiringFlag, ProjectileIsSpawning));
                    }
                }
                if (action == Interactable.Action.UseStop)
                {
                    // End Firing
                    triggerPressed = false;
                }

                // "Spell-Menu" Action
                if (action == Interactable.Action.AlternateUseStart)
                {
                    spellMenuPressed = true;
                    if (SlideToggleLock())
                    {
                        return;
                    }

                    StartLongPress();
                }
                if (action == Interactable.Action.AlternateUseStop)
                {
                    spellMenuPressed = false;
                }
            }

            if (action == Interactable.Action.Grab)
            {
                if (handle.Equals(mainHandle))
                {
                    if (interactor.playerHand == Player.local.handRight)
                    {
                        mainHandleHeldRight = true;
                    }
                    if (interactor.playerHand == Player.local.handLeft)
                    {
                        mainHandleHeldLeft = true;
                    }

                    if ((mainHandleHeldRight || mainHandleHeldLeft) && (slideController != null))
                    {
                        slideController.UnlockSlide();
                    }
                }

                if (handle.Equals(slideHandle))
                {
                    if (interactor.playerHand == Player.local.handRight)
                    {
                        slideHandleHeldRight = true;
                    }
                    if (interactor.playerHand == Player.local.handLeft)
                    {
                        slideHandleHeldLeft = true;
                    }
                    if (slideController != null)
                    {
                        slideController.SetHeld(true);
                    }
                    slideController.ForwardState();
                }
            }

            if (action == Interactable.Action.Ungrab)
            {
                if (handle.Equals(mainHandle))
                {
                    if (interactor.playerHand == Player.local.handRight)
                    {
                        mainHandleHeldRight = false;
                    }
                    if (interactor.playerHand == Player.local.handLeft)
                    {
                        mainHandleHeldLeft = false;
                    }

                    if (!mainHandleHeldRight && !mainHandleHeldLeft)
                    {
                        if (interactor.playerHand == Player.local.handRight)
                        {
                            slideHandleHeldRight = false;
                        }
                        if (interactor.playerHand == Player.local.handLeft)
                        {
                            slideHandleHeldLeft = false;
                        }
                        if (((slideController != null)))
                        {
                            slideController.LockSlide();
                        }
                        ForceDrop();
                    }
                }

                if (handle.Equals(slideHandle))
                {
                    if (slideController != null)
                    {
                        slideController.SetHeld(false);
                    }
                }
            }
        }
コード例 #5
0
        protected void LateUpdate()
        {
            if (checkForLongPress)
            {
                if (spellMenuPressed)
                {
                    if ((Time.time - lastSpellMenuPress) > module.longPressTime)
                    {
                        // Long Press Detected
                        if (module.longPressToEject)
                        {
                            MagazineRelease();
                        }
                        CancelLongPress();
                    }
                }
                else
                {
                    // Long Press Self Cancelled (released button before time)
                    // Short Press Detected
                    CancelLongPress();
                    if (!module.longPressToEject)
                    {
                        MagazineRelease();
                    }
                }
            }

            if (!mainHandleHeldLeft && !mainHandleHeldRight)
            {
                triggerPressed = false;
                if (slideController != null)
                {
                    slideController.LockSlide();
                }
            }
            if ((slideObject.transform.localPosition.z <= PULL_THRESHOLD) && !isPulledBack)
            {
                if (slideController != null)
                {
                    if (slideController.IsHeld())
                    {
                        // Entered PulledBack position
                        if (pullbackSound != null)
                        {
                            pullbackSound.Play();
                        }
                        isPulledBack    = true;
                        isRacked        = false;
                        playSoundOnNext = true;
                        if (!roundChambered)
                        {
                            chamberRoundOnNext = true;
                            UpdateAmmoCounter();
                        }
                        else
                        {
                            FrameworkCore.ShootProjectile(item, module.ammoID, shellEjectionPoint, null, module.shellEjectionForce, 1.0f, false, slideCapsuleStabilizer);
                            roundChambered     = false;
                            chamberRoundOnNext = true;
                        }
                        slideController.ChamberRoundVisible(false);
                    }
                }
            }
            if ((slideObject.transform.localPosition.z > (PULL_THRESHOLD - RACK_THRESHOLD)) && isPulledBack)
            {
                // Show chamber ammo
                if (CountAmmoFromMagazine() > 0)
                {
                    slideController.ChamberRoundVisible(true);
                }
            }
            if ((slideObject.transform.localPosition.z >= RACK_THRESHOLD) && !isRacked)
            {
                // Entered Rack position"
                isRacked     = true;
                isPulledBack = false;

                if (chamberRoundOnNext)
                {
                    if (ConsumeOneFromMagazine())
                    {
                        slideController.ChamberRoundVisible(true);
                        chamberRoundOnNext = false;
                        roundChambered     = true;
                    }
                }
                if (playSoundOnNext)
                {
                    if (rackforwardSound != null)
                    {
                        rackforwardSound.Play();
                    }
                    playSoundOnNext = false;
                }
                UpdateAmmoCounter();
            }

            if (slideController != null)
            {
                slideController.FixCustomComponents();
            }
            else
            {
                return;  // TODO: Remove this return, so we initialize even if we don't fix custom components
            }
            if (slideController.initialCheck)
            {
                return;
            }
            try
            {
                if (mainHandleHeldRight || mainHandleHeldLeft)
                {
                    slideController.UnlockSlide();
                    slideController.initialCheck = true;
                }
            }
            catch { Debug.Log("[Fisher-ModularFirearms] Slide EXCEPTION"); }
        }
        protected void LateUpdate()
        {
            if ((slideObject.transform.localPosition.z <= PULL_THRESHOLD) && !isPulledBack)
            {
                if (slideController != null)
                {
                    if (slideController.IsHeld())
                    {
                        //currentSlideState = false;
                        if (pullbackSound != null)
                        {
                            pullbackSound.Play();
                        }
                        isPulledBack    = true;
                        isRacked        = false;
                        playSoundOnNext = true;
                        slideController.LockedBackState();
                        FrameworkCore.Animate(Animations, module.openAnimationRef);
                        shellReceiver.data.disableTouch = false;
                        //if (shellReceiver.data.locked && (currentReceiverAmmo < module.maxReceiverAmmo))
                        //{
                        //    shellReceiver.data.locked = false;
                        //}
                        if (roundChambered)
                        {
                            if (roundSpent)
                            {
                                FrameworkCore.ShootProjectile(item, module.shellID, shellEjectionPoint, null, module.shellEjectionForce, 1.0f, false, slideCapsuleStabilizer);
                            }
                            else
                            {
                                FrameworkCore.ShootProjectile(item, module.ammoID, shellEjectionPoint, null, module.shellEjectionForce, 1.0f, false, slideCapsuleStabilizer);
                            }
                            roundChambered = false;
                            slideController.ChamberRoundVisible(false);
                        }
                        if (CountAmmoFromReceiver() > 0)
                        {
                            chamberRoundOnNext = true;
                        }
                    }
                }
            }
            if ((slideObject.transform.localPosition.z > (PULL_THRESHOLD - RACK_THRESHOLD)) && isPulledBack)
            {
                if (CountAmmoFromReceiver() > 0)
                {
                    slideController.ChamberRoundVisible(true);
                }
            }
            if ((slideObject.transform.localPosition.z >= RACK_THRESHOLD) && !isRacked)
            {
                //currentSlideState = true;
                isRacked     = true;
                isPulledBack = false;
                shellReceiver.data.disableTouch = true;
                slideController.ForwardState();
                FrameworkCore.Animate(Animations, module.closeAnimationRef);
                if (playSoundOnNext)
                {
                    if (rackforwardSound != null)
                    {
                        rackforwardSound.Play();
                    }
                    playSoundOnNext = false;
                }

                if (chamberRoundOnNext)
                {
                    if (!ConsumeOneFromReceiver())
                    {
                        return;
                    }
                    slideController.ChamberRoundVisible(true);
                    chamberRoundOnNext = false;
                    roundChambered     = true;
                    roundSpent         = false;
                }
            }

            if (slideController != null)
            {
                slideController.FixCustomComponents();
            }
            else
            {
                return;
            }
            if (slideController.initialCheck)
            {
                return;
            }
            try
            {
                if (gunGripHeldRight || gunGripHeldLeft)
                {
                    slideController.UnlockSlide();
                    slideController.initialCheck = true;
                }
            }
            catch { Debug.Log("[ModularFirearmsFramework] Slide EXCEPTION"); }
        }
        public bool Fire()
        {
            PreFireEffects();
            //FirearmFunctions.ShotgunBlast(item, module.projectileID, rayCastPoint, module.blastRange, module.blastForce, module.bulletForce, FirearmFunctions.GetItemSpellChargeID(item), module.throwMult, false, slideCapsuleStabilizer);
            //FirearmFunctions.ProjectileBurst(item, module.projectileID, muzzlePoint,  FirearmFunctions.GetItemSpellChargeID(item), module.bulletForce, module.throwMult, false, slideCapsuleStabilizer);
            ItemData spawnedItemData = Catalog.GetData <ItemData>(module.projectileID, true);
            String   imbueSpell      = GetItemSpellChargeID(item);

            var projectileData = Catalog.GetData <ItemData>(module.projectileID, true);

            if ((muzzlePoint == null) || (String.IsNullOrEmpty(module.projectileID)))
            {
                return(false);
            }
            if (projectileData == null)
            {
                Debug.LogError("[ModularFirearmsFramework][ERROR] No projectile named " + module.projectileID.ToString());
                return(false);
            }
            foreach (Vector3 offsetVec in buckshotOffsetPosiitions)
            {
                projectileData.SpawnAsync(i =>
                {
                    try
                    {
                        //i.transform.position = muzzlePoint.position + offsetVec;
                        //i.transform.rotation = Quaternion.Euler(muzzlePoint.rotation.eulerAngles);
                        //i.rb.velocity = this.item.rb.velocity;
                        //i.rb.AddForce(i.rb.transform.forward * 1000.0f * module.bulletForce);
                        //this.item.IgnoreObjectCollision(i);
                        //i.IgnoreObjectCollision(this.item);
                        //i.IgnoreRagdollCollision(Player.local.creature.ragdoll);

                        i.Throw(1f, Item.FlyDetection.Forced);
                        item.IgnoreObjectCollision(i);
                        i.IgnoreObjectCollision(item);
                        i.IgnoreRagdollCollision(Player.local.creature.ragdoll);
                        IgnoreProjectile(this.item, i, true);
                        i.transform.position = muzzlePoint.position + offsetVec;
                        i.transform.rotation = Quaternion.Euler(muzzlePoint.rotation.eulerAngles);
                        i.rb.velocity        = item.rb.velocity;
                        i.rb.AddForce(i.rb.transform.forward * 1000.0f * module.bulletForce);

                        if (slideCapsuleStabilizer != null)
                        {
                            try
                            {
                                i.IgnoreColliderCollision(slideCapsuleStabilizer);
                                foreach (ColliderGroup CG in this.item.colliderGroups)
                                {
                                    foreach (Collider C in CG.colliders)
                                    {
                                        Physics.IgnoreCollision(i.colliderGroups[0].colliders[0], C);
                                    }
                                }
                                // i.IgnoreColliderCollision(shooterItem.colliderGroups[0].colliders[0]);
                                //Physics.IgnoreCollision(IgnoreArg1, projectile.definition.GetCustomReference(projectileColliderReference).GetComponent<Collider>());
                            }
                            catch { }
                        }

                        Projectiles.BasicProjectile projectileController = i.gameObject.GetComponent <Projectiles.BasicProjectile>();
                        if (projectileController != null)
                        {
                            projectileController.SetShooterItem(this.item);
                        }

                        //-- Optional Switches --//
                        //i.rb.useGravity = false;
                        //i.Throw(throwMult, Item.FlyDetection.CheckAngle);
                        //i.SetColliderAndMeshLayer(GameManager.GetLayer(LayerName.Default));
                        //i.SetColliderLayer(GameManager.GetLayer(LayerName.None));
                        //i.ignoredItem = shooterItem;
                        //shooterItem.IgnoreObjectCollision(i);
                        //Physics.IgnoreLayerCollision(GameManager.GetLayer(LayerName.None), GameManager.GetLayer(LayerName.Default));

                        if (!String.IsNullOrEmpty(imbueSpell))
                        {
                            // Set imbue charge on projectile using ItemProjectileSimple subclass
                            //Projectiles.SimpleProjectile projectileController = i.gameObject.GetComponent<Projectiles.SimpleProjectile>();
                            if (projectileController != null)
                            {
                                projectileController.AddChargeToQueue(imbueSpell);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.Log("[ModularFirearmsFramework] EXCEPTION IN SPAWNING " + ex.Message + " \n " + ex.StackTrace);
                    }
                },
                                          Vector3.zero,
                                          Quaternion.Euler(Vector3.zero),
                                          null,
                                          false);
            }

            //FirearmFunctions.ShootProjectile(item, module.projectileID, rayCastPoint, FirearmFunctions.GetItemSpellChargeID(item), module.bulletForce, 1.0f, false, slideCapsuleStabilizer, true);
            //FirearmFunctions.ShootProjectile(item, module.shellID, shellEjectionPoint, null, module.shellEjectionForce);
            FrameworkCore.ApplyRecoil(item.rb, module.recoilForces, 1.0f, gunGripHeldLeft || slideGripHeldLeft, gunGripHeldRight || slideGripHeldRight, module.hapticForce);
            return(true);
        }