private void Start() { _playerAudio = GetComponentInChildren <PlayerAudio>(); _rigidbody = GetComponent <Rigidbody>(); _aim = FindObjectOfType <AimCursor>(); _playerAnimator = GetComponentInChildren <PlayerAnimatorController>(); }
// Update is called once per frame void Update() { if (isBetting) { for (int i = 0; i < playersBetting.Count; i++) { if (playersBetting[i].bets > 0) { return; } } BetManager.instance.StartButton.SetActive(true); canStartRace = true; } if (isRacing) { //musicManager.isStartingRace = true; elapsedTime += Time.deltaTime; courseSlider.value = elapsedTime; if (elapsedTime >= gameLengthInSec) { EndRace(); } } if (!isBetting && !isRacing && CountDown) { if (!cursorHasBeenInstantiate) { cursorHasBeenInstantiate = true; foreach (Player player in playersBetting) { AimCursor cursor = Instantiate(aimCursor, gameCamera.transform, false); cursor.transform.position = new Vector3(cursor.transform.position.x, cursor.transform.position.y, 5); cursor.SetPlayer(player); } } if (elapsedTimeCountDown <= 5) { countDownCanvas.gameObject.SetActive(true); elapsedTimeCountDown += Time.deltaTime; countDownText.text = (5 - (int)elapsedTimeCountDown).ToString(); } else { CountDown = false; countDownCanvas.gameObject.SetActive(false); Hud.instance.gameObject.SetActive(true); StartRace(); } } }
private void SetCrosshairState(AimCursor aimCursor, bool isOutOfRange) { if (isOutOfRange) { aimCursor.AimCursorBottom.color = new Color(0.5f, 0.5f, 0.5f); aimCursor.AimCursorTop.color = new Color(0.5f, 0.5f, 0.5f); aimCursor.AimCursorLeft.color = new Color(0.5f, 0.5f, 0.5f); aimCursor.AimCursorRight.color = new Color(0.5f, 0.5f, 0.5f); } else { aimCursor.AimCursorBottom.color = new Color(1f, 1f, 1f); aimCursor.AimCursorTop.color = new Color(1f, 1f, 1f); aimCursor.AimCursorLeft.color = new Color(1f, 1f, 1f); aimCursor.AimCursorRight.color = new Color(1f, 1f, 1f); } }
private void Start() { _cursor = FindObjectOfType <AimCursor>(); }
public void PerFrameUpdate() { //run delay timer for tooltip if (_isShowingToolTip) { if (!NGUITools.GetActive(ToolTip)) { NGUITools.SetActive(ToolTip.gameObject, true); } Vector3 pos = Input.mousePosition + new Vector3(0, 10, 0); pos.x = Mathf.Clamp01(pos.x / Screen.width); pos.y = Mathf.Clamp01(pos.y / Screen.height); ToolTip.transform.position = GameManager.Inst.UIManager.UICamera.ViewportToWorldPoint(pos);; //_toolTipTimer = 0; /* * if(_toolTipTimer < ToolTipDelay) * { * _toolTipTimer += Time.unscaledDeltaTime; * } * else * { * * } */ } if (InputEventHandler.Instance.State == UserInputState.PopupOpen || InputEventHandler.Instance.State == UserInputState.Dialogue) { SetCursorState(CursorState.Default); HideToolTip(); GameManager.Inst.UIManager.HUDPanel.HideTargetName(); } //Debug.Log(Input.mousePosition); if (GameManager.Inst.PlayerControl.IsGamePaused || InputEventHandler.Instance.State != UserInputState.Normal) { return; } //UnityEngine.Cursor.visible = false; if (CurrentState == CursorState.Aim) { UnityEngine.Cursor.visible = false; AimCursor aimCursor = ActiveCursor.GetComponent <AimCursor>(); if (aimCursor != null) { //float climb = GameManager.Inst.PlayerControl.SelectedPC.AimTarget.localPosition.y; float armFatigue = GameManager.Inst.PlayerControl.SelectedPC.MyStatus.ArmFatigue / GameManager.Inst.PlayerControl.SelectedPC.MyStatus.MaxArmFatigue; float amount = GameManager.Inst.Constants.ArmFatigueRecoil.Evaluate(Mathf.Clamp(armFatigue, 0, 1)); float baseAmount = 5; if (GameManager.Inst.PlayerControl.SelectedPC.IsHipAiming || GameManager.Inst.PlayerControl.SelectedPC.UpperBodyState != HumanUpperBodyStates.Aim) { baseAmount = 15; } amount = amount * 100 + baseAmount + 20 * GameManager.Inst.PlayerControl.SelectedPC.MyAI.WeaponSystem.GetTurnMoveScatter(); aimCursor.SetExpansion(amount); Weapon currentWeapon = GameManager.Inst.PlayerControl.SelectedPC.MyReference.CurrentWeapon.GetComponent <Weapon>(); if (currentWeapon.IsRanged) { Gun gun = (Gun)currentWeapon; if (gun.Barrel.Range < Vector3.Distance(GameManager.Inst.PlayerControl.SelectedPC.transform.position, GameManager.Inst.PlayerControl.SelectedPC.AimPoint)) { SetCrosshairState(aimCursor, true); } else { SetCrosshairState(aimCursor, false); } } else { SetCrosshairState(aimCursor, false); } } } else { UnityEngine.Cursor.visible = true; } float centerAlpha = CursorAim.GetComponent <AimCursor>().AimCursorCenter.alpha; CursorAim.GetComponent <AimCursor>().SetCenterCursorAlpha(Mathf.Lerp(centerAlpha, 0, Time.deltaTime * 3)); //update cursor state based on what player is doing GameObject aimedObject = GameManager.Inst.PlayerControl.GetAimedObject(); if (GameManager.Inst.PlayerControl.SelectedPC.MyAI.ControlType == AIControlType.Player) { //if(GameManager.Inst.PlayerControl.SelectedPC.GetCurrentAnimWeapon() != WeaponAnimType.Unarmed && !GameManager.Inst.UIManager.IsCursorInHUDRegion()) if ((GameManager.Inst.PlayerControl.SelectedPC.UpperBodyState == HumanUpperBodyStates.Aim || GameManager.Inst.PlayerControl.SelectedPC.UpperBodyState == HumanUpperBodyStates.HalfAim) && !GameManager.Inst.UIManager.IsCursorInHUDRegion()) { SetCursorState(CursorState.Aim); /* * //now check if aimed object is enemy * Character aimedChar = GameManager.Inst.PlayerControl.GetAimedObject().GetComponent<Character>(); * if(aimedChar != null && aimedChar.Faction != GameManager.Inst.PlayerControl.SelectedPC.Faction) * { * //mark cursor as red * CursorAim.color = new Color(1, 0, 0); * } */ } else if (aimedObject != null && Vector3.Distance(GameManager.Inst.PlayerControl.SelectedPC.transform.position, aimedObject.transform.position) < 15) { if (aimedObject.GetComponent <PickupItem>() != null) { PickupItem pickup = aimedObject.GetComponent <PickupItem>(); string quantity = ""; if (pickup.Quantity > 1) { quantity = "(" + pickup.Quantity + ")"; } //ShowToolTip(pickup.Item.Name + quantity); GameManager.Inst.UIManager.HUDPanel.ShowTargetName(pickup.Item.Name + quantity, 1); SetCursorState(CursorState.Hand); } else if (aimedObject.GetComponent <StoryObject>() != null) { //ShowToolTip(aimedObject.GetComponent<StoryObject>().Name); GameManager.Inst.UIManager.HUDPanel.ShowTargetName(aimedObject.GetComponent <StoryObject>().Name, 1); SetCursorState(CursorState.Hand); } else if (aimedObject.GetComponent <Character>() != null) { Character aimedCharacter = aimedObject.GetComponent <Character>(); int relationship = aimedCharacter.MyAI.IsCharacterEnemy((Character)GameManager.Inst.PlayerControl.SelectedPC); if (aimedCharacter != null && aimedCharacter.MyStatus.Health > 0 && relationship >= 2 && aimedCharacter.MyAI.ControlType != AIControlType.Player && !aimedCharacter.IsHidden) { SetCursorState(CursorState.Talk); } else { SetCursorState(CursorState.Default); } string name = aimedCharacter.Name; if (relationship < 1) { name = aimedCharacter.Faction.ToString(); } if (!string.IsNullOrEmpty(aimedCharacter.Title)) { name = aimedCharacter.Title + " " + name; } if (!string.IsNullOrEmpty(name) && !aimedCharacter.IsHidden) { //ShowToolTip(name); GameManager.Inst.UIManager.HUDPanel.ShowTargetName(name, relationship); } } else if (aimedObject.tag == "SerumLab") { //ShowToolTip("Serum Lab"); GameManager.Inst.UIManager.HUDPanel.ShowTargetName("Serum Lab", 1); SetCursorState(CursorState.Hand); } else { DeathCollider deathCollider = aimedObject.GetComponent <DeathCollider>(); if (deathCollider != null) { Character aimedCharacter = deathCollider.ParentCharacter; if (aimedCharacter != null && aimedCharacter.MyStatus.Health <= 0) { SetCursorState(CursorState.Hand); } else { SetCursorState(CursorState.Default); } } else if (aimedObject.tag == "Chest" && aimedObject.GetComponent <Chest>() != null) { SetCursorState(CursorState.Hand); } else if (aimedObject.tag == "Door" || aimedObject.tag == "LightSwitch") { SetCursorState(CursorState.Hand); } else if (aimedObject.tag == "Portal") { SetCursorState(CursorState.Portal); } else { //Debug.Log("setting cursor to default"); SetCursorState(CursorState.Default); } HideToolTip(); GameManager.Inst.UIManager.HUDPanel.FadeTargetName(); } } else { //Debug.Log("setting cursor to default"); SetCursorState(CursorState.Default); HideToolTip(); GameManager.Inst.UIManager.HUDPanel.FadeTargetName(); } } else { //Debug.Log("setting cursor to default"); SetCursorState(CursorState.Default); HideToolTip(); GameManager.Inst.UIManager.HUDPanel.HideTargetName(); } }