// Start is called before the first frame update void Start() { hit = 0; player = GameObject.FindGameObjectWithTag("Player"); text = GameObject.FindGameObjectWithTag("gameover").GetComponent <Text>(); hpscript = player.GetComponent <HPScript>(); }
private IEnumerator AddHpOnTimer(HPScript hpScript, float hpToAdd, float timer) { yield return(new WaitForSeconds(timer)); SoundManager.PlaySFX(Transfering); hpScript.CurrentHp += hpToAdd; }
protected virtual void ComponentSetup() { moveScript = GetComponent <MovementInterface> (); hpScript = GetComponent <HPScript> (); if (hpScript == null) { hpScript = gameObject.AddComponent <HPScript> (); } hpScript.MaxHP = maxHP; hpScript.Death += OnDeath; onCollisionDamageScript = gameObject.GetComponent <DamageOnCollision> (); if (onCollisionDamageScript == null) { onCollisionDamageScript = gameObject.AddComponent <DamageOnCollision> (); } onCollisionDamageScript.Damage = onCollisionDamage; onCollisionDamageScript.TagList = onCollisionDamageTags; visionScript = GetComponent <EnemyVision> (); if (visionScript == null) { visionScript = gameObject.AddComponent <EnemyVision> (); } visionScript.AggroDistance = aggroDistance; visionScript.AvatarDetected += OnAvatarDetected; visionScript.LostVision += OnLostVision; visionScript.SeeingAvatar += OnSeeingAvatar; }
public void RealSkill() { Fix64 ff = (Fix64)bombforce; Vector2 actionplacev = transform.position; Fix64Vector2 actionplacef = (Fix64Vector2)actionplacev; Collider2D[] colliders = Physics2D.OverlapCircleAll(actionplacev, radius + 0.1f); foreach (Collider2D hit in colliders) { /*Fix64 dfs = ((Fix64Vector2)(Vector2)hit.transform.position - actionplacef).LengthSquare(); * if (dfs > rfs) * continue;*/ HPScript hp = hit.GetComponent <HPScript>(); if (hp != null) { hp.GetHurt(damage); Rigidbody2D rb = hit.GetComponent <Rigidbody2D>(); if (rb != null) { Fix64Vector2 explforce; explforce = (Fix64Vector2)rb.position - actionplacef; hit.GetComponent <RBScript>().GetPushed(explforce.normalized() * ff, pushtime); } } } }
private void OnCollisionEnter2D(Collision2D collision) { if (!photonView.isMine) { return; } if (gameObject.GetComponent <DestroyScript>().selfprotect&& collision.gameObject == sender) { return; } /*if (selfprotect && collision.gameObject.GetComponent<ShieldScript>().sender == sender) * return;*/ Rigidbody2D rb = collision.gameObject.GetComponent <Rigidbody2D>(); HPScript hp = collision.gameObject.GetComponent <HPScript>(); if (hp != null && rb != null) { Vector2 explforce; Rigidbody2D selfrb = gameObject.GetComponent <Rigidbody2D>(); explforce = rb.position - selfrb.position; collision.gameObject.GetComponent <RBScript>().GetPushed(explforce.normalized * bombpower, pushtime); //hp.GetKicked(explforce.normalized * bombpower); hp.GetHurt(bombdamage); Jumb(); bonus = true; } if (selfbreak) { gameObject.GetComponent <DestroyScript>().Destroyself(); } }
public void FollowScoreOf(IPlatformer2DUserControl control, HPScript hpScript) { CurrentScores.Add(new PlayerScoreTracker {CurrentScore = 0, Player = control.m_PlayerData}); var data = new ScoreData() {HpScript = hpScript, Platformer2DUserControl = control}; data.HpScript.Dead += HpScript_Dead; ScoreDatas.Add(data); }
public void Skill() { //photonView.RPC("RealSkill", PhotonTargets.All); //gameObject.GetComponent<MoveScript>().stopwalking(); //gameObject.GetComponent<StealthScript>().StealthEnd(); currentcooldown = 0; skillavaliable = false; float radius = 1.5f; Vector2 actionplace = transform.position; Collider2D[] colliders = Physics2D.OverlapCircleAll(actionplace, radius); foreach (Collider2D hit in colliders) { HPScript hp = hit.GetComponent <HPScript>(); if (hp != null) { if (hit == gameObject.GetComponent <Collider2D>()) { hp.GetHurt(Mathf.Min(10, hp.currentHP - 1)); } else { hp.GetHurt(10); Rigidbody2D rb = hit.GetComponent <Rigidbody2D>(); if (rb != null) { Vector2 explforce; explforce = rb.position - actionplace; hit.GetComponent <RBScript>().GetPushed(explforce.normalized * 15, 1f); } } } } }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.tag != "Projectile") { if (col.gameObject.tag == "Enemy" && allegiance == Allegiance.Good) { HPScript hpScript = col.gameObject.GetComponent <HPScript> (); if (hpScript != null) { hpScript.Damage(damage); } else { Debug.LogWarning("Enemy [" + col.gameObject.name + "] doesn't have an HPScript."); } Destroy(gameObject); } else if (col.gameObject.tag == "Player" && allegiance == Allegiance.Bad) { HPScript hpScript = col.gameObject.GetComponent <HPScript> (); if (hpScript != null) { hpScript.Damage(damage); } else { Debug.LogWarning("Player [" + col.gameObject.name + "] doesn't have an HPScript."); } Destroy(gameObject); } } }
// Use this for initialization void Start() { if (_hpScript == null) { _hpScript = GetComponent <HPScript>(); } _hpScript.HpChanged += HpScriptOnHpChanged; _originalX = _gameObjectToScale.transform.localScale.x; _sprite = _gameObjectToScale.GetComponent <SpriteRenderer>(); if (_sprite == null) { Debug.LogError("ScaleBasedOnHP cannot find the sprite render on " + _gameObjectToScale.name); } else { if (_isLowHpFlash) { _changer = GetComponent <ChangeToPlayerColor>(); if (_changer == null) { Debug.LogError("ScaleBasedOnHP cannot find the ChangeToPlayerColor on " + _gameObjectToScale.name); } else { _originalColor = _changer.Controller.m_PlayerData.PlayerSponsor.SponsorColor; _currentColor = _changer.Controller.m_PlayerData.PlayerSponsor.SponsorColor; } } } }
// Use this for initialization private void Start() { if (_hpScript == null) _hpScript = GetComponent<HPScript>(); if (_hpScript == null) _hpScript = GetComponentInParent<HPScript>(); if (_hpScript == null) Debug.LogError("Could not find HpScript"); _hpScript.Dead += HpScriptOnDead; }
// Use this for initialization void Start() { GameObject TheCanvas = GameObject.Find("Canvas2"); MyInfoHP = GameObject.Instantiate(MyInfoText, TheCanvas.transform); rb2d = GetComponent <Rigidbody2D>(); hps = GetComponent <HPScript>(); }
void Start() { curFirePoints = firePoints; timeEarthSkill = timeEarthSkillKD; timeHealSkill = timeHealSkillKD; hpScript = GetComponent <HPScript>(); UICtrl = FindObjectOfType <UIController>(); playerMovement = GetComponent <PlayerMovement>(); }
IEnumerator FillStamina(HPScript hpScript) { while (hpScript.currentStamina < hpScript.maxStamina) { hpScript.currentStamina += (hpScript.maxStamina / 60); yield return(new WaitForSeconds(Time.deltaTime)); } yield return(null); }
IEnumerator FillStun(HPScript hpScript) { while (hpScript.currentStun > 0) { hpScript.currentStun -= (hpScript.maxStun / 60); yield return(new WaitForSeconds(Time.deltaTime)); } yield return(null); }
// Use this for initialization protected virtual void Start() { _delayManager = GetComponent <DelayManager>(); _inputManager = GetComponent <IPlatformer2DUserControl>(); _hpScript = GetComponent <HPScript>(); _hpScript.Dead += _hpScript_Dead; DartFired += OnDartFired; _feedback = GetComponent <Feedback>(); }
IEnumerator FillHP(HPScript hpScript) { while (hpScript.currentHp < hpScript.maxHP) { hpScript.currentHp += (hpScript.maxHP / 60); yield return(new WaitForSeconds(Time.deltaTime)); } yield return(null); }
// Update is called once per frame void Update() { GameObject rycerz = GameObject.Find("rycerz"); HPScript hpscript = rycerz.GetComponent <HPScript>(); filled = (float)hpscript.hP; filled /= 100; pasek.fillAmount = filled; }
void Awake() { hpScript = GetComponent <HPScript> (); if (hpScript == null) { hpScript = gameObject.AddComponent <HPScript> (); } hpScript.MaxHP = maxHP; hpScript.Death += OnDeath; }
private void OnCollisionEnter2D(Collision2D collision) { if (transform.parent != null) { HPScript a = collision.gameObject.GetComponent <HPScript>(); if (a != null) { a.ReciveDamage(DMG); } } }
private void OnCollisionEnter2D(Collision2D collision) { Rigidbody2D rb = collision.gameObject.GetComponent <Rigidbody2D>(); HPScript hp = collision.gameObject.GetComponent <HPScript>(); if (hp != null && rb != null) { hp.GetHurt(leechdamage); sender.GetComponent <HPScript>().GetHurt(-leechdamage); } gameObject.GetComponent <DestroyScript>().Destroyself(); }
void Update() { GameObject rycerz = GameObject.Find("rycerz"); HPScript hpscript = rycerz.GetComponent <HPScript>(); iloscHp = (float)hpscript.hP; if (iloscHp < 0) { SceneManager.LoadScene(5); } }
public void Skill(Fix64Vector2 actionplace) { //DoSkill.singing = 0; //停止吟唱中技能 Fix64Vector2 singplace = (Fix64Vector2)GetComponent <Rigidbody2D>().position; Fix64Vector2 skilldirection = actionplace - singplace; Fix64 md64 = (Fix64)maxdistance; Fix64 skdl = skilldirection.Length(); Fix64 realdistance; if (skdl <= md64) { realdistance = skdl; } else { realdistance = md64; } if (realdistance <= (Fix64)0.51) { return; } //半径小于自身半径时不施法 else { //gameObject.GetComponent<DoSkill>().Fire = null; Fix64Vector2 realplace = singplace + skilldirection.normalized() * realdistance; Rigidbody2D selfrb2d = gameObject.GetComponent <Rigidbody2D>(); GetComponent <DoSkill>().BeforeSkill(); //MS.controllable = true; currentcooldown = 0; skillavaliable = false; Vector2 rpv2 = realplace.ToV2(); if (Physics2D.OverlapPoint(rpv2)) { Collider2D hit = Physics2D.OverlapPoint(rpv2); HPScript hps = hit.GetComponent <HPScript>(); if (hps != null) { Rigidbody2D rb2d = hit.GetComponent <Rigidbody2D>(); selfrb2d.position = rb2d.position; hps.TransferTo(singplace.ToV2()); } else { transform.position = rpv2; } } else { transform.position = rpv2; } } }
private bool CheckForHPCollision(GameObject toCheck) { var ret = false; if (_targetHpScript == null) { _targetHpScript = toCheck.GetComponent <HPScript>(); if (_targetHpScript == null) { var checkShield = toCheck.GetComponent <ShieldReRouter>(); if (checkShield == null) { _targetHpScript = toCheck.GetComponentInParent <HPScript>(); } else { _hitAWall = true; StickDart(toCheck); OnDartCollision(); SoundManager.PlaySFX(GroundImpact); } } else { //If target is shielding, do not use the target script; var shield = _targetHpScript.gameObject.GetComponent <shield>(); if (shield.IsShieldActive) { _targetHpScript = null; } OnDartDestroyed(); } if (_targetHpScript == SourceHPScript) { _targetHpScript = null; _ignoreWalls = true; } //Check if we got our hpScript if (_targetHpScript != null) { SubscribeToTargetHPScript(true); OnDartCollision(); ret = true; StickDart(toCheck); SoundManager.PlaySFX(PlayerImpact); } } return(ret); }
public void FollowScoreOf(IPlatformer2DUserControl control, HPScript hpScript) { CurrentScores.Add(new PlayerScoreTracker { CurrentScore = 0, Player = control.m_PlayerData }); var data = new ScoreData() { HpScript = hpScript, Platformer2DUserControl = control }; data.HpScript.Dead += HpScript_Dead; ScoreDatas.Add(data); }
public void rollSkill() { float radius = transform.lossyScale.x / 2; Vector2 actionplace = transform.position; Collider2D[] colliders = Physics2D.OverlapCircleAll(actionplace, radius); foreach (Collider2D hit in colliders) { HPScript hp = hit.GetComponent <HPScript>(); if (hp != null) { hp.GetHurt(rolldamage * Time.fixedDeltaTime); } } }
private IEnumerator SuckHpFrom(HPScript hpScript) { while (true) { if (Time.deltaTime > 0 && GameManager.instance.CurrentState == GameState.Playing) { float hpToSuck = _settings.HpSuckedPerSecond * Time.deltaTime; hpScript.CurrentHp -= hpToSuck; OnJuiceSucked(new JuiceSuckedEventArgs { HpSucked = hpToSuck }); } yield return(null); } }
// Use this for initialization private void Start() { if (_hpScript == null) { _hpScript = GetComponent <HPScript>(); } if (_hpScript == null) { _hpScript = GetComponentInParent <HPScript>(); } if (_hpScript == null) { Debug.LogError("Could not find HpScript"); } _hpScript.Dead += HpScriptOnDead; }
// Use this for initialization void Start() { LeftTrigger = "p" + playerNum + "LeftTrigger"; RightTrigger = "p" + playerNum + "RightTrigger"; LeftBumper = "p" + playerNum + "LeftBumper"; RightBumper = "p" + playerNum + "RightBumper"; LeftX = "p" + playerNum + "LeftX"; LeftY = "p" + playerNum + "LeftY"; RightX = "p" + playerNum + "RightX"; RightY = "p" + playerNum + "RightY"; AButton = "p" + playerNum + "A"; RightStickClick = "p" + playerNum + "RightStickClick"; rend = GetComponent <SpriteRenderer>(); rb = GetComponent <Rigidbody2D>(); playerCol = GetComponent <BoxCollider2D>(); lastGrave = null; inHitstun = false; frames = 0; //get enemy player num once lol this took me years enemyPlayerNum = (playerNum == 1) ? 2 : 1; dashCount = dashMax; playerShovel = GetComponentInChildren <ShovelScript>(); // acceleration = Vector2.zero; force = Vector2.zero; speed = Vector2.zero; spawnManager = GameObject.Find("RespawnManager").GetComponent <RespawnScript>(); scoreManager = GameObject.Find("ScoreManager").GetComponent <ScoreScript>(); collManager = GameObject.Find("CollisionManager").GetComponent <CollisionScript>(); cameraShake = GameObject.Find("Main Camera").GetComponentInChildren <CameraShakeScript>(); hpVisual = GameObject.Find("P" + playerNum + "HP").GetComponentInChildren <HPScript>(); //transform.position = spawnManager.getSpawnpoint(playerNum).position; health = maxHealth; hpVisual.updateVisual(health); hitstunTimer = hitstunMaxTimer; slayTimer = 0; //position = transform.position; }
private void OnCollisionEnter2D(Collision2D collision) { //if (!photonView.isMine) //return; Rigidbody2D rb = collision.gameObject.GetComponent <Rigidbody2D>(); HPScript hp = collision.gameObject.GetComponent <HPScript>(); if (hp != null && rb != null) { Vector2 explforce; Rigidbody2D selfrb = gameObject.GetComponent <Rigidbody2D>(); explforce = rb.position - selfrb.position; collision.gameObject.GetComponent <RBScript>().GetPushed((FixMath.Fix64Vector2)(explforce.normalized * bombpower), pushtime); hp.GetHurt(bombdamage); } gameObject.GetComponent <DestroyScript>().Destroyself(); }
void OnTriggerEnter2D(Collider2D col) { bool foundIt = false; for (int i = 0; !foundIt && i < tagList.Length; i++) { if (col.tag.Equals(tagList [i])) { Debug.Log("[" + col.name + "] was hit by [" + name + "]. " + damage + " DAMAGE."); HPScript s = col.gameObject.GetComponent <HPScript> (); if (s != null) { s.Damage(damage); } } } }
// Use this for initialization private void Start() { _particleScript = SingleParticle.GetComponent <PhysicsSingleParticle>(); if (_particleScript == null) { Debug.Log("gameObject attachs is a nonParticle"); } if (_hpScript == null) { Debug.Log("Attempting to getComponentFor hpScript"); _hpScript = GetComponent <HPScript>(); if (_hpScript == null) { Debug.LogError("hpScript not found"); } } _hpScript.HpImpactReceived += HpScriptOnHpImpactReceived; }
void OnTriggerEnter(Collider other) { // Add Feedback // Sound, particle, etc. // If what this pickup is touched by is NOT the player, then exit out and do nothing. if (other.tag != "Player") { return; } HPScript hp = other.GetComponent <HPScript>(); hp.TakeDamage(Value); gameObject.SetActive(false); Mesh.SetActive(false); }
// Use this for initialization void Start() { if (_hpScript == null) _hpScript = GetComponent<HPScript>(); _hpScript.HpChanged += HpScriptOnHpChanged; _originalX = _gameObjectToScale.transform.localScale.x; _sprite = _gameObjectToScale.GetComponent<SpriteRenderer>(); if (_sprite == null) Debug.LogError("ScaleBasedOnHP cannot find the sprite render on " + _gameObjectToScale.name); else { if (_isLowHpFlash) { _changer = GetComponent<ChangeToPlayerColor>(); if (_changer == null) Debug.LogError("ScaleBasedOnHP cannot find the ChangeToPlayerColor on " + _gameObjectToScale.name); else { _originalColor = _changer.Controller.m_PlayerData.PlayerSponsor.SponsorColor; _currentColor = _changer.Controller.m_PlayerData.PlayerSponsor.SponsorColor; } } } }
private void HandleHpScript(HPScript hpScript) { _collidedWithSmth = true; var shield = hpScript.gameObject.GetComponent<shield>(); if (shield != null && shield.IsShieldActive) { StickTo(shield.gameObject); SoundManager.PlaySFX(Severed); } else { _collidedWithSmth = true; _target = hpScript; StickTo(hpScript.gameObject); _suckHpCoroutine = StartCoroutine(SuckHpFrom(hpScript)); _hpScriptToUnsubscribe = hpScript; _dartToUnsubscribe = this; hpScript.Dead += HpScript_Dead; DartDestroyed += HpScript_Dead; SoundManager.PlaySFX(PlayerImpact); } OnDartCollision(); }
public void AddImmuneTarget(HPScript hpScript) { _immuneTargets.Push(hpScript); }
private IEnumerator SuckHpFrom(HPScript hpScript) { while (true) { if (Time.deltaTime > 0 && GameManager.instance.CurrentState == GameState.Playing) { float hpToSuck = _settings.HpSuckedPerSecond * Time.deltaTime; hpScript.CurrentHp -= hpToSuck; OnJuiceSucked(new JuiceSuckedEventArgs { HpSucked = hpToSuck }); } yield return null; } }
// Use this for initialization protected virtual void Start() { _delayManager = GetComponent<DelayManager>(); _inputManager = GetComponent<IPlatformer2DUserControl>(); _hpScript = GetComponent<HPScript>(); _hpScript.Dead += _hpScript_Dead; DartFired += OnDartFired; _feedback = GetComponent<Feedback>(); }
public virtual void Start() { hpScript = hp.GetComponent<HPScript>(); }
private bool CheckForHPCollision(GameObject toCheck) { var ret = false; if (_targetHpScript == null) { _targetHpScript = toCheck.GetComponent<HPScript>(); if (_targetHpScript == null) { var checkShield = toCheck.GetComponent<ShieldReRouter>(); if (checkShield == null) { _targetHpScript = toCheck.GetComponentInParent<HPScript>(); } else { _hitAWall = true; StickDart(toCheck); OnDartCollision(); SoundManager.PlaySFX(GroundImpact); } } else { //If target is shielding, do not use the target script; var shield = _targetHpScript.gameObject.GetComponent<shield>(); if (shield.IsShieldActive) _targetHpScript = null; OnDartDestroyed(); } if (_targetHpScript == SourceHPScript) { _targetHpScript = null; _ignoreWalls = true; } //Check if we got our hpScript if (_targetHpScript != null) { SubscribeToTargetHPScript(true); OnDartCollision(); ret = true; StickDart(toCheck); SoundManager.PlaySFX(PlayerImpact); } } return ret; }
protected virtual void Start() { if (m_GunReference == null) m_GunReference = GetComponentInChildren<gunRef>().gameObject; m_Controller = GetComponent<IPlatformer2DUserControl>(); m_DelayManager = GetComponent<DelayManager>(); if(m_HpScript == null) m_HpScript = GetComponent<HPScript>(); if (m_muzzleFlash != null && m_muzzleFlash.enabled) m_muzzleFlash.enabled = false; _feedBack = GetComponent<Feedback>(); if (_feedBack == null) Debug.LogError("Gun (Arc or shield) is unable to get the Feedback component on " + gameObject.name); //else _feedBack.CanShootFeedbackEvent += ResetDelayManager; }
private IEnumerator AddHpOnTimer(HPScript hpScript, float hpToAdd, float timer) { yield return new WaitForSeconds(timer); SoundManager.PlaySFX(Transfering); hpScript.CurrentHp += hpToAdd; }
// Use this for initialization private void Start() { _particleScript = SingleParticle.GetComponent<PhysicsSingleParticle>(); if(_particleScript == null)Debug.Log("gameObject attachs is a nonParticle"); if (_hpScript == null) { Debug.Log("Attempting to getComponentFor hpScript"); _hpScript = GetComponent<HPScript>(); if (_hpScript == null) { Debug.LogError("hpScript not found"); } } _hpScript.HpImpactReceived += HpScriptOnHpImpactReceived; }