Inheritance: MonoBehaviour
Esempio n. 1
0
 // Use this for initialization
 protected override void Start()
 {
     base.Start();
     controller    = GetComponent <PlayerController>(); // PlayerController와 Player 스크립트가 같은 오브젝트에 붙어 있다고 가정
     gunController = GetComponent <GunController>();
     viewCamera    = Camera.main;
 }
Esempio n. 2
0
 protected override void Start()
 {
     base.Start ();
     controller = GetComponent<PlayerController> ();
     gunController = GetComponent<GunController> ();
     viewCamera = Camera.main;
 }
Esempio n. 3
0
    private void DrawWeapon(int weaponID)
    {
        meleeObject.SetActive(false);

        GunController toInstantiate = WeaponDatabase.GetWeaponByID(weaponID);

        currentGC = (GunController)Instantiate(toInstantiate);
        currentGC.transform.parent        = weaponsParent;
        currentGC.transform.localPosition = toInstantiate.thirdPersonPosition;
        currentGC.transform.localRotation = toInstantiate.thirdPersonRotation;
        currentGC.StripFunctions(true);
        currentVisuals   = currentGC.GetComponent <GunVisuals>();
        muzzleBrightness = currentGC.muzzleLight.intensity;
        GetComponent <AudioSource>().PlayOneShot(drawSound, 0.7f);

        targetFireRate = 60f / Mathf.Max(currentGC.firstRPM, (currentGC.secondMode != GunController.FireMode.None) ? currentGC.secondRPM : 0f, (currentGC.thirdMode != GunController.FireMode.None) ? currentGC.thirdRPM : 0f);
        currentGHP     = null;
        pullPinSound   = null;
        throwSound     = null;

        if (currentVisuals)
        {
            foreach (GameObject go in currentVisuals.activateOnUse)
            {
                go.SetActive(false);
            }

            currentGC.firePos.GetComponent <AudioSource>().volume = 1f;
        }
    }
Esempio n. 4
0
    // Use this for initialization
    protected override void Start()
    {
        warningText.text = "";
        if(isInUse){
        audios = GetComponents<AudioSource>();

        walking = audios[1];

        shooting = audios[3];
        //	BGMusic.Play();
        //	BGMusic.volume = 0.8f;

        base.Start ();
        controller = GetComponent<PlayerController>();
        viewCamera = Camera.main;
        gunController = GetComponent<GunController>();
        }
        else{
            audios = GetComponents<AudioSource>();

            walking = audios[1];

            shooting = audios[3];
            base.Start ();
            controller = GetComponent<PlayerController>();
            viewCamera = Camera.main;
            gunController = GetComponent<GunController>();
        }
    }
Esempio n. 5
0
    void Update()
    {
        if (CEScript.ownGun == 1 && UIImage == OwnImage.Primary)
        {
            PriGCScript = CEScript.PrimaryWeapon.GetComponent <GunController>();

            // 武器を更新する
            selectGunSprite(PriGCScript.gunType, PrimaryImage);

            // 明るくする
            PrimaryImage.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);

            // 使っていない方は薄くする
            if (SecondaryImage != null)
            {
                SecondaryImage.color = new Color(1.0f, 1.0f, 1.0f, 0.5f);
            }
        }
        else if (CEScript.ownGun == 2 && UIImage == OwnImage.Secondary)
        {
            SecGCScript = CEScript.SecondaryWeapon.GetComponent <GunController>();

            // 武器を更新する
            selectGunSprite(SecGCScript.gunType, SecondaryImage);

            // 明るくする
            SecondaryImage.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);

            // 使っていない方は薄くする
            if (PrimaryImage != null)
            {
                PrimaryImage.color = new Color(1.0f, 1.0f, 1.0f, 0.5f);
            }
        }
    }
    private IEnumerator NextLevel()
    {
        yield return(new WaitForSeconds(3f));

        AsyncOperation op = SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex + 1);

        while (op != null && !op.isDone)
        {
            yield return(null);
        }
        _playerTransform = GameObject.FindGameObjectWithTag("Character")?.transform;
        fadeText         = GameObject.FindGameObjectWithTag("FadeText")?.GetComponent <FadeText>();

        PlayerMovement playerMovement = _playerTransform.gameObject.GetComponent <PlayerMovement>();
        GunController  gunController  = _playerTransform.gameObject.GetComponentInChildren <GunController>();

        playerMovement.StopPlayer();
        playerMovement.enabled = false;
        if (gunController != null)
        {
            gunController.enabled = false;
        }

        StartCoroutine(fadeText.DoShowAndHideIntro(2f));
        while (fadeText.Busy)
        {
            yield return(null);
        }

        playerMovement.enabled = true;
        if (gunController != null)
        {
            gunController.enabled = true;
        }
    }
    // public Gun gun;

    protected override void Start()
    {
        base.Start();
        myRigidBody   = GetComponent <Rigidbody>();
        gunController = GetComponent <GunController>();
        mainCamera    = FindObjectOfType <Camera>();
    }
Esempio n. 8
0
 void Awake()
 {
     controller    = GetComponent <PlayerController> ();
     gunController = GetComponent <GunController> ();
     viewCamera    = Camera.main;
     FindObjectOfType <Spawner> ().OnNewWave += OnNewWave;
 }
Esempio n. 9
0
 private void Awake()
 {
     playerController = GetComponent <PlayerController>();      //  assumo che PlayerController sia attaccato allo stesso oggetto a cui è attaccato questo script
     gunController    = GetComponent <GunController>();
     viewCamera       = Camera.main;
     FindObjectOfType <Spawner>().OnNewWave += OnNewWave;
 }
Esempio n. 10
0
 // Use this for initialization
 void Start()
 {
     asEngine        = GetComponent <AudioSource> ();
     car             = GetComponent <myCarController> ();
     gun             = GameObject.Find("SpawnRay").GetComponent <GunController> ();
     timeBetweenShot = gun.GetTimeBetweenShot();
 }
Esempio n. 11
0
    private void DrawGrenade(int grenadeID)
    {
        meleeObject.SetActive(false);

        GrenadeController toInstantiate = GrenadeDatabase.GetGrenadeByID(grenadeID);
        GrenadeController grenInstance  = (GrenadeController)Instantiate(toInstantiate);

        grenInstance.transform.parent        = weaponsParent;
        grenInstance.transform.localPosition = toInstantiate.thirdPersonPosition;
        grenInstance.transform.localRotation = toInstantiate.thirdPersonRotation;
        grenInstance.PrepareForMultiplayer();
        GetComponent <AudioSource>().PlayOneShot(drawSound, 0.7f);

        pullPinSound               = toInstantiate.pullPinSound;
        throwSound                 = toInstantiate.throwSound;
        currentGHP                 = grenInstance.GetComponent <GrenadeHandler_Proxy>();
        currentGHP.whp             = this;
        currentGHP.grenadePrefab   = grenInstance.grenadePrefab;
        currentGHP.displayMesh     = grenInstance.displayMesh;
        currentGHP.throwStr        = grenInstance.throwStrength;
        currentGHP.tossStr         = grenInstance.tossStrength;
        currentGHP.ignoreColliders = ignoreGrenades;
        baseDelay       = grenInstance.baseDelay;
        detonationDelay = grenInstance.detonationDelay;
        Destroy(grenInstance);

        currentGC      = null;
        currentVisuals = null;
    }
Esempio n. 12
0
    // Update is called once per frame
    void Update()
    {
        enemiesLeftDisplay = GameObject.Find("EnemiesLeftBox").GetComponent <Text>();

        healthDisplay = GameObject.Find("HealthDisplayBox").GetComponent <Text>();

        bulletsDisplay = GameObject.Find("BulletsDisplayBox").GetComponent <Text>();

        player = GameObject.Find("Yimmy");

        if (enemiesLeft < 1)
        {
            winBall.SetActive(true);
        }

        else
        {
            winBall.SetActive(false);
        }
        enemiesLeftDisplay.text = "Enemies Left: " + enemiesLeft;

        MyFirstPersonControler playerScript = player.GetComponent <MyFirstPersonControler>();

        healthDisplay.text = "Health: " + playerScript.playerHealth;

        GunController gunScript = gun.GetComponent <GunController>();

        bulletsDisplay.text = "Bullets Left: " + gunScript.bullets;

        //if (winBall == null && Input.GetKeyDown(KeyCode.Space))
        //{
        //  SceneManager.LoadScene("Scene_00", LoadSceneMode.Single);
        //  round++;
        //}
    }
Esempio n. 13
0
    void Awake()
    {
        _playerController = GetComponent <PlayerController>();
        _gunController    = GetComponent <GunController>();

        HealthDisplaySystem.DisplayHP(true);
    }
Esempio n. 14
0
 public override void Start()
 {
     base.Start();
     controller = GetComponent<PlayerController>();
     gunController = GetComponent<GunController>();
     cam = Camera.main;
 }
Esempio n. 15
0
    // Use this for initialization
    void Start()
    {
        weaponType = "Minigun";

        pController = GetComponent <PlayerController>();
        gController = FindObjectOfType <GunController>();
        viewCamera  = FindObjectOfType <Camera>();

        switch (weaponType)
        {
        case "Basic Blaster":
            bullets  = 30;
            cbullets = bullets;
            charges  = 2;    // 4 cargadores
            break;

        case "Minigun":
            bullets  = 60;
            cbullets = bullets;
            charges  = 10;    // 4 cargadores
            break;

        default:
            break;
        }
    }
Esempio n. 16
0
 // Use this for initialization
 void Start()
 {
     gmi     = GameManager.Instance;
     mainCam = FindObjectOfType <Camera>();
     gun     = GetComponentInChildren <GunController>();
     Invoke("LoadPlayer", 0.05f);
 }
Esempio n. 17
0
	void  Start () {
		maStoreCam = GameObject.FindGameObjectWithTag ("MainCameraStore");
		Destroy (maStoreCam);
		stScript = FindObjectOfType (typeof(StoreStuff)) as StoreStuff;
		money = 5;
		//money = System.Int32.Parse (stScript.moneyText.text);
		//Debug.Log ("Money is " + money);
		controller = GetComponent<PlayerController> ();
		gunController = GetComponent<GunController> ();
		
		moneyText = GameObject.FindGameObjectWithTag ("money");
		mText = moneyText.GetComponent<Text> ();
		viewCamera = Camera.main;
		//swordButton = GameObject.Find ("swordButton");
		startRot = transform.eulerAngles;
		sword = GameObject.FindGameObjectWithTag ("sword");
		bow = GameObject.FindGameObjectWithTag ("bow");
		
		sword.transform.localEulerAngles = new Vector3(0,90,50);
		sword.transform.position =  GameObject.FindGameObjectWithTag("hold").transform.position;
		sword.transform.SetParent(this.transform);
		
		playerHealth = 3.0;
		
		
		hltScript = FindObjectOfType (typeof(Health2)) as Health2;


		incHealthScript = FindObjectOfType (typeof(IncreaseHealth)) as IncreaseHealth;
		Debug.Log ("tempHealth" + incHealthScript.temp);
		playerHealth = incHealthScript.temp;
		hltScript.takeHeart();
		
	}
    void EquipGun(int index)
    {
        if (currentGun)
        {
            // Store the current gun's information
            if (currentGun.gunID == 1)
            {
                ar_ammo   = currentGun.GetTotalAmmo();
                ar_clip   = currentGun.GetCurrentMagAmmo();
                ar_damage = currentGun.GetDamage();
            }
            else if (currentGun.gunID == 2)
            {
                shotgun_ammo   = currentGun.GetTotalAmmo();
                shotgun_clip   = currentGun.GetCurrentMagAmmo();
                shotgun_damage = currentGun.GetDamage();
            }
            else if (currentGun.gunID == 3)
            {
                pistol_ammo   = currentGun.GetTotalAmmo();
                pistol_clip   = currentGun.GetCurrentMagAmmo();
                pistol_damage = currentGun.GetDamage();
            }
            Destroy(currentGun.gameObject);     // Destroy the current gun
        }

        // Instatiate a new gun
        currentGun = Instantiate(guns[index], handHold.position, handHold.rotation) as GunController;
        currentGun.transform.parent = handHold;
        currentGun.gui = gui;
        animator.SetFloat("Weapon ID", currentGun.gunID);

        GetStoredGunInfo();     // Check if gun has stored info
    }
Esempio n. 19
0
        protected override void DefaultValues()
        {
            base.DefaultValues();

            gunController = new GunController();
            gunController.fireController = this;
        }
Esempio n. 20
0
 private void CallbackWeaponChangedEvent(object _, WeaponChangedEventArgs args)
 {
     this.Cleanup();
     this.usedGunController = args.NewGunController;
     this.initialFireRate   = args.NewGunController.FireRate;
     this.UpdateEffectOnController();
 }
Esempio n. 21
0
 protected override void Start(){
     base.Start();
     controller = GetComponent<PlayerController>();
     gunController = GetComponent<GunController>();
     rb = GetComponent<Rigidbody>();
     viewCamera = Camera.main.transform;
 }
Esempio n. 22
0
    public LayerMask collideMask; // What objects can "block its view of the Player"

    // Start is called before the first frame update
    protected override void Start()
    {
        // Set up inherited properties
        base.Start();

        // Set up variables and initialise runtime references
        player   = FindObjectOfType <Player>();
        navAgent = GetComponent <NavMeshAgent>();

        if (moveSpeed == 0)
        {
            navAgent.enabled = false;
        }
        else
        {
            navAgent.speed        = moveSpeed;
            navAgent.angularSpeed = turningSpeed;
        }


        gunController = GetComponentInChildren <GunController>();

        // Calculate half the enemy tank's height (used later)
        halfHeight = GetComponent <BoxCollider>().size.y / 2;
    }
Esempio n. 23
0
	protected   void  Start () {

		money = 0;
		controller = GetComponent<PlayerController> ();
		gunController = GetComponent<GunController> ();

		moneyText = GameObject.FindGameObjectWithTag ("money");
		mText = moneyText.GetComponent<Text> ();
		viewCamera = Camera.main;
		//swordButton = GameObject.Find ("swordButton");
		startRot = transform.eulerAngles;
		sword = GameObject.FindGameObjectWithTag ("sword");
		bow = GameObject.FindGameObjectWithTag ("bow");

		sword.transform.localEulerAngles = new Vector3(0,90,50);
		sword.transform.position =  GameObject.FindGameObjectWithTag("hold").transform.position;
		sword.transform.SetParent(this.transform);

		playerHealth = 3.0;

		mText.text = "Money: " + money; 
		hltScript = FindObjectOfType (typeof(Health)) as Health;
		hltScript.takeHeart ();

	}
Esempio n. 24
0
 void Awake()
 {
     controller = GetComponent<PlayerController> ();
     gunController = GetComponent<GunController> ();
     viewCamera = Camera.main;
     FindObjectOfType<Spawner> ().OnNewWave += OnNewWave;
 }
Esempio n. 25
0
 protected override void Start()
 {
     base.Start();
     viewCamera    = Camera.main;
     gunController = GetComponent <GunController>();
     controller    = GetComponent <PlayerControler>();
 }
Esempio n. 26
0
 protected override void Start()
 {
     base.Start();
     playerRigidbody = GetComponent <Rigidbody>();
     gunController   = GetComponent <GunController>();
     mainCamera      = Camera.main;
 }
Esempio n. 27
0
 void Awake()
 {
     mapGen         = FindObjectOfType <MapGenerator>();
     spawner        = FindObjectOfType <Spawner>();
     cameraFollower = FindObjectOfType <CameraFollow>();
     gunController  = FindObjectOfType <GunController>();
 }
Esempio n. 28
0
    void Awake()
    {
        if(isBlue) {
            bulletPrefab = Resources.Load<Rigidbody>("BulletBlue");
            controller = gameObject.AddComponent<TurretController>();
        }
        else {
            bulletPrefab = Resources.Load<Rigidbody>("BulletRed");
            controller = gameObject.AddComponent<TurretController>();
        }

        initPos = transform.position;
        halfW = renderer.bounds.size.x/2;

        if(isBlue) {
            halfW *= -1;

            minDeg = 270.5f;
            maxDeg = 359.5f;
        }
        else {
            bulletSpeed *= -1;

            minDeg = 0.5f;
            maxDeg = 89.5f;
        }
    }
Esempio n. 29
0
 // Use this for initialization
 void Start()
 {
     gunController         = GetComponent <GunController>();
     currentHealth         = maxHealth;
     healthSlider.maxValue = maxHealth;
     healthSlider.value    = currentHealth;
 }
Esempio n. 30
0
        public void SubscribeToGuns()
        {
            leftGun  = playerShooting.LeftHandGun;
            rightGun = playerShooting.RightHandGun;

            if (leftGun)
            {
                var leftWeapon = leftGun.Weapon;
                leftWeapon.OnShot      -= UpdateAmmoLeft;
                leftWeapon.OnReloadEnd -= UpdateAmmoLeft;
                leftWeapon.OnShot      += UpdateAmmoLeft;
                leftWeapon.OnReloadEnd += UpdateAmmoLeft;

                UpdateAmmoLeft();
            }
            else
            {
                leftGunText.text = "";
            }

            if (rightGun)
            {
                var rightWeapon = rightGun.Weapon;
                rightWeapon.OnShot      -= UpdateAmmoRight;
                rightWeapon.OnReloadEnd -= UpdateAmmoRight;
                rightWeapon.OnShot      += UpdateAmmoRight;
                rightWeapon.OnReloadEnd += UpdateAmmoRight;

                UpdateAmmoRight();
            }
            else
            {
                rightGunText.text = "";
            }
        }
Esempio n. 31
0
 void Awake()
 {
     go            = GameObject.Find("Pathfinder");
     grid          = go.GetComponent <CustomGrid>();
     animator      = GetComponentInChildren <Animator>();
     gunController = GetComponent <GunController>();
 }
Esempio n. 32
0
    /*
     *  Setting active gun based on the activeGunIndex, and setting all others to inactive.
     */
    void SetActiveGun()
    {
        for (int i = 0; i < guns.Count; i++)
        {
            GunController gun = guns[i];
            // deleting a null if this is one.
            if (gun == null)
            {
                guns.RemoveAt(i);
                if (guns.Count == 0)
                {
                    break;
                }
                i--;
                continue;
            }

            if (i == activeGunIndex)
            {
                activeGunIndex = i;
                activeGun      = gun;
                activeAmmo     = ammos[(int)gun.GetAmmoType()];
                uiViewSprite.ChangeGun(gun.gunName, gun.viewSpriteHeight, gun.viewSpriteFPS);
                gun.DisableShot(uiViewSprite.gunSwapSpeed);
            }
            else
            {
                gun.ToggleFiring(false);
                uiViewSprite.ToggleFiring(false);
            }
        }
    }
Esempio n. 33
0
 protected override void Start()
 {
     base.Start();
     pc = GetComponent<PlayerController>();
     gc = GetComponent<GunController>();
     cam = Camera.main;
 }
Esempio n. 34
0
 public override void MouseOne(GunController gunController)
 {
     gunController.OnBarrelChanged.Invoke(GunController.Barrel.LEFT, false);
     gunController.Shoot();
     //play gun animation
     gunController.SetState(new LeftBarrelEmpty());
 }
 public void PickUpGun(GunController newGun)
 {
     newGun.PickedUp(GetComponent <Rigidbody2D>());
     guns.Add(newGun);
     GameManager.Instance.AddWeapon(newGun.name);
     if (newGun.transform.parent)
     {
         if (newGun.transform.parent.GetComponent <Cupgrade>() != null)
         {
             newGun.transform.parent.GetComponent <Cupgrade>().RemoveItem(newGun.gameObject);
         }
     }
     newGun.transform.parent        = weaponHolder;
     newGun.transform.localPosition = Vector3.zero;
     newGun.transform.localRotation = Quaternion.identity;
     newGun.transform.localScale    = new Vector3(Mathf.Abs(newGun.transform.localScale.x), Mathf.Abs(newGun.transform.localScale.y), Mathf.Abs(newGun.transform.localScale.z));
     if (shooting.GetWeaponHeld() == null)
     {
         SwitchToWeapon(guns.Count - 1);
     }
     else
     {
         newGun.gameObject.SetActive(false);
     }
     return;
 }
    bool BodySnatch()
    {
        if (Physics.Raycast(transform.position, transform.forward, out RaycastHit hit0, snatchDistance))
        {
            if (hit0.transform.tag == "Human")
            {
                state = PLAYERSTATE.NEWBODY;
                if (hostBody != null)
                {
                    if (gunCtrl != null)
                    {
                        gunCtrl.transform.parent = null;

                        Transform hostGunSpot = hostBody.GetGunSpot();
                        gunCtrl.transform.position = hostGunSpot.position;
                        gunCtrl.transform.rotation = Quaternion.Euler(hostGunSpot.eulerAngles.x, hostGunSpot.eulerAngles.y, hostGunSpot.eulerAngles.z);
                        gunCtrl.transform.parent   = hostBody.transform;
                    }
                    //handle letting go of the current snatched body
                    hostBody.Depossess();

                    gunCtrl = null;
                }
                hostBody = hit0.transform.GetComponent <HumanController>();
                return(true);
            }
        }
        return(false);
    }
Esempio n. 37
0
    public bool SeenGun()
    {
        _planes = GeometryUtility.CalculateFrustumPlanes(Camera.main);

        GunController[] gunControllers = GameObject.FindObjectsOfType <GunController>();

        for (int i = 0; i < gunControllers.Length; i++)
        {
            //print ("in for");
            GunController temp = gunControllers [i];

            if (GeometryUtility.TestPlanesAABB(_planes, temp.GetComponent <SphereCollider> ().bounds))
            {
                //print ("in testplanes");
                RaycastHit hit = new RaycastHit();
                Vector3    dir = transform.position - temp.transform.position;
                Ray        ray = new Ray(temp.transform.position, dir);
                Physics.Raycast(ray, out hit, dir.magnitude);

                if (hit.collider == GetComponent <CapsuleCollider> ())
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Esempio n. 38
0
    void PickupGun()
    {
        _planes = GeometryUtility.CalculateFrustumPlanes(Camera.main);

        GunController[] gunControllers = GameObject.FindObjectsOfType <GunController>();

        for (int i = 0; i < gunControllers.Length; i++)
        {
            //print ("in for");
            GunController temp = gunControllers [i];

            if (GeometryUtility.TestPlanesAABB(_planes, temp.GetComponent <SphereCollider> ().bounds))
            {
                //print ("in testplanes");
                RaycastHit hit = new RaycastHit();
                Vector3    dir = transform.position - temp.transform.position;
                Ray        ray = new Ray(temp.transform.position, dir);
                Physics.Raycast(ray, out hit, dir.magnitude);

                if (hit.collider == GetComponent <CapsuleCollider> ())
                {
                    temp.GetComponent <SphereCollider> ().enabled = false;
                    _gun = temp.GetComponent <GunController> ();
                    _gun.transform.SetParent(_hand.transform);
                    //_gun.transform.parent = _hand.transform;
                    _gun.transform.localScale   *= .085f;
                    _gun.transform.localPosition = Vector3.zero;
                    _gun.transform.localRotation = Quaternion.identity;
                }
            }
        }
    }
Esempio n. 39
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();
        EntityType type = EntityType.Enemy | EntityType.GuardEnemy;

        AddType(type);

        speed = 2.0f;

        enemyNearby   = false;
        gunController = GetComponent <GunController>();

        blackboard.treeData.Add("eyes", eyes);
        blackboard.treeData.Add("gunController", gunController);

        NodeSequencer root = new NodeSequencer(new BTNode[]
        {
            new NodeSelector(new BTNode[]
            {
                new ActionCheckForEnemiesInSight(),
                new NodeAlwaysFail(
                    new ActionLookForEnemy()
                    )
            }),
            new ActionUseWeapon()
        });


        brain = new AIBrain(root, blackboard);

        brain.Start();
    }
Esempio n. 40
0
    // Update is called once per frame
    void Update()
    {
        gun = guns[currentGun];

        if (health <= 0)
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }

        moveInput = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical"));
        mVelocity = moveInput / slowness;

        //rotation
        Ray   cameraRay   = rayCamera.ScreenPointToRay(Input.mousePosition);
        Plane groundPlane = new Plane(Vector3.up, Vector3.zero);
        float rayLength;

        if (groundPlane.Raycast(cameraRay, out rayLength))
        {
            Vector3 pointToLook = cameraRay.GetPoint(rayLength);
            Debug.DrawLine(cameraRay.origin, pointToLook, Color.blue);

            transform.LookAt(new Vector3(pointToLook.x, transform.position.y, pointToLook.z));
        }
        if (Input.GetMouseButtonDown(0))
        {
            gun.isFiring = true;
        }
        if (Input.GetMouseButtonUp(0))
        {
            gun.isFiring = false;
        }
    }
Esempio n. 41
0
    // Use this for initialization
    protected override void Start()
    {
        base.Start();
        controlador = GetComponent<PlayerController> ();
        controladorArma = GetComponent<GunController> ();
        camera = Camera.main;

        anim = GetComponent<Animator>();
    }
Esempio n. 42
0
    protected override void Start()
    {
        base.Start ();

        mController    = GetComponent<PlayerController> ();
        mGunController = GetComponent<GunController> ();
        mAnimation     = GetComponent<BipedAnimation> ();
        mCamera        = Camera.main;
        mFloorPlane    = new Plane (Vector3.up, 0.8f);
    }
 public override void Awake()
 {
     base.Awake();
     m_RigidBody = GetComponent<Rigidbody>();
     m_Capsule = GetComponent<CapsuleCollider>();
     m_gunController = GetComponent<GunController>();
     m_animator = GetComponent<Animator>();
     m_audio = GameObject.FindGameObjectWithTag("Map").GetComponent<AudioManager>();
     mouseLook.Init (transform, cam.transform);
     OnDeath += HandleDeath;
     m_isMine = false;
 }
Esempio n. 44
0
    void Start()
	{
		golem = transform.Find("Golem");
        wallCreator = golem.Find("wallcreator").GetComponent<GolemCreateWall>();

		wizard = transform.Find("Wizard");
        gun = wizard.Find("Gun").Find("Spells").GetComponent<GunController>();

        symState = GetComponent<SymbiotState>();

        SetInputs(GameObject.Find("GameManager").GetComponent<ControllerScheme>().GetInputs(GetComponent<PlayerEnergy>().team));
	}
Esempio n. 45
0
        public void IfThereAreNoBullets_ShootFail()
        {
            Mock<IFire> fireControllerMock = new Mock<IFire>();

            GunController controller = new GunController();
            controller.bulletsLeft = 0;
            controller.fireController = fireControllerMock.Object;

            controller.ApplyFire();

            fireControllerMock.Verify(c => c.Fire(), Times.Never);
        }
Esempio n. 46
0
        public void IfThereAreBulletsAShootSucceed()
        {
            Mock<IFire> fireControllerMock = new Mock<IFire>();

            GunController controller = new GunController();
            controller.fireController = fireControllerMock.Object;

            controller.ApplyFire();

            Assert.AreEqual(4, controller.bulletsLeft);

            fireControllerMock.Verify(c => c.Fire());
        }
Esempio n. 47
0
    protected override void Start()
    {
        base.Start();
        controller = GetComponent<PlayerController>();
        gunController = GetComponent<GunController>();
        viewCamera = Camera.main;
        combo = 1;
        canDodge = true;
        dodging = false;

        audioSource = GetComponent<AudioSource>();

        anim = GetComponentInChildren<Animator>();
        cam = Camera.main.transform;

        onDeath += GameOver;
    }
Esempio n. 48
0
    // This method should only be called once and it should be called before any other method.
    // As a precausion this method will only assert if called multiple times.
    private void Init()
    {
        Assert.IsFalse(hasInit);
        if (isLocalPlayer)
        {
        }
        else
        {
        }

        gameRigidBody = GetComponent<Rigidbody>();
        gunController = GetComponent<GunController>();
        gunController.gunControllerDelegate = this;

        health = 100f;
        rendererList = new Renderer[0];
        hasInit = true;
        gameEnded = false;
    }
Esempio n. 49
0
	void Start () {
		gun = transform.Find ("Gun").GetComponent<GunController> ();     //Recieve Script Object
	}
Esempio n. 50
0
    /// <summary>
    /// Called when the AI is initialized and the body has been ste.
    /// Set up gun parenting and grab the AI Animator and the Gun Controller
    /// </summary>
    public override void BodyInit()
    {
        base.BodyInit();

        if (_gunPrefab == null || _gunMount == null)
            throw new System.Exception("AimAndFireELement requires a Gun Prefab and Gun Mount");

        GameObject tGun = (GameObject)GameObject.Instantiate(_gunPrefab);
        tGun.transform.parent = _gunMount;
        tGun.transform.localPosition = Vector3.zero;
        tGun.transform.localRotation = Quaternion.identity;

        _animator = AI.Animator as MecanimAnimator;
        if (_animator == null)
            throw new System.Exception("AimAndFireELement only works with a MecanimAnimator on your AI");

        _gunController = tGun.GetComponentInChildren<GunController>();
        if (_gunController == null)
            throw new System.Exception("AimAndFireELement requires a GunController located on the Gun Prefab");

        _gunController.shooter = AI.Body;
    }
 void Start()
 {
     gunController = GetComponent<GunController>();
     controller = GetComponent<CharacterController>();
     cam = Camera.main;
 }
    void EquipGun(int index)
    {
        if (currentGun)
        {
            // Store the current gun's information
            if (currentGun.gunID == 1)
            {
                ar_ammo = currentGun.GetTotalAmmo();
                ar_clip = currentGun.GetCurrentMagAmmo();
                ar_damage = currentGun.GetDamage();
            }
            else if (currentGun.gunID == 2)
            {
                shotgun_ammo = currentGun.GetTotalAmmo();
                shotgun_clip = currentGun.GetCurrentMagAmmo();
                shotgun_damage = currentGun.GetDamage();
            }
            else if (currentGun.gunID == 3)
            {
                pistol_ammo = currentGun.GetTotalAmmo();
                pistol_clip = currentGun.GetCurrentMagAmmo();
                pistol_damage = currentGun.GetDamage();
            }
            Destroy(currentGun.gameObject);     // Destroy the current gun
        }

        // Instatiate a new gun
        currentGun = Instantiate (guns[index], handHold.position, handHold.rotation) as GunController;
        currentGun.transform.parent = handHold;
        currentGun.gui = gui;
        animator.SetFloat ("Weapon ID", currentGun.gunID);

        GetStoredGunInfo();     // Check if gun has stored info
    }
    // PRAGMA MARK - Public
    // PRAGMA MARK - Protected
    protected void Awake()
    {
        _healthComponent = GetComponent<HealthComponent>();
        _gunController = GetComponentsInChildren<GunController>()[0];

        _rigidbody = GetComponent<Rigidbody2D>();

        _rightArm = transform.Find("Body/RightArm");
        _leftArm = transform.Find("Body/LeftArm");
    }
Esempio n. 54
0
    // Use this for initialization
    void Start () {
		instance = this;
        RestartLevel();
        Debug.Log("Time.fixedDeltaTime: " + Time.fixedDeltaTime);

        gunController = playerGun.GetComponent<GunController>();

        // Når vi starter spillet skal vi sørge for at alle knapperne er farvet korrekt
        ColorBlock knap1Farve = knap1.colors;
        knap1Farve.normalColor = knap1Normal;
        knap1.colors = knap1Farve;
        knap1.GetComponent<Image>().color = knap1Normal;

        ColorBlock knap2Farve = knap2.colors;
        knap2Farve.normalColor = knap2Normal;
        knap2.colors = knap2Farve;
        knap2.GetComponent<Image>().color = knap2Normal;

        ColorBlock knap3Farve = knap3.colors;
        knap3Farve.normalColor = knap3Normal;
        knap3.colors = knap3Farve;
        knap3.GetComponent<Image>().color = knap3Normal;

        ColorBlock knap4Farve = knap4.colors;
        knap4Farve.normalColor = knap4Normal;
        knap4.colors = knap4Farve;
        knap4.GetComponent<Image>().color = knap4Normal;

        StartCoroutine(RotateEnvironment());

        // Quick-fix, so the initial weapon has proper damage, before we press any of the buttons in the side
        SetDamagePotential(10.0f);

		knap1.GetComponent<Image> ().color = new Color (1f, 1f, 1f, 0.3f);
		knap2.GetComponent<Image> ().color = new Color (0.259f, 0.259f, 0.259f, 0.3f);
		knap3.GetComponent<Image> ().color = new Color (0.259f, 0.259f, 0.259f, 0.3f);
		knap4.GetComponent<Image> ().color = new Color (0.259f, 0.259f, 0.259f, 0.3f);

		knap1.GetComponent<Button> ().interactable = true;
		knap2.GetComponent<Button> ().interactable = false;
		knap3.GetComponent<Button> ().interactable = false;
		knap4.GetComponent<Button> ().interactable = false;
    }
Esempio n. 55
0
    // Use this for initialization
    void Start()
    {
        rigid = transform.GetComponent<Rigidbody>();
        //maxSpeed = 3.0F;
        gunController = GetComponent<GunController>();
        controller = GetComponent<CharacterController>();

        anim = transform.GetComponent<Animator>();
    }
Esempio n. 56
0
    //public AudioClip[] footstepSounds;
    // Use this for initialization
    void Start()
    {
        rigid = transform.GetComponent<Rigidbody>();
        //maxSpeed = 3.0F;
        gunController = GetComponent<GunController>();
        controller = GetComponent<CharacterController>();

        anim = transform.GetComponent<Animator>();

        //Loading the items into the array
        //		footstepSounds =  new AudioClip[]{(AudioClip)Resources.Load("Audio/footsteps-gravel"),
        //			(AudioClip)Resources.Load("footsteps-gravel2"),
        //			(AudioClip)Resources.Load("footsteps-gravel3"),
        //			(AudioClip)Resources.Load("footsteps-gravel4")};
    }
Esempio n. 57
0
	void Start () {
		gun = transform.GetChild (5).GetComponent<GunController> ();     //Recieve Script Object
	}
Esempio n. 58
0
	void Start () {
		controller = GetComponent<PlayerController> ();
		gunController = GetComponent<GunController> ();
		viewCamera = Camera.main;
	}
Esempio n. 59
0
 // Use this for initialization
 void Start()
 {
     gunController = GetComponent<GunController>();
     gunController.startingGun.fireMode = Gun.FireMode.Single;
 }
Esempio n. 60
0
    // Use this for initialization
    void Start()
    {
        Random.seed = 34234;

        gunController = transform.FindChild("Gun").GetComponent<GunController>();

        characterSprite = transform.FindChild("Sprite");

        drivingPosition = new Vector3(0.75f, 0.85f, 0.7685489f);
        shootingPosition = new Vector3(-1.05f, 1.8f, -0.01f);

        characterSprite.position = drivingPosition + transform.position;

        initialY = transform.position.y;
    }