Inheritance: MonoBehaviour
 // Use this for initialization
 void Start()
 {
     Motor = GetComponent<CharacterMotor2>();
     Shot = GetComponent<CharacterShot>();
     Life = GetComponent<CharacterHealth>();
     Damage = GetComponent<TakeDamage>();
 }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     brickWallBreak = GameObject.Find ("Player").GetComponent<CharacterPlayer> ().brickWallBreak;
     theCharacterHealth = GetComponent<CharacterHealth> ();
     theSpriteRenderer = GetComponent<SpriteRenderer> ();
     theSpriteRenderer.sprite = threeHitWall;
 }
Esempio n. 3
0
        public string _name; //character name

        #endregion Fields

        #region Constructors

        public Character()
        {
            _name = "";
            _id = 0;
            _fame = 0;
            _age = 0;
            _jobID = -1;
            _mindset = new CharacterMindset();
            _bodyneeds = new CharacterBodyNeeds();
            _currentActionFinishTime = new Gametime(0, 0, 0);
            _health = new CharacterHealth();
            _characterActions = new characterActionPriorityQueue(); //the list of actions the character wants to do
            _characterPreviousActions = new List<actionHistory>();
            _characterinventory = new CharacterInventory();
            _locationID = Consts.stronghold_yard;
            _homeID = Consts.stronghold_yard;

            //eating events
            _bodyneeds._hungryEvent += this.OnHungryEventHandler; //hungry event listener

            //determining gender 50-50
            if (Consts.rand.Next(1, 1000) > 500)
            {
                _gender = Consts.gender.Male;
            }
            else _gender = Consts.gender.Female;
        }
    void Awake()
    {
        _Target = GameObject.FindGameObjectWithTag ("Player").transform;
        _Health = GetComponent<CharacterHealth> ();
        _Navigation = GetComponent <NavMeshAgent> ();
        _Animation = GetComponent<Animator>();

        //SetRandomNavTarget();
    }
Esempio n. 5
0
    void Start()
    {
        healthScript = GetComponentInParent<CharacterHealth> ();
        //Store the actual character
        character = transform.parent;
        //Set the actual parent to be the canvas; if it stayed with the character
        //it would wiggle all over
        transform.SetParent (GameObject.Find ("EnemyHealthCanvas").transform);

        slider = GetComponentInChildren<Slider> ();
        text = GetComponentInChildren<Text> ();
        text.text = charName;
    }
Esempio n. 6
0
 private void GetStats()
 {
     if (playerHandler != null)
     {
         if (playerHandler.kartInstance != null)
         {
             shield = playerHandler.kartInstance.GetComponent<CharacterShield>();
             health = playerHandler.kartInstance.GetComponent<CharacterHealth>();
             ammo = playerHandler.kartInstance.GetComponent<CharacterAmmo>();
         }
         killsText.text = "K : " + playerHandler.kills;
         deathsText.text = "D : " + playerHandler.deaths;
     }
     else
         LookForPlayerHandler();
 }
 protected virtual void Init()
 {
     barImage = GetComponent<Image> ();
     if (characterHealth == null)
     {
         // No health assigned try to find one
         if (characterLoader == null) characterLoader = CharacterLoader.GetCharacterLoader();
         if (characterLoader != null)
         {
             characterLoader.CharacterLoaded += HandleCharacterLoaded;
         }
         else
         {
             characterHealth = GameObject.FindObjectOfType<CharacterHealth> ();
             if (characterHealth == null) Debug.LogWarning ("Couldn't find a character health!");
         }
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Init this instance.
 /// </summary>
 protected virtual void Init()
 {
     Character character = GetComponentInParent<Character> ();
     if (character == null)
     {
         Debug .LogWarning ("ItemToLives should be a child of a GameObject with a character attached.");
     }
     else if (itemType == null || itemType == "")
     {
         Debug.LogWarning ("No item type specified, ItemToLives wont work.");
     }
     else
     {
         itemManager = character.GetComponentInChildren<ItemManager>();
         characterHealth = character.GetComponentInChildren<CharacterHealth>();
         if (itemManager == null) Debug.LogWarning("Character does not have an ItemManager, ItemToLives will not work");
         if (characterHealth == null) Debug.LogWarning("Character does not have a CharacterHealth, ItemToLives will not work");
         if (itemManager != null && characterHealth != null)
         {
             itemManager.ItemCollected += HandleItemCollected;
         }
     }
 }
 private void Awake()
 {
     ch   = GetComponent <CharacterHealth>();
     anim = GetComponent <Animator>();
 }
Esempio n. 10
0
 void Start()
 {
     controller = new CharacterHealth(playerHealth);
     healthBar.setMaxHealth(playerHealth);
     playerAnimator = GetComponent <Animator>();
 }
Esempio n. 11
0
 public void RemoveCharacter(CharacterHealth characterHealth)
 {
     _characters.Remove(characterHealth);
 }
Esempio n. 12
0
 // Use this for initialization
 void Start()
 {
     Life = GetComponent<CharacterHealth>();
 }
Esempio n. 13
0
 public AttackCommand(Unit self, CharacterHealth _target)
 {
     Executer    = self;
     healtTarget = _target;
     DoCommand();
 }
Esempio n. 14
0
 // Use this for initialization
 public void Start()
 {
     thePlayerDesiredPoint = GameObject.Find ("PlayerDesiredPoint");
     theCharacterMotor = GetComponent<CharacterMotor> ();
     theCharacterHealth = GetComponent<CharacterHealth> ();
 }
Esempio n. 15
0
        private void CreateItemDisplay(ItemModel item, List <ItemModel> list)
        {
            var frame = new Frame();

            frame.CornerRadius = 5;
            frame.Padding      = new Thickness(15, 15, 5, 15);

            var layout = new StackLayout();

            layout.Orientation = StackOrientation.Horizontal;

            var Name = new Label();

            Name.Text = item.item;
            Name.VerticalTextAlignment = TextAlignment.Center;
            Name.Margin         = new Thickness(0, 0, 10, 0);
            Name.FontAttributes = FontAttributes.Bold;
            if (item.item.Contains("HealthPotion"))
            {
                Name.TextColor      = Color.FromHex("#F44336");
                frame.BorderColor   = Color.FromHex("#F44336");
                Name.FontAttributes = FontAttributes.Bold;
            }
            else
            {
                Name.TextColor      = Color.DarkTurquoise;
                frame.BorderColor   = Color.DarkTurquoise;
                Name.FontAttributes = FontAttributes.Bold;
            }


            var extras = new Label();

            extras.FontSize  = 10;
            extras.TextColor = Color.Black;
            extras.Text      = string.Format("{0}: {1} - {2} {3}",
                                             ItemInfoModel.ObtainItemString(item.item, true),
                                             ItemInfoModel.ObtainItemInfo(item.item, true),
                                             ItemInfoModel.ObtainItemInfo(item.item, false),
                                             ItemInfoModel.ObtainItemString(item.item, false));
            extras.HorizontalTextAlignment = TextAlignment.Center;
            extras.HorizontalOptions       = LayoutOptions.CenterAndExpand;
            extras.VerticalTextAlignment   = TextAlignment.Center;

            var button = new Button();

            button.HorizontalOptions = LayoutOptions.EndAndExpand;
            button.Text            = "USE";
            button.CornerRadius    = 5;
            button.BackgroundColor = Color.White;
            button.TextColor       = Color.Accent;


            button.Clicked += async(s, e) =>
            {
                if (battlesequence)
                {
                    battlesequence = false;
                    await Task.Run(async() =>
                    {
                        Animations.CloseStackLayout(layout, "closing", 30, 500);
                    });

                    Items.Children.Remove(frame);
                    pots.Remove(item); // Remove off list
                    string invetory = "";
                    foreach (ItemModel itemInv in pots)
                    {
                        if (!String.IsNullOrEmpty(itemInv.item))
                        {
                            invetory += itemInv.item + ","; // Create string for file
                        }
                    }
                    UserModel.Rewrite("Items:", invetory, dungeon.items.Localfile);

                    try
                    {
                        dungeon.items.Invfile.Object.Items = invetory;
                        await dungeon.items.UpdateInv();
                    }
                    catch { }

                    dungeon.itemInv.pots = this.pots;

                    await ItemAbility.FadeTo(0, 200);

                    DisableorEnableFrameLayouts(false, ItemAbility);

                    if (item.item.Contains("HealthPotion"))
                    {
                        int buff = Obtainbuff(item.item);
                        CharacterHP += buff;
                        await Announcer(string.Format("Healed for {0}", buff.ToString()), true);

                        CharacterHealth.Text = CharacterHP.ToString();
                        CharacterHealth.RelRotateTo(360, 500);
                        await CharacterHealth.ScaleTo(5, 300);

                        await CharacterHealth.ScaleTo(1, 300);
                    }
                    else if (item.item.Contains("MagicPotion"))
                    {
                        int buff = Obtainbuff(item.item);
                        CharacterMP += buff;
                        await Announcer(string.Format("Restored {0} Mana", buff.ToString()), true);

                        CharacterMana.Text = CharacterMP.ToString();
                        CharacterMana.RelRotateTo(360, 500);
                        await CharacterMana.ScaleTo(5, 300);

                        await CharacterMana.ScaleTo(1, 300);
                    }

                    await Announcer("BOSS TURN", false);

                    BossAttack();
                }
            };

            layout.Children.Add(Name);
            layout.Children.Add(extras);
            layout.Children.Add(button);

            frame.Content = layout;
            Items.Children.Add(frame);
        }
 // Use this for initialization
 void Start()
 {
     player     = GameObject.Find("Neko");
     chr_health = player.GetComponent <CharacterHealth>();
 }
Esempio n. 17
0
 private void Awake()
 {
     Health          = new CharacterHealth(maxHealth);
     Health.OnDeath += Health_OnDeath;
 }
 void Awake()
 {
     characterHealth = FindObjectOfType <CharacterHealth>();
 }
Esempio n. 19
0
 // Use this for initialization
 public void Start()
 {
     theCharacterHealth = GetComponent <CharacterHealth> ();
     player             = GameObject.FindGameObjectWithTag("Player");
 }
Esempio n. 20
0
 private void Start()
 {
     characterHealth = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterHealth>();
     tip0.SetActive(false);
     tip1.SetActive(false);
 }
Esempio n. 21
0
 void Awake()
 {
     charHealth = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterHealth>();
 }
Esempio n. 22
0
 // Use this for initialization
 void Start()
 {
     characterHealth = GetComponent <CharacterHealth>();
 }
Esempio n. 23
0
 /// <summary>
 /// Get attackValue ready for combat for specific character.
 /// </summary>
 /// <param name="manager"></param>
 public void Initialize(CombatManager manager)
 {
     this.manager = manager;
     myHealth = manager.GetComponent<CharacterHealth>();
 }
Esempio n. 24
0
 // Use this for initialization
 void Start()
 {
     theCharacterHealth = GameObject.Find ("Player").GetComponent<CharacterHealth> ();
     theSpriteRenderer = GetComponent<Image> ();
     theSpriteRenderer.sprite = heartFull;
 }
Esempio n. 25
0
 void Start()
 {
     theCharacterHealth = GetComponentInParent<CharacterHealth> ();
 }
 void Start()
 {
     controller    = new CharacterHealth(enemyHealth);
     enemyAnimator = GetComponent <Animator>();
 }
Esempio n. 27
0
 private void Awake()
 {
     health  = new CharacterHealth(maxHealth);
     glowMat = renderer.materials[1];
     glowMat.SetColor("Emission", onColor);
 }
 private void Awake()
 {
     rigidBody = GetComponent <Rigidbody2D>();
     anim      = GetComponent <Animator>();
     ch        = GetComponent <CharacterHealth>();
 }
 // Use this for initialization
 void Start()
 {
     CHH = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterHealth>();
     zh  = GetComponent <zombieHealth>();
 }
Esempio n. 30
0
        public void DamageTest()
        {
            CharacterHealth health = FixtureCreateHealth("testchar");

            AttachEvents(health);

            health.startingHealth = 2;
            health.maxHealth      = 2;

            health.Start();
            Assert.That(health.lives, Is.EqualTo(1));
            Assert.That(health.health, Is.EqualTo(2));
            Assert.That(health.IsInvulnerable(), Is.EqualTo(false));

            Assert.That(onHealCalled, Is.EqualTo(true));
            Assert.That(onDamageCalled, Is.EqualTo(false));
            Assert.That(onImmunityCalled, Is.EqualTo(false));
            Assert.That(onMaxHealthCalled, Is.EqualTo(true));
            Assert.That(onInjuredCalled, Is.EqualTo(false));
            Assert.That(onHurtCalled, Is.EqualTo(false));
            Assert.That(onDeathCalled, Is.EqualTo(false));
            Assert.That(onGameOverCalled, Is.EqualTo(false));
            Assert.That(onInvulnerabilityStartCalled, Is.EqualTo(false));
            Assert.That(onRespawnCalled, Is.EqualTo(false));

            ResetCallbacks();

            health.Damage(1, null);

            Assert.That(onHealCalled, Is.EqualTo(false));
            Assert.That(onDamageCalled, Is.EqualTo(true));
            Assert.That(onImmunityCalled, Is.EqualTo(false));
            Assert.That(onMaxHealthCalled, Is.EqualTo(false));
            Assert.That(onInjuredCalled, Is.EqualTo(true));
            Assert.That(onHurtCalled, Is.EqualTo(false));
            Assert.That(onDeathCalled, Is.EqualTo(false));
            Assert.That(onGameOverCalled, Is.EqualTo(false));
            Assert.That(onInvulnerabilityStartCalled, Is.EqualTo(true));
            Assert.That(onRespawnCalled, Is.EqualTo(false));

            // after recieve damage time to be invulnerable
            Assert.That(health.IsInvulnerable(), Is.EqualTo(true));

            ResetCallbacks();

            // TEST add time, wait until invulnerability ends
            umgr.forceFixedDeltaTime = 0.25f;
            umgr.FixedUpdate();
            Assert.That(health.IsInvulnerable(), Is.EqualTo(true));

            umgr.forceFixedDeltaTime = 2.0f;
            umgr.FixedUpdate();
            Assert.That(health.IsInvulnerable(), Is.EqualTo(false));
            Assert.That(onInvulnerabilityEndCalled, Is.EqualTo(true));

            ResetCallbacks();

            health.immunity = DamageType.Water;

            // TEST invulnerable to recieved damage
            var obj3       = new GameObject();
            var damage     = obj3.AddComponent <Damage>();
            var character2 = obj3.AddComponent <Character>();

            Assert.NotNull(damage);
            damage.type             = DamageType.Water;
            damage.causer           = character2.GetComponent <CharacterHealth>();
            damage.causer.alignment = Alignment.Enemy;

            health.Damage(damage);
            Assert.That(onHealCalled, Is.EqualTo(false));
            Assert.That(onDamageCalled, Is.EqualTo(true));
            Assert.That(onImmunityCalled, Is.EqualTo(true));
            Assert.That(onMaxHealthCalled, Is.EqualTo(false));
            Assert.That(onInjuredCalled, Is.EqualTo(false));
            Assert.That(onHurtCalled, Is.EqualTo(false));
            Assert.That(onDeathCalled, Is.EqualTo(false));
            Assert.That(onGameOverCalled, Is.EqualTo(false));
            Assert.That(onInvulnerabilityStartCalled, Is.EqualTo(false));
            Assert.That(onRespawnCalled, Is.EqualTo(false));

            ResetCallbacks();
            /// damage again, kill character

            health.Damage(1, null);
            Assert.That(onHealCalled, Is.EqualTo(false));
            Assert.That(onDamageCalled, Is.EqualTo(true));
            Assert.That(onImmunityCalled, Is.EqualTo(false));
            Assert.That(onMaxHealthCalled, Is.EqualTo(false));
            Assert.That(onInjuredCalled, Is.EqualTo(true));
            Assert.That(onHurtCalled, Is.EqualTo(false));
            Assert.That(onDeathCalled, Is.EqualTo(true));
            Assert.That(onGameOverCalled, Is.EqualTo(true));
            Assert.That(onInvulnerabilityStartCalled, Is.EqualTo(false));
            Assert.That(onRespawnCalled, Is.EqualTo(false));
        }
Esempio n. 31
0
 void Start()
 {
     jump_delay = Random.value;
     toast = gameObject.GetComponent<Rigidbody2D>();
     animator = gameObject.GetComponent<Animator>();
     collide = gameObject.GetComponent<PolygonCollider2D>();
     characterUI = character.GetComponent<CharacterHealth>();
 }
 public override void OnDeath(CharacterHealth health)
 {
     GameObject.FindGameObjectWithTag("WaveManager").GetComponent<WaveManager> ().EnemyDeath ();
     Destroy (gameObject);
 }
Esempio n. 33
0
 void Awake()
 {
     CharHealth  = this.CharacterHealth;
     WeapControl = this.WeaponControl;
 }
 /// <summary>
 /// Create a NonPlayableCharacter with the specified health, ammo, and weapon objects, plus the given name
 /// </summary>
 /// <param name="health">CharacterStatusElement for health</param>
 /// <param name="ammo">CharacterStatusElement for ammo</param>
 /// <param name="weapon">CharacterStatusElement for the current weapon</param>
 /// <param name="name">The character's name</param>
 /// <param name="detector">Collision detector with which the object should register.</param>
 public NonPlayableCharacterAbstract(CharacterHealth health, CharacterAmmo ammo, CharacterWeapon weapon, string name, CollisionDetectorInterface detector)
     : base(health, ammo, weapon, name, detector)
 {
 }
 public abstract void OnDeath(CharacterHealth health);
 /// <summary>
 /// Create a NonPlayableCharacter with the specified health, ammo, and weapon objects, plus the given name.
 /// Also, specify the AnimationSet, frameLengthModifier, velocity, position, direction,
 /// and depth of the character.
 /// </summary>
 /// <param name="pipeline">List of objects from which the object should be drawn.</param>
 /// <param name="health">CharacterStatusElement for health</param>
 /// <param name="ammo">CharacterStatusElement for ammo</param>
 /// <param name="weapon">CharacterStatusElement for the current weapon</param>
 /// <param name="name">The character's name</param>
 /// <param name="detector">Collision detector with which this object should register.</param>
 /// <param name="animations">AnimationSet containing all animations for this object</param>
 /// <param name="frameLengthModifier">Float representing the ratio of frames in an animation to movement along the screen</param>
 /// <param name="velocity">Vector of velocity, representing both direction of movement and magnitude</param>
 /// <param name="position">Position of object relative to the top left corner</param>
 /// <param name="direction">Vector representing the direction of the object</param>
 /// <param name="depth">Depth the object is to be drawn to</param>
 public NonPlayableCharacterAbstract(List<DrawableObjectAbstract> pipeline, CharacterHealth health, CharacterAmmo ammo, CharacterWeapon weapon, string name, CollisionDetectorInterface detector, AnimationSet animations, float frameLengthModifier, Vector2 velocity, Vector2 position, Vector2 direction, float depth)
     : base(pipeline, health, ammo, weapon, name, detector, animations, frameLengthModifier, velocity, position, direction, depth)
 {
 }
Esempio n. 37
0
 public void AddCharacter(CharacterHealth characterHealth)
 {
     _characters.Add(characterHealth);
 }
Esempio n. 38
0
    // Use this for initialization
    void Start()
    {
        theCharacterHealth = GetComponent<CharacterHealth> ();

        shotStartPos = transform.FindChild ("ShotStartPos").gameObject.GetComponent<Transform> ();

        groundCheckObj = transform.FindChild ("GroundCheck").gameObject;
        groundCheck = groundCheckObj.GetComponent<Collider2D> ();

        playerRigidbody = GetComponent<Rigidbody2D> ();
        //		playerCollider = GetComponent<Collider2D> ();

        jumpTimeCounter = jumpTime;

        hoverSlider = FindObjectOfType<Slider> ();

        hoverSlider.maxValue = jumpTime;
    }
Esempio n. 39
0
    void UpdateGunAimingAndShooting(Spine.Bone gunBone)
    {
        const float LowerRotationBound = -90.0f;
        const float UpperRotationBound = 90.0f;

        // temp variables
        float   tempRot;
        Vector3 tempVec;

        // gun bone rotation
        tempVec = Camera.main.WorldToScreenPoint(new Vector3(gunBone.WorldX + player.transform.position.x, gunBone.WorldY + (player.transform.position.y), 0));
        tempVec = Input.mousePosition - tempVec;
        Vector3 direction = tempVec;

        // if (shotReady)
        //{
        direction.Normalize();
        tempRot          = Mathf.Atan2(tempVec.y, tempVec.x * player.transform.localScale.x) * Mathf.Rad2Deg;
        gunBone.Rotation = Mathf.Clamp(tempRot, LowerRotationBound, UpperRotationBound) - gunBone.parent.LocalToWorldRotation(gunBone.parent.rotation);
        //}

        Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        mousePos.z = gunTarget.transform.position.z;
        gunTarget.transform.position = mousePos;

        if (mousePos.x >= player.transform.position.x)
        {
            playerAnim.aimDirection = 1.0f;
        }
        else
        {
            playerAnim.aimDirection = -1.0f;
        }

        if (shotReady && !playedCockedSfx && Input.GetMouseButton(0))
        {
            playedCockedSfx = true;
            shotgunCockSource.Stop();
            shotgunCockSource.pitch = CharacterMovement.GetRandomPitch(0.2f) * TimeManager.GetInstance().GetCurrentTimescale();
            shotgunCockSource.Play();
        }

        if (Input.GetMouseButtonUp(0) && shotReady)
        {
            lastTimeFired   = 0.0f;
            shotReady       = false;
            playedCockedSfx = false;
            playedReload    = false;

            // shotgun sfx
            {
                shotgunSource.Stop();
                shotgunSource.pitch = CharacterMovement.GetRandomPitch(0.2f) * TimeManager.GetInstance().GetCurrentTimescale();
                shotgunSource.Play();
            }

            var playerCollider = player.GetComponent <CapsuleCollider2D>();
            if (playerCollider)
            {
                playerCollider.enabled = false;
            }
            RaycastHit2D hit = Physics2D.Raycast(new Vector2(gunBone.WorldX + player.transform.position.x,
                                                             gunBone.WorldY + (player.transform.position.y)),
                                                 direction);

            bool personHit = false;
            if (hit.collider != null)
            {
                CharacterHealth characterHealth = hit.collider.gameObject.GetComponent <CharacterHealth>();

                if (characterHealth)
                {
                    personHit = true;

                    characterHealth.ChangeHealth(-100.0f);

                    var bloodBurst = characterHealth.bloodBurst;

                    if (bloodBurst)
                    {
                        bloodBurst.Stop();
                        bloodBurst.transform.position = new Vector3(hit.point.x, hit.point.y, bloodBurst.transform.position.z);
                        bloodBurst.Play();
                    }

                    bloodSplashSource.Stop();
                    bloodSplashSource.pitch = CharacterMovement.GetRandomPitch(0.2f) * TimeManager.GetInstance().GetCurrentTimescale();
                    bloodSplashSource.PlayDelayed(0.05f);
                }
                else if (hit.collider.gameObject.tag == "Ground")
                {
                    groundSplash.Stop();
                    groundSplash.transform.position = new Vector3(hit.point.x, hit.point.y, groundSplash.transform.position.z);
                    groundSplash.Play();

                    ricochetAudioSource.Stop();
                    ricochetAudioSource.pitch = CharacterMovement.GetRandomPitch(0.2f) * TimeManager.GetInstance().GetCurrentTimescale();
                    ricochetAudioSource.Play();
                }
            }
            if (playerCollider)
            {
                playerCollider.enabled = true;
            }

            // camera shake
            cameraShake.originalPos = Camera.main.transform.localPosition;
            if (personHit)
            {
                cameraShake.shakeAmount   = 0.5f;
                cameraShake.shakeDuration = 0.12f;
            }
            else
            {
                cameraShake.shakeAmount   = 0.2f;
                cameraShake.shakeDuration = 0.1f;
            }
        }
    }
Esempio n. 40
0
 public override bool onApply(CharacterHealth health)
 {
     base.onApply(health);
     modify(stat, health.character.stats, -decreaseAmount);
     return(true);
 }
 public override void OnDeath(CharacterHealth health)
 {
     Destroy (gameObject);
 }
Esempio n. 42
0
 // Start is called before the first frame update
 void Awake()
 {
     characterHealth = player.GetComponent <CharacterHealth>();
     playerLevel     = player.GetComponent <PlayerLevel>();
 }
Esempio n. 43
0
 void Start()
 {
     healthScript = GetComponent<CharacterHealth> ();
     healthSlider = GameObject.Find ("HUDCanvas").transform.Find("StatsPanel").Find("PlayerHealthBar").GetComponent<Slider> ();
 }
Esempio n. 44
0
		void Awake ()
		{
				CharHealth = this.CharacterHealth;
				WeapControl = this.WeaponControl;
		}
Esempio n. 45
0
        public void AlignamentTest()
        {
            CharacterHealth health = FixtureCreateHealth("testchar");

            AttachEvents(health);
            ResetCallbacks();

            health.startingLives  = 2;
            health.maxLives       = 2;
            health.startingHealth = 2;
            health.maxHealth      = 2;
            health.alignment      = Alignment.Enemy;

            health.Start();

            CharacterHealth health2 = FixtureCreateHealth("testchar2");

            health2.startingLives  = 2;
            health2.maxLives       = 2;
            health2.startingHealth = 2;
            health2.maxHealth      = 2;
            health2.alignment      = Alignment.Enemy;
            Damage damage = health2.gameObject.AddComponent <Damage>();

            health2.Start();


            //------------------------------------------
            // DAMAGE NOT DEALT
            // cannot recieve damage from friends
            health.friendlyFire = false;
            ResetCallbacks();

            Assert.That(health.lives, Is.EqualTo(2));
            Assert.That(health.health, Is.EqualTo(2));

            health.Damage(damage);

            Assert.That(health.lives, Is.EqualTo(2));
            Assert.That(health.health, Is.EqualTo(2));

            Assert.That(onHealCalled, Is.EqualTo(false));
            Assert.That(onDamageCalled, Is.EqualTo(false));
            Assert.That(onImmunityCalled, Is.EqualTo(false));
            Assert.That(onMaxHealthCalled, Is.EqualTo(false));
            Assert.That(onInjuredCalled, Is.EqualTo(false));
            Assert.That(onHurtCalled, Is.EqualTo(false));
            Assert.That(onDeathCalled, Is.EqualTo(false));
            Assert.That(onGameOverCalled, Is.EqualTo(false));
            Assert.That(onInvulnerabilityStartCalled, Is.EqualTo(false));
            Assert.That(onRespawnCalled, Is.EqualTo(false));

            //------------------------------------------
            // DAMAGE NOT DEALT
            // can recieve damage but the damage is not meant for friends
            damage.friendlyFire = false;
            health.friendlyFire = true;

            health.Damage(damage);

            Assert.That(health.lives, Is.EqualTo(2));
            Assert.That(health.health, Is.EqualTo(2));

            Assert.That(onHealCalled, Is.EqualTo(false));
            Assert.That(onDamageCalled, Is.EqualTo(false));
            Assert.That(onImmunityCalled, Is.EqualTo(false));
            Assert.That(onMaxHealthCalled, Is.EqualTo(false));
            Assert.That(onInjuredCalled, Is.EqualTo(false));
            Assert.That(onHurtCalled, Is.EqualTo(false));
            Assert.That(onDeathCalled, Is.EqualTo(false));
            Assert.That(onGameOverCalled, Is.EqualTo(false));
            Assert.That(onInvulnerabilityStartCalled, Is.EqualTo(false));
            Assert.That(onRespawnCalled, Is.EqualTo(false));


            //------------------------------------------
            // DAMAGE DEALT
            // we can recieve damage from friends and damage is unfrienly!
            damage.friendlyFire = true;
            health.friendlyFire = true;

            Assert.That(health.lives, Is.EqualTo(2));
            Assert.That(health.health, Is.EqualTo(2));

            health.Damage(damage);

            Assert.That(health.lives, Is.EqualTo(2));
            Assert.That(health.health, Is.EqualTo(1));

            Assert.That(onHealCalled, Is.EqualTo(false));
            Assert.That(onDamageCalled, Is.EqualTo(true));
            Assert.That(onImmunityCalled, Is.EqualTo(false));
            Assert.That(onMaxHealthCalled, Is.EqualTo(false));
            Assert.That(onInjuredCalled, Is.EqualTo(true));
            Assert.That(onHurtCalled, Is.EqualTo(false));
            Assert.That(onDeathCalled, Is.EqualTo(false));
            Assert.That(onGameOverCalled, Is.EqualTo(false));
            Assert.That(onInvulnerabilityStartCalled, Is.EqualTo(true));
            Assert.That(onRespawnCalled, Is.EqualTo(false));
        }
Esempio n. 46
0
 // Use this for initialization
 public void Start()
 {
     theCharacterHealth = GetComponent<CharacterHealth> ();
 }
Esempio n. 47
0
 // Use this for initialization
 public void Start()
 {
     theCharacterHealth = GetComponent<CharacterHealth> ();
     player = GameObject.FindGameObjectWithTag ("Player");
 }
Esempio n. 48
0
 void Start()
 {
     player = gameObject.GetComponent<Rigidbody2D>();
     animator = gameObject.GetComponent<Animator>();
     characterHealth = GetComponent<CharacterHealth>();
 }
Esempio n. 49
0
 protected virtual void Awake()
 {
     // get references
     myMotor = GetComponent<CharacterMotor>();
     myTransform = transform;
     myGameObject = gameObject;
     myRigidbody = rigidbody;
     myHealth = GetComponent<CharacterHealth>();
     myMaterial = myTransform.FindChild("Body").renderer.materials[0];
 }
 public static bool isAlive(CharacterHealth character) {
     return character.Alive();
 }
Esempio n. 51
0
 public void Setup(CharacterHealth newTarget)
 {
     target = newTarget;
     frontImg.GetComponent <Image>().sprite = target.fillImage;
 }
 public static void setHealth(CharacterHealth character, float health) {
     character.health = health;
 }
Esempio n. 53
0
 void Awake()
 {
     characterHealth = GetComponent <CharacterHealth>();
     system          = GetComponent <ParticleSystem>();
 }
Esempio n. 54
0
        public TestCharacter(string name)
        {
            charObj      = new GameObject();
            charObj.name = name;
            character    = charObj.AddComponent <Character>();
            Assert.NotNull(character);
            health = charObj.GetComponent <CharacterHealth>();
            Assert.NotNull(health);
            health.Start();

            GameObject enterGO = charObj.CreateChild("enterAreas");

            enterGO.AddComponent <BoxCollider2D>();
            enterHitBox = enterGO.AddComponent <HitBox>();
            enterHitBox.Reset();
            enterHitBox.type             = HitBoxType.EnterAreas;
            enterHitBox.gameObject.layer = 1;

            enterBox2D        = enterHitBox.gameObject.AddComponent <BoxCollider2D>();
            enterBox2D.size   = new Vector2(1, 1);
            enterHitBox.owner = health;
            enterHitBox.Start();

            GameObject dealGO = charObj.CreateChild("dealHitBox");

            dealGO.AddComponent <BoxCollider2D>();
            dealHitBox = dealGO.AddComponent <HitBox>();
            Assert.NotNull(dealHitBox);

            dealHitBox.type             = HitBoxType.DealDamage;
            dealHitBox.useGlobalMask    = false;
            dealHitBox.collisionMask    = (1 << 2); // | (1 << ?)
            dealHitBox.gameObject.layer = 2;
            damage        = dealHitBox.gameObject.AddComponent <Damage>();
            damage.causer = health;
            damage.Start();
            dealHitBox.owner = health;

            dealBox2D      = dealHitBox.gameObject.AddComponent <BoxCollider2D>();
            dealBox2D.size = new Vector2(1, 1);
            dealHitBox.Start();

            GameObject recieveGO = charObj.CreateChild("recieveHitBox");

            recieveGO.AddComponent <BoxCollider2D>();
            recieveHitBox = recieveGO.AddComponent <HitBox>();
            Assert.NotNull(recieveHitBox);

            recieveHitBox.type             = HitBoxType.RecieveDamage;
            recieveHitBox.useGlobalMask    = false;
            recieveHitBox.collisionMask    = (1 << 2);
            recieveHitBox.gameObject.layer = 2;
            recieveHitBox.owner            = health;

            recieveBox2D      = recieveHitBox.gameObject.AddComponent <BoxCollider2D>();
            recieveBox2D.size = new Vector2(1, 1);
            recieveHitBox.Start();

            // init health callbacks
            health.onHeal                 += () => { onHealCalled = true; };
            health.onDamage               += () => { onDamageCalled = true; };
            health.onImmunity             += () => { onImmunityCalled = true; };
            health.onMaxHealth            += () => { onMaxHealthCalled = true; };
            health.onInjured              += (Damage dt, CharacterHealth to) => { onInjuredCalled = true; };
            health.onHurt                 += (Damage dt, CharacterHealth to) => { onHurtCalled = true; };
            health.onDeath                += () => { onDeathCalled = true; };
            health.onGameOver             += () => { onGameOverCalled = true; };
            health.onInvulnerabilityStart += () => { onInvulnerabilityStartCalled = true; };
            health.onInvulnerabilityEnd   += () => { onInvulnerabilityEndCalled = true; };
            health.onRespawn              += () => { onRespawnCalled = true; };
        }
Esempio n. 55
0
 private void Awake()
 {
     characterHealth = GetComponent <CharacterHealth>();
 }
Esempio n. 56
0
    // Controls Attack functions of Motion Sensor Enemy
    private void Attack()
    {
        CharacterHealth targetHealth = target.GetComponent <CharacterHealth>();

        targetHealth.healthSlider.value--;
    }
 public static float getHealth(CharacterHealth character) {
     return character.health;
 }
Esempio n. 58
0
 // Use this for initialization
 void Start()
 {
     target       = gameObject.GetComponentInParent <CharacterHealth>();
     cam          = Camera.main.gameObject;
     initialScale = transform.localScale;
 }
Esempio n. 59
0
 /// <summary>
 /// Unity OnEnable hook.
 /// </summary>
 void Start()
 {
     // Try looking for character health in self then parents
     if (health == null) health = gameObject.GetComponentInParent<CharacterHealth>();
     if (health == null) Debug.LogError ("Unable to find CharacterHealth for CharacterHurtBox");
 }
Esempio n. 60
0
 private void Awake()
 {
     characterHealth = GetComponent <CharacterHealth>();
     mainCamera      = Camera.main;
 }