コード例 #1
0
ファイル: BossScript.cs プロジェクト: ampaulg/Eyeball-Galaxy
    protected override void Start()
    {
        base.Start();

        gun = GetComponent <GunScript>();
        gun.ShooterTransform = transform;
    }
コード例 #2
0
        public void reapply()
        {
            //This is AmmoDisplay getting all of the GunScripts from this weapon, then saving the primary and secondary.
            gunScripts = this.GetComponents <GunScript>();
            GunScript g;

            for (int i = 0; i < gunScripts.Length; i++)
            {
                g = gunScripts[i] as GunScript;
                if (g.isPrimaryWeapon)
                {
                    gunScript = g;
                }
            }
            for (int q = 0; q < gunScripts.Length; q++)
            {
                g = gunScripts[q] as GunScript;
                if (!g.isPrimaryWeapon)
                {
                    if (gunScript.secondaryWeapon == g)
                    {
                        gunScriptSecondary = g;
                    }
                }
            }
        }
コード例 #3
0
ファイル: Hud.cs プロジェクト: qkralsrl1029/FPS-survival_ex
 void checkBullet()
 {
     currentGun         = theGunController.GetGun();
     bulletText[0].text = currentGun.carryBulletCount.ToString();
     bulletText[1].text = currentGun.reloadBulletCount.ToString();
     bulletText[2].text = currentGun.currentBulletCount.ToString();
 }
コード例 #4
0
    public GameObject bloodEffect; //blod effect prefab;

    /*
     * Upon hitting enemy it calls this method, gives it raycast hit info
     * and at that position it creates our blood prefab.
     */
    void InstantiateBlood(RaycastHit _hitPos, bool swordHitWithGunOrNot)
    {
        if (currentWeapo == "gun")
        {
            GunScript.HitMarkerSound();

            if (_hitSound)
            {
                _hitSound.Play();
            }
            else
            {
                print("Missing hit sound");
            }

            if (!swordHitWithGunOrNot)
            {
                if (bloodEffect)
                {
                    Instantiate(bloodEffect, _hitPos.point, Quaternion.identity);
                }
                else
                {
                    print("Missing blood effect prefab in the inspector.");
                }
            }
        }
    }
コード例 #5
0
ファイル: AmmoSet.cs プロジェクト: Elnya/FPS-Constructor-CS
 public void Apply(GunScript gscript)
 {
     gscript.ApplyToSharedAmmo();
     cache = gscript.ammoSetUsed;
     gscript.ammoSetUsed = val;
     gscript.AlignToSharedAmmo();
 }
コード例 #6
0
    // Use this for initialization
    void Start()
    {
        AIScript s = ((AIScript)gameObject.GetComponent<AIScript>());
        s.AddStateScript(this);

        g = this.gameObject.GetComponent<GunScript>();
    }
コード例 #7
0
ファイル: GameManager0.cs プロジェクト: RJTimmerman/inf-game
    private void Awake()
    {
        objectiveText = GameObject.Find("Objective Text").GetComponent <TextMeshProUGUI>(); objectiveText.text = objective; objectiveText.CrossFadeAlpha(0, 0, true);
        savedText     = GameObject.Find("Saved Text").GetComponent <TextMeshProUGUI>(); savedText.CrossFadeAlpha(0, 0, true);
        deathScreen   = GameObject.Find("Death Screen"); deathScreen.SetActive(false);
        victoryScreen = GameObject.Find("Victory Screen"); victoryScreen.SetActive(false);


        player           = GameObject.Find("Player");
        playerController = player.GetComponent <PlayerControllerCC>();
        playerHealth     = player.GetComponent <PlayerHealth>();
        cameraScript     = player.GetComponentInChildren <MouseRotate>();

        foreach (Transform child in player.transform.Find("First Person Camera"))
        {
            if (child.name.StartsWith("Gun "))
            {
                ownedGuns.Add(child.GetComponent <GunScript>()); if (child.gameObject.activeInHierarchy)
                {
                    currentGun = child.GetComponent <GunScript>();
                }
            }
        }
        enemies       = new List <GameObject>(GameObject.FindGameObjectsWithTag("Enemy"));
        livingEnemies = enemies.ToList();
    }
コード例 #8
0
ファイル: PowerUps.cs プロジェクト: arvindsouza/Apeocalypse
 // Use this for initialization
 void Start()
 {
     poweredUp = false;
     canPick   = 0;
     anim      = GetComponent <Animator>();
     gun       = FindObjectOfType <GunScript>();
 }
コード例 #9
0
ファイル: PlayAnim.cs プロジェクト: Elnya/FPS-Constructor-CS
 public void Remove(GunScript g)
 {
     if (removeAnim != "" && g.gunActive)
     {
         transform.parent.BroadcastMessage("PlayAnim", applyAnim);
     }
 }
コード例 #10
0
    void Update()
    {
        var mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        MouseOutlineTransform.position = new Vector3(mousePosition.x, mousePosition.y, 0F);
        var mouseX = mousePosition.x;

        if (mouseX > 0)
        {
            changeGunDirection(1);
            this.transform.position = new Vector3(mousePosition.x + 0.5F, this.transform.position.y, 0F);
        }
        else
        {
            changeGunDirection(-1);
            this.transform.position = new Vector3(mousePosition.x - 0.5F, this.transform.position.y, 0F);
        }

        bool shoot = Input.GetButtonDown("Fire1");

        shoot |= Input.GetButtonDown("Fire2");

        if (shoot)
        {
            GunScript gun = GetComponent <GunScript>();
            if (gun != null)
            {
                gun.Attack(MouseOutlineTransform.position);
            }
        }
    }
コード例 #11
0
    void AimAction(int i)
    {
        // --------------------- Aim --------------------------
        if (activeDevices[i] == Device.KeyboardMouse)                                                   // Mouse aiming

        {
            mouseInput = Input.mousePosition;

            activeGun = Main.Player <PuppetManip>(i).GetActiveGunScript();
            if (activeGun != null)
            {
                activeGun.MouseAimUpdate(mouseInput, i);
            }
            //Debug.Log(DeviceNames[ (int)activeDevices[i] ] + "_Mouse" + mouseInput);
        }
        else                                                                                                                                                                                                                                            // Normal aiming
        {
            aimInput.x = Input.GetAxisRaw(DeviceNames[(int)activeDevices[i]] + "_AimHorizontal");
            aimInput.y = Input.GetAxisRaw(DeviceNames[(int)activeDevices[i]] + "_AimVertical");

            activeGun = Main.Player <PuppetManip>(i).GetActiveGunScript();
            if (activeGun != null)
            {
                activeGun.KeyAimUpdate(aimInput, i);
            }
            //Debug.Log( DeviceNames[ (int)activeDevices[i] ] + "_Aim" + aimInput);
        }
    }
コード例 #12
0
    public override void OnInspectorGUI()
    {
        EditorUtility.SetDirty(target);
        GunScript gunScript = (GunScript)target;

        gunScript.active      = EditorGUILayout.Toggle("Enabled", gunScript.active);
        gunScript.hitEffect   = (GameObject)EditorGUILayout.ObjectField("Hit Particle Effect", gunScript.hitEffect, typeof(GameObject), false);
        gunScript.shootSound  = (AudioClip)EditorGUILayout.ObjectField("Sound of Shot", gunScript.shootSound, typeof(AudioClip), false);
        gunScript.emptySound  = (AudioClip)EditorGUILayout.ObjectField("Sound of Empty Shot", gunScript.emptySound, typeof(AudioClip), false);
        gunScript.reloadSound = (AudioClip)EditorGUILayout.ObjectField("Sound of Reload", gunScript.reloadSound, typeof(AudioClip), false);

        EditorGUILayout.Space();
        gunScript.damage      = EditorGUILayout.FloatField("Damage", gunScript.damage);
        gunScript.range       = Mathf.Max(EditorGUILayout.FloatField("Bullet Range", gunScript.range), 0);
        gunScript.automatic   = EditorGUILayout.Toggle("Automatic Firing", gunScript.automatic);
        gunScript.cooldown    = Mathf.Max(EditorGUILayout.FloatField("Shot Cooldown (s)", gunScript.cooldown), 0);
        gunScript.useMagazine = EditorGUILayout.Toggle("Use Magazines", gunScript.useMagazine);
        if (gunScript.useMagazine)
        {
            EditorGUI.indentLevel++;
            gunScript.magazineSize = Mathf.Max(EditorGUILayout.IntField("Magazine Size", gunScript.magazineSize), 1);
            gunScript.bulletsInMag = Mathf.Max(EditorGUILayout.IntField("Bullets in Magazine", gunScript.bulletsInMag), 0);
            gunScript.reloadTime   = Mathf.Max(EditorGUILayout.FloatField("Reload Time (s)", gunScript.reloadTime), 0);
            gunScript.autoReload   = EditorGUILayout.Toggle("Automatic Reloading", gunScript.autoReload);
            EditorGUI.indentLevel--;
        }
        GUILayout.BeginHorizontal();
        if (!gunScript.infiniteBullets)
        {
            gunScript.bulletPile = Mathf.Max(EditorGUILayout.IntField("Other Bullets", gunScript.bulletPile), 0);
        }
        gunScript.infiniteBullets = EditorGUILayout.Toggle("Infinite Bullets", gunScript.infiniteBullets);
        GUILayout.EndHorizontal();
    }
コード例 #13
0
ファイル: PlayerShooting.cs プロジェクト: BenV1121/GGJ
    // Use this for initialization
    void Start()
    {
        script = GetComponent("Gun" + gun + "Script") as GunScript;
        script.SwitchIn();

        //anim = GetComponentInParent<Animator>();
    }
コード例 #14
0
 void Start()
 {
     playerScript  = GetComponent <PlayerScript>();
     inputScript   = GetComponent <InputScript>();
     gunScript     = transform.GetComponentInChildren <GunScript>();
     grappleScript = transform.GetComponentInChildren <GrappleScript>();
     xRotation     = 0f;
 }
コード例 #15
0
 private void GetAutoRifleAmmoInfo()
 {
     // Get automatic rifle ammo info
     auto_rifle_script   = auto_rifle.GetComponent <GunScript>();
     auto_rifle_max_ammo = auto_rifle_script.maxAmmo;
     auto_rifle_ammo     = auto_rifle_script.currentAmmo;
     auto_rifle_mags     = auto_rifle_script.mags;
 }
コード例 #16
0
    // Start is called before the first frame update
    void Start()
    {
        gunObject        = transform.parent.parent.parent.GetComponent <GunScript>(); // Gets gun object
        materialRenderer = GetComponent <Renderer>();                                 // Gets material renderer

        maxLightIntensity = gunObject.maxLightMult;                                   // Sets max light strength
        minLightIntensity = gunObject.normLightMult;                                  // Sets min light strength
    }
コード例 #17
0
 // Start is called before the first frame update
 void Start()
 {
     audioSource      = GetComponent <AudioSource>();
     audioSource.clip = iceNoise;
     gun       = GetComponentInChildren <GunScript>();
     hook      = grappleHook.GetComponent <HookScript>();
     hook.ammo = 1f;
 }
コード例 #18
0
    public void GunInteraction(GunScript gun)
    {
        _gunScript.DropGun();

        HoldGun(gun);
        _playerController.RemoveTriggersFromList(_closestGameObject.GetComponents <Collider>());
        _gunScript = gun;
    }
コード例 #19
0
 public void AddGun(GunScript gun)
 {
     if(guns == null)
     {
         guns = new List<GunScript>();
     }
     guns.Add(gun);
 }
コード例 #20
0
        public void BuyAmmo(WeaponInfo g)
        {
            withdraw(g.ammoPrice);
            GunScript temp = g.gameObject.GetComponent <GunScript>().GetPrimaryGunScript();

            temp.clips = Mathf.Min(temp.clips + temp.ammoPerClip, temp.maxClips);
            temp.ApplyToSharedAmmo();
        }
コード例 #21
0
 public void Remove(GunScript gscript)
 {
     gscript.ammoPerClip -= cache;
     if (gscript.ammoLeft > gscript.ammoPerClip)
     {
         gscript.ammoLeft = gscript.ammoPerClip;
     }
 }
コード例 #22
0
ファイル: GunScriptEditor.cs プロジェクト: robinkunde/7DFPS
    private void OnEnable()
    {
        gun_script = (GunScript)target;
        systems    = gun_script.GetGunSystems();

        possible_components = typeof(GunComponent).GetAllDerivedTypes();
        possible_systems    = typeof(GunSystemBase).GetAllDerivedTypes(systems.GetType());
        Update();
    }
コード例 #23
0
 public void SwitchGun(GunScript gun)
 {
     if (currentGun != null)
     {
         Destroy(gun.gameObject);
     }
     currentGun = Instantiate(gun, gunPos.position, gunPos.rotation);
     currentGun.transform.parent = gunPos;
 }
コード例 #24
0
    void Start()
    {
        gun     = transform.GetChild(0).gameObject;
        grapple = transform.GetChild(1).gameObject;

        playerScript  = GetComponent <PlayerScript>();
        gunScript     = gun.GetComponent <GunScript>();
        grappleScript = grapple.GetComponent <GrappleScript>();
    }
コード例 #25
0
 public void Apply(GunScript gscript)
 {
     cache = val - gscript.ammoPerClip;
     gscript.ammoPerClip += cache;
     if (gscript.ammoLeft > gscript.ammoPerClip)
     {
         gscript.ammoLeft = gscript.ammoPerClip;
     }
 }
コード例 #26
0
 void Awake()
 {
     playerTransform = transform;
     playerBody      = GetComponent <Rigidbody2D>();
     playerAnim      = GetComponent <Animator>();
     playerRender    = GetComponent <SpriteRenderer>();
     armRender       = transform.GetChild(0).gameObject.GetComponent <SpriteRenderer>();
     gun             = transform.GetChild(0).gameObject.GetComponent <GunScript>();
 }
コード例 #27
0
 // Start is called before the first frame update
 void Start()
 {
     _hero       = GetComponent <Rigidbody2D>();
     _heroZone   = GetComponent <Collider2D>();
     _heroImages = GetComponentsInChildren <SpriteRenderer>();
     Debug.Log($"Init projectile {projectile.GetHashCode()}");
     _direction = new Vector3(1, 0);
     _gun       = _marker.GetComponent <GunScript>();
 }
コード例 #28
0
    void Update()
    {
        player = GameObject.FindGameObjectWithTag("LocalPlayer");
        GunScript gunScript = player.GetComponentInChildren <GunScript>();

        leftBar.GetComponent <RectTransform>().localScale   = new Vector2(initialScale.x, (gunScript.ammo > 0) ? initialScale.y : 0f);
        centerBar.GetComponent <RectTransform>().localScale = new Vector2(initialScale.x, (gunScript.ammo > 1) ? initialScale.y : 0f);
        rightBar.GetComponent <RectTransform>().localScale  = new Vector2(initialScale.x, (gunScript.ammo > 2) ? initialScale.y : 0f);
    }
コード例 #29
0
 void Start()
 {
     gScript     = GameObject.FindGameObjectWithTag("Gun").GetComponent <GunScript>();
     soundScript = GameObject.FindGameObjectWithTag("Sound").GetComponent <SoundScript>();
     anim        = gameObject.GetComponent <Animator>();
     InvokeRepeating("Flap", 0.15f, 0.15F);
     ranSpeed     = Random.Range(0.002f, 0.008f);
     RandomColour = Random.Range(1, 5);
     anim.SetInteger("IntChooser", RandomColour);
 }
コード例 #30
0
    void updateGunUI()
    {
        gunImage.sprite = currWeapon.GetComponent <SpriteRenderer>().sprite;

        gunName.text = currWeapon.GetComponent <WeaponPickup>().weaponName;

        gun          = currWeapon.GetComponent <GunScript>();
        gun.ammoText = AmmoText;
        gun.setAmmoCounter();
    }
コード例 #31
0
    private void HoldGun(GunScript gunScript)
    {
        if (gunScript)
        {
            _gunScript = gunScript;
            _gunScript.HoldGun(_playerController.RightHand, _playerController.GunAnchor);

            _animationsController.HoldGunIK.Gun = _gunScript.transform;
        }
    }
コード例 #32
0
    public void SwitchWeapons(int weaponIndex)
    {
        // If a weapon is equiped, disable it
        if (currentWeapon != -1)
            weapons[currentWeapon].SetActive(false);

        currentWeapon = weaponIndex;
        // Enable the new weapon
        weapons[currentWeapon].SetActive(true);
        weaponScript = weapons[currentWeapon].GetComponent<GunScript>();
    }
コード例 #33
0
 // Use this for initialization
 void Awake()
 {
     if (mainPlayer == null) {
         DontDestroyOnLoad (gameObject);
         mainPlayer = this;
     } else if (mainPlayer!=this) {
         Destroy (gameObject);
     }
     gun = GetComponentInChildren<GunScript> ();
     ship = GetComponentInChildren<ShipController> ();
     platformer = GetComponentInChildren<PlatformController> ();
 }
コード例 #34
0
 void Update()
 {
     _getGun = gun.GetComponent<GunScript>();
 }
コード例 #35
0
ファイル: Rapid.cs プロジェクト: Vylantze/Chaos-Children
 // Use this for initialization
 void Start()
 {
     gun = GetComponentInParent<GunScript> ();
     master = MasterPlayer.mainPlayer;
 }