private void UpdateDownArrow() { switch (downArrowState) { case ArrowState.Hide: if (downArrow.fillAmount > 0.0f) { downArrow.fillAmount -= arrowStep; } break; case ArrowState.Reveal: if (downArrow.fillAmount < 1.0f) { downArrow.fillAmount += arrowStep; } else { downArrowState = ArrowState.Visible; } break; case ArrowState.Visible: break; } }
void Start() { _state = ArrowState.SHOWING; _spriteRenderer = GetComponent <SpriteRenderer>(); _delta = 0f; SetAplha(0f); }
void Update() { _delta += Time.deltaTime; float t; switch (_state) { case ArrowState.SHOWING: t = _delta / ArrowSettings.Instance.timeShowing; SetAplha(Mathf.Lerp(0f, 1f, t)); if (t >= 1f) { _state = ArrowState.GOING; _delta = 0f; } break; case ArrowState.GOING: float alpha = transform.localEulerAngles.z * Mathf.Deg2Rad; transform.localPosition += ArrowSettings.Instance.vel * Time.deltaTime * (new Vector3(Mathf.Cos(alpha), Mathf.Sin(alpha), 0f)); t = _delta / ArrowSettings.Instance.timeGoing; SetAplha(Mathf.Lerp(1f, ArrowSettings.Instance.finalApha, t)); if (t >= 1f) { Destroy(gameObject); } break; } }
public ArrowContext(ArrowState arrowState) { this.CurrentState = arrowState; this.X = 0; this.Y = 0; }
public static GameState ComputeGameState() { var state = new GameState(); foreach (var player in GameObject.FindGameObjectsWithTag("Player") .OrderBy(p => p.GetComponent <PlayerAI>().index)) { var playerAi = player.GetComponent <PlayerAI>(); var playerState = new PlayerState(); playerState.x = player.transform.position.x; playerState.y = player.transform.position.y; playerState.index = playerAi.index; playerState.score = playerAi.score; playerState.color = playerAi.color; playerState.invincible = playerAi.invincibilityRemaining > 0; playerState.dead = playerAi.dead; state.playerStates.Add(playerState); } foreach (var arrow in GameObject.FindGameObjectsWithTag("Arrow") .OrderBy(a => a.GetComponent <ArrowAI>().player.index) .ThenBy(a => a.transform.position.x) .ThenBy(a => a.transform.position.y)) { var arrowState = new ArrowState(); arrowState.x = arrow.transform.position.x; arrowState.y = arrow.transform.position.y; arrowState.player = arrow.GetComponent <ArrowAI>().player.index; state.arrowStates.Add(arrowState); } return(state); }
public static GameState ReadFromPacket(Packet packet) { GameState state = new GameState(); var arrowCount = packet.ReadInt(); for (int i = 0; i < arrowCount; ++i) { var arrow = new ArrowState(); arrow.x = packet.ReadFloat(); arrow.y = packet.ReadFloat(); arrow.player = packet.ReadInt(); state.arrowStates.Add(arrow); } var playerCount = packet.ReadInt(); for (int i = 0; i < playerCount; ++i) { var player = new PlayerState(); player.x = packet.ReadFloat(); player.y = packet.ReadFloat(); player.index = packet.ReadInt(); player.score = packet.ReadInt(); player.color = new Color(); player.color.r = packet.ReadFloat(); player.color.g = packet.ReadFloat(); player.color.b = packet.ReadFloat(); player.invincible = packet.ReadBool(); player.dead = packet.ReadBool(); state.playerStates.Add(player); } return(state); }
private void UpdateUpArrow() { switch (upArrowState) { case ArrowState.Hide: if (upArrow.fillAmount != 0.0f) { upArrow.fillAmount -= arrowStep; } break; case ArrowState.Reveal: if (upArrow.fillAmount != 1.0f) { upArrow.fillAmount += arrowStep; } else { upArrowState = ArrowState.Visible; } break; case ArrowState.Visible: break; } }
// Use this for initialization void Start() { //Remember to add in code to check for audiosource spotLightTransform = GameObject.Find("Spotlight").transform; arrowState=ArrowState.None; leftArrow=GameObject.Find("Arrows/leftArrow"); rightArrow=GameObject.Find("Arrows/rightArrow"); upArrow=GameObject.Find("Arrows/upArrow"); downArrow=GameObject.Find("Arrows/downArrow"); }
public HMIArrow() { InitializeComponent(); this.tmrBlink = new Timer(); this.tmrBlink.Tick += this.OnBlink; this.Size = new Size(20, 70); this.arrowColor = Color.Red; this.state = ArrowState.On; this.blinkIsOn = true; //this.ValueChange += this.OnValueChange; }
public void FireArrow() { arrowState = ArrowState.flying; // need to add stuff about rotation direction if (gameObject.transform.lossyScale.x < 0) { velocity.x = -1 * moveSpeed; } else { velocity.x = moveSpeed; } }
void OnCollisionEnter(Collision collision) { if (m_state == ArrowState.FLYING) { IDamageable other_D = collision.gameObject.GetComponent <IDamageable>(); if (other_D != null) { other_D.DealDamage(m_src != null ? m_src : gameObject, m_damage); } m_state = ArrowState.HIT; m_spawnTime = Time.time; } }
private void arrow_MouseDown(object sender, MouseEventArgs e) { PictureBox p = sender as PictureBox; if (p.Name == "arrowup") { p.Image = ResClass.GetImgRes("scrollbar_arrowup_down"); currentArrow = ArrowState.Up; } else { p.Image = ResClass.GetImgRes("scrollbar_arrowdown_down"); currentArrow = ArrowState.Down; } timer.Enabled = true; }
public void SetResolution(ArrowState _arrowState) { int currentResolution = Settings.Instance.gameResolution; currentResolution += _arrowState == ArrowState.Next?1:-1; if (currentResolution > Settings.Instance.availableResolutions.Length - 1) { currentResolution = 0; } else if (currentResolution < 0) { currentResolution = Settings.Instance.availableResolutions.Length - 1; } Settings.Instance.gameResolution = currentResolution; SetResolution(); }
public void SetQuality(ArrowState _arrowState) { int currentQuality = (int)Settings.Instance.Quality; currentQuality += _arrowState == ArrowState.Next?1:-1; if (currentQuality > Extensions.GetEnumCount <Quality>() - 1) { currentQuality = 0; } else if (currentQuality < 0) { currentQuality = Extensions.GetEnumCount <Quality>() - 1; } Settings.Instance.Quality = (Quality)currentQuality; SetQuality(); }
private void OnCollisionEnter(Collision collision) { if (arrowLandFlag) { return; } arrowLandFlag = true; if (collision.gameObject.tag == "Target") //arrow scoring { currentState = ArrowState.LandedArrow; rigidbody.constraints = RigidbodyConstraints.FreezeAll; BowEvents.RaiseBowEvent(BowEvents.BowEventType.LandArrow); } else if (gameManager != null) //if arrow landed on ground { gameManager.AddScore(0); currentState = ArrowState.LandedArrow; BowEvents.RaiseBowEvent(BowEvents.BowEventType.LandArrow); } }
public void Shoot(float power) { if (gameObject.GetComponent <Rigidbody>() == null) { rigidbody = gameObject.AddComponent <Rigidbody>(); rigidbody.AddForce(Quaternion.Euler(new Vector3(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z)) * new Vector3(25f * power, 0, 0), ForceMode.VelocityChange); //Debug.Log("power = " + power); } lastFramePosition = transform.position; arrowState = ArrowState.flying; Global.flyTime = 0f; GameObject.Find("UI Root").transform.Find("Control - Colored Slider").gameObject.GetComponent <BoxCollider>().enabled = false; //addAcceleration = true; }
public static void UpdataUseSkill(List <Skill> m_SkillList, bool mustCheck = false, bool isCoexist = false) { if (m_SkillList == null) { skillList.Clear(); } else { skillList = m_SkillList; for (int i = 0; i < m_SkillList.Count; i++) { bool needAdd = true; for (int j = 0; j < allSkillList.Count; j++) { if (allSkillList[j].data.Name == m_SkillList[i].data.Name) { allSkillList[j].TargetWithHanderDic = m_SkillList[i].TargetWithHanderDic; needAdd = false; } } if (needAdd) { allSkillList.Add(m_SkillList[i]); } } } if (mustCheck) { arrowState = ArrowState.moveToUp; } else { arrowState = ArrowState.moveToDown; } OnUpArrowBtnClick(); SetSkillCardPos(isCoexist); }
static void OnUpArrowBtnClick() { TweenPosition arrow_Tp = arrow.GetComponent <TweenPosition>(); TweenRotation arrow_RT = arrow.GetComponent <TweenRotation>(); TweenPosition cardWidget_Tp = cardWidget.GetComponent <TweenPosition>(); arrow_Tp.enabled = true; cardWidget_Tp.enabled = true; arrow_RT.enabled = true; if (arrowState == ArrowState.moveToUp) { arrow_Tp.from = arrow_Tp.transform.localPosition; arrow_Tp.to = new Vector3(0, -183.9f, 0); arrowState = ArrowState.moveToDown; cardWidget_Tp.from = cardWidget_Tp.transform.localPosition; cardWidget_Tp.to = new Vector3(0, 3.5f, -5); arrow_RT.from = arrow_RT.transform.rotation.eulerAngles; arrow_RT.to = new Vector3(0, 0, 180); } else if (arrowState == ArrowState.moveToDown) { arrow_Tp.from = arrow_Tp.transform.localPosition; arrow_Tp.to = new Vector3(0, -518.94f, 0); arrowState = ArrowState.moveToUp; cardWidget_Tp.from = cardWidget_Tp.transform.localPosition; cardWidget_Tp.to = new Vector3(0, -1, -5); arrow_RT.from = arrow_RT.transform.rotation.eulerAngles; arrow_RT.to = new Vector3(0, 0, 0); } arrow_Tp.ResetToBeginning(); cardWidget_Tp.ResetToBeginning(); arrow_RT.ResetToBeginning(); }
// Update is called once per frame void Update() { if(Input.GetKey(KeyCode.UpArrow) && state == ArrowState.down){ menuPlay.transform.localScale = new Vector3(menuScale, menuScale, 1); menuControls.transform.localScale = new Vector3(1, 1, 1); transform.position = positionUp; state = ArrowState.up; } if(Input.GetKey(KeyCode.DownArrow) && state == ArrowState.up){ menuControls.transform.localScale = new Vector3(menuScale, menuScale, 1); menuPlay.transform.localScale = new Vector3(1, 1, 1); transform.position = positionDown; state = ArrowState.down; } if(Input.GetKey(KeyCode.Return)){ if(state == ArrowState.up) Application.LoadLevel("Act1Scene0"); else Application.LoadLevel("Act0Controls"); } }
static void OnCardDragFished() { arrowState = ArrowState.moveToDown; OnUpArrowBtnClick(); DragSkillCard current = DragSkillCard.current; string name = current.gameObject.name; Skill skill = null; for (int i = 0; i < allSkillList.Count; i++) { if (name == allSkillList[i].data.Name) { skill = allSkillList[i]; } } curSkill = skill; List <string> targetNameList = new List <string>(); foreach (string item in skill.TargetWithHanderDic.Keys) { targetNameList.Add(item); } int count = targetWidget.transform.childCount; for (int i = 0; i < targetNameList.Count; i++) { GameObject go = null; if (i < count) { go = targetWidget.transform.GetChild(i).gameObject; UISprite sprite = go.transform.FindRecursively("Sprite").GetComponent <UISprite>(); sprite.spriteName = targetNameList[i]; } else { go = GameObject.Instantiate(infoItem); go.transform.SetParent(targetWidget.transform, false); } UIButton button = go.GetComponent <UIButton>(); button.onClick.Clear(); button.onClick.Add(skill.TargetWithHanderDic[targetNameList[i]]); button.onClick.Add(new EventDelegate(OnTargetBtnClick)); UILabel nameLabel = go.transform.FindRecursively("nameLabel").GetComponent <UILabel>(); if (targetNameList[i] == "myself") { nameLabel.text = "自己"; } else if (targetNameList[i] == "scene") { nameLabel.text = "环境"; } go.name = targetNameList[i]; go.SetActive(true); } for (int i = targetWidget.transform.childCount - 1; i >= targetNameList.Count; i--) { GameObject go = targetWidget.transform.GetChild(i).gameObject; go.SetActive(false); } targetWidget.gameObject.SetActive(true); targetWidget.Reposition(); }
void OnTriggerEnter2D(Collider2D collider) { if (arrowState == ArrowState.flying) { if (System.Array.Exists(TagFilterArray, element => element == collider.tag)) { arrowState = ArrowState.stuck; velocity.x = 0; velocity.y = 0; if (collider.tag == "Deer") { Deer deer = collider.gameObject.GetComponent <Deer>(); deer.HitByArrow(); animator.Play(Fade); } if (collider.tag == "SmartRangedEnemy") { SmartRangedEnemy enemy = collider.gameObject.GetComponent <SmartRangedEnemy>(); enemy.HitByArrow(); animator.Play(Fade); } if (collider.tag == "Player") { Player player = collider.gameObject.GetComponent <Player>(); player.HitByEnemy(); animator.Play(Fade); } if (collider.tag == "Spiderwalker") { Spiderwalker enemy = collider.gameObject.GetComponent <Spiderwalker>(); enemy.HitByArrowArmor(); animator.Play(Fade); } if (collider.tag == "SWFoot") { Spiderwalker enemy = collider.transform.root.GetComponent <Spiderwalker>(); enemy.HitByArrowArmor(); animator.Play(Fade); } if (collider.tag == "SWViewport") { Spiderwalker enemy = collider.transform.root.GetComponent <Spiderwalker>(); enemy.HitByArrowFace(); animator.Play(Fade); } if (collider.tag == "SpiderShooter") { SpiderShooter enemy = collider.transform.root.GetComponent <SpiderShooter>(); print(enemy); enemy.HitByArrowArmor(); animator.Play(Fade); } if (collider.tag == "SpiderBall") { SpiderShooter enemy = collider.transform.root.GetComponent <SpiderShooter>(); enemy.HitByArrowFace(); animator.Play(Fade); } } } }
public void SetCharging() { arrowState = ArrowState.charging; }
private void arrow_MouseUp(object sender, MouseEventArgs e) { currentArrow = ArrowState.None; arrow_MouseLeave(sender, null); }
public void SetReleased() { arrowState = ArrowState.released; SetSpeed(chargeLevel); }
private void updateState() { switch (mousePosSection) { case MouseSection.UpArrow: if (isMouseDown) { upArrowState = ArrowState.MouseDown; } else { upArrowState = ArrowState.MouseHover; } downArrowState = ArrowState.NoBorder; barState = ScrollBarState.MouseHover; break; case MouseSection.DownArrow: upArrowState = ArrowState.NoBorder; if (isMouseDown) { downArrowState = ArrowState.MouseDown; } else { downArrowState = ArrowState.MouseHover; } barState = ScrollBarState.MouseHover; break; case MouseSection.BtnBar: upArrowState = ArrowState.NoBorder; downArrowState = ArrowState.NoBorder; if (isMouseDown) { barState = ScrollBarState.MouseDown; } else { barState = ScrollBarState.MouseHover; } break; case MouseSection.ScrollBar: upArrowState = ArrowState.NoBorder; downArrowState = ArrowState.NoBorder; barState = ScrollBarState.MouseHover; break; case MouseSection.Out: if (!isMouseDown) { upArrowState = ArrowState.Hide; downArrowState = ArrowState.Hide; barState = ScrollBarState.NoBack; } else { } break; } }
IEnumerator LateHideCore(float time) { yield return new WaitForSeconds(time); this.State = ArrowState.Hide; }
void Start() { GameObject.Find("Spotlight").transform.parent=transform; Camera.main.transform.parent=transform; arrowState1=ArrowState.None; arrowState2=ArrowState.None; arrowState3=ArrowState.None; leftArrow=GameObject.Find("Arrows/leftArrow1"); rightArrow=GameObject.Find("Arrows/rightArrow1"); upArrow=GameObject.Find("Arrows/upArrow1"); downArrow=GameObject.Find("Arrows/downArrow1"); leftArrow2=GameObject.Find("Arrows/leftArrow2"); rightArrow2=GameObject.Find("Arrows/rightArrow2"); upArrow2=GameObject.Find("Arrows/upArrow2"); downArrow2=GameObject.Find("Arrows/downArrow2"); leftArrow3=GameObject.Find("Arrows/leftArrow3"); rightArrow3=GameObject.Find("Arrows/rightArrow3"); upArrow3=GameObject.Find("Arrows/upArrow3"); downArrow3=GameObject.Find("Arrows/downArrow3"); }
// Start is called before the first frame update void Start() { m_state = ArrowState.FLYING; m_spawnTime = Time.time; }
private void Awake() { foreach (Transform ui in GetComponentsInChildren <Transform>()) { if (ui.GetComponent <Image>() != null) { if (ui.name.Contains("Magnitude")) { magnitude = ui.GetComponent <Image>(); magnitude.fillAmount = 0.0f; } else if (ui.name.Contains("Speed")) { speed = ui.GetComponent <Image>(); speed.fillAmount = 0.0f; } else if (ui.name.Contains("TravelUp")) { upArrow = ui.GetComponent <Image>(); upArrow.fillAmount = 0.0f; } else if (ui.name.Contains("TravelDown")) { downArrow = ui.GetComponent <Image>(); downArrow.fillAmount = 0.0f; } else if (ui.name.Contains("Arrow")) { directionArrow = ui.GetComponent <Image>(); directionArrow.color = new Color(1.0f, 1.0f, 1.0f, 0.0f); } else if (ui.name.Contains("AmmoUI")) { AmmoUI = ui.GetComponent <Image>(); AmmoUI.fillAmount = 1.0f; } else if (ui.name.Contains("AmmoIcon")) { AmmoIcon = ui.GetComponent <Image>(); AmmoIcon.color = Color.white; } else { Debug.Log("Fund HUD child with no matching name: " + ui.name); } } else if (ui.name != "HUD") //don't need to find the HUD parent { if (ui.name.Contains("Direction")) { direction = ui; } else if (ui.name.Contains("AltoUI")) { AltoUI = ui.gameObject; } else if (ui.name.Contains("GameUI")) { GameUI = ui.gameObject; } else if (ui.name.Contains("UI Text")) { TextUI = ui.gameObject; } else if (ui.name.Contains("ScoreUI")) { Score = ui.GetComponent <TextMesh>(); } else if (ui.name.Contains("TimerUI")) { TimerUI = ui.GetComponent <TextMesh>(); } else { Debug.Log("Found HUD child with no matching name: " + ui.name); } } } upArrowState = ArrowState.Hide; downArrowState = ArrowState.Hide; arrowStep = revealTime / 1.0f; foreach (Image i in ControllerSpeedUI.GetComponentsInChildren <Image>()) { if (i.name.Contains("Up")) { upSpeed = i; arrowEdge = i.sprite; } else if (i.name.Contains("Down")) { downSpeed = i; } else { Debug.Log("Found child of speed UI that doesn't match: " + i.name); } } GameUI.SetActive(false); started = true; }
public void setState(ArrowState state) { _State = state; }