void Start() { inventory = GetComponent <Inventory>(); playerRotation = GetComponent <PlayerRotation>(); swapWeaponsText = GameObject.Find("Swap Weapons Text"); textMeshProUGUI = swapWeaponsText.GetComponent <TextMeshProUGUI>(); }
void Awake () { // first get the playermovement and playerrotation on THIS script's gameobject _playerMovement_ref = GetComponent<PlayerMovement> (); _playerRotation_ref = GetComponent<PlayerRotation>(); // and the player m_Player = GetComponent<Player>(); // then tell the inputcontrollermanager to set its static variables to match // THIS script's _iControllerNumber, InputControllerManager.KeyMap map = InputControllerManager.WhatControllerAmI(_iControllerNumber); // THEN set THIS script's movement and rotation script axis values to match the inputcontroller's values // [playermovement] _playerMovement_ref._horizontalAxis = map._horizontalAxis; _playerMovement_ref._verticalAxis = map._verticalAxis; // [playerrotation] _playerRotation_ref._horizontalAxis = map._horizontalAxis; _playerRotation_ref._verticalAxis = map._verticalAxis; m_Player.m_Attack = map._button01; m_Player.m_Pause = map._buttonPause; }
/// <summary> /// 視点回転 /// </summary> public void RotationViewAction() { if (PlayerRotation.isRotationMoving) { if (InputManager.Instance.IsTouchEnd(PlayerRotation.touchID)) { PlayerRotation.OnPointerUP(); } else { PlayerRotation.OnPointerMove(); } } else { int touchID = InputManager.Instance.GetAnyTouchBeginID(); if (touchID != -1) { if (InputManager.Instance.IsUITouch(touchID)) { if (!PlayerRotation.isRotationMoving) { if (LayerMask.LayerToName(InputManager.Instance.GetRaycastResult(touchID).gameObject.layer) == "CameraRotationUI") { PlayerRotation.OnPointerDown(touchID); } } } } } }
/// <summary> /// Use this for initialisation. /// </summary> void Start() { m_transform = gameObject.GetComponent <Transform>(); if (!m_transform) { Debug.LogError("Could not find component Transform"); } m_rigidbody = gameObject.GetComponent <Rigidbody2D>(); if (!m_rigidbody) { Debug.LogError("Could not find component Rigidbody2D"); } m_playerInput = gameObject.GetComponent <PlayerInput>(); if (!m_playerInput) { Debug.LogError("Could not find component PlayerInput"); } m_playerAnimation = gameObject.GetComponent <PlayerAnimation>(); if (!m_playerAnimation) { Debug.LogError("Could not find component PlayerAnimation"); } m_playerRotation = gameObject.GetComponent <PlayerRotation>(); if (!m_playerRotation) { Debug.LogError("Could not find component PlayerRotation"); } m_gameManager = GameObject.FindObjectOfType <GameManager>(); if (!m_gameManager) { Debug.LogError("Could not find component GameManager"); } }
/// <summary> /// Use this for initialisation. /// </summary> void Start() { m_playerPhysics = gameObject.GetComponent <PlayerPhysics>(); if (!m_playerPhysics) { Debug.LogError("Could not find component PlayerPhysics"); } m_playerRotation = gameObject.GetComponent <PlayerRotation>(); if (!m_playerRotation) { Debug.LogError("Could not find component PlayerRotation"); } m_camera = Camera.main; if (!m_camera) { Debug.LogError("Could not find component Camera"); } m_slingshotDirectionIndicator = GameObject.FindObjectOfType <SlingshotDirectionIndicator>(); if (!m_slingshotDirectionIndicator) { Debug.LogError("Could not find component SlingshotDirectionIndicator"); } m_gameManager = GameObject.FindObjectOfType <GameManager>(); if (!m_gameManager) { Debug.LogError("Could not find component GameManager"); } // Hide the slingshot input until needed m_slingshotDirectionIndicator.StopSlingshotInput(); }
void Start() { movement = GetComponent <PlayerMovement>(); rotation = GetComponent <PlayerRotation>(); attacking = GetComponent <PlayerAttacking>(); boxCheck = GetComponent <PlayerBoxCheck>(); rb = GetComponent <Rigidbody>(); }
// Use this for initialization void Start () { swordAttack = GetComponent<SwordAttack>(); areaAttack = GetComponent<AreaAttack>(); missileAttack = GetComponent<MissileAttack>(); playerRotation = GetComponent<PlayerRotation>(); }
public static PlayerRotation GetInstance() { if (_instance == null) { _instance = new GameObject("PlayerRotation").AddComponent <PlayerRotation>(); } return(_instance); }
void Start() { _ih = GetComponent <InputHandler>(); _pr = GetComponentInChildren <PlayerRotation>(); _cc = GetComponent <CharacterController>(); _anim = GameObject.Find("Arms").GetComponent <Animator>(); _inventory = Inventory.Instance; _gun = GetComponentInChildren <GunManager>(); _camAnim = Camera.main.gameObject.GetComponent <Animator>(); _rb = GetComponent <Rigidbody>(); _col = GetComponent <CapsuleCollider>(); _inventory.Initialize(); if (debugMode) { _inventory.MaxAll(); } Cursor.lockState = CursorLockMode.Locked; if (SceneManager.GetActiveScene().name.Contains("Level")) { if (SceneManager.GetActiveScene().name.Contains("1")) { Saver.Instance.DeleteProgress(); var stats = Saver.Instance.GetStats(); Inventory.Instance._health = 100; Inventory.Instance._pistolAmmo = 15; Inventory.Instance._shotgunAmmo = 5; Inventory.Instance._rocketLauncherAmmo = 1; Inventory.Instance.RemoveItem(EItemType.SHOTGUN); Inventory.Instance.RemoveItem(EItemType.ROCKET_LAUNCHER); Inventory.Instance.RequestUpdateHUD(); } else { var stats = Saver.Instance.GetStats(); if (stats.hasShotgun) { Inventory.Instance.AddItem(EItemType.SHOTGUN); } if (stats.hasRocketLauncher) { Inventory.Instance.AddItem(EItemType.ROCKET_LAUNCHER); } Inventory.Instance._health = stats.health; Inventory.Instance._pistolAmmo = stats.pistolAmmo; Inventory.Instance._shotgunAmmo = stats.shotgunAmmo; Inventory.Instance._rocketLauncherAmmo = stats.rocketLauncherAmmo; Inventory.Instance.RequestUpdateHUD(); } } _playerPainKey = Pool.Instance.GetSharedPoolKey("PlayerPain"); _playerJumpKey = Pool.Instance.GetSharedPoolKey("PlayerJump"); _playerDeathKey = Pool.Instance.GetSharedPoolKey("PlayerDeath"); }
public PlayerProjectile(PlayerRotation direction, Point spawnLocation) : base((direction == PlayerRotation.Up || direction == PlayerRotation.Down) ? new Size(20, 50) : new Size(50, 20)) { BackColor = Color.White; Location = spawnLocation; this.direction = direction; Speed = 15; }
public void CalculateYRotationShouldReturnExpectedRotation() { float mouseX = 10f; float deltaTime = 10f; PlayerRotation player = new PlayerRotation(10f); Vector3 expected = new Vector3(0.0f, 1000f, 0.0f); Assert.AreEqual(expected, player.CalculateYRotation(mouseX, deltaTime)); }
private void OnEnable() { playerRotation = GetComponent <PlayerRotation>(); prefsData = PlayerPrefsPersistentData.LoadData(); locationName = prefsData.LocationName; //Debug.Log("locationName " + locationName); }
void Start() { _rb = GetComponent <Rigidbody>(); _ih = GetComponent <InputHandler>(); _pr = GetComponentInChildren <PlayerRotation>(); _hb = GetComponentInChildren <HeadBob>(); // TODO: Mover isso para outro lugar Cursor.lockState = CursorLockMode.Locked; }
void Awake() { //Obtain components rb = GetComponent <Rigidbody>(); playerRotation = GetComponent <PlayerRotation>(); raycastDetection = GetComponent <RaycastDetection>(); animator = GetComponent <Animator>(); changeForm = GetComponent <ChangeForm>(); respawnPos = transform.position; }
void MakeSingleton() { if (RotationCon == null) { RotationCon = this; } else if (RotationCon != null) { Destroy(gameObject); } }
void OnTriggerEnter2D(Collider2D coll) { this.health--; currentHealth.text = "Health: " + this.health; if (this.health == 0) { // Trigger player death Player = GameObject.Find("Player").GetComponent <PlayerRotation>(); Player.handleExplosion(); } }
private void Start() { playerRotation = GetComponent <PlayerRotation>(); place = GameObject.Find(locationName).GetComponent <DestinationPlace>(); transform.parent = place.interactiveLocation; // place = transform.parent.parent.GetComponent<DestinationPlace>(); SetNewTransform(place); }
void Awake() { //Obtain components rb = GetComponent <Rigidbody>(); playerRotation = GetComponent <PlayerRotation>(); raycastDetection = GetComponent <RaycastDetection>(); animator = GetComponent <Animator>(); respawnPos = transform.position; gravityBody = GetComponent <GravityBody>(); gravityBody.enabled = false; }
void Awake() { PlayerTargeting = GetComponent <PlayerTargeting> (); PlayerRotation = GetComponent <PlayerRotation> (); PlayerMovement = GetComponent <PlayerMovement> (); myTag = GetComponent <Tag> (); rbody = GetComponent <Rigidbody> (); Collider collider = GetComponent <Collider> (); distToGround = collider.bounds.extents.y; }
void Start() { GameObject gameControllerObject = GameObject.FindWithTag("GameController"); gameController = gameControllerObject.GetComponent <GameController>(); playerMovement = GetComponent <PlayerMovement>(); playerRotation = GetComponent <PlayerRotation>(); playerShooting = GetComponentInChildren <PlayerShooting>(); playerAudio = GetComponent <AudioSource>(); rigidbody = GetComponent <Rigidbody>(); currentHealth = startingHealth; }
void Start() { gate = true; isMove = true; SR = GetComponent <SpriteRenderer>(); rgdy = GetComponent <Rigidbody2D>(); Camera = GameObject.Find("MainCamera"); originPos = Camera.transform.localPosition; PR = GetComponent <PlayerRotation>(); }
private void Awake() { m_Rigidbody2D = GetComponent <Rigidbody2D>(); playerRotation = GetComponent <PlayerRotation>(); if (OnLandEvent == null) { OnLandEvent = new UnityEvent(); } if (OnCrouchEvent == null) { OnCrouchEvent = new BoolEvent(); } }
private void Awake() { switch (inputOptions) { case InputOptions.KEYBOARD: playerInput = new KeyboardInput(); break; case InputOptions.GAMEPAD: break; } playerMovement = new PlayerMovement(transform, Camera.main, playerInput, speed, GetComponent <Rigidbody>(), jumpPower, groundChecker); playerRotation = new PlayerRotation(rotationSpeed, transform, Camera.main, playerInput, GetComponent <Rigidbody>()); }
void Awake() { //Rewired int realNum = numPlayer - 1; playerInput = ReInput.players.GetPlayer(realNum); healthScript = GetComponent <PlayerHealth>(); abilityScript = GetComponent <PlayerAbility>(); shootScript = GetComponent <PlayerShoot>(); rotationScript = GetComponentInChildren <PlayerRotation>(); //burstParticleSys = burstParticles.GetComponent<ParticleSystem>(); //moveParticleSys = moveParticles.GetComponent<ParticleSystem>(); frozen = false; }
public static Bitmap RotateImage(Image img, PlayerRotation direction) { //create a new empty bitmap to hold the rotated image Bitmap bmp = new Bitmap(img.Width, img.Height); bmp.SetResolution(img.HorizontalResolution, img.VerticalResolution); //make a graphics object from the empty bitmap Graphics gfx = Graphics.FromImage(bmp); //Put the rotation point in the center of the image gfx.TranslateTransform((float)bmp.Width / 2, (float)bmp.Height / 2); //get the right direction and rotate the image switch (direction) { case PlayerRotation.Up: gfx.RotateTransform(0f); break; case PlayerRotation.Down: gfx.RotateTransform(180f); break; case PlayerRotation.Left: gfx.RotateTransform(270f); break; case PlayerRotation.Right: gfx.RotateTransform(90f); break; } //move the image back gfx.TranslateTransform(-(float)bmp.Width / 2, -(float)bmp.Height / 2); //draw passed in image onto graphics object gfx.DrawImage(img, new Point(0, 0)); //dispose graphics object gfx.Dispose(); //return rotated image return(bmp); }
public override void OnStartLocalPlayer() { base.OnStartLocalPlayer(); // get the character controller of parent object //characterController = GetComponent<CharacterController>(); // setup character position RaycastHit hit; // raycast hit for below raycast Vector3 pos = this.transform.position; //height = characterController.height; //radius = characterController.radius; if (Physics.Raycast(new Ray(pos, Vector3.down), out hit)) // cast ray from current player position into ground beneath { this.transform.position = new Vector3(pos.x, hit.point.y /*+ (height / 2) + 0.2f */, pos.z); // set the player to land on the ground beneath } //jumpState = JumpState.Grounded; //jumpCoeff = Mathf.Sqrt(-1 * Physics.gravity.y * jumpHeight * 2); // velocity required to reach jumpHeight isAlive = true; shouldRotate = true; // setup camera //accelRate += frictionCoeff; /*cameraObj = new GameObject(); * cameraObj.transform.parent = this.transform; * cameraObj.transform.localPosition = new Vector3(0f, 1.545f, 0f); * cameraObj.transform.rotation = new Quaternion(0f, 0f, 0f, 1f); * Camera.main.GetComponent<PlayerCamera>().setTarget(cameraObj.transform); * camera = cameraObj.GetComponentInChildren<Camera>(); * camera.fieldOfView = 60f; */ playerRotation = GetComponent <PlayerRotation>(); playerTranslation = GetComponent <PlayerTranslation>(); animator = GetComponent <Animator>(); // disable mesh renders as they get in way of view frustum SkinnedMeshRenderer[] meshRenderers = GetComponentsInChildren <SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer r in meshRenderers) { r.enabled = false; } }
// Use this for initialization void Start() { _playerRotation = gameObject.GetComponent <PlayerRotation>(); if (_caracterTransform == null) { _caracterTransform = gameObject.GetComponent <Transform>(); } if (_playerTransform == null) { _playerTransform = gameObject.GetComponentInParent <Transform>(); } // // _myRigidbody = gameObject.GetComponent<Rigidbody>(); // if (_caracterTransform == null) // { // _myRigidbody = gameObject.AddComponent<Rigidbody>(); // } _isGrounded = true; _isJumping = false; }
public HyperDirection rotate(PlayerRotation rotateDirection) { switch (rotateDirection) { case PlayerRotation.toRightSide: return(new HyperDirection(this.toSide, this.standing, DirectionOpposite(this.facing), this.unSeen)); case PlayerRotation.toLeftSide: return(new HyperDirection(DirectionOpposite(this.toSide), this.standing, this.facing, this.unSeen)); case PlayerRotation.toGround: return(new HyperDirection(DirectionOpposite(this.standing), this.facing, this.toSide, this.unSeen)); case PlayerRotation.toSky: return(new HyperDirection(this.standing, DirectionOpposite(this.facing), this.toSide, this.unSeen)); case PlayerRotation.toUnseenRight: return(new HyperDirection(this.unSeen, this.standing, this.toSide, DirectionOpposite(this.facing))); case PlayerRotation.toUnseenLeft: return(new HyperDirection(DirectionOpposite(this.unSeen), this.standing, this.toSide, this.facing)); } return(this); }
// Use this for initialization void Start() { //Get Script components rotation = GetComponent<PlayerRotation>(); }
public void SetDirection(PlayerRotation rotation) { direction = rotation; BackgroundImage = RotateImage(playerImage, direction); IsMoving = true; }
private void Awake() { playerRotation = FindObjectOfType <PlayerRotation>(); playerManager = FindObjectOfType <PlayerManager>(); }
void Start() { agent = GetComponent <NavMeshAgent> (); rotation = GetComponent <PlayerRotation> (); }
void Awake() { pv = GetComponent <PhotonView>(); pc = GetComponent <PlayerControl>(); pr = GetComponent <PlayerRotation>(); f1g = GameObject.Find("Field1GameManager").GetComponent <Field1GameManager>(); // gyroscope sensor gyro = Input.gyro; gyro.enabled = true; standFirePos = transform.FindChild("StandFirePos"); crouchFirePos = transform.FindChild("CrouchFirePos"); firePos = standFirePos; standFocus = transform.FindChild("StandFocus"); crouchFocus = transform.FindChild("CrouchFocus"); focus = standFocus; health = 100; crouched = false; active = true; bodyDamage = 20; branchDamage = 10; curBullets = 30; totalBullets = 60; if (pv.isMine) { // fire button event fireButton = GameObject.Find("FireButton") as GameObject; EventTrigger trigger1 = fireButton.GetComponent <EventTrigger>(); EventTrigger.Entry onFirePointerDown = new EventTrigger.Entry(); onFirePointerDown.eventID = EventTriggerType.PointerDown; onFirePointerDown.callback.AddListener(delegate { OnFirePointerDownDelegate(); }); trigger1.triggers.Add(onFirePointerDown); EventTrigger.Entry onFirePointerUp = new EventTrigger.Entry(); onFirePointerUp.eventID = EventTriggerType.PointerUp; onFirePointerUp.callback.AddListener(delegate { OnFirePointerUpDelegate(); }); trigger1.triggers.Add(onFirePointerUp); // crouch button event crouchButton = GameObject.Find("CrouchButton") as GameObject; EventTrigger trigger2 = crouchButton.GetComponent <EventTrigger>(); EventTrigger.Entry onCrouchPointerClick = new EventTrigger.Entry(); onCrouchPointerClick.eventID = EventTriggerType.PointerClick; onCrouchPointerClick.callback.AddListener(delegate { OnCrouchPointerClickDelegate(); }); trigger2.triggers.Add(onCrouchPointerClick); //// reload button event //reloadButton = GameObject.Find("ReloadButton") as GameObject; //EventTrigger trigger3 = reloadButton.GetComponent<EventTrigger>(); //EventTrigger.Entry onReloadPointerClick = new EventTrigger.Entry(); //onReloadPointerClick.eventID = EventTriggerType.PointerClick; //onReloadPointerClick.callback.AddListener(delegate { OnReloadPointerClickDelegate(); }); //trigger3.triggers.Add(onReloadPointerClick); // zoom button event //zoomButton = GameObject.Find("ZoomButton") as GameObject; //EventTrigger trigger4 = zoomButton.GetComponent<EventTrigger>(); //EventTrigger.Entry onZoomPointerClick = new EventTrigger.Entry(); //onZoomPointerClick.eventID = EventTriggerType.PointerClick; //onZoomPointerClick.callback.AddListener(delegate { OnZoomPointerClickDelegate(); }); //trigger4.triggers.Add(onZoomPointerClick); // set crouch button swappable with stand and crouch image crouchImage = crouchButton.transform.FindChild("CrouchImage").gameObject.GetComponent <RawImage>(); standImage = crouchButton.transform.FindChild("StandImage").gameObject.GetComponent <RawImage>(); crouchImage.enabled = true; standImage.enabled = false; // for aim effect aimLeft = GameObject.Find("AimImage1").GetComponent <RawImage>(); aimRight = GameObject.Find("AimImage2").GetComponent <RawImage>(); aimTop = GameObject.Find("AimImage3").GetComponent <RawImage>(); aimBottom = GameObject.Find("AimImage4").GetComponent <RawImage>(); GameObject go = GameObject.Find("HPImage"); if (go != null) { hpBar = go.GetComponent <Image>(); } hpBar.color = Color.green; go = GameObject.Find("HPText"); if (go != null) { hpText = go.GetComponent <Text>(); } go = GameObject.Find("PointText"); if (go != null) { hpPoint = go.GetComponent <Text>(); } go = GameObject.Find("CurBullet"); if (go != null) { curBullet = go.GetComponent <Text>(); } go = GameObject.Find("TotalBullet"); if (go != null) { totalBullet = go.GetComponent <Text>(); } curBullet.text = curBullets.ToString(); totalBullet.text = " / " + totalBullets.ToString(); weaponsCrate = GameObject.Find("WeaponsCrate"); getCratePanel = GameObject.Find("GetCrate"); go = GameObject.Find("GetCrateBar"); if (go != null) { getCrateBar = go.GetComponent <Image>(); } go = GameObject.Find("GetCratePercent"); if (go != null) { getCratePercent = go.GetComponent <Text>(); } getCrateBar.color = new Color(2.0f, 2.0f, 2.0f, 0.4f); getCrateBar.fillAmount = 0.0f; getCratePanel.SetActive(false); StartCoroutine(WaitForCrate()); try { ajc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); ajo = ajc.GetStatic <AndroidJavaObject>("currentActivity"); if (ajo.Call <int>("StartProximityService") != 0) { Debug.Log("native failed"); } } catch (Exception exc) { Debug.Log(exc.Message); } } else { pc.setDefaultSetting(); } }
// Use this for initialization void Start() { Transform torsoObj = transform.Find("Torso"); TorsoRB = torsoObj.GetComponent<Rigidbody2D>(); Transform groundCollider = transform.Find("GroundCollider"); GroundMotor = groundCollider.GetComponent<SliderJoint2D>(); GroundTrigger = GetComponentInChildren<GroundTrigger>(); InputManager = GetComponent<InputManager>(); PlayerRotation = GetComponentInChildren<PlayerRotation>(); VineTrigger = GetComponentInChildren<VineTrigger>(); Animator = GetComponentInChildren<Animator>(); RightArmRB = transform.Find("Torso/UpperArm_R/LowerArm_R").GetComponent<Rigidbody2D>(); LeftArmRB = transform.Find("Torso/UpperArm_L/LowerArm_L").GetComponent<Rigidbody2D>(); HandOffset = transform.Find("Torso/UpperArm_R/LowerArm_R/ArmEndPoint_R").localPosition; ChangeState(STATE.FRONT_FLIP); }