// Use this for initialization private void Start() { ShieldIsUp = false; shieldAnimator = shieldObject.GetComponent <Animator>(); gun = gunObject.GetComponent <PlayerGun>(); originalShotInterval = gun.ShotInterval; }
private void Update() { Vector2 aimingVector = PlayerGun.GetAimingVector(); AimFollow.position = new Vector2(PlayerTransform.position.x + (aimingVector.x * MaxX), PlayerTransform.position.y + (aimingVector.y * MaxY)); }
internal void SetControllerNumber(int number) { controllerNumber = number; horizontalAxis = "J" + controllerNumber + "Horizontal"; verticalAxis = "J" + controllerNumber + "Vertical"; horizontalRightAxis = "J" + controllerNumber + "RightHorizontal"; verticalRightAxis = "J" + controllerNumber + "RightVertical"; aButton = "J" + controllerNumber + "A"; xButton = "J" + controllerNumber + "X"; rightTriggerButton = "J" + controllerNumber + "RightTrigger"; startButton = "J" + controllerNumber + "Start"; // Set all controls GameObject PCBinding = GameObject.Find("PCBinding"); ControllerPlayerBinding cpBinding = PCBinding.GetComponent <ControllerPlayerBinding>(); Crosshair player_tank_crosshair_script = player_tank_crosshair.GetComponent <Crosshair>(); if (cpBinding.getControllerBinding(tank_number) == 5) { isKeyboard = true; } player_tank_crosshair_script.SetCrosshairControls(horizontalRightAxis, verticalRightAxis, isKeyboard); player_tank_gun_script = player_tank_gun.GetComponent <PlayerGun>(); print(player_tank_gun_script); player_tank_gun_script.SetGunController(xButton, rightTriggerButton); }
// TODO ? // setup custom constructed class with HP, ammo?, and wich class is currently being used. http://ilkinulas.github.io/development/unity/2016/05/30/monobehaviour-constructor.html public void SetCrosshair(GameObject crosshair_tank) { player_tank_crosshair = crosshair_tank; PlayerGun player_tank_gun_script = player_tank_gun.GetComponent <PlayerGun>(); player_tank_gun_script.SetCrosshairBarrel(player_tank_crosshair); }
void Start() { crouchTrigger.enabled = false; //Defaults to facing right. facingRight = true; //Enables mobility. canMove = true; //SpawnPoint respawnPosition = transform.position; //References to other scripts. theLevelManager = FindObjectOfType <LevelManager>(); lastPositionScript = FindObjectOfType <LastPosition>(); evolveScript = FindObjectOfType <Evolve>(); thePlayerController = FindObjectOfType <PlayerController>(); playerGun = FindObjectOfType <PlayerGun>(); //Assign variables rb2d = gameObject.GetComponent <Rigidbody2D>(); anim = gameObject.GetComponent <Animator>(); //Start with full health currentHealth = maxHealth; transform.position = lastPositionScript.pos; }
public PlayerItem(ContentManager content, Vector2 position, Stage stage, string itemType) : base(content, position, stage, itemType) { _imageTexture = content.Load <Texture2D>(string.Format("Sprites/Enemies/PlayerItem{0}", itemType)); ExplosionSound = content.Load <SoundEffect>("Sounds/playeritem"); ExplosionAnimation.Initialize(content.Load <Texture2D>("Sprites/Explosion1"), this.WorldPosition, 36, 36, 3, 150, Color.White, 1f, false, false, this.CurrentStage); CollisionIsHazardous = false; VulnerableToBullets = false; switch (itemType) { case "MachineGun": Gun = new PlayerGun(); Gun.Initialize(content, GunType.MachineGun); break; case "RapidGun": Gun = new PlayerGun(); Gun.GunType = GunType.Rapid; break; case "SpreadGun": Gun = new PlayerGun(); Gun.Initialize(content, GunType.Spread); break; } Velocity.X = 0.7f; IsOnGround = true; JumpInProgress = true; IsJumping = true; JumpLaunchVelocity = -1200f; GravityAcceleration = 300f; MaxJumpTime = 0.6f; }
void Update() { if (player == null) { player = GameObject.FindGameObjectWithTag("Player"); playerScript = player.GetComponent <PlayerControl>(); dashScript = player.GetComponent <DashScript>(); shootScript = player.GetComponent <PlayerGun>(); } if (Input.GetKeyDown(KeyCode.C)) // fix this to implement on collider { if (paused == true) { Resume(); playerScript.enabled = true; dashScript.enabled = true; shootScript.enabled = true; } else { Pause(); playerScript.enabled = false; dashScript.enabled = false; shootScript.enabled = false; } } }
private void OnTriggerEnter(Collider collision) { if (collision.gameObject.tag == "Player") { PlayerGun playerGun = collision.gameObject.GetComponent <PlayerGun>(); if (!playerGun.fireObject) { playerGun.fireObject = true; playerGun.iFire = this; currentDuration = maxDuration; fireTrue = false; audioSource.clip = pickUpBullet; audioSource.Play(); } } if (!fireTrue) { return; } if (collision.gameObject.tag == "EnemyBullet") { collision.gameObject.GetComponent <EnemyBulletScript>().DestroyObject(); Instantiate(hitEnemyParticle, transform.position, hitEnemyParticle.transform.rotation); TimeManager.Instance.DoSlowMotionEnemyHit(); Camera.main.transform.DOShakePosition(.4f, .5f, 20, 90, false, true); audioSource.clip = hitOtherBullet; audioSource.Play(); } }
void Start() { player = FindObjectOfType <PlayerGun>(); rb = GetComponent <Rigidbody>(); transform.rotation = Quaternion.Euler(rotation); SetAbility(); }
void Awake() { playerGun = GameObject.FindGameObjectWithTag("Player").GetComponent < PlayerGun > (); ammoText = GetComponentsInChildren < Text > ()[Constants.INDEX_AMMOUI_TXT_COUNT]; ammoSlider = GetComponentInChildren < Slider > (); sliderFill = GetComponentsInChildren < Image > () [Constants.INDEX_AMMOUI_IMG_FILL]; }
// Use this for initialization void Start() { myRigidbody = GetComponent <Rigidbody2D> (); anim = GetComponent <Animator>(); dashScript = GetComponent <DashScript>(); gunScript = GetComponent <PlayerGun>(); }
void Awake() { gunDictionary = new Dictionary <string, PlayerWeapon>(); PlayerGunInstance = this; audio2 = GetComponent <AudioSource>(); GetGunConfig(); }
void Start() { controller = gameObject.GetComponent <CharacterController>(); movement = new Movement(gameObject, controller , _moveAcc: moveAcc, _moveMax: moveMax , _friction: moveFriction, _gravity: moveGravity) { isRetainMotionEnabled = true }; movementProfileNormal = new MovementProfile(_moveAcc: moveAcc, _moveMax: moveMax , _friction: moveFriction, _gravity: moveGravity, _isMoveEnabled: true , _isFrictionEnabled: true, _isGravityEnabled: true, _isRetainMotionEnabled: false); movementProfileAirdash = new MovementProfile(_moveAcc: moveAccAirdash, _moveMax: moveMax , _friction: moveFrictionAirdash, _gravity: moveGravity, _isRetainMotionEnabled: true); cameraScript = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <MoveCamera>(); currentGun = transform.Find("Main Camera/Handgun").gameObject; currentGunScript = currentGun.GetComponent <PlayerGun>(); thisTransform = gameObject.transform; }
private void OnTriggerEnter2D(Collider2D c) { if (c.tag == "Player") { PlayerGun player = c.GetComponent <PlayerGun>(); player.bombCount += quantity; } }
public void setTankNumber(int tanknr) { tank_number = tanknr; string player_b = "Barrel " + tanknr; PlayerGun playerGun = GameObject.Find(player_b).GetComponent <PlayerGun>(); angle_shot = playerGun.angle; }
private void Start() { compilerstatus.SetActive(false); player = GameObject.FindGameObjectWithTag("Player"); playerScript = player.GetComponent <PlayerControl>(); dashScript = player.GetComponent <DashScript>(); shootScript = player.GetComponent <PlayerGun>(); }
// Start is called before the first frame update void Start() { PG = FindObjectOfType <PlayerGun>(); PM = FindObjectOfType <PlayerMovement>(); StartCoroutine(SlowDown()); StartCoroutine(ScreenChange()); }
private void Awake() { m_Rigidbody = GetComponent <Rigidbody>(); m_Gun = GetComponentInChildren <PlayerGun>(); visuals = GetComponentInChildren <MeshRenderer>().gameObject; visualsBasePosition = visuals.transform.localPosition; visualsBaseRotation = visuals.transform.localRotation; }
public void DrawGun(PlayerGun gun) { DrawShopIcon( new GUIContent(gun.Name, gun.Description), contentColors[gun.rare], gunBackColors[0], Vector3.zero, true); }
// Update is called once per frame void Update() { if (!gun) { gun = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerGun>(); } chargeSlider.value = gun.ammo; }
public void DrawGun(PlayerGun gun) { DrawShopIcon( new GUIContent(gun.Name, gun.Description), contentColors[gun.rare], gunBackColors[0], Vector3.zero, true); }
void OnStart() { levelManagerScript = FindObjectOfType <LevelManager>(); tvPlayer = FindObjectOfType <PlayerController>(); playerGunScript = FindObjectOfType <PlayerGun>(); playerRouterScript = FindObjectOfType <PlayerRouter>(); plasmaPlayer = FindObjectOfType <PlasmaPlayer>(); }
void Awake() { shootableMask = LayerMask.GetMask("Shootable"); gunParticles = GetComponent < ParticleSystem > (); gunLine = GetComponent < LineRenderer > (); gunAudio = GetComponents < AudioSource > (); gunLight = GetComponent < Light > (); playerGun = GetComponentInParent < PlayerGun > (); }
public override void Shoot() { if (NbBullets > 0) { PlayerGun.ShootBullet(4f); PlayerGun.ShootBullet(); PlayerGun.ShootBullet(-4f); NbBullets--; } }
// Use this for initialization void Start() { tvPlayer = FindObjectOfType <PlayerController>(); plasmaPlayer = FindObjectOfType <PlasmaPlayer>(); theLevelManagerScript = FindObjectOfType <LevelManager>(); playerGunScript = FindObjectOfType <PlayerGun>(); playerRouterScript = FindObjectOfType <PlayerRouter>(); bossScript = FindObjectOfType <Boss>(); levelCompleteImage.SetActive(false); }
// Use this for initialization void Start() { gun = GetComponent <PlayerGun>(); keyQueue = new KeyQueue(); notes = GameObject.FindGameObjectWithTag("Keytar").GetComponents <AudioSource>(); music = GameObject.FindGameObjectWithTag("Music").GetComponent <Music>(); songKey = music.getSongKey(); startingNote = music.getNoteKey(); stats = GetComponent <PlayerStats>(); }
void Awake() { floorMask = LayerMask.GetMask("Floor"); animChar = GetComponent < Animator > (); animHUD = GameObject.Find ("HUDCanvas").GetComponent < Animator > (); playerRigidbody = GetComponent < Rigidbody > (); playerAudio = GetComponents < AudioSource > (); playerGun = GetComponent < PlayerGun > (); playerShooting = GetComponentInChildren<PlayerShooting> (); }
/// <summary> /// Activates the guns. /// </summary> /// <param name="gunsToActivate">Guns to activate.</param> public void ActivateGuns(PlayerGun[] gunsToActivate) { guns.ForEach (g => g.gameObject.SetActive(false)); for (int i = 0; i < gunsToActivate.Length; i++) { int index = (int)gunsToActivate[i]; guns[index].gameObject.SetActive(true); } }
private void Awake() { if (instance != null) { Destroy(this.gameObject); } else { instance = this; } }
// Start is called before the first frame update void Start() { shopScreenUI.SetActive(false); Dialog.SetActive(false); ShieldsMessage.SetActive(false); VPNMessage.SetActive(false); vpnHUDImage.SetActive(false); tvPlayer = FindObjectOfType <PlayerController>(); playerGunScript = FindObjectOfType <PlayerGun>(); levelManagerScript = FindObjectOfType <LevelManager>(); playerRouterScript = FindObjectOfType <PlayerRouter>(); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { boostSnd = GetNode <AudioStreamPlayer>("boostSnd"); medSnd = GetNode <AudioStreamPlayer>("medSnd"); hurtSnd = GetNode <AudioStreamPlayer>("hurtSnd"); head = GetNode <Spatial>("Head"); camera = GetNode <Camera>("Head/Camera"); gun = GetNode <PlayerGun>("Head/Gun"); healthMeter = GetNode <TextureProgress>("HUD/HealthMeter"); fuelMeter = GetNode <TextureProgress>("HUD/FuelMeter"); healthNum = GetNode <Label>("HUD/HealthMeter/HealthNum"); healthNum.Text = healthMeter.Value.ToString(); Input.SetMouseMode(Input.MouseMode.Captured); }
public override void Update() { if (_numberOfShots == 0) { return; } _currentTime += Time.deltaTime; if (_currentTime > 0.1f) { _currentTime = 0f; _numberOfShots--; PlayerGun.ShootBullet(); } }
private void Start() { codeBlockPanel = GameObject.FindGameObjectWithTag("CodeBlocks"); solutionPanel = GameObject.FindGameObjectWithTag("SolutionBlocks"); outputText = GameObject.Find("OutputText").GetComponent <Text>(); popUpText = transform.GetChild(1).gameObject.GetComponent <Text>(); popUpText.enabled = false; screen = transform.GetChild(0).gameObject; screen.SetActive(false); player = GameObject.FindGameObjectWithTag("Player"); playerScript = player.GetComponent <PlayerControl>(); dashScript = player.GetComponent <DashScript>(); shootScript = player.GetComponent <PlayerGun>(); }
private void Awake() { Instance = this; #region Add Player Script Components playerWalkMove = GetComponent <PlayerWalkMove>(); playerCarMove = GetComponent <PlayerCarMove>(); rb = GetComponent <Rigidbody>(); inventory = GetComponent <PlayerInventory>(); playerGun = GetComponentInChildren <PlayerGun>(); playerCollider = GetComponent <CapsuleCollider>(); #endregion playerWalkMove.enabled = true; playerCarMove.enabled = false; }
private void Update() { PlayerGun pRoot = FindObjectOfType <PlayerGun>(); if (pRoot != null) { player = pRoot.transform; if (Vector3.Distance(player.position, transform.position) <= distanceToPickup) { if (!inZone) { AudioManager.Play(soundEffect, 1, 1, false); FindObjectOfType <PlayerStats>().health += 20; Destroy(gameObject); } inZone = true; } else { inZone = false; } } // Find enemies in vicinity Enemy[] enemies = FindObjectsOfType <Enemy>(); bool foundEnemies = false; foreach (Enemy enemy in enemies) { if (Vector3.Distance(enemy.transform.position, transform.position) <= distanceToPickup) { foundEnemies = true; if (!enemyInZone) { enemyInZone = true; enemy.health += 20; Destroy(gameObject); } } } if (!foundEnemies && enemyInZone) { enemyInZone = false; } }
void Awake() { playerGun = GameObject.FindGameObjectWithTag("Player").GetComponent < PlayerGun > (); gunText = GetComponent < Text > (); }
// Use this for initialization void Start() { // this is to count the rays that spot the player rayCount = 0; script = GetComponent<EnemyController> (); meshes = GetComponentsInChildren<MeshRenderer> (); boxes = GetComponentsInChildren<BoxCollider> (); enemySounds = GetComponents<AudioSource> (); //set spawn to original point on map for respawn agent = GetComponent<NavMeshAgent> (); transform.position = patrolPoints [0].position; currentPoint = 0; spawningPoint = transform.position; healthDamage = health / 10; // make sure the enemy has the player gameObject to find if (player == null) { player = GameObject.FindGameObjectWithTag ("Player"); } playerAct = player.GetComponentInChildren<PlayerGun> (); direction = (new Vector3(Random.Range(-1.0f,1.0f), Random.Range(-1.0f,1.0f),0.0f)).normalized; transform.Rotate(direction); }