//게임 시작 준비. void UpdateGameIn() { //스테이지 구축. GameObject stage = GameObject.Find("Stage"); if (stage == null) { stage = Instantiate(m_stagePrefabs[m_gameCount]) as GameObject; stage.name = "Stage"; return; } //페이드인을 기다립니다. GameObject[] blocks = GameObject.FindGameObjectsWithTag("Block"); foreach (GameObject obj in blocks) { BlockScript b = obj.GetComponent <BlockScript>(); if (b.IsFadeIn()) { return; } } //게임 시작으로 전환. m_state = State.Game; m_gameTime = 0; //발사할 수 있게 합니다. GameObject[] bars = GameObject.FindGameObjectsWithTag("Bar"); foreach (GameObject obj in bars) { BarScript bar = obj.GetComponent <BarScript>(); bar.SetShotEnable(true); //발사기능 OFF. } }
//스테이지를 바꾸는 연출.. void UpdateGameChanging() { //초밥 페이드 아웃 시작. GameObject[] blocks = GameObject.FindGameObjectsWithTag("Block"); foreach (GameObject obj in blocks) { BlockScript b = obj.GetComponent <BlockScript>(); b.FadeOut(); } //탄환 소거. GameObject[] balls = GameObject.FindGameObjectsWithTag("Ball"); foreach (GameObject obj in balls) { Destroy(obj); } //발사할 수 없게 합니다. GameObject[] bars = GameObject.FindGameObjectsWithTag("Bar"); foreach (GameObject obj in bars) { BarScript bar = obj.GetComponent <BarScript>(); bar.SetShotEnable(false); //발사 기능 OFF. } //다음 상태로 전환. m_state = State.GameOut; }
private void Awake() { dataDialog = GameObject.Find(DataDialogScript.DataDialogName).GetComponent <DataDialogScript>(); progressBar = transform.Find("ChildIndicatorPanel").GetComponentInChildren <BarScript>(); progressBar.transform.localPosition -= new Vector3(progressBar.gameObject.GetComponent <SpriteRenderer>().sprite.bounds.extents.x, 0, 0); onCompleteSound = GameObject.Find("InteractableBuildings").GetComponent <AudioSource>(); }
//private float damage = 0.1f; // Use this for initialization void Start() { ResetPoint = GameObject.Find("Resetpoint"); bar = GameObject.FindObjectOfType <BarScript>(); RigidBody = GetComponent <Rigidbody>(); MainCamera = FindObjectOfType <Camera>(); bar.fillAmount = maxStamina; }
/** * <summary>Awake is called when the script instance is being loaded. * Awake is used to initialize any variables or game state before the game starts. Awake is called only once during the lifetime of the script instance, * being always invoked before Start().</summary> * <see>https://docs.unity3d.com/ScriptReference/MonoBehaviour.Awake.html</see> */ void Awake() { //Check if instance already exists if (Instance == null) { //if not, set instance to this Instance = this; } }
// Use this for initialization void Start() { counter = 0; damageDealt = 0; player = GameObject.FindGameObjectWithTag("Player"); healthbar = FindObjectOfType <BarScript>(); backpack = player.transform.Find("Backpack").gameObject; items = backpack.GetComponent <itemController>(); }
public void healthbarUpdate() { bar = player.GetComponent <Player>().getBarScript(); bar.Value = currentHealth; bar.MaxValue = maxHealth; if (currentHealth > maxHealth) { currentHealth = maxHealth; } }
// Use this for initialization void Start() { maxHP = 100; currentHP = 100; this.SetTimeBetweenAttacks(defaultTimeBetweenAttacks); timeSinceLastAttack = 0f; health = transform.GetChild(0).GetChild(0).gameObject.GetComponent <BarScript>(); attackTimer = transform.GetChild(0).GetChild(1).gameObject.GetComponent <BarScript>(); enemyArea = GameObject.Find("EnemySpace").GetComponent <EnemyArea>(); allyArea = GameObject.Find("AllySpace").GetComponent <AllyArea>(); }
// Use this for initialization void Start() { this.transform.position = currentTile.characterPosition; this.talkTarget = null; pathHelper = gameObject.GetComponent <Astar>() as Astar; audioSource = GetComponent <AudioSource>(); audioSource.playOnAwake = false; audioSource.outputAudioMixerGroup = sfx; // audioManager = GameObject.FindObjectOfType<AudioManager>(); // // if(audioManager == null) // { // Debug.LogError("Audio Manager is not in the scene"); // } GameObject uiElement = GameObject.FindGameObjectWithTag("UILife"); if (uiElement != null) { Transform targetChild = uiElement.transform.GetChild(uiIndex); if (targetChild != null) { barScript = targetChild.gameObject.GetComponentInChildren <BarScript>(); barScript.SetName(gameObject.name); } else { Debug.LogError("UI Child Not Found"); }; } else { Debug.LogError("UI for lifes not found"); } GameObject[] tiles = GameObject.FindGameObjectsWithTag("Tile"); Tile currTile = null; for (int i = 0; i < tiles.Length; i++) { currTile = tiles[i].GetComponent <Tile>(); if (currTile.useAstar || Random.Range(0, 101) < markedTilesPercentage) { pathHelper.AddTile(currTile); } } roamingT = 0f; }
private IEnumerator ProgressBar(int steps) { progressBar.SetActive(true); BarScript script = progressBar.GetComponent <BarScript>(); for (int i = 0; i < steps; i++) { yield return(new WaitForSeconds(1f)); Debug.Log("FILL"); script.IncreaseProgress(); } progressBar.SetActive(false); script.ResetBar(); }
void Start() { spawnManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <SpawnManager>(); switch (barChoose) { case 0: bar = GameObject.FindGameObjectWithTag("Resources").GetComponent <BarScript>(); break; case 1: bar = GameObject.FindGameObjectWithTag("Spells").GetComponent <BarScript>(); break; } }
public void Fireball_Event() { BarScript bS = FindObjectOfType <BarScript>(); GameObject projectile = Instantiate(fireballs[bS.fireballType], fb_spawnPos.position, Quaternion.Euler(transform.right)) as GameObject; // fireball.GetComponent<Rigidbody>().AddForce(fireball.transform.right * fb_speed); if (facingRight) { projectile.GetComponent <Rigidbody>().AddForce(fireballs[bS.fireballType].transform.right * projectile.GetComponent <Fireball>().fbSpeed); } else { projectile.GetComponent <Rigidbody>().AddForce(-fireballs[bS.fireballType].transform.right * projectile.GetComponent <Fireball>().fbSpeed); } }
// Use this for initialization void Awake() { dataDialogUI = transform.Find(DataDialogName + "UI").gameObject; Transform textGrouper = dataDialogUI.transform.FindChild("TextGrouper"); childName = textGrouper.FindChild("ChildName").GetComponent <Text>(); childLocation = textGrouper.FindChild("ChildLocation").GetComponent <Text>(); Transform barGrouper = dataDialogUI.transform.FindChild("BarGrouper"); healthBar = barGrouper.FindChild("HealthBar").GetComponentInChildren(typeof(BarScript)) as BarScript; safetyBar = barGrouper.FindChild("SafetyBar").GetComponentInChildren(typeof(BarScript)) as BarScript; educationBar = barGrouper.FindChild("EducationBar").GetComponentInChildren(typeof(BarScript)) as BarScript; happinessBar = barGrouper.FindChild("HappinessBar").GetComponentInChildren(typeof(BarScript)) as BarScript; }
void Awake() { // Setting up references. groundCheck1 = transform.Find("groundCheck1"); groundCheck2 = transform.Find("groundCheck2"); rigidbody2d = GetComponent <Rigidbody2D> (); animator = GetComponent <Animator> (); isDead = false; curMonkeyHealth = monkeyHealth; missionOver = false; //healthScale = healthBar.transform.localScale; healthBar = GameObject.FindGameObjectWithTag("HealthBar").GetComponent <BarScript>(); healthBar.MaxValue = monkeyHealth; ui_score = GameObject.FindGameObjectWithTag("UI_Score").GetComponent <Text> (); }
// Use this for initialization void Start() { playerRotation = transform.rotation; if (GetComponent <Rigidbody>()) { rigidbody = GetComponent <Rigidbody>(); } else { Debug.LogError("Character needs a rigidbody"); } forwardInput = rotateInput = jumpInput = 0; anim = GetComponent <Animator>(); barScript = GetComponent <BarScript>(); }
// void OnCollisionEnter2D(Collision2D col) { //효과 생성. //그대로 두면 지면에 파고들기에 카메라 방향으로 위치를 옮깁니다 Vector3 effectPos = transform.position - 3 * Camera.main.transform.forward; Instantiate(m_hitEffectPrefab, effectPos, transform.rotation); //SE audio.Play(); if (col.gameObject.tag == "Bar") { BarScript bar = col.gameObject.GetComponent <BarScript>(); SetPlayerId(bar.GetBarId()); m_velocity += 0.3f; } if (col.gameObject.tag == "Ball") { // 공 끼리의 충돌은 역방향으로 튀게 합니다. m_direction *= -1.0f; } else { // 공 이외의 충돌은 충돌면의 법선 방향으로 반전합니다. float range = Mathf.Sin(Mathf.Deg2Rad * 3); //3도 정도는 허용합니다. Vector2 normal = col.contacts[0].normal; if (normal.x > range || normal.x < -range) { m_direction.x *= -1.0f; } if (normal.y > range || normal.y < -range) { m_direction.y *= -1.0f; } } // 반전된 방향으로 현재 속도를 합해 설정합니다. rigidbody2D.velocity = m_velocity * m_direction; }
void Awake() { if (pInstance != null) { Destroy(gameObject); //print("Duplicate music player is self-destructing"); } else { pInstance = this; healthBar = GameObject.Find("RadialBar").GetComponent <BarScript>(); energyBar = GameObject.Find("EnergyBar").GetComponent <BarScript>(); shieldBar = GameObject.Find("ShieldBar").GetComponent <BarScript>(); DontDestroyOnLoad(gameObject); } health.Initialize(healthBar); energy.Initialize(energyBar); shield.Initialize(shieldBar); }
/// <summary> /// Links this Avatar to a Unit which it represents. This serves as a constructor in practice, /// moving this class from a template which defines a Unit, to a visual representation of it. /// </summary> /// <param name="unit">The Unit to link this too</param> public void SetUnit(Unit unit) { if (unit.Avatar != this) { throw new ArgumentException("Assigned Unit has a different Avatar"); } if (_unit != null) { throw new ArgumentException("This Avatar has already been assigned a Unit"); } _unit = unit; Position = unit.Position.ToVector3(); Rotation = unit.Facing.GetBearingRotation(); // make UI elements _hpBar = Instantiate(GuiComponents.GetHpBar()).GetComponent <BarScript>(); _epBar = Instantiate(GuiComponents.GetEpBar()).GetComponent <BarScript>(); TeamColorPaint(); //FMODUnity.RuntimeManager.PlayOneShot (inSound, Position); }
void Start() { flySpeed = meteorScriptableObject.flySpeed; turnSpeed = meteorScriptableObject.turnSpeed; health = meteorScriptableObject.maxHealth; meteorSize = meteorScriptableObject.meteorSize; meteorDamage = health / 3; parent = transform.parent.gameObject; //rb = transform.Find("Meteor").GetComponent<Rigidbody2D>(); //Wyszukanie komponentu Rigidbody2D z dzieci o nazwie "Meteor" rb = this.GetComponent <Rigidbody2D>(); //Lokalne wyszukanie komponentu Rigidbody rb.gravityScale = 0; rb.angularDrag = 0; healthBar = parent.transform.Find("HealthBar").GetComponent <BarScript>(); float rotationRandom; rotationRandom = Random.Range(-50f, 50f); rb.angularVelocity = turnSpeed * rotationRandom * 10 * Time.fixedDeltaTime; Vector2 randomForce; randomForce = new Vector2(flySpeed * Random.Range(-5f, 5f), flySpeed * Random.Range(-5f, 5f)); Vector2 force; force = randomForce; rb.AddForce(force); healthBar.SetSize(barSize); healthBar.SetColor(Color.green); }
public void setBar(BarScript setMe) { bar = setMe; }
/* The initial setting of the MaxVal and CurrentVal allows the StatScript.MaxVal to trigger the BarScript.MaxValue, * which sets the BarScript.Value, which updates the fillAmount properly for BarScript.HandleBar. */ public void Initialize(BarScript barUI) { bar = barUI; this.MaxVal = maxVal; this.CurrentVal = currentVal; }
public void PickTarget(int targetID) { target = targets[targetID]; }
private void OnMouseUpAsButton() { if (open) { if (openObject.name.Equals(name)) { switch (SceneManager.GetActiveScene().name) { case "mainMap": GameObject.Find("1").GetComponent <BoxCollider2D>().enabled = true; break; case "secondaryMap": GameObject.Find("1").GetComponent <BoxCollider2D>().enabled = true; GameObject.Find("2").GetComponent <BoxCollider2D>().enabled = true; GameObject.Find("3").GetComponent <BoxCollider2D>().enabled = true; GameObject.Find("4").GetComponent <BoxCollider2D>().enabled = true; GameObject.Find("5").GetComponent <BoxCollider2D>().enabled = true; GameObject.Find("6").GetComponent <BoxCollider2D>().enabled = true; GameObject.Find("7").GetComponent <BoxCollider2D>().enabled = true; GameObject.Find("8").GetComponent <BoxCollider2D>().enabled = true; break; case "tertiaryMap": for (int i = 1; i < count + 1; i++) { GameObject.Find(i.ToString()).GetComponent <BoxCollider>().enabled = true; } break; default: break; } switch (name) { case "Backpack": Destroy(openObject); break; case "SelectCard": GlobalVariable.FightCards.Clear(); for (int i = 0; i < CardSelect.count; i++) { GlobalVariable.FightCards.Add(CardSelect.fightCardsGrids[i].gameProp); } CardSelect.Clear(); BarScript.Clear(); Destroy(openObject); break; case "SkillSelect": SkillSelect.Clear(); Destroy(openObject); break; default: break; } open = false; return; } else { switch (openObject.name) { case "Backpack": Destroy(openObject); break; case "SelectCard": GlobalVariable.FightCards.Clear(); for (int i = 0; i < CardSelect.count; i++) { GlobalVariable.FightCards.Add(CardSelect.fightCardsGrids[i].gameProp); } CardSelect.Clear(); BarScript.Clear(); Destroy(openObject); break; case "SkillSelect": SkillSelect.Clear(); Destroy(openObject); break; default: break; } switch (name) { case "Backpack": openObject = Instantiate(Resources.Load <GameObject>("PanelPrefabs/Backpack"), new Vector3(0, 0, 0), Quaternion.identity); openObject.name = "Backpack"; break; case "SelectCard": openObject = Instantiate(Resources.Load <GameObject>("PanelPrefabs/SelectCard"), new Vector3(0, 0, 0), Quaternion.identity); openObject.name = "SelectCard"; break; case "SkillSelect": openObject = Instantiate(Resources.Load <GameObject>("PanelPrefabs/SkillSelect"), new Vector3(0, 0, 0), Quaternion.identity); openObject.name = "SkillSelect"; break; default: break; } open = true; return; } } if (!open) { switch (SceneManager.GetActiveScene().name) { case "mainMap": GameObject.Find("1").GetComponent <BoxCollider2D>().enabled = false; break; case "secondaryMap": GameObject.Find("1").GetComponent <BoxCollider2D>().enabled = false; GameObject.Find("2").GetComponent <BoxCollider2D>().enabled = false; GameObject.Find("3").GetComponent <BoxCollider2D>().enabled = false; GameObject.Find("4").GetComponent <BoxCollider2D>().enabled = false; GameObject.Find("5").GetComponent <BoxCollider2D>().enabled = false; GameObject.Find("6").GetComponent <BoxCollider2D>().enabled = false; GameObject.Find("7").GetComponent <BoxCollider2D>().enabled = false; GameObject.Find("8").GetComponent <BoxCollider2D>().enabled = false; break; case "tertiaryMap": for (int i = 1; i < count + 1; i++) { GameObject.Find(i.ToString()).GetComponent <BoxCollider>().enabled = false; } break; default: break; } switch (name) { case "Backpack": openObject = Instantiate(Resources.Load <GameObject>("PanelPrefabs/Backpack"), new Vector3(0, 0, 0), Quaternion.identity); openObject.name = "Backpack"; break; case "SelectCard": openObject = Instantiate(Resources.Load <GameObject>("PanelPrefabs/SelectCard"), new Vector3(0, 0, 0), Quaternion.identity); openObject.name = "SelectCard"; break; case "SkillSelect": openObject = Instantiate(Resources.Load <GameObject>("PanelPrefabs/SkillSelect"), new Vector3(0, 0, 0), Quaternion.identity); openObject.name = "SkillSelect"; break; default: break; } open = true; return; } }
// Use this for initialization void Start() { health = FindObjectOfType <playerHealth>(); healthbar = FindObjectOfType <BarScript>(); currentValue = health.getArmor(); }
// Use this for initialization void Start() { player = FindObjectOfType <PlayerScript2>(); playerbar = FindObjectOfType <BarScript>(); enemy = FindObjectOfType <EnemyScript>(); }
// Use this for initialization void Awake() { buttons = transform.GetComponentsInChildren <InputButton> (); bar = transform.FindChild("Bar").GetComponent <BarScript>(); spriteResult = "white"; }
public Stat() { bar = new BarScript(); }
// Use this for initialization void Start() { /* while (GameObject.Find ("SpawnPoint" + i) != null) { * i++; * } */ for (int d = 0; d < 3; d++) { data [d] = new float[highest]; } for (int k = 0; k < 3; k++) { for (int l = 0; l < 3; l++) { data [k] [l] = Random.Range(1f, 10f); } } for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { n = (j + (3 * i)); //( j + (10*(i-1))- 1) Debug.Log(n); if (!GameObject.Find("Bar" + n)) { spawn = GameObject.Find("SpawnPoint" + n); barPrefab = GameObject.Find("Bar_Prefab"); barScript = barPrefab.GetComponent <BarScript> (); barScript.max = data[i][j]; barScript.highest = highest; // theBar.transform.localScale = new Vector3 (x, y, z); theBar = Instantiate(barPrefab, spawn.transform.position, Quaternion.identity); theBar.name = "Bar" + n; } } } /* * * for (int d = 0; d < highest; d++ ){ * data [d] = new float[highest]; * } * * for (int k = 0; k < highest; k++ ){ * for (int l = 0; l < highest; l++ ){ * data [k] [l] = Random.Range (-5f , 20f); * } * } * * for (int i = 0; i < highest; i++ ){ * for (int j = 0; j < highest; j++ ){ * GameObject theBar = GameObject.Find ("Bar_Prefab"); * BarScript barScript = theBar.GetComponent<BarScript> (); * barScript.max = data[i][j]; * barScript.highest = highest; * Instantiate(theBar, new Vector3(i * 2f, 0, j * 2f), Quaternion.identity); * * } * } * Debug.Log ("finish"); */ }