public void OnTriggerEnter(Collider col) { GameObject otherObject = col.gameObject; if (otherObject.name == "ColliderAttack") { GameObject otherObjectPlayer = FindParentWithTag(otherObject, "Player"); // checking if the ColliderAttacker s from another player if (otherObjectPlayer.name != this.gameObject.name) { if (otherObjectPlayer.GetComponent <PlayerBehaviorScript> ().isAttacking == false) { return; } int damageDealt = otherObjectPlayer.GetComponent <PlayerAttributes> ().computeDamageDealt(); int damageReduction = GetComponent <PlayerAttributes> ().computeDamageReduction(); int totalDamage = damageDealt - damageReduction; if (isServer) { TakeDamage(totalDamage); } else { // find the local player -> tell him/her to apply damage GameObject manager = GameObject.FindGameObjectWithTag("Manager"); ManagerReferences refs = manager.GetComponent <ManagerReferences> (); string playerUniqueName = GetComponent <PlayerID> ().playerUniqueName; refs.localPlayer.GetComponent <PlayerHealth> ().CmdTakeDamage(totalDamage, playerUniqueName); } } } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { // add item to inventory (backpack) GameObject imageObject = Instantiate(Resources.Load(NameOfSlotImage)) as GameObject; ItemAttributes attributes = imageObject.AddComponent <ItemAttributes> (); ItemAttributes attributesToClone = GetComponent <ItemAttributes> (); attributes.cloneAttributesFrom(attributesToClone); // we need to clone the value from the item on the ground to the item image GameObject manager = GameObject.FindGameObjectWithTag("Manager"); ManagerReferences refs = manager.GetComponent <ManagerReferences> (); if (other.GetComponent <PlayerBehaviorScript> ().isLocalPlayer) { GameObject backpack = refs.backpack; backpack.GetComponent <BackpackManager> ().AddItem(imageObject); if (isServer) { Destroy(this.gameObject); } else { refs.localPlayer.GetComponent <PlayerBehaviorScript> ().CmdDestroyObject(this.gameObject); } } } }
// Update is called once per frame void FixedUpdate() { if (Input.GetMouseButtonDown(0)) { ManagerReferences refs = GameObject.Find("Manager").GetComponent <ManagerReferences>(); if (refs.gameIsON && body.gravityScale == 0) // graityScale == 0 علشان منعملش فك فريز لجسم فعلا مش فريز { refs.UnFreezPlayer(); } //add force upward or add impules upward if (body != null) { body.AddForce(Vector2.up * intansity);//push to up } } //limit force //Debug.Log("velocity" + body.velocity.y); if (body.velocity.y > Maxvelocity) { body.AddForce(Vector2.down * intansity); ///To reduce the force of the ball when falling down to keep going up } }
// Start is called before the first frame update void Start() { fieldEmailAddress = GameObject.Find("InputFieldEmail"); textEmail = GameObject.Find("InputFieldEmailText").GetComponent <Text>(); fieldPassword = GameObject.Find("InputFieldPassword"); textPassword = GameObject.Find("InputFieldPasswordText").GetComponent <Text>(); fieldReenterPassword = GameObject.Find("InputFieldPassword2"); textReenterPassword = GameObject.Find("InputFieldPassword2Text").GetComponent <Text>(); buttonJoinGame = GameObject.Find("ButtonJoinGame"); buttonSwapRegistration = GameObject.Find("ButtonSwapRegistration"); textSwapButton = buttonSwapRegistration.GetComponentInChildren <Text>(); buttonRegister = GameObject.Find("ButtonRegister"); showRegistration = false; textSwapButton.text = "Sign Up"; textFeedback = GameObject.Find("TextFeedback").GetComponent <Text>(); textFeedback.text = ""; managerReferences = GameObject.Find("Manager").GetComponent <ManagerReferences>(); DisplayLoginPanel(); }
Transform startParent; // this is the original slot the item was inside of public override void OnStartLocalPlayer() { GameObject manager = GameObject.FindGameObjectWithTag("Manager"); ManagerReferences refs = manager.GetComponent <ManagerReferences> (); statsItemUI = refs.StatsItemUI; statsItemUI.SetActive(false); // it is now hidden; }
void Start() { if (owner == null) { ManagerReferences refs = getManagerRefs(); owner = refs.localPlayer; } }
// Use this for initialization void Start() { if (owner == null) { ManagerReferences refs = getManagerRefs(); //owner = FindParentWithTag (this.gameObject, "Player"); //refs.localPlayer; } }
public int ScoreAmount = 1; //Score void OnTriggerEnter2D(Collider2D other) //To know when the ball reaches the circles { if (other.gameObject.tag == "Player") { ManagerReferences refs = GameObject.Find("Manager").GetComponent <ManagerReferences>(); refs.IncreaseScore(ScoreAmount); this.gameObject.SetActive(false); //Make coin Hidden Destroy(this); //Make coin Destroy the script } }
// Use this for initialization void Start() { GameObject manager = GameObject.FindGameObjectWithTag("Manager"); ManagerReferences refs = manager.GetComponent <ManagerReferences> (); StatsUI = refs.StatsUI; textStrength = refs.playerStatsTextStrength; textDexterity = refs.playerStatsTextDexterity; textIntelligence = refs.playerStatsTextIntelligence; textDamage = refs.playerStatsTextDamage; }
// Start is called before the first frame update void Start() { //Ball Color ManagerReferences refs = GameObject.Find("Manager").GetComponent <ManagerReferences>(); if (refs != null) { Color newColor = refs.Colors[(int)colorIndex]; gameObject.GetComponent <SpriteRenderer>().color = newColor; } // }
//give color to Ball void StupIntialColor() { ManagerReferences refs = GameObject.Find("Manager").GetComponent <ManagerReferences>(); if (refs != null) { int colorsCount = refs.Colors.Length; int randomIndex = Random.Range(0, colorsCount - 1); // get random color Color newColor = refs.Colors[randomIndex]; SpriteRenderer renderer = GetComponent <SpriteRenderer>(); renderer.color = newColor; } }
public ColorUsed[] AllowedColor; // to choic the color from allowed colors void OnTriggerEnter2D(Collider2D other) //To know when the ball reaches the circles { if (other.gameObject.tag == "Player") //player الحاجه الى بتحرك بيها التاج بتاعها اسمه { ManagerReferences refs = GameObject.Find("Manager").GetComponent <ManagerReferences>(); int index = Random.Range(0, AllowedColor.Length - 1); ColorUsed newColor = AllowedColor[index]; refs.SwitchPlayerColor(newColor); this.gameObject.SetActive(false); //Make coin Hidden Destroy(this); //Make coin Destroy the script } }
public void getLocalPlayer() { if (player == null) { GameObject manager = GameObject.FindGameObjectWithTag("Manager"); ManagerReferences refs = manager.GetComponent <ManagerReferences> (); player = refs.localPlayer; //Debug.Log("just set local player name to " + player.name); } else { //Debug.Log("local player name is " + player.name); } }
void EquipTestItems2() { GameObject manager = GameObject.FindGameObjectWithTag("Manager"); ManagerReferences refs = manager.GetComponent <ManagerReferences> (); Attributes attributes = new Attributes(); attributes.Fill(5, 1, 4, 5); CmdEquipItemOnRightHand("MyPrefabs/gear/sword-simple-2", refs.localPlayer.name, attributes); CmdEquipItemOnLeftHand("MyPrefabs/gear/shield-round-wood", refs.localPlayer.name, attributes); CmdEquipItemOnHead("MyPrefabs/gear/helmet-2", refs.localPlayer.name, attributes); CmdEquipLeftShoulderWith("MyPrefabs/gear/shoulder-2-left", refs.localPlayer.name, attributes); CmdEquipRightShoulderWith("MyPrefabs/gear/shoulder-2-right", refs.localPlayer.name, attributes); CmdEquipBuckleWith("MyPrefabs/gear/buckle-2", refs.localPlayer.name, attributes); }
public void HandleDamage(int amount, string playerUniqueName) { if (isServer) { GameObject p = GameObject.Find(playerUniqueName); p.GetComponent <PlayerHealth> ().TakeDamage(amount); } else { GameObject manager = GameObject.FindGameObjectWithTag("Manager"); ManagerReferences refs = manager.GetComponent <ManagerReferences> (); GameObject localPlayer = refs.localPlayer; localPlayer.GetComponent <PlayerHealth> ().CmdTakeDamage(amount, playerUniqueName); } }
void SetIdentity() { if (!isLocalPlayer) { this.transform.name = playerUniqueName; } else { // case when it is the local client player // we need to create the ID transform.name = MakeUniqueIdentity(); GameObject manager = GameObject.FindGameObjectWithTag("Manager"); ManagerReferences refs = manager.GetComponent <ManagerReferences> (); refs.localPlayer = this.gameObject; } }
void OnTriggerEnter2D(Collider2D other) //To know when the ball reaches the circles { if (other.gameObject.tag == "Player") //player الحاجه الى بتحرك بيها التاج بتاعها اسمه { //Check if it is the same color or not Color playerColor = other.gameObject.GetComponent <SpriteRenderer>().color; //this to get ball color Color thisColor = this.gameObject.GetComponent <SpriteRenderer>().color; //this to get shape color if (playerColor != thisColor) { Debug.Log("Game Over"); ManagerReferences refs = GameObject.Find("Manager").GetComponent <ManagerReferences>(); //Game Over if (refs != null) { refs.GameOverPanel.SetActive(true); Time.timeScale = 0;//Makes the game stop when you click on the wrong color(Show panel GameOver) } } } }
public void OnPointerEnter(PointerEventData eventData) { if (statsItemUI == null) { GameObject manager = GameObject.FindGameObjectWithTag("Manager"); ManagerReferences refs = manager.GetComponent <ManagerReferences> (); statsItemUI = refs.StatsItemUI; } statsItemUI.SetActive(true); Vector3 pos = transform.position; float computedOffsetX = statsItemUIOffsetX; if (pos.x > Screen.width / 2) { computedOffsetX = computedOffsetX * -2.5f; } statsItemUI.transform.position = new Vector3(pos.x + computedOffsetX, pos.y + statsItemUIOffsetY, pos.z); PanelItemStatsScript statsScript = statsItemUI.GetComponent <PanelItemStatsScript> (); //draggedItem = gameObject; ItemAttributes attributes = gameObject.GetComponent <ItemAttributes> (); if (attributes == null) { Debug.Log("ItemAttributes is null"); } if (statsScript == null) { Debug.Log("statsScript is null"); } statsScript.textStrength.text = "Strength: " + attributes.Strength.ToString(); statsScript.textDexterity.text = "Dexterity: " + attributes.Dexterity.ToString(); statsScript.textIntelligence.text = "Intelligence: " + attributes.Intelligence.ToString(); statsScript.textDamage.text = "Damage: " + attributes.Damage.ToString(); }