public void SelectUnit(HeroScript toSelect) { selectedUnit = toSelect; GameObject[] units = GameObject.FindGameObjectsWithTag("Hero"); for (int i = 0; i < units.Length; i++) { HeroScript heroScript = units[i].GetComponent <HeroScript>(); heroScript.selected = false; heroScript.UpdateVisuals(); } if (toSelect != null) { selectedUnit.selected = true; UpdateUI(toSelect); selectedUnit.UpdateVisuals(); } else { namePanel.SetActive(false); } }
// Use this for initialization void Start() { itemmanager = GameObject.FindGameObjectWithTag("ItemManager").GetComponent <ItemManager>(); Hero = GameObject.FindGameObjectWithTag("Hero").GetComponent <HeroScript>(); QuestUi = GameObject.FindGameObjectWithTag("QuestUi").GetComponent <QuestUiScript>(); EntityId = itemmanager.entities.FindIndex(x => x.GetComponent <Entity>().EntityName == EntityName); }
public void UpdateUI(HeroScript unit) { healthImage.fillAmount = unit.currentHealth / 100f; defenseImage.fillAmount = unit.currentDefense / 100f; nameText.text = unit.unitName; namePanel.SetActive(true); }
void OnTriggerStay2D(Collider2D other) { if (paused) { return; } if (colliderIsHero(other) && this.isDying == false) { MovableHeroScript moveableHero = other.GetComponent <MovableHeroScript> (); if (moveableHero != null && moveableHero.isDragging) { return; } else { isTouchingHero(other); } HeroScript heroCharacter = other.GetComponent <HeroScript> (); attackTimer -= Time.deltaTime / currentAttackSpeed; if (attackTimer <= 0.0f && heroIsInFront(other)) { attackTimer = defaultAttackSpeed; attackSound.Play(); bool didKillhero = heroCharacter.takeDamage(attackPower); if (didKillhero) { stoppedTouchingHero(other); } } } }
// Use this for initialization void Start() { WeaponId = 0; heroscript = Hero.GetComponent <HeroScript>(); itemmanager = GameObject.FindGameObjectWithTag("ItemManager").GetComponent <ItemManager>(); noty = GameObject.FindGameObjectWithTag("NotificationManager").GetComponent <NotificationManagerScript>(); }
public void Save() { file = File.Create(path); hero = GameObject.FindGameObjectWithTag("Hero").GetComponent <HeroScript>(); if (hero != null) { save.inventory = hero.inventory; save.Gold = hero.gold; save.MaxHealth = hero.MaxHealth; save.MaxMana = hero.MaxMana; save.Level = hero.Level; save.Exp = hero.Exp; save.SkillPoints = hero.SkillPoints; save.Scene = loader.currscene; save.PlayerX = hero.gameObject.transform.position.x; save.PlayerY = hero.gameObject.transform.position.y; } skillui = GameObject.FindGameObjectWithTag("SkillUi").GetComponent <SkillUIScript>(); if (skillui != null) { save.skills = skillui.skills; } bf.Serialize(file, save); file.Close(); }
// Update is called once per frame void Update() { HeroScript hs = (HeroScript)player.GetComponent <HeroScript> (); // Get the current platform RaycastHit hit; if (Physics.Raycast(transform.position, Vector3.down, out hit, 5) && !hs.charOnLadder && !hs.touchingLadder) { if (hit.collider.gameObject.tag.Equals("bck")) { dir = -1; } else if (hit.collider.gameObject.tag.Equals("fwd")) { dir = 1; } } Vector3 pos = transform.position; //TODO: Get the direction from the current platform pos.x = player.transform.position.x - 6 * dir; pos.y = player.transform.position.y + 2; pos.z = player.transform.position.z; pos.x = Mathf.Clamp(pos.x, -22, 29); Quaternion rot = transform.rotation; rot = Quaternion.Euler(0, dir * 90, 0); transform.position = pos; transform.rotation = rot; }
protected override void AddCollectableToHero(HeroScript heroScript) { var weapon = heroScript.gameObject.GetComponent<WeaponHandlerScript> (); if (weapon == null) return; weapon.AddAmmo (additionalAmmo); }
void InitAlly(GameObject obj, string type) { HeroScript sc = obj.GetComponent("HeroScript") as HeroScript; sc.type = type; heroes.Add(sc); players.Add(sc); }
void init() { { s_script = transform.GetComponent <GameScript>(); MainCamera = GameObject.Find("Main Camera"); AttackBtnList = transform.Find("AttackBtnList").gameObject; GameUI = transform.Find("UI").gameObject; } //// 创建PVP英雄 //{ // GameObject obj = GameUtil.CreatePVPHero(); // HeroList.Add(obj); // heroScript = obj.GetComponent<HeroScript>(); // heroScript.addBloodBar(); //} // 创建地牢英雄 { GameObject obj = GameUtil.CreateDiLaoHero(); HeroList.Add(obj); heroScript = obj.GetComponent <HeroScript>(); heroScript.addBloodBar(); heroScript.heroData.Speed = 0.02f; GameObject.Find("Main Camera").GetComponent <TrackGameObjScript>().startTrack(obj); GameObject.Find("Lights").GetComponent <TrackGameObjScript>().startTrack(obj); } // 怪物1 { GameObject obj = GameUtil.CreateEnemy(); obj.transform.localPosition = new Vector3(11.92f, -4.61f, 20f); obj.transform.localRotation = Quaternion.Euler(0, -90, 0); HobgoblinList.Add(obj); obj.GetComponent <HobgoblinScript>().addBloodBar(); } // 怪物2 { GameObject obj = GameUtil.CreateEnemy(); obj.transform.localPosition = new Vector3(-11.92f, -4.61f, 20f); obj.transform.localRotation = Quaternion.Euler(0, 90, 0); HobgoblinList.Add(obj); obj.GetComponent <HobgoblinScript>().addBloodBar(); } //Debug.Log(Mathf.Sin(Mathf.Deg2Rad * 0)); //Debug.Log(Mathf.Cos(Mathf.Deg2Rad * 0)); }
IEnumerator DieRoutine(int dienum) { GameObject DeadDude = PlayerList[dienum - 1].PlayerObject; HeroScript killme = DeadDude.GetComponent <HeroScript>(); DeadDude.SetActive(false); yield return(new WaitForSeconds(killme.respawntime)); DeadDude.SetActive(true); killme.CHealth = killme.maxhealth; DeadDude.transform.position = Spawns[dienum - 1].transform.position; DeadDude.GetComponent <ReceiveInfo>().ReceivedStop(); }
void TouchEndState(FingerInput input) { if (this.DragBuilding != null) { this.DragBuilding.IsSelect = false; } if (this.SelectBuilding != null) { this.SelectBuilding = null; } /* if (CameraManager.Instance.IsEnablePan == false) * { * CameraManager.Instance.IsEnablePan = true; * * }*/ }
public void tour(bool isHero) { if (isHero) { HeroScript hero = GameObject.FindObjectOfType <HeroScript>(); hero.canMove = true; } else { EnemyScript[] enemies = GameObject.FindObjectsOfType <EnemyScript>(); foreach (EnemyScript enemy in enemies) { enemy.DansLaChampDeLaCamera(); enemy.Move(); } tour(true); } }
void FixedUpdate() { if (isMoving) { float step = speed * Time.deltaTime; GetComponent <Animator>().SetBool("isMoving", true); transform.position = Vector3.MoveTowards(transform.position, target, step); if (transform.position == target) { isMoving = false; HeroScript hero = GameObject.FindObjectOfType <HeroScript>(); GetComponent <Animator>().SetBool("isMoving", false); if (isHero) { hero.turn.tour(false); } } } }
void TouchBeginState(FingerInput input) { if (input.currentRayHitLayer == Define.LAYERMASK_BUILDING) { /* CameraManager.Instance.IsEnablePan = false;*/ this.SelectBuilding = input.currentRayHitTransform.GetComponent <HeroScript>(); if (this.DragBuilding == null) { this.DragBuilding = this.SelectBuilding; this.DragBuilding.IsSelect = true; } else { this.DragBuilding.IsSelect = false; this.DragBuilding = this.SelectBuilding; this.DragBuilding.IsSelect = true; } } }
void Awake() { // Get the character controller _heroScript = GetComponent<HeroScript>(); _mainCamera = GameObject.FindWithTag("MainCamera"); _characterSelect = GameObject.FindWithTag("PersistentCharSelect").GetComponent<PersistentCharacterSelect>(); _chargeThresholdTimerReset = _chargeThresholdTimer; switch (_playerNumber) { case PlayerNumber.Brawler: playerId = _characterSelect.GetBrawler(); break; case PlayerNumber.Shooter: playerId = _characterSelect.GetShooter(); break; case PlayerNumber.Mage: playerId = _characterSelect.GetMage(); break; } }
public override Entity TargetFindandPathSearch(EntityType entityType) { float searchRange = 1000000.0f; HeroScript targetBuilding = null; Transform target = EntityManager.Instance.GetCloseEntity(myTransform.position, searchRange, EntityType.Defense); if (target != null) { this.myTarget = target; targetBuilding = this.myTarget.GetComponent <HeroScript>(); if (targetBuilding != null) { Vector3 targetPos = targetBuilding.GetTargetPos(myTarget.position, myTransform.position); if (this.aILerp != null) { this.aILerp.SearchPath(targetPos); } } } return(targetBuilding); }
public IEnumerator ShowSword() { if (this.GetComponent <HeroScript>() != null) { HeroScript hero = this.GetComponent <HeroScript>(); hero.ToggleWeapon(hero.secondaryWeaponInHand, hero.secondaryWeaponHidden); } else { sword.SetActive(true); } yield return(new WaitForSeconds(0.8f)); if (this.GetComponent <HeroScript>() != null) { HeroScript hero = this.GetComponent <HeroScript>(); hero.ToggleWeapon(hero.secondaryWeaponHidden, hero.secondaryWeaponInHand); } else { sword.SetActive(false); } }
public void Load() { if (!File.Exists(path)) { file = File.Create(path); save.Scene = 12; save.PlayerX = -6; save.PlayerY = -2.36f; bf.Serialize(file, save); } else { file = File.Open(path, FileMode.Open); save = (Save)bf.Deserialize(file); hero = GameObject.FindGameObjectWithTag("Hero").GetComponent <HeroScript>(); if (hero != null) { hero.inventory = save.inventory; hero.gold = save.Gold; hero.MaxHealth = save.MaxHealth; hero.MaxMana = save.MaxMana; hero.Level = save.Level; hero.Exp = save.Exp; hero.SkillPoints = save.SkillPoints; loader.SwitchScene(save.Scene); hero.gameObject.transform.position = new Vector3(save.PlayerX, save.PlayerY, 0); } skillui = GameObject.FindGameObjectWithTag("SkillUi").GetComponent <SkillUIScript>(); if (skillui != null) { skillui.skills = save.skills; skillui.UpdateSkillUi(); } } file.Close(); }
protected virtual void AddCollectableToHero(HeroScript heroScript) { Debug.Log (heroScript.stevesName + " colected " + Name); }
void Awake() { S = this; // Set the Singleton bounds = Utils.CombineBoundsOfChildren(this.gameObject); //set the bounds (with combined bounds of children ) }
// Use this for initialization void Start() { HeroScript = (HeroScript)GameObject.FindGameObjectWithTag("Player") .GetComponent <HeroScript>(); }
void Start() { GameObject hero = GameObject.Find("Hero"); _heroScript = hero.GetComponent <HeroScript>(); }
public void Start() { playerScript = player.GetComponent <HeroScript>(); offset = transform.position - player.transform.position; }
private void attack(HeroScript cible) { health = cible.GetComponent <HealthScript>(); health.Damage(arme.degat); }
public bool tirer(HeroScript hero, EnemyScript cible) { verif = true; int compare; tableauCourant = hero.mouvements.Script.tableauCases; switch (arme.effet) { case "Degat": { if (hero.mouvements.posY == cible.mouvements.posY) { if (hero.mouvements.posX > cible.mouvements.posX) { direction = -1; int dep = hero.mouvements.posX; compare = dep - cible.mouvements.posX; } else { direction = 1; int dep = cible.mouvements.posX; compare = dep - hero.mouvements.posX; } //compare=2; if (compare == 1) { } else { if (compare <= arme.distance) { for (int cpt = 1; cpt <= compare; cpt++) { if (tableauCourant[hero.mouvements.posX + cpt, hero.mouvements.posY].GetCase() == EtatCase.Enemy || tableauCourant[hero.mouvements.posX + cpt, hero.mouvements.posY].GetCase() == EtatCase.Empty || tableauCourant[hero.mouvements.posX + cpt, hero.mouvements.posY].GetCase() == EtatCase.HalfObstacle || tableauCourant[hero.mouvements.posX + cpt, hero.mouvements.posY].GetCase() == EtatCase.Trap) { verif = true; } else { if (tableauCourant[hero.mouvements.posX + compare, hero.mouvements.posY].GetCase() == EtatCase.Enemy) { verif = true; } else { verif = false; break; } } } } else { verif = false; } } } else { if (hero.mouvements.posX == cible.mouvements.posX) { if (hero.mouvements.posY > cible.mouvements.posY) { int dep = hero.mouvements.posY; compare = dep - cible.mouvements.posY; } else { int dep = cible.mouvements.posY; compare = dep - hero.mouvements.posY; } if (compare <= arme.distance) { for (int cpt = 1; cpt <= compare; cpt++) { if (arme.distance != 1) { Debug.Log("distance != 1"); if (tableauCourant[hero.mouvements.posX, hero.mouvements.posY + cpt].GetCase() == EtatCase.Enemy || tableauCourant[hero.mouvements.posX, hero.mouvements.posY + cpt].GetCase() == EtatCase.Empty || tableauCourant[hero.mouvements.posX, hero.mouvements.posY + cpt].GetCase() == EtatCase.HalfObstacle || tableauCourant[hero.mouvements.posX, hero.mouvements.posY + cpt].GetCase() == EtatCase.Trap) { Debug.Log("dans if long"); verif = true; } else { verif = false; break; } } } } else { verif = false; } } else { verif = false; } } break; } case "Repousser": { for (int cpt = 0; cpt < arme.distance; cpt++) { if (tableauCourant[hero.mouvements.posX + cpt, hero.mouvements.posY].GetCase() == EtatCase.Empty) { verif = true; } else { verif = false; break; } } if (verif == true) { for (int cpt = 1; cpt <= 2 /*nb de case ou on le repousse*/; cpt++) { if (tableauCourant[hero.mouvements.posX + cpt, hero.mouvements.posY].GetCase() == EtatCase.Empty) { verif = true; } else { verif = false; break; } } } break; } default: { break; } } if (verif == true) { attack(cible); //spawnProjectile (hero); } else { verif = false; } return(verif); }
// Use this for initialization void Awake() { foreach (Transform child in transform) { child.gameObject.SetActive(false); } int ID = 0; if (GetComponentInParent <UnitScript>().isPlayerOne == false) { ID = 1; } switch (Player.Players[ID].Race) { case Faction.Human: GetComponentInParent <AnimController>().MyAnimator = transform.GetChild(0).GetComponent <Animator>(); GetComponentInParent <UnitMovement>().myBody = transform.GetChild(0); transform.GetChild(0).gameObject.SetActive(true); break; case Faction.Elves: GetComponentInParent <AnimController>().MyAnimator = transform.GetChild(1).GetComponent <Animator>(); GetComponentInParent <UnitMovement>().myBody = transform.GetChild(1); transform.GetChild(1).gameObject.SetActive(true); break; case Faction.Neutral: Debug.LogError("This hero is neutral and should probably not be: " + transform.root.position); break; default: break; } HeroScript hs = GetComponentInParent <HeroScript>(); if (hs == null) { return; } Transform[] children = GetComponentsInChildren <Transform>(); foreach (Transform child in children) { if (child.gameObject.activeSelf && child.gameObject.tag == "HiddenSecWeapon") { hs.secondaryWeaponHidden = child.gameObject; child.gameObject.SetActive(!hs.secondaryWeaponInHandOnStart); } if (child.gameObject.activeSelf && child.gameObject.tag == "SecWeapon") { hs.secondaryWeaponInHand = child.gameObject; child.gameObject.SetActive(hs.secondaryWeaponInHandOnStart); } if (child.gameObject.activeSelf && child.gameObject.tag == "HiddenPriWeapon") { hs.primaryWeaponHidden = child.gameObject; } if (child.gameObject.activeSelf && child.gameObject.tag == "PriWeapon") { hs.primaryWeaponInHand = child.gameObject; } } }
void Start() { heroScript = player.GetComponent <HeroScript>(); }
protected override void AddCollectableToHero(HeroScript heroScript) { heroScript.AddHealth(additionalHealth); }
void LinkMethod() //ссылки { heroScript = GameObject.Find("Hero").GetComponent <HeroScript> (); foodScript = GameObject.Find("EmptyGameHelper").GetComponent <FoodGeneration>(); }
private void Awake() { s_instance = this; }
public bool tirer(EnemyScript hero /*vie de la cible*/, HeroScript cible) { tableauCourant = hero.mouvements.Script.tableauCases; int compare; switch (arme.effet) { case "Degat": { if (hero.mouvements.posY == cible.mouvements.posY) { if (hero.mouvements.posX > cible.mouvements.posX) { int dep = hero.mouvements.posX; compare = dep - cible.mouvements.posX; } else { int dep = cible.mouvements.posX; compare = dep - hero.mouvements.posX; } //compare=2; if (compare == 1) { } else { if (compare <= arme.distance) { int check; if (hero.mouvements.posY == 1) { check = 1; } else { if (hero.mouvements.posY == 2) { check = 2; } else { if (hero.mouvements.posY == 0) { check = 2; } } } for (int cpt = 1; cpt <= compare; cpt++) { if (hero.mouvements.posX > cible.mouvements.posX) { if (tableauCourant[hero.mouvements.posX - cpt, hero.mouvements.posY].GetCase() == EtatCase.Hero || tableauCourant[hero.mouvements.posX - cpt, hero.mouvements.posY].GetCase() == EtatCase.Empty || tableauCourant[hero.mouvements.posX + cpt, hero.mouvements.posY].GetCase() == EtatCase.HalfObstacle || tableauCourant[hero.mouvements.posX + cpt, hero.mouvements.posY].GetCase() == EtatCase.Trap) { verif = true; } else { verif = false; break; } } else { if (tableauCourant[hero.mouvements.posX + cpt, hero.mouvements.posY].GetCase() == EtatCase.Hero || tableauCourant[hero.mouvements.posX + cpt, hero.mouvements.posY].GetCase() == EtatCase.Empty || tableauCourant[hero.mouvements.posX + cpt, hero.mouvements.posY].GetCase() == EtatCase.HalfObstacle || tableauCourant[hero.mouvements.posX + cpt, hero.mouvements.posY].GetCase() == EtatCase.Trap) { verif = true; } else { verif = false; break; } } } } else { verif = false; } } } else { if (hero.mouvements.posX == cible.mouvements.posX) { if (hero.mouvements.posY > cible.mouvements.posY) { int dep = hero.mouvements.posY; compare = dep - cible.mouvements.posY; } else { int dep = cible.mouvements.posY; compare = dep - hero.mouvements.posY; } if (compare <= arme.distance) { if (hero.mouvements.posY == 1) { check = 1; } else { if (hero.mouvements.posY == 2) { check = 2; } else { if (hero.mouvements.posY == 0) { check = 2; } } } for (int cpt = 1; cpt <= check; cpt++) { if (hero.mouvements.posY > cible.mouvements.posY) { if (arme.distance != 1) { if (tableauCourant[hero.mouvements.posX, hero.mouvements.posY - cpt].GetCase() == EtatCase.Hero || tableauCourant[hero.mouvements.posX, hero.mouvements.posY - cpt].GetCase() == EtatCase.Empty || tableauCourant[hero.mouvements.posX, hero.mouvements.posY - cpt].GetCase() == EtatCase.HalfObstacle || tableauCourant[hero.mouvements.posX, hero.mouvements.posY - cpt].GetCase() == EtatCase.Trap) { verif = true; } else { verif = false; break; } } } else { if (arme.distance != 1) { if (tableauCourant[hero.mouvements.posX, hero.mouvements.posY + cpt].GetCase() == EtatCase.Hero || tableauCourant[hero.mouvements.posX, hero.mouvements.posY + cpt].GetCase() == EtatCase.Empty || tableauCourant[hero.mouvements.posX, hero.mouvements.posY + cpt].GetCase() == EtatCase.HalfObstacle || tableauCourant[hero.mouvements.posX, hero.mouvements.posY + cpt].GetCase() == EtatCase.Trap) { verif = true; } else { verif = false; break; } } } } } else { verif = false; } } else { verif = false; } } break; } default: { break; } } if (verif == true) { attack(cible); } else { verif = false; } return(verif); }
// Use this for initialization void Start() { HeroScript =(HeroScript)GameObject.FindGameObjectWithTag("Player") .GetComponent<HeroScript>(); }
// Use this for initialization void Start() { hero = GameObject.FindObjectOfType <HeroScript>(); }
// Use this for initialization void Start() { DontDestroyOnLoad(gameObject); HeroScript = Hero.GetComponent <HeroScript>(); }