// Use this for initialization void Start() { ga = GameObject.FindGameObjectWithTag("GameAdmin").GetComponent <GameAdmin>(); ga.can_place_turret = true; turrets = new Turret[num_of_turrets]; troops = new Troop[num_of_troops]; turret_buttons = new Button[num_of_turrets]; troop_buttons = new Button[num_of_troops]; turrets[0] = turret0; turrets[1] = turret1; turrets[2] = turret2; turrets[3] = turret3; turrets[4] = turret4; turret_buttons[0] = turret0_button; turret_buttons[1] = turret1_button; turret_buttons[2] = turret2_button; turret_buttons[3] = turret3_button; turret_buttons[4] = turret4_button; troops[0] = troop0; troops[1] = troop1; troops[2] = troop2; troops[3] = troop3; troops[4] = troop4; troops[5] = troop5; troop_buttons[0] = troop0_button; troop_buttons[1] = troop1_button; troop_buttons[2] = troop2_button; troop_buttons[3] = troop3_button; troop_buttons[4] = troop4_button; troop_buttons[5] = troop5_button; }
private void OnMouseDown() { ga = GameObject.FindGameObjectWithTag("GameAdmin").GetComponent <GameAdmin>(); if ((ga.destroySelectButtonPressed) && (ga.destroySelectsLeft > 0)) { Destroy(gameObject); ga.destroySelectsLeft--; } }
// Use this for initialization void Start() { ga = GameObject.FindGameObjectWithTag("GameAdmin").GetComponent <GameAdmin>(); gameObject.GetComponent <Collider2D>().isTrigger = true; placed = false; troop_in_range = false; paralyzed = false; transform.localScale = new Vector3(0.1355172f, 0.1355172f, 0.1355172f); }
/// <summary> /// Constructor de la clase <see cref="ConnectWin"/>. /// </summary> /// <param name="init">InitWin.</param> /// <param name="gA">GameAdmin.</param> public ConnectWin(InitWin init, GameAdmin gA) { this.init = init; this.gA = gA; net = NetMode.Instance; net.Conn = this; InitializeComponent(); textIp.Text = this.LocalIPAddress(); btnSend.Visibility = Visibility.Hidden; }
//シングルトン用コード void Awake() { if(instance == null) { instance = this; DontDestroyOnLoad(this); } else { Destroy(this); } }
// Update is called once per frame void Update () { ap_name_text.text = "A. Player: " + PlayerPrefs.GetString("attplayername"); ap_gold_text.text = "Gold: " + PlayerPrefs.GetInt("ap_money"); ap_troops_sent_text.text = "Troops Sent: " + PlayerPrefs.GetInt("troops_sent"); ap_troops_killed_text.text = "Troops Killed: " + PlayerPrefs.GetInt("troops_killed"); dp_name_text.text = "D. Player: " + PlayerPrefs.GetString("defplayername"); dp_gold_text.text = "Gold: " + PlayerPrefs.GetInt("dp_money"); dp_turrets_built_text.text = "Turrets Built: " + PlayerPrefs.GetInt("turrets_built"); dp_troops_killed_text.text = "Troops Killed: " + PlayerPrefs.GetInt("troops_killed"); string minutes = ((int)(gameTimer / 60)).ToString(); string seconds_s = ((int)(gameTimer % 60)).ToString(); if (seconds_s.Length == 1) { seconds_s = "0" + seconds_s; } timer_text.text = minutes + ":" + seconds_s; currentGameTime += Time.deltaTime; if (currentGameTime >= gameTimerInterval) { PlayerPrefs.SetInt("ap_money", PlayerPrefs.GetInt("ap_money") + 200); PlayerPrefs.SetInt("dp_money", PlayerPrefs.GetInt("dp_money") + 100); gameTimer -= 1; currentGameTime = 0.0f; if (gameTimer < ogGameTimer/2) { PlayerPrefs.SetInt("ap_money", PlayerPrefs.GetInt("ap_money") + 200); PlayerPrefs.SetInt("dp_money", PlayerPrefs.GetInt("dp_money") + 150); } } if (gameTimer < ogGameTimer/2) { GameObject[] allObjects = UnityEngine.Object.FindObjectsOfType<GameObject>(); ga = GameObject.FindGameObjectWithTag("GameAdmin").GetComponent<GameAdmin>(); for (int i = 0; i < allObjects.Length; i++) { GameObject obj = allObjects[i]; if (obj.activeInHierarchy && obj.CompareTag("Troop") && !obj.GetComponent<Troop>().halftime_upgraded && (!ga.freezeButtonPressed)) { obj.GetComponent<Troop>().currHealth += 5; obj.GetComponent<Troop>().speedMult += 0.3f; obj.GetComponent<Troop>().halftime_upgraded = true; } } } if (timer_text.text == "0:00") { End(PlayerPrefs.GetString("defplayername")); } }
public virtual void Damage(float dmg) { if (currHealth - dmg <= 0) { if (!rezzed) { ga = GameObject.FindGameObjectWithTag("GameAdmin").GetComponent <GameAdmin>(); string type = gameObject.GetComponent <Troop>().name; Vector2 pos = new Vector2(gameObject.GetComponent <Troop>().transform.position.x, gameObject.GetComponent <Troop>().transform.position.y); Vector2 dir = new Vector2(gameObject.GetComponent <Troop>().direction.x, gameObject.GetComponent <Troop>().direction.y); TroopCopy tp = new TroopCopy(type, pos, dir); ga.deadTroops.Add(tp); } Instantiate(deathParticle, transform.position, transform.rotation); Destroy(gameObject); } currHealth -= dmg; }
/// <summary> /// Manejador para el botón Aceptar. /// </summary> /// <param name="sender">Event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void btnAccept_Click(object sender, RoutedEventArgs e) { if ((Texboxname.Text.Length == 0) || (Texboxpwd.Password.Length == 0)) { Textlogin.Text = "El usuario y/o la contraseña son vacios."; Textlogin.Foreground = Brushes.Orange; } else { GameAdmin g = GameAdmin.Instance; bool b = g.loginPlayer(Texboxname.Text, Texboxpwd.Password); if (b == true) { ConnectWin conect = new ConnectWin(init, g); conect.Show(); this.Visibility = Visibility.Hidden; } else { Textlogin.Text = "Usuario o contraseña incorrectos..."; Textlogin.Foreground = Brushes.Red; } } }
/// <summary> /// Manejador para el botón Aceptar. /// </summary> /// <param name="sender">Event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void btnAccept_Click(object sender, RoutedEventArgs e) { if ((Tboxuser.Text.Length == 0) || (Tboxpwd.Password.Length == 0) || (ruta.Length == 0)) { Textprofile.Text = "El usuario, contraseña y/o imagen no pueden ser vacios."; Textprofile.Foreground = Brushes.Orange; } else { p = new Player(Tboxuser.Text, Tboxpwd.Password, ruta); GameAdmin g = GameAdmin.Instance; if (g.existPlayer(p.Name)) { g.insertPlayer(p); init.Visibility = Visibility.Visible; this.Close(); } else { Textprofile.Text = "Nombre ya existente en la base de datos."; Textprofile.Foreground = Brushes.Red; } } }
// Use this for initialization void Start() { ga = GameObject.FindGameObjectWithTag("GameAdmin").GetComponent <GameAdmin>(); ga.destroy_button = delete5Troops_button; ga.freeze_button = freezeTroops_button; }
public void setGameAdmin(GameAdmin admin) { _admin = admin; }
// Use this for initialization void Start() { ga = GameObject.FindGameObjectWithTag("GameAdmin").GetComponent <GameAdmin>(); homeLivesLeftText.text = PlayerPrefs.GetInt("homeLivesLeft").ToString(); camShake = ga.GetComponent <CameraShake>(); }
public void setGameAdminReference(GameAdmin admin) { _admin = admin; }