IEnumerator ReloadRoutine() { yield return(null); //in case the the previous weapon was switch while reloading, give it a frame to stop the ReloadRoutine reloading = true; uiButtonWeapon.button.interactable = false; uiButtonWeapon.labelAlt.alignment = TextAnchor.MiddleLeft; UnitPlayer player = GameControl.GetPlayer(); while (player != null && player.Reloading()) { string dot = ""; int count = (int)Mathf.Floor((Time.time * 3) % 4); for (int i = 0; i < count; i++) { dot += "."; } for (int i = count; i < 3; i++) { dot += " "; } uiButtonWeapon.labelAlt.text = "Reloading" + dot; float durationRemain = player.GetReloadDuration() - player.GetCurrentReload(); uiButtonWeapon.labelAlt2.text = durationRemain <= 0 ? "" : durationRemain.ToString("f1") + "s"; yield return(null); } uiButtonWeapon.labelAlt.text = ""; uiButtonWeapon.labelAlt.alignment = TextAnchor.MiddleRight; uiButtonWeapon.labelAlt2.text = ""; uiButtonWeapon.button.interactable = true; reloading = false; }
// Use this for initialization void Start() { imageResume = imageResume.GetComponent<Image>(); imageExit = imageExit.GetComponent<Image>(); player = player.GetComponent<UnitPlayer>(); textResume = textResume.GetComponent<Text>(); textExit = textExit.GetComponent<Text>(); menu = menu.GetComponent<Canvas>(); images = new Image[TOTAL_OPTIONS]; texts = new Outline[TOTAL_OPTIONS]; images[0] = imageResume; images[1] = imageExit; texts[0] = textResume.GetComponent<Outline>(); texts[1] = textExit.GetComponent<Outline>(); images[0].enabled = true; texts[0].enabled = true; for (int i = 0; i < TOTAL_OPTIONS; i++) { images[i].enabled = false; texts[i].enabled = false; } menu.enabled = false; }
IEnumerator ShootRoutine() { AttackStats aStats = new AttackStats(); aStats.damageMin = damage; aStats.damageMax = damage; Vector3 offsetPos = new Vector3(0, 0.75f, 0); while (true) { yield return(new WaitForSeconds(Random.Range(0.5f * cooldown, 2f * cooldown))); for (int n = 0; n < 12; n++) { UnitPlayer player = GameControl.GetPlayer(); AttackInstance attInstance = new AttackInstance(player, aStats); GameObject soObj = (GameObject)Instantiate(shootObject, thisT.position + offsetPos, Quaternion.Euler(0, n * 30, 0)); soObj.GetComponent <ShootObject>().Shoot(player.thisObj.layer, range, thisT, attInstance); } } }
void Update() { UnitPlayer player = GameControl.GetPlayer(); if (player == null) { return; } cursorT.localPosition = Input.mousePosition * UIMainControl.GetScaleFactor(); rectDefaultCursor.sizeDelta = cursorDefaultSize + new Vector2(player.GetRecoil() * 2, player.GetRecoil() * 2); if (player.Reloading()) { ShowReloading(); imgReloading.fillAmount = player.GetCurrentReload() / player.GetReloadDuration(); } else { HideReloading(); } }
void UpdateTab() { for (int i = 0; i < AbilityManager.GetAbilityCount(); i++) { if (i == AbilityManager.GetSelectID()) { abilityItemList[i].selectHighlight.SetActive(true); abilityItemList[i].button.interactable = false; } else { abilityItemList[i].selectHighlight.SetActive(false); abilityItemList[i].button.interactable = true; } } UnitPlayer player = GameControl.GetPlayer(); for (int i = 0; i < player.weaponList.Count; i++) { string clip = player.weaponList[i].currentClip < 0 ? "∞" : player.weaponList[i].currentClip.ToString(); string ammo = player.weaponList[i].ammo < 0 ? "∞" : player.weaponList[i].ammo.ToString(); weaponItemList[i].labelAlt.text = clip + "/" + ammo; if (i == player.weaponID) { weaponItemList[i].selectHighlight.SetActive(true); weaponItemList[i].button.interactable = false; } else { weaponItemList[i].selectHighlight.SetActive(false); weaponItemList[i].button.interactable = true; } } }
// Update is called once per frame void Update() { lbRespawnCount.text = GameControl.GetPlayerLife().ToString(); UnitPlayer player = GameControl.GetPlayer(); if (player == null) { lbHP.text = "0/" + player.GetFullHitPoint(); //barHP.sizeDelta=new Vector2(-barHPLength, 0); sliderHPBar.value = 0; return; } //sliderHitPointBar.value=player.hitPoint/player.hitPointFull; //sliderEnergyBar.value=player.energy/player.energyFull; sliderHPBar.value = player.hitPoint / player.GetFullHitPoint(); lbHP.text = Mathf.Round(player.hitPoint) + "/" + Mathf.Round(player.GetFullHitPoint()); //barHP.sizeDelta=new Vector2((1-(player.hitPoint/player.GetFullHitPoint()))*-barHPLength, 0); sliderEnergyBar.value = player.energy / player.GetFullEnergy(); lbEnergy.text = Mathf.Round(player.energy) + "/" + Mathf.Round(player.GetFullEnergy()); //barEnergy.sizeDelta=new Vector2((1-(player.energy/player.GetFullEnergy()))*-barEnergyLength, 0); if (!reloading) { string clip = player.GetCurrentClip() < 0 ? "∞" : player.GetCurrentClip().ToString(); string ammo = player.GetAmmo() < 0 ? "∞" : player.GetAmmo().ToString(); uiButtonWeapon.labelAlt.text = clip + "/" + ammo; } if (GameControl.EnableAltFire()) { Ability ability = player.GetWeaponAbility(); if (ability != null) { uiButtonAltFire.label.text = ability.currentCD <= 0 ? "" : ability.currentCD.ToString("f1") + "s"; uiButtonAltFire.button.interactable = ability.IsReady() == "" ? true : false; } } int creditTgt = GameControl.GetCredits(); if (credit != creditTgt) { updateSpeed = Mathf.Max(minUpdateSpeed, Mathf.Abs(1f / (float)(creditTgt - credit))); credit = (int)Mathf.Round(Mathf.Lerp(credit, creditTgt, updateSpeed)); } int scoreTgt = GameControl.GetScore(); if (score != scoreTgt) { updateSpeed = Mathf.Max(minUpdateSpeed, Mathf.Abs(1f / (float)(scoreTgt - score))); score = (int)Mathf.Round(Mathf.Lerp(score, scoreTgt, updateSpeed)); } //lbCredit.text=""; //lbCredit.text="Credits: "+(credit<0 ? "-" : "")+"$"+Mathf.Abs(credit); lbScore.text = "Score: " + score; }
public void EndInputMode(UnitPlayer _Player) { UserInterface.ActivateBellRing(false); m_HasStartedShaking = false; }
public void StartInputMode(UnitPlayer _Player) { m_Direction = E_Direction.None; }
public void StartInputMode(UnitPlayer _Player) { }
public void EndInputMode(UnitPlayer _Player) { UserInterface.ActivateBellRing(false); }
public void StartInputMode(UnitPlayer _Player) { UserInterface.ActivateMagicalFormula(true); }
void Update() { if (!enableMouseNKeyInput) { return; } if (Input.GetButtonDown("Cancel") || Input.GetKeyDown(KeyCode.Escape) && !GameControl.IsGameOver()) { _TogglePause(); } //if(Input.GetKeyDown(KeyCode.C) && !GameControl.IsGameOver()) ToggleLevelPerkMenu(); /* * if(Input.GetKeyDown(KeyCode.Q)){ * Debug.Log("Paused for screen shot. Fire from UIMainControl"); * if(Time.timeScale==1) Time.timeScale=0; * else Time.timeScale=1; * } */ if (GameControl.IsGamePlaying()) { UnitPlayer player = GameControl.GetPlayer(); if (player != null && !player.IsDestroyed() && Input.touchCount == 0) { //Debug.Log("Fire!! "+Time.time); //movement if (Input.GetButton("Horizontal") || Input.GetButton("Vertical")) { player.Move(new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")), Input.GetKey(KeyCode.LeftShift)); } //brake if (Input.GetKey(KeyCode.Space)) { player.Brake(); } //switch weapon if (Input.GetAxisRaw("Mouse ScrollWheel") != 0 && scrollCD <= 0) { player.ScrollWeapon(Input.GetAxis("Mouse ScrollWheel") > 0 ? 1 : -1); scrollCD = 0.15f; } scrollCD -= Time.deltaTime; string[] names = Input.GetJoystickNames(); bool hasJoystick = names.Length > 0 ? true : false; //turret facing //player.AimTurretMouse(Input.mousePosition); //player.AimTurretDPad(Input.mousePosition-new Vector3(Screen.width/2, Screen.height/2)); if (Input.GetButton("RightThumbStick_X") || Input.GetButton("RightThumbStick_Y")) { player.AimTurretDPad(new Vector2(Input.GetAxisRaw("RightThumbStick_X"), Input.GetAxisRaw("RightThumbStick_Y"))); } else if (!hasJoystick) { player.AimTurretMouse(Input.mousePosition); } //fire bool continousFire = player.ContinousFire() & (Input.GetMouseButton(0) || Input.GetButton("Fire1")); if (Input.GetMouseButtonDown(0) || Input.GetButtonDown("Fire1") || continousFire) { player.FireWeapon(); } //alt fire, could fire weapon alt-mode to launch selected ability if (Input.GetMouseButtonDown(1) || Input.GetButtonDown("Fire2")) { player.FireAbility(); } //launch ability if (Input.GetMouseButtonDown(2) || Input.GetButtonDown("Fire3")) { player.FireAbilityAlt(); } //reload if (Input.GetKeyDown(KeyCode.R) || Input.GetButtonDown("Jump")) { player.Reload(); } //bring up the chracter & perk menu if (UILevelPerkMenu.Enabled() && Input.GetKeyDown(KeyCode.C)) { ToggleLevelPerkMenu(); } } } }
public void EndInputMode(UnitPlayer _Player) { m_HasStartedSwipe = false; UserInterface.HideMovementLine(); }
public void StartTurn() { if (m_MovingDirection != E_Direction.None && !m_Enemy.IsMoving()) { I_Tile currentTile = m_Enemy.GetTile(); if (currentTile != null) { bool isPlayerAtNorth = currentTile.GetNeighbour(E_Direction.North).GetUnit() is UnitPlayer; bool isPlayerAtSouth = currentTile.GetNeighbour(E_Direction.South).GetUnit() is UnitPlayer; bool isPlayerAtEast = currentTile.GetNeighbour(E_Direction.East).GetUnit() is UnitPlayer; bool isPlayerAtWest = currentTile.GetNeighbour(E_Direction.West).GetUnit() is UnitPlayer; if (isPlayerAtNorth || isPlayerAtSouth || isPlayerAtEast || isPlayerAtWest) { if (isPlayerAtNorth) { m_Enemy.TurnToward(E_Direction.North); UnitPlayer player = currentTile.GetNeighbour(E_Direction.North).GetUnit() as UnitPlayer; if (!player.IsAttackedByEnemy()) { player.SetAttackingEnemy(m_Enemy); } } else if (isPlayerAtSouth) { m_Enemy.TurnToward(E_Direction.South); UnitPlayer player = currentTile.GetNeighbour(E_Direction.South).GetUnit() as UnitPlayer; if (!player.IsAttackedByEnemy()) { player.SetAttackingEnemy(m_Enemy); } } else if (isPlayerAtEast) { m_Enemy.TurnToward(E_Direction.East); UnitPlayer player = currentTile.GetNeighbour(E_Direction.East).GetUnit() as UnitPlayer; if (!player.IsAttackedByEnemy()) { player.SetAttackingEnemy(m_Enemy); } } else if (isPlayerAtWest) { m_Enemy.TurnToward(E_Direction.West); UnitPlayer player = currentTile.GetNeighbour(E_Direction.West).GetUnit() as UnitPlayer; if (!player.IsAttackedByEnemy()) { player.SetAttackingEnemy(m_Enemy); } } } else { m_TimerMove -= Time.deltaTime; if (m_TimerMove < 0) { List <E_Direction> directionsPossible = new List <E_Direction>(); if (m_MovingDirection != E_Direction.South && m_Enemy.CanMoveTo(E_Direction.North)) { directionsPossible.Add(E_Direction.North); } if (m_MovingDirection != E_Direction.North && m_Enemy.CanMoveTo(E_Direction.South)) { directionsPossible.Add(E_Direction.South); } if (m_MovingDirection != E_Direction.West && m_Enemy.CanMoveTo(E_Direction.East)) { directionsPossible.Add(E_Direction.East); } if (m_MovingDirection != E_Direction.East && m_Enemy.CanMoveTo(E_Direction.West)) { directionsPossible.Add(E_Direction.West); } if (directionsPossible.Count > 0) { m_MovingDirection = directionsPossible[Random.Range(0, directionsPossible.Count)]; m_TimerMove = Random.Range(1.0f, 3.0f); } } if (m_Enemy.CanMoveTo(m_MovingDirection)) { m_Enemy.Move(m_MovingDirection); } else { if (!m_Enemy.GetTile().GetNeighbour(m_MovingDirection).IsWalkable() || m_Enemy.GetTile().GetNeighbour(m_MovingDirection).GetUnit() is UnitEnemy) { List <E_Direction> directionsPossible = new List <E_Direction>(); if (m_MovingDirection != E_Direction.North && m_Enemy.CanMoveTo(E_Direction.North)) { directionsPossible.Add(E_Direction.North); } if (m_MovingDirection != E_Direction.South && m_Enemy.CanMoveTo(E_Direction.South)) { directionsPossible.Add(E_Direction.South); } if (m_MovingDirection != E_Direction.East && m_Enemy.CanMoveTo(E_Direction.East)) { directionsPossible.Add(E_Direction.East); } if (m_MovingDirection != E_Direction.West && m_Enemy.CanMoveTo(E_Direction.West)) { directionsPossible.Add(E_Direction.West); } if (directionsPossible.Count > 0) { m_MovingDirection = directionsPossible[Random.Range(0, directionsPossible.Count)]; } } } } } else { TurnOrder.RemoveUnit(this); } } }
public static void OnPlayerRespawn(UnitPlayer player) { instance._OnPlayerRespawn(player); }
// Update is called once per frame void Update() { //if timer is enabled, show the timer if (GameControl.EnableTimer()) { float remainingDuration = GameControl.GetRemainingDuration(); if (remainingDuration > 0) { //float duration=objective.survivalDuration; //int minO=(int)Mathf.Floor(duration/60); //int secO=(int)Mathf.Floor(duration%60); int minR = (int)Mathf.Floor(remainingDuration / 60); int secR = (int)Mathf.Floor(remainingDuration % 60); lbTimer.text = "Time Left: " + minR + ":" + (secR > 9 ? secR.ToString() : "0" + secR); } else { lbTimer.text = "Time Left: 0:00"; } } else { lbTimer.text = ""; } lbRespawnCount.text = GameControl.GetPlayerLife().ToString(); UnitPlayer player = GameControl.GetPlayer(); if (player == null) { lbHP.text = "0/" + player.GetFullHitPoint(); //barHP.sizeDelta=new Vector2(-barHPLength, 0); sliderHPBar.value = 0; return; } //sliderHitPointBar.value=player.hitPoint/player.hitPointFull; //sliderEnergyBar.value=player.energy/player.energyFull; sliderHPBar.value = player.hitPoint / player.GetFullHitPoint(); lbHP.text = Mathf.Round(player.hitPoint) + "/" + Mathf.Round(player.GetFullHitPoint()); //barHP.sizeDelta=new Vector2((1-(player.hitPoint/player.GetFullHitPoint()))*-barHPLength, 0); sliderEnergyBar.value = player.energy / player.GetFullEnergy(); lbEnergy.text = Mathf.Round(player.energy) + "/" + Mathf.Round(player.GetFullEnergy()); //barEnergy.sizeDelta=new Vector2((1-(player.energy/player.GetFullEnergy()))*-barEnergyLength, 0); if (playerProgress != null) { sliderExpBar.value = Mathf.Max(0.01f, playerProgress.GetCurrentLevelProgress()); } if (!reloading) { if (!player.UseEnergyAsAmmo()) { string clip = player.GetCurrentClip() < 0 ? "∞" : player.GetCurrentClip().ToString(); string ammo = player.GetAmmo() < 0 ? "∞" : player.GetAmmo().ToString(); uiButtonWeapon.labelAlt.text = clip + "/" + ammo; } else { uiButtonWeapon.labelAlt.text = "Use Energy"; } } if (GameControl.EnableAltFire()) { Ability ability = player.GetWeaponAbility(); if (ability != null) { uiButtonAltFire.label.text = ability.currentCD <= 0 ? "" : ability.currentCD.ToString("f1") + "s"; uiButtonAltFire.button.interactable = ability.IsReady() == "" ? true : false; } } int creditTgt = GameControl.GetCredits(); if (credit != creditTgt) { updateSpeed = Mathf.Max(minUpdateSpeed, Mathf.Abs(1f / (float)(creditTgt - credit))); credit = (int)Mathf.Round(Mathf.Lerp(credit, creditTgt, updateSpeed)); } int scoreTgt = GameControl.GetScore(); if (score != scoreTgt) { updateSpeed = Mathf.Max(minUpdateSpeed, Mathf.Abs(1f / (float)(scoreTgt - score))); score = (int)Mathf.Round(Mathf.Lerp(score, scoreTgt, updateSpeed)); } //lbCredit.text=""; //lbCredit.text="Credits: "+(credit<0 ? "-" : "")+"$"+Mathf.Abs(credit); lbScore.text = "Score: " + score; }
// Use this for initialization void Start() { bulletOrigin = transform.Find("BulletOrigin"); Character = GameObject.FindGameObjectWithTag("Player").GetComponent<UnitPlayer>(); }
public void SpawnPlayer(UnitPlayer player) { Player = player; ClientInfo.Player = player; }
void Start() { this.player = GameObject.Find("PlayerShip").GetComponent <UnitPlayer> (); }
public void EndInputMode(UnitPlayer _Player) { UserInterface.ActivateMeleeFight(false); }
//cannot be called from constructor, because Unity. public void initialize() { Character = GameObject.FindGameObjectWithTag("Player").GetComponent<UnitPlayer>(); }
public void UpdateInputMode(UnitPlayer _Player, ControllerPlayer _Controller) { if (Input.touchCount >= 1) { Touch touch = Input.touches[0]; if (!m_HasStartedSwipe) { m_HasStartedSwipe = true; m_SwipeStartPosition = touch.position; } UserInterface.DisplayMovementLine(m_SwipeStartPosition, touch.position); if (touch.phase == TouchPhase.Canceled) { m_HasStartedSwipe = false; UserInterface.HideMovementLine(); } else if (touch.phase == TouchPhase.Ended) { Vector2 swipeDirection = touch.position - m_SwipeStartPosition; if (swipeDirection.sqrMagnitude > 100) { if (Mathf.Abs(swipeDirection.x) > Mathf.Abs(swipeDirection.y)) { if (swipeDirection.x > 0) { m_DirectionBuffer = E_Direction.East; } else { m_DirectionBuffer = E_Direction.West; } } else { if (swipeDirection.y > 0) { m_DirectionBuffer = E_Direction.North; } else { m_DirectionBuffer = E_Direction.South; } } } m_HasStartedSwipe = false; UserInterface.HideMovementLine(); } } if (_Player.CanMove()) { if (m_DirectionBuffer != E_Direction.None && _Player.CanMoveTo(m_DirectionBuffer)) { m_MovingDirection = m_DirectionBuffer; m_DirectionBuffer = E_Direction.None; } if (m_MovingDirection != E_Direction.None) { I_Unit unitOnTile = _Player.GetTile().GetNeighbour(m_MovingDirection).GetUnit(); if (_Player.CanMoveTo(m_MovingDirection)) { _Player.Move(m_MovingDirection); TurnOrder.StartAllUnitsTurn(); } else if (unitOnTile is UnitEnemy) { _Player.SetAttackingEnemy(unitOnTile as UnitEnemy); } else { m_MovingDirection = E_Direction.None; } } } _Controller.SetAnimatorBool("IsMoving", _Player.IsMoving()); }
void Awake() { player = GameObject.Find("Player").GetComponent<UnitPlayer> (); }
public static UnitPlayer Get() { if (m_Instance == null) m_Instance = (UnitPlayer)FindObjectOfType(typeof(UnitPlayer)); return m_Instance; }
public abstract void Cast(UnitPlayer _Player);
public void StartInputMode(UnitPlayer _Player) { UserInterface.ActivateBellRing(true); UserInterface.SetBellRing(); m_TimesShaked = 0; }
void Start() { this.player = GameObject.Find("PlayerShip").GetComponent <UnitPlayer>(); this.textHp = GameObject.Find("TextHp").GetComponent <Text> (); this.test = new Vector3(5f, 3f, 0); }
public void UpdateInputMode(UnitPlayer _Player, ControllerPlayer _Controller) { }
public void EndInputMode(UnitPlayer _Player) { UserInterface.EndMagicalFormulaDrawing(new Vector2(Input.mousePosition.x, Input.mousePosition.y)); UserInterface.ActivateMagicalFormula(false); }
public void EndInputMode(UnitPlayer _Player) { }
public override void Cast(UnitPlayer _Player) { GameObject.Instantiate(Resources.Load <GameObject>("Entities/Fireball"), _Player.transform.position, _Player.transform.rotation); }
// Use this for initialization void Start() { bulletOrigin = transform.Find("BulletOrigin"); arrowModel = (GameObject)Resources.Load("arrow"); Character = GameObject.FindGameObjectWithTag("Player").GetComponent<UnitPlayer>(); }