Inheritance: MonoBehaviour
Example #1
1
 void Awake()
 {
     myTransform = GetComponent<Transform>();
     myRigidBody = GetComponent<Rigidbody>();
     myHealth = GetComponent<Health>();
     BloodParticle = GetComponentInChildren<ParticleSystem>();
 }
Example #2
0
    // basic melee attack which just deals damage and runs animation. простая атака ближнего боя которая наносит урон и проигрывает анимацию
    public void basicMelee()
    {
        this.towerManager.isphysDmg=true;
        this.towerManager.ismageDmg=false;
        if(attackAreaMeleeEnter.enemy!=null) // check if there is something in front of the tower.  проверить есть ли какой-то объект перед башней.
        {
            if(attackAreaMeleeEnter.enemy.gameObject.tag.Contains("Enemy")) //check if thing in front of tower is actually an enemy. проверить если этот объект с тегом враг
            {
                hp = attackAreaMeleeEnter.enemy.gameObject.GetComponent("Health") as Health; // get health component of an enemy. берем компонент health из объекта врага
                animator = this.GetComponent<Animator>();// animator

                // attack with cooldown of two seconds and play animation. атакует с интервалом в две секунды и играет анимацию.
                if (timeStamp<=Time.time)
                {
                    hp.getDamage(damage);
                    timeStamp=Time.time+2.0f;
                    animator.SetBool("Attack",false);
                }

                // if enemy is dead, destroy enemy object. если враг мертв, уничтожаем его объект и ставим idle анимацию.
                if (hp.isDead())
                {
                    Destroy(attackAreaMeleeEnter.enemy.gameObject);
                    animator.SetBool("Attack",true);
                }
            }
        }
    }
	// Use this for initialization
	void Start () {
        counterText = GetComponent<Text>() as Text;
        set_seconds = maxSeconds;
        seconds = set_seconds;
        healthScript = healthObject.GetComponent<Health>();
		musicManager = canvas.GetComponent<MusicManager> ();
	}
Example #4
0
 public Lazer(Vec2 pos, Vec2 p2)
 {
     Health = new Health(0.2);
     Position = pos;
     this.p2 = p2;
     Velocity = Direction * Speed;
 }
	// Use this for initialization
	void Start () {
		if( GameObject.Find ("Player" + playerNumber.ToString ()) != null)
		health = GameObject.Find ("Player" + playerNumber.ToString ()).GetComponent<Health>();
		if (health == null) {
			health = GameObject.Find ("DetachedTop" + playerNumber.ToString ()).GetComponent<Health>();
		}
	}
Example #6
0
 //===================================================
 // UNITY METHODS
 //===================================================
 /// <summary>
 /// Awake.
 /// </summary>
 void Awake()
 {
     health = GetComponent<Health>();
     hitFlash = GetComponent<HitFlash>();
     startingHealth = health.HealthValue;
     a = footman.GetComponent<Animator>();
 }
    void FixedUpdate()
    {
        //		Debug.Log( "stuff :: " + targetHealth );

        if ( ! targetHealth )
        {
        //			Debug.Log( "target died ! ");

            inRangeList.Remove( targetTransform );

            targetHealth = null;
            targetTransform = null;
        }

        // Either attack your target or pull the first target of the list to attack next !
        if ( targetTransform )
        {
            approachTarget();
        }
        // If there's no current target & there's enemies in range - start attack:
        else if ( inRangeList.Count > 0 )
        {
            targetTransform = inRangeList[ 0 ];
            targetHealth = targetTransform.GetComponent<Health>();

            Debug.Log( "in range :: " + inRangeList.Count );

            if( targetTransform )
                startAttack();
        }
    }
Example #8
0
	void OnTriggerEnter2D(Collider2D other) 
	{
		scriptMove = player.GetComponent<CharacterMovement> ();
		scriptHP = player.GetComponent<Health> ();
		if (other.tag == "Hero"){
			Destroy(gameObject);
			float rekt = Random.value;
			if (rekt <= 0.2) {
				scriptMove.speed = 3f;
				//textbox.text = "Faster Speed! :)";
			} else if (rekt > 0.2 && rekt <= 0.3) {
				scriptMove.speed = 1.5f;
				//textbox.text = "Slower Speed! :(";
			} else if (rekt > 0.3 && rekt <= 0.5) {
				scriptHP.Heal (1);
				//textbox.text = "+1 HP!! :D";
			} else if (rekt > 0.5 && rekt <= 0.6) {
				scriptHP.TakeDamage (1);
				//textbox.text = "-1 HP!";
			} else if (rekt > 0.6 && rekt <= 0.9) {
				scriptArrow.arrowDamage = 2;
			} else {
				scriptMove.speed = 2.5f;
				scriptArrow.arrowDamage = 1;
			}
			AudioSource.PlayClipAtPoint(sound, transform.position);
		}
	}
Example #9
0
 void DealSplashDamage()
 {
     // checks which colliders are inside splash radius - they are denoted as victims
     Collider[] victimsArray = Physics.OverlapSphere(transform.position, splashRadius);
     foreach (Collider victim in victimsArray)
     {
     //			Debug.Log (victim.name + " in splash range");
         if (victim.GetComponent<Health>())
         {
             victimHealth = victim.GetComponent<Health>();
         }
         // check if something is blocking a straight line from explosion nucleus to victim
         // LineCast starts from 0.52 units above the explosion in order to include possible player colliders
         // that otherwise might be containing the LineCast start
         RaycastHit hitInfo;
         if (Physics.Linecast(transform.position + 0.52f * Vector3.up, victim.transform.position, out hitInfo))
         {
     //				Debug.Log(victim.name + " not shielded by objects");
             Debug.DrawLine(transform.position, victim.transform.position,Color.red, 10f);
             // Linecast to victim's position can be obstructed by victim's own collider,
             // which naturally cannot be considered being safe from splash.
             // Victim has to be behind some other collider to be shielded from splash.
             // Indestructible walls will be exempt from taking splash damage (because they cannot be damaged)
             if (hitInfo.collider.transform.position == victim.transform.position && "Indestructible" != victim.tag)
             {
     //					Debug.Log(victim.name + " damaged by splash");
                 victimHealth.DealDamage (damage, shooter);
             }
         }
     }
 }
    void Awake()
    {
        rigidbody = GetComponent<Rigidbody2D>();
        body = GetComponent<PolygonCollider2D>();
        feet = GetComponent<CircleCollider2D>();
        health = GetComponent<Health>();
        standing = body.points;
        crouched = new Vector2[standing.Length];
        grounded = false;
        onWall = false;
        upSlope = false;
        downSlope = false;

        int min = 0;
        for (int i = 0; i < standing.Length; i++)
        {
            if (standing[i].y < standing[min].y)
                min = i;
        }
        for (int i = 0; i < standing.Length; i++)
        {
            float newY = (standing[i].y - standing[min].y) * 0.5f + standing[min].y;
            crouched[i] = new Vector2(standing[i].x, newY);
        }
    }
Example #11
0
     //private Animator animator;


     public void Start()
     {
          // Components
          moveController = GetComponent<EnemyMoveController>();
          animationController = GetComponent<AnimationController>();
          sprRend = GetComponent<SpriteRenderer>();
          collider = GetComponent<BoxCollider2D>();
          health = GetComponent<Health>();
          player = FindObjectOfType<Player>();

          //laser = GetComponent<Projectile> ();
          //laserObject = GetComponent <Projectile> ();

          //rigidbody2D.mass = 10;

          distance = new Vector2(0, 0);
          speed = new Vector2(0, 0);
          isAgro = false;

          rnd = new System.Random(Guid.NewGuid().GetHashCode());
          t = 3 + rnd.Next(0, 3000) / 1000f;

          teleporting = false;
          teleportCD = 11;
          temp = 0;
          canTeleport = true;

          facing = new Vector2(0, 0);

     }
Example #12
0
 // Use this for initialization
 void Start()
 {
     _wheel = GetComponent<WheelCollider>();
     //bikerhealth = transform.parent.Find( "bodyHealthTrigger" ).GetComponent<Health>();
     bikerhealth = transform.parent.GetComponentInChildren<Health>();
     bikerscore = transform.parent.GetComponent<Score>();
 }
Example #13
0
 public Repair(Actor self, Actor host, WDist closeEnough)
 {
     this.host = Target.FromActor(host);
     this.closeEnough = closeEnough;
     repairsUnits = host.Info.TraitInfo<RepairsUnitsInfo>();
     health = self.TraitOrDefault<Health>();
 }
Example #14
0
 void hurt(Health otherHealth)
 {
     if (otherHealth && damageGroups.Contains(otherHealth.damageGroup))
     {
         if(damageCount == 0) {
             otherHealth.hurt(damage);
         }
         else {
             int hits = 0;
             if (gameObjectHits.TryGetValue(otherHealth, out hits))
             {
                 if (hits < damageCount)
                 {
                     gameObjectHits[otherHealth] = hits + 1;
                     otherHealth.hurt(damage);
                 }
             }
             else
             {
                 gameObjectHits[otherHealth] = 1;
                 otherHealth.hurt(damage);
             }
         }
     }
 }
     public void Start()
     {

          //animator = GetComponent<Animator>();
          player = FindObjectOfType<Player>();
          moveController = GetComponent<EnemyMoveController>();
          health = GetComponent<Health>();
          isInvincible = false;
          isAgro = false;
          sprRend = GetComponent<SpriteRenderer>();
          maxVelocity = 1;
          currentVelocity = 0;

          left = new Vector3(-0.3f, 0, 0);
          right = new Vector3(0.3f, 0, 0);
          up = new Vector3(0, 0.3f, 0);
          down = new Vector3(0, -0.3f, 0);
          west = new Quaternion(0, 0, 90, 0);
          east = new Quaternion(0, 0, -90, 0);
          north = new Quaternion(0, 0, 0, 0);
          south = new Quaternion(0, 0, 180, 0);

          shield = Instantiate(shieldObj, transform.position, transform.rotation) as GameObject;

     }
Example #16
0
    private void OnEnable()
    {
        SO = new SerializedObject(target);
        myHealth = (Health)target;

        statusEffects = Enum.GetNames(typeof (HitInfo.Effects));
    }
Example #17
0
File: Game.cs Project: Zylann/GGJ14
    public void Initialize()
    {
        // Finding GameObjects
        m_object_player = GameObject.Find("Player");
        m_object_helpers = GameObject.Find ("Helpers");
        m_object_duckfield = GameObject.Find("Duckfield");
        m_object_audio = GameObject.Find("Audio");
        m_object_cameraman = GameObject.Find("Main Camera");

        // Finding Components
        m_collision_prober = m_object_player.GetComponent<CollisionProber>();
        m_scoring = m_object_player.GetComponent<Scoring>();
        m_health = m_object_player.GetComponent<Health>();
        m_walker = m_object_player.GetComponent<Walker>();
        m_jumper = m_object_player.GetComponent<Jumper>();

        m_time_helper = m_object_helpers.GetComponent<TimeHelper>();
        m_screen_helper = m_object_helpers.GetComponent<ScreenHelper>();

        m_duckfield = m_object_duckfield.GetComponent<DuckField>();

        m_duckization = m_object_audio.GetComponent<DuckizationController>();

        m_cameraman = m_object_cameraman.GetComponent<Cameraman>();
        m_ig_menu = m_object_cameraman.GetComponent<IgMenu>();
    }
        public override Activity Tick(Actor self)
        {
            if (IsCanceled) return NextActivity;
            if (host != null && !host.IsInWorld) return NextActivity;

            health = self.TraitOrDefault<Health>();
            if (health == null) return NextActivity;
            if (health.DamageState == DamageState.Undamaged)
                return NextActivity;

            if (remainingTicks == 0)
            {
                var repairsUnits = host.Info.Traits.Get<RepairsUnitsInfo>();
                var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
                var hpToRepair = repairsUnits.HpPerStep;
                var cost = (hpToRepair * unitCost * repairsUnits.ValuePercentage) / (health.MaxHP * 100);

                if (!self.Owner.PlayerActor.Trait<PlayerResources>().TakeCash(cost))
                {
                    remainingTicks = 1;
                    return this;
                }
                self.InflictDamage(self, -hpToRepair, null);

                if (host != null)
                    host.Trait<RenderBuilding>()
                        .PlayCustomAnim(host, "active");

                remainingTicks = repairsUnits.Interval;
            }
            else
                --remainingTicks;

            return this;
        }
 void OnEnable()
 {
     m_health = GetComponent<Health> ();
             if (!m_health) {
                     Debug.Log (gameObject.name);
             }
 }
Example #20
0
	protected   void  Start () {

		money = 0;
		controller = GetComponent<PlayerController> ();
		gunController = GetComponent<GunController> ();

		moneyText = GameObject.FindGameObjectWithTag ("money");
		mText = moneyText.GetComponent<Text> ();
		viewCamera = Camera.main;
		//swordButton = GameObject.Find ("swordButton");
		startRot = transform.eulerAngles;
		sword = GameObject.FindGameObjectWithTag ("sword");
		bow = GameObject.FindGameObjectWithTag ("bow");

		sword.transform.localEulerAngles = new Vector3(0,90,50);
		sword.transform.position =  GameObject.FindGameObjectWithTag("hold").transform.position;
		sword.transform.SetParent(this.transform);

		playerHealth = 3.0;

		mText.text = "Money: " + money; 
		hltScript = FindObjectOfType (typeof(Health)) as Health;
		hltScript.takeHeart ();

	}
Example #21
0
 public Bullet(Vec2 pos, Vec2 p2)
 {
     Health = new Health(0.5);
     Position = pos;
     this.p2 = p2;
     Velocity = Direction * Speed;
 }
Example #22
0
	void Start () {
		anim = GetComponent<Animator> ();
		moveAllowed = true;
		health = (Health)gameObject.GetComponent ("Health");
		//if you start as Mabellle, which I think should be default
		TurnIntoNormal ();
	}
Example #23
0
	// Use this for initialization
	void Start () {
		blackStyle.normal.textColor = Color.black;
		rb2D = GetComponent<Rigidbody2D>();
		labelRect = new Rect (0, 0, 100, 100);
		offset = new Vector2 (-5, -5);
		health = gameObject.GetComponent<Health> ();
	}
Example #24
0
    void Awake()
    {
        rb = GetComponent<Rigidbody2D> ();
        rb.centerOfMass = new Vector2 (0, 0);

        health = GetComponent<Health> ();
    }
Example #25
0
 void GetHealthComponent()
 {
     if (gameObject.tag == "Player"){
         HealthRemainingText = GameObject.Find("CurrentHealth").GetComponent<Text>();
         PlayerHealth = NetworkManager.MyPlayer.GetComponent<Health>();
     }
 }
 public CharacterBuilder WithHealth()
 {
     if (_stats == null)
         throw new NullReferenceException("Stats cannot be null otherwise character cannot have health");
     _health = new Health((int)_stats.HealthPoints).HealthGeneration();
     return this;
 }
        public DnsRecord[] GetMatchingDnsRecords(string domainName, Health.Direct.Common.DnsResolver.DnsStandard.RecordType typeID)
        {
            DnsRecord[] records = Store.DnsRecords.Get(domainName, typeID);

            if (!records.IsNullOrEmpty())
            {
                return records; 
            }            

            // For NS and SOA records, check if we own the question domain. 
            if (typeID == DnsStandard.RecordType.SOA ||
                typeID == DnsStandard.RecordType.NS)
            {   
                string owningDomain = QuestionDomainToOwnedDomain(domainName);

                if (owningDomain == null)
                {
                    return null; 
                }

                records = Store.DnsRecords.Get(owningDomain, typeID);

                // apply the question's domain before returning the records.
                foreach (DnsRecord record in records)
                {
                    DnsResourceRecord newRecord = record.Deserialize();
                    newRecord.Name = domainName;

                    record.DomainName = domainName;
                    record.RecordData = newRecord.Serialize();
                }
            }   

            return records;
        }
Example #28
0
 public Sell(Actor self)
 {
     health = self.TraitOrDefault<Health>();
     sellableInfo = self.Info.TraitInfo<SellableInfo>();
     playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
     IsInterruptible = false;
 }
Example #29
0
	//more setup
	void Start()
	{
		checkpoints = GameObject.FindGameObjectsWithTag("Respawn");
		health = GameObject.FindGameObjectWithTag("Player").GetComponent<Health>();
		if(!health)
			Debug.LogError("For Checkpoint to work, the Player needs 'Health' script attached", transform);
	}
        public ActionResult Add(Health.Areas.Prescription.Models.Prescription model)
        {
            PrescriptionContext pc = new PrescriptionContext();
            HealthDB.Model.Prescription p = new HealthDB.Model.Prescription();
            p.DoctorId = model.PrescribedByUserId;
            p.Dosage = model.Strength;
            p.DrugName = model.DrugName;
            if (model.GroupName != null)
                p.GroupName = model.GroupName;
            p.Instruction = model.Direction;
            p.Invoice = DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + "_" + model.PatientUserId + "_" + model.PrescribedByUserId;
            p.PatientId = model.PatientUserId;
            p.PharmacistId = model.PharmacistUserId;
            p.PrescriptionTypeId = model.PrescriptionTypeId;
            p.Quantity = model.Quantity;
            p.PrescriptionStatusId = 1;
            pc.Prescriptions.InsertOnSubmit(p);

            IEnumerable<DrugName> DrugNames = from drugs in pc.DrugNames
                                              where drugs.Name == model.DrugName
                                              select drugs;
            if (DrugNames == null)
            {
                DrugName dn = new DrugName();
                dn.Name = model.DrugName;
                pc.DrugNames.InsertOnSubmit(dn);
            }

            pc.SubmitChanges();
            model = GetPrescription(model.PatientUserId, model.PrescribedByUserId, DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + "_" + model.PatientUserId + "_" + model.PrescribedByUserId, model);

            return View(model);
        }
Example #31
0
        /// <summary>
        ///     Returns health prediction on a unit.
        /// </summary>
        /// <param name="unit">The Unit</param>
        /// <returns>Unit's predicted health</returns>
        public float GetHealthPrediction(Obj_AI_Base unit)
        {
            var time = (int)((this.Delay * 1000) + (this.From.Distance(unit.ServerPosition) / this.Speed) - 100);

            return(Health.GetPrediction(unit, time));
        }
Example #32
0
    void Update()
    {
        playerHealth.DeathCheck();    // first things first =)

        // game timer
        if (currentLives >= 0 && player != null)
        {
            time += Time.deltaTime;
            ui.setTime((int)time);
        }

        if (player == null)    // player has died
        {
            if (currentLives > 0)
            {
                ui.ShowRespawnScreen();

                if (Input.GetButtonDown("Restart"))    // button space
                {
                    // player respawn --> set defaults
                    ui.HideRespawnScreen();
                    player         = spawner.SpawnPlayer();
                    playerHealth   = player.GetComponent <Health>();
                    playerControls = player.GetComponent <PlayerControls>();
                    currentLives--;
                    forceField = GameObject.FindWithTag("Force_Field");
                    forceField.SetActive(false);
                    ui.toggleAutoCannon();
                    ui.setMechs(currentLives, lives);
                    soundManager.PlaySound("WeaponChange");
                }
            }
            else
            {
                // game over
                ui.ShowEndScreen(score, time);
            }
        }

        // player controls
        if (Input.GetButtonDown("Autocannon"))    // button 1
        {
            playerControls.weapon      = PlayerControls.Weapon.Autocannon;
            playerControls.weaponIndex = 0;
            ui.toggleAutoCannon();
            soundManager.PlaySound("WeaponChange");
        }
        else if (Input.GetButtonDown("Missiles"))    // button 2
        {
            playerControls.weapon      = PlayerControls.Weapon.Missiles;
            playerControls.weaponIndex = 1;
            ui.toggleMissiles();
            soundManager.PlaySound("WeaponChange");
        }
        else if (Input.GetButtonDown("Energy beam"))    // button 3
        {
            playerControls.weapon      = PlayerControls.Weapon.Beam;
            playerControls.weaponIndex = 2;
            ui.toggleBeam();
            soundManager.PlaySound("WeaponChange");
        }
        else if (Input.GetButtonDown("Shields"))    // button F
        {
            if (!playerHealth.shieldsOn && playerHealth.GetCurrentPower() > 0)
            {
                playerHealth.shieldsOn = true;
                ui.shieldsOn();
                forceField.SetActive(true);
                soundManager.PlaySound("ShieldsOn");
            }
            else
            {
                playerHealth.shieldsOn = false;
                ui.shieldsOff();
                forceField.SetActive(false);
                soundManager.PlaySound("ShieldsOff");
            }
        }

        // heat damage is reduced over time
        if (playerHealth.GetCurrentHeat() > 0)
        {
            playerHealth.AddHeat(-playerHealth.heatCoolingRate * Time.deltaTime);
            SetHeat(playerHealth.GetCurrentHeat(), playerHealth.maxHeat);
        }

        // shields being on drains power
        if (playerHealth.GetCurrentPower() > 0 && playerHealth.shieldsOn)
        {
            playerHealth.ReducePower(playerHealth.heatCoolingRate * Time.deltaTime);
            SetPower(playerHealth.GetCurrentPower(), playerHealth.maxPower);
        }
    }
 public void Show(Health health)
 {
     show = !health.IsDead();
     Invoke("Delay", delay);
 }
Example #34
0
 private void Start()
 {
     health = GetComponent <Health>();
 }
Example #35
0
 private void LookForTarget()
 {
     target = playerDetector.GetFirstDetected <Health>();
 }
Example #36
0
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     helth  = player.GetComponent <Health>();
 }
Example #37
0
 void INotifyCreated.Created(Actor self)
 {
     health = self.TraitOrDefault <Health>();
 }
Example #38
0
 private void Start()
 {
     health = GetComponent <Health>();
     dead   = GetComponent <IDead>();
     Assert.IsNotNull(dead);
 }
Example #39
0
 private void Start()
 {
     navMeshAgent = GetComponent <NavMeshAgent>();
     health       = GetComponent <Health>();
 }
    private IEnumerator buzz(float time)
    {
        /* Using a Raycast out the front of the Dino to detect a collision seems to work
         * well for forward melee attacks such as this as it prevents a weapon like the BuzzSaw
         * here from doing damage to dinos behind the attacker on trigger pull who may be in
         * range of the "capsule colliders", but are in fact behind the BuzzSaw attacker where
         * the attack should not affect them. Darren */

        RaycastHit[] targets;
        bool         hitOne  = false;
        float        seconds = time;

        DinoCollisions myCollision = GetComponent <DinoCollisions>();

        myCollision.enabled = false;

        DinoCollisions damageColl = null;
        Vector3        buzzForward;

        while (seconds > 0)
        {
            buzzForward = transform.forward;
            targets     = Physics.SphereCastAll(this.transform.position, ColliderRadius, buzzForward, ColliderRange);

            foreach (RaycastHit rayHit in targets)
            {
                if (rayHit.transform.tag == "Dino" || rayHit.transform.tag == "Ai")
                {
                    damageColl         = rayHit.transform.GetComponent <DinoCollisions>();
                    damageColl.enabled = false;

                    if (hitOne == false)
                    {
                        Debug.Log(rayHit.transform.name + "Took BuzzSaw damage");
                        Health health = rayHit.transform.GetComponent <Health>();
                        health.Damage(BuzzSawDamage);
                    }
                    hitOne = true;
                    break;
                }
            }

            if (hitOne == true)
            {
                break;
            }
            // COMMENTS: On instantaneous speed burst...

            /* I tried the AccelationMod from motioncontrol here and in
             * one other place and it didn't seem to have any effect on speed */
            // motControl.AccelerationMod(BuzzSpeedFactor, duration);


            /* I tried several different versions of the AddForce/AddRelativeForce etc with
             * or without a ForceMode. The ForceMode.VelocityChange did speed up the Spino
             * but on collision with damagable walls this newly applied force had him bouncing
             * around like he's in a pinball machine, or blasting other dinos in to outerspace. So
             * I'm finding the rigidbody.velocity = transform.TransformDirection(Vector3.forward) * speedfactor;
             * method to be the best way to go for a temporary, instant speed burst. Darren */
            //this.rigidbody.AddForce(buzzForward * BuzzSpeedFactor, ForceMode.VelocityChange);
            rigidbody.velocity = buzzForward * BuzzSpeedFactor + new Vector3(0, rigidbody.velocity.y, 0);
            seconds           -= Time.deltaTime;
            yield return(null);
        }

        if (damageColl != null)
        {
            damageColl.enabled = true;
        }
        myCollision.enabled = true;

        hitOne = false;

        netanim.SetBool("Melee", false);
    }
Example #41
0
 private void Awake()
 {
     health       = GameObject.FindGameObjectWithTag("Player").GetComponent <Health>();
     healthPoints = GetComponent <Text>();
 }
Example #42
0
 public RepairBuilding(Actor self, Actor target)
     : base(self, target)
 {
     this.target = target;
     health      = target.Trait <Health>();
 }
Example #43
0
        protected override void Draw()
        {
            if (Radar2D.Option.IsVisible)
            {
                Radar2D.Draw(Render2D, RenderSurface.Size);
            }

            foreach (Player player in _players)
            {
                if (player.IsValid() && player.Name != _localPlayer.Name)
                {
                    if (Name.Option.IsVisible)
                    {
                        if (!Name.Option.IsOnlyEnemyVisible || Name.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            Name.Draw_y(Render2D, player.Position, _localPlayer.ViewProj, new Size(1920, 1080), player.Name, player.Height, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                        }
                    }

                    if (Health.Option.IsVisible)
                    {
                        if (!Health.Option.IsOnlyEnemyVisible || Health.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            Health.Draw_y(Render2D, player.Position, _localPlayer.ViewProj, new Size(1920, 1080), player.Health, player.MaxHealth, player.Height, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                        }
                    }

                    if (Box2D.Option.IsVisible)
                    {
                        if (!Box2D.Option.IsOnlyEnemyVisible || Box2D.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            Box2D.Draw_y(Render2D, new Size(1920, 1080), _localPlayer.ViewProj, player.Position, player.Height, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                        }
                    }

                    if (Box3D.Option.IsVisible)
                    {
                        if (!Box3D.Option.IsOnlyEnemyVisible || Box3D.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            Box3D.Draw_y(Render2D, player.BoundingBox(), player.Position, player.Yaw, _localPlayer.ViewProj, new Size(1920, 1080), player.IsVisible, _localPlayer.TeamId == player.TeamId);
                        }
                    }

                    if (SnapLine.Option.IsVisible)
                    {
                        if (!SnapLine.Option.IsOnlyEnemyVisible || SnapLine.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            SnapLine.Draw_y(Render2D, player.Position, _localPlayer.ViewProj, RenderSurface.Size, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                        }
                    }

                    if (Radar2D.Option.IsVisible)
                    {
                        if (!Radar2D.Option.IsOnlyEnemyVisible || Radar2D.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            Radar2D.DrawPlayer(Render2D, player.Position, _localPlayer.Position, RenderSurface.Size, _localPlayer.Yaw, player.IsVisible, _localPlayer.TeamId == player.TeamId);

                            if (Radar2D.Option.IsVisibleName)
                            {
                                Radar2D.DrawName(Render2D, player.Position, _localPlayer.Position, RenderSurface.Size, player.Name, _localPlayer.Yaw, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                            }
                        }
                    }

                    if (CrosshairRadar.Option.IsVisible)
                    {
                        if (!CrosshairRadar.Option.IsOnlyEnemyVisible || CrosshairRadar.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            CrosshairRadar.DrawPlayer(Render2D, player.Position, _localPlayer.Position, RenderSurface.Size, _localPlayer.Yaw, player.IsVisible, _localPlayer.TeamId == player.TeamId);

                            if (CrosshairRadar.Option.IsVisibleName)
                            {
                                CrosshairRadar.DrawName(Render2D, player.Position, _localPlayer.Position, RenderSurface.Size, player.Name, _localPlayer.Yaw, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                            }
                        }
                    }

                    if (DisplayRadar.Option.IsVisible)
                    {
                        if (!DisplayRadar.Option.IsOnlyEnemyVisible || DisplayRadar.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            DisplayRadar.DrawPlayer(Render2D, player.Position, _localPlayer.Position, RenderSurface.Size, _localPlayer.Yaw, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                        }
                    }
                }
            }

            if (Crosshair.Option.IsVisible)
            {
                Crosshair.Draw(Render2D, RenderSurface.Size);
            }
        }
Example #44
0
 void Awake()
 {
     player       = GameObject.FindGameObjectWithTag("Player");
     playerHealth = player.GetComponent <Health> ();
     enemyHealth  = GetComponent <Health>();
 }
Example #45
0
    public void DealDamage()
    {
        GameObject hgo = new GameObject("Health");
        Health     h   = hgo.AddComponent <Health>();

        Vector3 res;

        // Basic, and return values.

        h.Reset(100f, 100f, 100f, 100f);
        res = h.DealDamage(100f, 0f);
        Assert.AreEqual(100f, h.CurrentHealth);
        Assert.AreEqual(100f * Health.ARMOUR_RESISTANCE, h.CurrentArmour);
        Assert.AreEqual(new Vector3(0f, 100f * Health.ARMOUR_RESISTANCE, 0f), res);

        h.Reset(100f, 100f, 100f, 0f);
        res = h.DealDamage(100f, 0f);
        Assert.AreEqual(0f, h.CurrentHealth);
        Assert.AreEqual(0f, h.CurrentArmour);
        Assert.AreEqual(new Vector3(100f, 0f, 0f), res);

        h.Reset(100f, 100f, 100f, 100f);
        res = h.DealDamage(200f, 0f);
        Assert.AreEqual(100f, h.CurrentHealth);
        Assert.AreEqual(0f, h.CurrentArmour);
        Assert.AreEqual(new Vector3(0f, 200f * Health.ARMOUR_RESISTANCE, 0f), res);

        h.Reset(100f, 100f, 100f, 100f);
        res = h.DealDamage(250f, 0f);
        Assert.AreEqual(50f, h.CurrentHealth);
        Assert.AreEqual(0f, h.CurrentArmour);
        Assert.AreEqual(new Vector3(50f, 100f, 0f), res);

        h.Reset(100f, 100f, 100f, 100f);
        res = h.DealDamage(300f, 0f);
        Assert.AreEqual(0f, h.CurrentHealth);
        Assert.AreEqual(0f, h.CurrentArmour);
        Assert.AreEqual(new Vector3(100f, 100f, 0f), res);

        h.Reset(100f, 100f, 100f, 100f);
        res = h.DealDamage(350f, 0f);
        Assert.AreEqual(0f, h.CurrentHealth);
        Assert.AreEqual(0f, h.CurrentArmour);
        Assert.AreEqual(new Vector3(100f, 100f, 50f), res);

        h.Reset(100f, 100f, 100f, 100f);
        res = h.DealDamage(0f, 0f);
        Assert.AreEqual(100f, h.CurrentHealth);
        Assert.AreEqual(100f, h.CurrentArmour);
        Assert.AreEqual(new Vector3(0f, 0f, 0f), res);

        // Using armour pen.

        h.Reset(100f, 100f, 100f, 100f);
        res = h.DealDamage(100f, 1f);
        Assert.AreEqual(0f, h.CurrentHealth);
        Assert.AreEqual(100f, h.CurrentArmour);
        Assert.AreEqual(new Vector3(100f, 0f, 0f), res);

        h.Reset(100f, 100f, 100f, 100f);
        res = h.DealDamage(175f, 1f);
        Assert.AreEqual(0f, h.CurrentHealth);
        Assert.AreEqual(100f, h.CurrentArmour);
        Assert.AreEqual(new Vector3(100f, 0f, 75f), res);

        h.Reset(100f, 100f, 100f, 100f);
        res = h.DealDamage(0f, 1f);
        Assert.AreEqual(100f, h.CurrentHealth);
        Assert.AreEqual(100f, h.CurrentArmour);
        Assert.AreEqual(new Vector3(0f, 0f, 0f), res);

        h.Reset(100f, 100f, 100f, 100f);
        res = h.DealDamage(100f, 0.5f);
        Assert.AreEqual(50f, h.CurrentHealth);
        Assert.AreEqual(100f - 50f * Health.ARMOUR_RESISTANCE, h.CurrentArmour);
        Assert.AreEqual(new Vector3(50f, 50f * Health.ARMOUR_RESISTANCE, 0f), res);

        h.Reset(100f, 100f, 100f, 100f);
        res = h.DealDamage(100f, 0.25f);
        Assert.AreEqual(75f, h.CurrentHealth);
        Assert.AreEqual(100f - 75f * Health.ARMOUR_RESISTANCE, h.CurrentArmour);
        Assert.AreEqual(new Vector3(25f, 75f * Health.ARMOUR_RESISTANCE, 0f), res);

        for (float i = 0; i < 100f; i++)
        {
            for (int j = 0; j <= 20; j++)
            {
                float p = j / 20f;

                h.Reset(100f, 100f, 100f, 100f);
                res = h.DealDamage(i, p);

                float exArmour = 100f - i * (1f - p) * Health.ARMOUR_RESISTANCE;
                float exHealth = 100f - (i * p);

                Assert.AreEqual(exHealth, h.CurrentHealth, 0.01f, "Health - Using damage {0} and pen {1}", i, p);
                Assert.AreEqual(exArmour, h.CurrentArmour, 0.01f, "Armour - Using damage {0} and pen {1}", i, p);
                Assert.AreEqual(100f - exHealth, res.x, 0.01f);
                Assert.AreEqual(100f - exArmour, res.y, 0.01f);
                Assert.AreEqual(0f, res.z, 0.01f);
            }
        }
    }
Example #46
0
 public async Task <IActionResult> UpdateHealth([FromRoute] string id, [FromBody] Health health) => await UpdateRpgModel(id, Builders <FiveEModel> .Update.Set(sheet => sheet.Health, health), health);
Example #47
0
 private void Start()
 {
     m_Rigidbody2D = GetComponent <Rigidbody2D>();
     m_Health      = GetComponent <Health>();
 }
Example #48
0
 // Use this for initialization
 void Start()
 {
     rigidbody2D  = GetComponent <Rigidbody2D>();
     collider2D   = GetComponent <Collider2D>();
     healthScript = GetComponent <Health>();
 }
Example #49
0
 void Awake()
 {
     spaceship      = GetComponent <Rigidbody2D> ();
     normalMovement = GetComponent <SpaceshipMovement> ();
     healthSystem   = GetComponent <Health> ();
 }
Example #50
0
 /// <summary>
 /// Called when a health has exited the effect.
 /// </summary>
 /// <param name="toAffect">The health to be affected.</param>
 /// <param name="inWorld">The WorldEffectInWorld which holds additional data.</param>
 public virtual void OnExit(Health toAffect, WorldEffectInWorld inWorld)
 {
 }
Example #51
0
 void Start()
 {
     healthBar    = GetComponent <Slider>();
     playerHealth = GameObject.FindObjectOfType <Health>();
 }
Example #52
0
 void Start()
 {
     health           = GetComponent <Health>();
     health.onDeath  += Health_onDeath;
     health.onDamage += Health_onDamage;
 }
Example #53
0
 void Start()
 {
     playerLove = this.GetComponent <Health> ();
 }
Example #54
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        // Destroy bullet if it hits a wall
        if (collision.gameObject.layer == 12)
        {
            Destroy(this.gameObject);
            return;
        }

        // Make sure required variables are here
        Team   targetTeam   = collision.gameObject.GetComponent <Team>();
        Team   bulletTeam   = this.GetComponent <Team>();
        Health targetHealth = collision.gameObject.GetComponent <Health>();

        if (bulletTeam == null || targetTeam == null || targetHealth == null)
        {
            return;
        }

        // Make sure enemy bullets dont hit enemies and player bullets dont hit players
        if (targetTeam.TeamID != bulletTeam.TeamID)
        {
            // Layer 8 is enemies so this checks if the bullet hit an enemy
            if (collision.gameObject.layer == 8)
            {
                // Check the bullet hit a red dude as thet are the ONLY ONE we can attack
                if (collision.gameObject.GetComponent <CommanderEnemy>() != null && bulletTeam.TeamID != TeamIDs.Turret && collision.gameObject.GetComponent <Invincible>() == null)
                {
                    collision.gameObject.GetComponent <Health>().Amount -= Damage;
                    GameObject.Find("GameManager").GetComponent <ScoreCounter>().Score++;
                }
                else if (collision.gameObject.GetComponent <StatueEnemy>() != null && bulletTeam.TeamID == TeamIDs.Turret && collision.gameObject.GetComponent <Invincible>() == null)
                {
                    // Comment this out to disable turret bullets killing statues
                    collision.gameObject.GetComponent <Health>().Amount -= Damage;
                    Destroy(this.gameObject);
                    // Comment above to disable turret bullets killing statues

                    return;
                }
                if (collision.gameObject.GetComponent <CommanderEnemy>() != null && bulletTeam.TeamID == TeamIDs.Turret)
                {
                    return;
                }
            } // Check if we hit player head collision box
            else
            {
                // Dont deal damage if we are invincible
                if (collision.gameObject.GetComponent <Invincible>() == null)
                {
                    collision.gameObject.GetComponent <Health>().Amount -= Damage;

                    // Give temporary invincibility after being hit
                    Invincible invincible = collision.gameObject.AddComponent <Invincible>();
                    invincible.Duration = InvulnerabilityDuration;
                    // Flash the sprite red to show we got hit
                    if (collision.gameObject.GetComponent <FlashSpriteRed>() == null)
                    {
                        FlashSpriteRed flashRed = collision.gameObject.AddComponent <FlashSpriteRed>();
                        flashRed.Duration    = 0.5f;
                        flashRed.startColor  = new Color(1, 0, 0, 0.125f);
                        flashRed.targetColor = new Color(1, 0, 0, 1f);
                    }
                    collision.gameObject.GetComponent <Health>().PlayPainSound();
                }
            }
            Destroy(this.gameObject);
        }
    }
Example #55
0
 public void Attack(CombatTarget combatTarget)
 {
     GetComponent <ActionScheduler>().StartAction(this);
     target = combatTarget.GetComponent <Health>();
 }
Example #56
0
 // Use this for initialization
 void Start()
 {
     myHealth = GetComponent <Health>();
 }
Example #57
0
 public RepairableBuilding(Actor self, RepairableBuildingInfo info)
 {
     Health = self.Trait <Health>();
     Info   = info;
 }
Example #58
0
 // Use this for initialization
 public void Start()
 {
     health = GetComponent <Health>();
     anim   = GetComponentInChildren <Animator>();
     body   = GetComponent <Rigidbody2D>();
 }
Example #59
0
 private void Start()
 {
     playerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent <Health>(); // доступ к скрипту Health игрок Player
     healthBar    = GetComponent <Slider>();
 }
Example #60
0
 public void Cancel()
 {
     StopAttack();
     target = null;
 }