IEnumerator Countdown() { player.ADrunning = true; player.isShielded = true; GameObject shield = Instantiate(player.shieldV1, player.shieldPos.position, Quaternion.identity); ShieldScript ss = shield.GetComponent <ShieldScript>(); ss.player = player; ss.Appear(); yield return(new WaitForSeconds(ss.ADuration)); shield.GetComponent <SphereCollider>().enabled = true; float t = 0.0f; float start = 1; float end = 0; while (t < time) { t += Time.deltaTime; player.ADprgbar.fillAmount = Mathf.Lerp(start, end, t / time); yield return(null); } shield.GetComponent <SphereCollider>().enabled = false; ss.Disappear(); yield return(new WaitForSeconds(ss.ADuration)); Destroy(shield); player.PlayTakeAnimation(); player.isShielded = false; player.hasItem = false; player.currentItem = null; Destroy(player.currentItemIcon); player.ADrunning = false; }
void Start() { portals = new GameObject[] { GameObject.Find("Portal"), GameObject.Find("Portal (1)"), GameObject.Find("Portal (2)"), GameObject.Find("Portal (3)") }; shieldScript = GameObject.Find("Shield").GetComponent <ShieldScript>(); lastFireTime = Time.time; }
public void HurtPeople(GameObject collider) { if (collider.layer != 8) { StatesManager states = collider.GetComponent <StatesManager>(); if (states != null) { if (!states.isDodge) { states.Hurt(damage); Instantiate(blood, transform.position, Quaternion.LookRotation(-transform.forward)); } } else { Instantiate(sparks, transform.position, Quaternion.LookRotation(-transform.forward)); } ShieldScript shieldScript = collider.GetComponent <ShieldScript>(); if (shieldScript != null) { gameObject.SetActive(false); } } }
void Start() { manager = GameObject.Find("Main Camera").GetComponent <NPCManager>(); characterController = GetComponent <CharacterController>(); //weaponText = canvas.GetComponentInChildren<Text>(); shield = gameObject.GetComponentInChildren <ShieldScript>(); laser = gameObject.GetComponentInChildren <LaserScript>(); charge = gameObject.GetComponentInChildren <ChargeScript>(); bomb = gameObject.GetComponentInChildren <BombScript>(); laserSound = gameObject.GetComponent <AudioSource>(); cameraScript = GameObject.Find("Main Camera").GetComponent <CameraFollow>(); futurePosition = GetComponentInChildren <FuturePositionScript>().transform; if (Input.GetJoystickNames().Length > 0) { isControllerConnected = true; } transform.position = spawnPoint; if (GameObject.Find("PlayerUI")) { ui = GameObject.Find("PlayerUI").GetComponent <PlayerUI>(); } }
private void Setup() { sysScr = GetComponent <SystemScript>(); gridPos = sysScr.GridPos; //needs more info... //ship = LevelManager.Instance.Ships [playerID].GetComponent <ShipScript> (); GameObject _ship = transform.parent.parent.parent.parent.gameObject; //ShipScript _shipScr = _ship.GetComponent <ShipScript> (); pwrMngr = _ship.GetComponent <ShipPowerMngr> (); hScr = sysScr.GetOriginObj().GetComponent <HealthScript> (); //Debug.LogError (_ship.transform.childCount); if (_ship.transform.childCount < 7) { //if (_ship.transform.GetChild (7) == null) { //Debug.LogError ("shield stuff called"); GameObject _shield = (GameObject)Instantiate(shield, _ship.transform); shield = _shield; shieldScr = shield.GetComponent <ShieldScript> (); shieldScr.Setup(gridPos.Z); /* * GameObject _field = _ship.transform.GetChild (1).gameObject; * * shield.transform.position = _field.transform.position; * shield.transform.localScale = (_field.transform.localScale * 16 / 1920); * //float _scale = (Screen.width / shield.GetComponent <SpriteRenderer> ().bounds.size.x); * float _scale0 = (_field.transform.localScale.x * 16 / 1920); * float _scale1 = (_field.transform.localScale.y * 16 / 1080); * //shield.transform.localScale = new Vector3 (_scale, _scale, _scale); * * shield.transform.localScale = new Vector3 (_scale0, _scale1); */ } else { //Debug.LogError ("no shield stuff called"); shield = _ship.transform.GetChild(6).gameObject; shieldScr = shield.GetComponent <ShieldScript> (); } //IncreaseShieldCapacity (shieldBoost); pwrMngr.PowerSetup(systemType, powerReq); originShldSys = GetOriginShielSystem(); originShldSys.fullPwrReq += powerReq; if (this == originShldSys) { isOrigin = true; pwrMngr.AddToSysScrList(systemType, sysScr); } }
void Start() { maincamera = GameObject.Find("Main Camera"); guiScript = maincamera.GetComponent<GUIScript>(); soundManager = GameObject.Find("SoundManager").GetComponent<SoundManager>(); shieldScript = GameObject.Find("l_arm").GetComponent<ShieldScript>(); swordScript = GameObject.Find("r_arm").GetComponent<SwordScript>(); }
private void OnTriggerEnter2D(Collider2D other) { Debug.Log("hit " + other.name); if (other.gameObject.tag == "shield" && !hasReflected) { ShieldScript shield = other.GetComponent <ShieldScript>(); if (shield.reflecting) { transform.Rotate(0, 0, (other.transform.eulerAngles.z - transform.eulerAngles.z)); Instantiate(parryParticle, transform.position, transform.rotation); hasReflected = true; shield.hasReflected = hasReflected; shield.isRecharging = false; shield.reflecting = false; if (shield.shieldHealth < shield.maxShieldHealth) { shield.shieldHealth++; } shield.rechargeTime = shield.maxRechargeTimer; shield.activeReflectTimer = shield.maxTimeReflecting; shield.aSource.PlayOneShot(shield.aClipReflect); } else if (!shield.isRecharging) { shield.aSource.PlayOneShot(shield.aClipBlock); shield.shieldHealth--; Destroy(gameObject); } } if (other.gameObject.tag == "Player") { ShipControler ship = other.GetComponent <ShipControler>(); if (ship.invFrames >= ship.maxInvFrames) { ship.TakeDamage(); Destroy(gameObject); } } if (lifeSpawn > 0.1f && other.gameObject.tag == "enemy") { EnemyScript enemy = other.GetComponent <EnemyScript>(); if (!hasReflected) { enemy.TakeDamage(); gManager.score += 50; } else { enemy.health -= 3; gManager.score += 200; } Destroy(gameObject); } }
void Start() { shield = transform.Find("Shield").GetComponent <ShieldScript>(); gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); beforePlayerLife = playerinfo.life; coolTime[0] = jumpTime; coolTime[1] = 0; beforeTransform = transform; playerAnimation = transform.Find("kitten").GetComponent <Animation>(); playerAnimation["Run"].speed = 0.7f; }
void InitializeShieldColliders() { shieldScript = GetComponentInChildren <ShieldScript>(true); adaptiveShield = GetComponentInChildren <AdaptiveShieldScript>(true); shieldScript.gameObject.SetActive(true); adaptiveShield.gameObject.SetActive(true); adaptiveShield.shieldOn = false; shieldScript.TurnOffShield(); }
private void Awake() { collider_ = GetComponent <Collider2D>(); aiPath_ = GetComponent <AIPath>(); myMovement_ = GetComponent <IMovableActor>(); mySenses_ = GetComponent <ISensingActor>(); mySenses_.SetLookForPlayerLoS(true, maxDistance: 10); me_ = GetComponent <IEnemy>(); myPhysics_ = GetComponent <IPhysicsActor>(); transform_ = transform; enemyScript_ = GetComponent <EnemyScript>(); enemyScript_.SetDamageFilter(DamageFilter); shield_ = GetComponentInChildren <ShieldScript>(); shield_.gameObject.SetActive(false); }
void Start() { if (player) { portals = new GameObject[] { GameObject.Find("Portal (0)"), GameObject.Find("Portal (1)"), GameObject.Find("Portal (2)"), GameObject.Find("Portal (3)") }; shieldScript = GameObject.Find("Shield").GetComponent <ShieldScript>(); } else { portals = new GameObject[] { GameObject.Find("Portal (0)P2"), GameObject.Find("Portal (1)P2"), GameObject.Find("Portal (2)P2"), GameObject.Find("Portal (3)P2") }; shieldScript = GameObject.Find("ShieldP2").GetComponent <ShieldScript>(); } lastFireTime = Time.time; }
private void OnEnable() { audioSource = GetComponent <AudioSource>(); animator = GetComponent <Animator>(); weapon = GetComponentInChildren <WeaponManager>(); ShieldScript shield = GetComponentInChildren <ShieldScript>(); if (shield != null) { this.shield = shield.gameObject; } weapon.gameObject.SetActive(false); head = animator.GetBoneTransform(HumanBodyBones.Head); states = GetComponentInParent <StatesManager>(); }
void Start() { EventManager.AddEventListener(EventDefs.PLAYER_HEALTH_UPDATE, UpdateHealth); EventManager.AddEventListener(EventDefs.PLAYER_SHIELD_UPDATE, UpdateShield); playerShip = PlayerShipScript.player; healthCicle.fillAmount = playerShip.MaxHealth / 100f; ShieldScript playerShield = playerShip.Shield; if (playerShield != null) { shieldCicle.fillAmount = playerShield.ShieldAmount.Remap(0f, playerShield.maxShieldAmount, 0f, 1f); m_playerShield = playerShield; } else { shieldCicle.gameObject.SetActive(false); } }
void Start() { EventManager.AddEventListener( EventDefs.PLAYER_HEALTH_UPDATE, UpdateHealth ); EventManager.AddEventListener( EventDefs.PLAYER_SHIELD_UPDATE, UpdateShield ); playerShip = PlayerShipScript.player; healthCicle.fillAmount = playerShip.MaxHealth/100f; ShieldScript playerShield = playerShip.Shield; if( playerShield != null ) { shieldCicle.fillAmount = playerShield.ShieldAmount.Remap(0f,playerShield.maxShieldAmount,0f,1f); m_playerShield = playerShield; } else { shieldCicle.gameObject.SetActive( false ); } }
// Basically the Start method of the script, // since the Start of a base class script will not be called protected void InitShip() { if (m_exploder == null) { m_exploder = Resources.Load("ShipPrefabs/ShipExplosion") as GameObject; } m_thrust = GetComponent <ThrustScript>(); m_hitParticles = GetComponentInChildren <HitParticleSpawner>(); InitWeapons(); // Temporary Transform shieldTrans = transform.FindChild("Shield"); if (shieldTrans != null) { m_shield = shieldTrans.GetComponent <ShieldScript>(); } }
// Use this for initialization void Start() { idle = true; animation.Play("idle"); forward = true; animation.Stop(); cc = GetComponent <CharacterController> (); speed = new Vector3(0, 0, 0); grounder = transform.Find("GroundChecker").gameObject; distToGround = collider.bounds.extents.y; //Debug.Log ("distance" +distToGround); if (justSpawned) { CreateSpawnParticle(); } pc = gameObject.GetComponent <PlatformerController>(); Physics.IgnoreLayerCollision(8, 12); shield = transform.Find("Shield").gameObject.GetComponent <ShieldScript>(); InvokeRepeating("CheckBroadcasts", 0, 0.25f); }
void Start() { this.Team = TeamSide.Players; MainCam = GameObject.FindGameObjectWithTag("MainCamera"); if (transform.parent.tag == "Pl2") { this.Health = 120f; SecondCam = GameObject.FindGameObjectWithTag("CameraP1"); if (GlobalData.p2armor == true) { Health += GlobalData.armorAmount; } } else { this.Health = 60f; if (GlobalData.p1armor == true) { Health += GlobalData.armorAmount; } SecondCam = GameObject.FindGameObjectWithTag("CameraP2"); if (transform.parent.Find("pl1-shield") != null) { shields = transform.parent.Find("pl1-shield").GetComponent <ShieldScript>(); } } cts = GameObject.FindGameObjectWithTag("CameraTeller").GetComponent <CameraTellerScript>(); if (MaxHP == 0) { MaxHP = Health; } }
void Start() { manager = GameObject.Find("Main Camera").GetComponent<NPCManager>(); characterController = GetComponent<CharacterController>(); //weaponText = canvas.GetComponentInChildren<Text>(); shield = gameObject.GetComponentInChildren<ShieldScript>(); laser = gameObject.GetComponentInChildren<LaserScript>(); charge = gameObject.GetComponentInChildren<ChargeScript>(); bomb = gameObject.GetComponentInChildren<BombScript>(); laserSound = gameObject.GetComponent<AudioSource>(); cameraScript = GameObject.Find("Main Camera").GetComponent<CameraFollow>(); futurePosition = GetComponentInChildren<FuturePositionScript>().transform; if (Input.GetJoystickNames().Length > 0) { isControllerConnected = true; } transform.position = spawnPoint; if (GameObject.Find("PlayerUI")) { ui = GameObject.Find("PlayerUI").GetComponent<PlayerUI>(); } }
private void OnEnable() { Shield = GetComponent <ShieldScript>(); }
private void GetShield() { shield = transform.GetChild(6).GetComponent <ShieldScript> (); //int _int = shield.Power; }
void OnCollisionEnter2D() { ShieldScript shield = transform.parent.gameObject.GetComponent <ShieldScript> (); shield.isHit(); }
void OnCollisionEnter2D(Collision2D collision) { int damagePlayer = 0; // Ignore collision when player is invincible Physics2D.IgnoreCollision(collision.gameObject.GetComponent <Collider2D>(), GetComponent <Collider2D>(), isInvincible); if (!isInvincible) { // Collision with enemy EnemyScript enemy = collision.gameObject.GetComponent <EnemyScript>(); if (enemy != null && collision.gameObject.GetComponent <BossScript>() == null) { // Kill the enemy HealthScript enemyHealth = enemy.GetComponent <HealthScript>(); if (enemyHealth != null) { damagePlayer = enemyHealth.hp / 3; if (shieldLevel + 1 >= damagePlayer) { enemyHealth.Damage(enemyHealth.hp); // kill enemy } } if (damagePlayer < 1) { damagePlayer = 1; } } } // Is this a bonus? CollectableScript collectable = collision.gameObject.GetComponentInChildren <CollectableScript>(); if (collectable != null) { // Is this a shield bonus? ShieldScript shield = collision.gameObject.GetComponent <ShieldScript>(); if (shield != null) { shieldLevel = shield.shieldLevel; lastShieldLevel = shieldLevel; updateShieldUi(); updateLifeUi(false); SoundEffectsHelper.Instance.MakeShieldSound(true); Destroy(shield.gameObject); // Remember to always target the game object, otherwise you will just remove the script } else { SoundEffectsHelper.Instance.MakePickupSound(); } // Is this a weapon bonus? changeWeapon(collision.gameObject); // Is this a bomb bonus? BombScript bomb = collision.gameObject.GetComponent <BombScript>(); if (bomb != null) { if (nbBombs < MAX_BOMB) { nbBombs++; GameHelper.Instance.pickupBomb(); } SoundEffectsHelper.Instance.MakePickupSound(); } GameHelper.Instance.collectBonus(collectable.getId()); Destroy(collision.gameObject); // Remember to always target the game object, otherwise you will just remove the script } // Damage the player if necessery if (this.takeDamage(damagePlayer)) { GetComponent <HealthScript>().Damage(1); } }
void OnCollisionEnter2D(Collision2D collision) { bool hell = false; //collision with ff FerrofluidScript goo = collision.gameObject.GetComponent <FerrofluidScript> (); HealthScript playerHealth = GetComponent <HealthScript> (); FloorScript floor = collision.gameObject.GetComponent <FloorScript> (); PopUpScript popUp = collision.gameObject.GetComponent <PopUpScript> (); BossFight boss = collision.gameObject.GetComponent <BossFight> (); ShieldScript shield = collision.gameObject.GetComponent <ShieldScript> (); ShieldNumber shieldnumber = collision.gameObject.GetComponent <ShieldNumber> (); FfScript ffBottle = collision.gameObject.GetComponent <FfScript> (); WingsCounter wings = collision.gameObject.GetComponent <WingsCounter> (); RobotArm robot = GetComponent <RobotArm> (); OrangeCell orangeCell = collision.gameObject.GetComponent <OrangeCell>(); RedCell redCell = collision.gameObject.GetComponent <RedCell>(); BlueCell blueCell = collision.gameObject.GetComponent <BlueCell>(); MetalCell metalCell = collision.gameObject.GetComponent <MetalCell>(); MazePlatform maze = collision.gameObject.GetComponent <MazePlatform>(); //BridgePlatformScript bridge = GetComponent<BridgePlatformScript> (); if (collision.gameObject.tag == "orange") { // damagePlayer = true; // Debug.Log("shield not hit"); // if(playerHealth != null) // playerHealth.Damage(orangeCell.damage,respawnPosX,respawnPosY,false); if (shieldGO.activeSelf == true) { damagePlayer = false; shieldHits--; metalCell.hitByShield = true; Debug.Log("shield hit"); //orangeCell = null; if (playerHealth != null) { playerHealth.Damage(orangeCell.damage, respawnPosX, respawnPosY, true); } } else { damagePlayer = true; Debug.Log("shield not hit"); if (playerHealth != null) { playerHealth.Damage(orangeCell.damage, respawnPosX, respawnPosY, false); } } } if (collision.gameObject.tag == "red") { damagePlayer = true; Debug.Log("shield not hit"); if (playerHealth != null) { playerHealth.Damage(redCell.damage, respawnPosX, respawnPosY, false); } } if (collision.gameObject.tag == "blue") { damagePlayer = true; Debug.Log("shield not hit"); if (playerHealth != null) { playerHealth.Damage(blueCell.damage, respawnPosX, respawnPosY, false); } } if (collision.gameObject.tag == "metal") { // damagePlayer = true; // Debug.Log("shield not hit"); // if(playerHealth != null) // playerHealth.Damage(orangeCell.damage,respawnPosX,respawnPosY,false); if (shieldGO.activeSelf == true) { damagePlayer = false; shieldHits--; metalCell.hitByShield = true; Debug.Log("shield hit"); } else { damagePlayer = true; Debug.Log("shield not hit"); if (playerHealth != null) { playerHealth.Damage(orangeCell.damage, respawnPosX, respawnPosY, false); } } } if (floor != null) { damagePlayer = true; hell = true; } if (hell) { if (playerHealth != null) { playerHealth.Damage(floor.damage, respawnPosX, respawnPosY, false); } } if (collision.gameObject.name == "Checkpoint1") { CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>(); respawnPosX = checkpoint.posX; respawnPosY = checkpoint.posY; Destroy(collision.gameObject.GetComponent <Collider2D>()); } if (collision.gameObject.name == "Checkpoint2") { CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>(); respawnPosX = checkpoint.posX; respawnPosY = checkpoint.posY; Destroy(collision.gameObject.GetComponent <Collider2D>()); } if (collision.gameObject.name == "Checkpoint3") { CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>(); respawnPosX = checkpoint.posX; respawnPosY = checkpoint.posY; Destroy(collision.gameObject.GetComponent <Collider2D>()); } if (collision.gameObject.name == "Checkpoint4") { CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>(); respawnPosX = checkpoint.posX; respawnPosY = checkpoint.posY; Destroy(collision.gameObject.GetComponent <Collider2D>()); } // if (collision.gameObject.name == "atomo") { // popUp.showPopUp = true; // popUp.gameObject.GetComponent<Renderer>().enabled = false; // Destroy(popUp.gameObject.GetComponent<Collider2D>()); // } if (collision.gameObject.tag == "MovingPlatform") { this.transform.parent = collision.transform; } // if (collision.gameObject.tag == "lever"){ // RobotArm.move = true; // } // // if (collision.gameObject.tag == "lever1") { // RobotArm.move1 = true; // } if (collision.gameObject.tag == "Boss") { boss.gameObject.GetComponent <Renderer>().enabled = true; showPopUp = true; maxSpeed = 0; if (i == 5) { maxSpeed = 25; Destroy(boss.gameObject); boss.gameObject.GetComponent <Renderer>().enabled = false; } } if (collision.gameObject.tag == "Door") { Application.LoadLevel("Hidrofobia"); } if (wings != null) { wings.GetComponent <Renderer>().enabled = false; wings.GetComponent <PolygonCollider2D>().enabled = false; wingsCounter = 7; } if (collision.gameObject.tag == "shield") { ShieldCounterManager.AddShield(shieldnumber.shieldNumber); Destroy(shieldnumber.gameObject); shieldFlag = true; Debug.Log("Shield available"); } if (collision.gameObject.tag == "ffbottle") { FfCounterManager.AddFF(ffBottle.ffNumber); gunFlag = true; Destroy(ffBottle.gameObject); } //platform activator if (collision.gameObject.tag == "ActivatePlatform") { collision.gameObject.GetComponent <Animator>().enabled = true; } if (collision.gameObject.tag == "Boots") { collision.gameObject.GetComponent <Renderer>().enabled = false; collision.gameObject.GetComponent <PolygonCollider2D>().enabled = false; time = 5; } if (collision.gameObject.tag == "box") { bool founded = false; BoxController box = collision.gameObject.GetComponent <BoxController>(); box.Founded(true); Destroy(collision.gameObject); } if (collision.gameObject.tag == "Bridge1") { BridgePlatformScript.bridge1 = true; } if (collision.gameObject.tag == "Bridge2") { BridgePlatformScript.bridge2 = true; } if (collision.gameObject.tag == "Bridge3") { BridgePlatformScript.bridge3 = true; } if (collision.gameObject.tag == "Bridge4") { BridgePlatformScript.bridge4 = true; } if (collision.gameObject.tag == "Bridge5") { BridgePlatformScript.bridge5 = true; } if (collision.gameObject.tag == "Bridge6") { BridgePlatformScript.bridge6 = true; } if (collision.gameObject.tag == "Bridge7") { BridgePlatformScript.bridge7 = true; } if (collision.gameObject.name == "MetallicFloorFerroFluidMAP 159") { MazePlatform.ground = true; transform.parent = collision.transform; } }
void Start() { shieldBar = GetComponent<Image> (); shield = GameObject.FindGameObjectWithTag ("Player").GetComponent<ShieldScript> (); max = shield.ShieldTime; }
//Add shield to list function, takes a script parameter, called when a shield is enembled and stores //the shield on the list public void AddShieldToList(ShieldScript script) { shields.Add(script); }
// Basically the Start method of the script, // since the Start of a base class script will not be called protected void InitShip() { if(m_exploder == null) m_exploder = Resources.Load("ShipPrefabs/ShipExplosion") as GameObject; m_thrust = GetComponent<ThrustScript>(); m_hitParticles = GetComponentInChildren<HitParticleSpawner>(); InitWeapons(); // Temporary Transform shieldTrans = transform.FindChild( "Shield" ); if( shieldTrans != null ) { m_shield = shieldTrans.GetComponent<ShieldScript>(); } }