void Start() { //Script init GameObject[] objs = GameObject.FindGameObjectsWithTag("Bro"); foreach (GameObject obj in objs) { myBro = obj.GetComponent <Bro>(); if (myBro != null) { if (myBro.isMe) { break; } } } if (!myBro.isBlue) { joyBack.anchorMin = new Vector2(1, 0); joy.anchorMin = new Vector2(1, 0); joyBack.anchorMax = new Vector2(1, 0); joy.anchorMax = new Vector2(1, 0); joyBack.anchoredPosition = new Vector2(-90, 90); joy.anchoredPosition = new Vector2(-90, 90); useTrans.anchorMin = new Vector2(0, 0); useTrans.anchorMax = new Vector2(0, 0); useTrans.anchoredPosition = new Vector2(70, 70); } }
IEnumerator ApplyDamage() { while (true) { Vector2 pos2D = new Vector2(transform.position.x, transform.position.y); ContactFilter2D conFil = new ContactFilter2D(); conFil.SetLayerMask(LayerMask.GetMask("Bros")); Collider2D[] results = new Collider2D[10]; int numCol = Physics2D.OverlapCircle(pos2D, radius, conFil, results); List <Rigidbody2D> rigidbodies = new List <Rigidbody2D>(); for (int i = 0; i < numCol; i++) { if (results[i].attachedRigidbody != null && !rigidbodies.Contains(results[i].attachedRigidbody)) { rigidbodies.Add(results[i].attachedRigidbody); } } foreach (Rigidbody2D rb in rigidbodies) { if (rb.gameObject.tag == "Bro") { Bro bro = rb.gameObject.GetComponent <Bro>(); if (bro.isMe || bro.isBlue != fromBlue) { bro.ChangeHealth(damage, fromId, 0, Vector2.zero); } } } yield return(new WaitForSeconds(tickLength)); } }
private void OnTriggerEnter2D(Collider2D collision) { Bro player = collision.GetComponent <Bro>(); if (player != null) { player.TakeDamage(20); Destroy(gameObject); } }
void OnTriggerExit2D(Collider2D other) { Bro bro = other.gameObject.GetComponent <Bro>(); if (bro != null) { if (bro.isMe) { hud.ChangeUseButton(false); bro.pickupType = -1; } } }
void CreateSelf() { //Get spawn point Vector3 selfSpawn; if (PhotonNetwork.offlineMode) { selfSpawn = blueSpawn; } else { if (RoomWait.isBlue) { selfSpawn = blueSpawn; } else { selfSpawn = redSpawn; } } //Create self GameObject self; self = PhotonNetwork.Instantiate(broNames[BroSelect.selectedBro], selfSpawn, rot, 0); self.GetComponent <BoxCollider2D>().isTrigger = false; self.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic; //Setup bro component Bro bro = self.GetComponent <Bro>(); bro.isMe = true; bro.respawnLoc = selfSpawn; if (PhotonNetwork.offlineMode) { bro.GetComponent <PhotonView>().RPC("SetTeam", PhotonTargets.AllBuffered, true); } else { bro.GetComponent <PhotonView>().RPC("SetTeam", PhotonTargets.AllBuffered, RoomWait.isBlue); } //Get player (for practice mode) if (PhotonNetwork.offlineMode) { player = self; } }
void ApplyForce() { Vector2 pos2D = new Vector2(transform.position.x, transform.position.y); ContactFilter2D conFil = new ContactFilter2D(); conFil.SetLayerMask(LayerMask.GetMask("Bros")); Collider2D[] results = new Collider2D[10]; int numCol = Physics2D.OverlapCircle(pos2D, radius, conFil, results); List <Rigidbody2D> rigidbodies = new List <Rigidbody2D>(); for (int i = 0; i < numCol; i++) { if (results[i].attachedRigidbody != null && !rigidbodies.Contains(results[i].attachedRigidbody)) { rigidbodies.Add(results[i].attachedRigidbody); } } foreach (Rigidbody2D rb in rigidbodies) { Vector2 posVec = new Vector2(rb.position.x - transform.position.x, rb.position.y - transform.position.y); Vector2 forceVec; if (posVec.magnitude < 0.6f) { forceVec = posVec.normalized / 0.6f * explosionForce; } else { forceVec = posVec.normalized / posVec.magnitude * explosionForce; } if (rb.gameObject.tag == "Bro") { Bro bro = rb.gameObject.GetComponent <Bro>(); if (bro.isMe || bro.isBlue != fromBlue) { bro.ChangeHealth(1f / posVec.magnitude * damage, fromId, 0, forceVec); } } rb.AddForce(forceVec, ForceMode2D.Impulse); rb.angularVelocity = Random.value * 180f - 90f; } }
void CreateEnemy() { //Create enemy GameObject enemy = PhotonNetwork.Instantiate(broNames[enemyBroType], redSpawn, rot, 0); enemy.AddComponent <Enemy>(); enemy.GetComponent <BoxCollider2D>().isTrigger = false; enemy.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic; //Setup bro component Bro bro = enemy.GetComponent <Bro>(); bro.isMe = false; bro.respawnLoc = redSpawn; bro.GetComponent <PhotonView>().RPC("SetTeam", PhotonTargets.AllBuffered, false); }
public void Calling() { GameObject.Find("PhoneButton").GetComponent <AudioSource>().Play(); Message.gameObject.SetActive(true); switch (Name.text) { case "Братишка": Message.SetTextTips("Звонок " + Name.text, Name.text + ", " + _helpText + "\n\n" + "- Выезжаю, держись, братишка!"); Bro bro = GameObject.FindGameObjectWithTag("Bro").GetComponent <Bro>(); bro.Help(); break; default: Message.SetTextTips("Звонок " + Name.text, Name.text + ", " + _helpText + "\n\n" + "- Прекратите свои шутки!"); break; } Message.ShowMessage(); ChangeEnergy(); }
void Awake() { //Physics init grav = Physics2D.gravity; //Script init bro = GetComponent <Bro>(); //Enemy inits if (PracticeDifficulty.difficulty == 0) { shootTime = 4f; } else if (PracticeDifficulty.difficulty == 1) { shootTime = 2.5f; } else if (PracticeDifficulty.difficulty == 2) { shootTime = 1f; } else { shootTime = 0.5f; } goals = GameObject.FindGameObjectsWithTag("Goal"); giveUpTime = 3f; goalRad = 0.5f; lastX = 0; checkXTime = 0.1f; checkSafeTime = 0.1f; safeDis = 2.5f; }
public BroTotalInCurrencyRest(Bro bro, decimal amount) { Bro = bro.Id; Amount = amount; }
public BroRest(Bro bro) { Id = bro.Id; Name = bro.Name; IsHidden = bro.IsHidden; }
public Register(string uri) { this.uri = uri; InitializeComponent(); Bro.Navigate(new Uri(uri)); }
public BroTotalRest(Bro bro, Dictionary <Currency, decimal> amounts) { Bro = bro.Id; Amounts = amounts.Select(p => new AmountRest(p.Key, p.Value)).ToList(); }
public BroTotalRest(Bro bro, Dictionary<Currency, decimal> amounts) { Bro = bro.Id; Amounts = amounts.Select(p => new AmountRest(p.Key, p.Value)).ToList(); }