Inheritance: MonoBehaviour
Example #1
0
 void Start()
 {
     animator      = GetComponent <Animator>();
     combo         = 0;
     comboCut      = motionTime * 2;
     count         = 0.0f;
     isCrossAttack = false;
     isAttackCombo = false;
     isLongAttack  = false;
     pDamage       = GetComponent <PlayerDamage>();
 }
Example #2
0
    void Start()
    {
        _pAbilities = transform.GetComponent <PlayerAbilities>();
        _pMovement  = transform.GetComponent <PlayerMovement>();
        _pDamage    = transform.GetComponent <PlayerDamage>();
        _pRigidbody = transform.GetComponent <Rigidbody2D>();
        _pCollider  = transform.GetComponent <CircleCollider2D>();

        GameManager.instance.OnPauseGame  += Lock;
        GameManager.instance.OnResumeGame += Unlock;
    }
Example #3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        PlayerDamage playerDamage = other.GetComponent <PlayerDamage>();

        if (playerDamage != null)
        {
            playerDamage.Hit(damage);
        }

        Destroy(gameObject);
    }
Example #4
0
    void Start()
    {
        controller = GetComponent <CharacterController>();
        animator   = GetComponent <Animator>();
        pDamage    = GetComponent <PlayerDamage>();

        moveDir  = Vector3.zero;
        isWalk   = false;
        isRun    = false;
        isGround = false;
    }
Example #5
0
 private void Awake()
 {
     // Singleton
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Example #6
0
    void Awake()
    {
        pd = gameObject.GetComponent <PlayerDamage>();
        if (!positionDisplay)
        {
            positionDisplay = transform;
        }

        hpStyle.font             = guiSKin.font;
        hpStyle.fontSize         = guiSKin.GetStyle("Label").fontSize;
        hpStyle.normal.textColor = Color.white;
        hpStyle.alignment        = TextAnchor.MiddleCenter;
    }
Example #7
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        PlayerDamage player = collision.GetComponent <PlayerDamage>();

        if (player != null)
        {
            if (player.healt < 5)
            {
                player.AddHealth(addLife);
                Destroy(gameObject);
            }
        }
    }
        public override void Gain(GameObject player)
        {
            if (!hasBeenPickedUp)
            {
                base.Gain(player);
                PlayerDamage damageScript = player.GetComponent <PlayerDamage>();
                damageScript.livesRemaining += gain;

                damageScript.livesText.SetText("x " + damageScript.livesRemaining.ToString());

                PlayerPrefs.SetInt("PlayerCurrentLives", damageScript.livesRemaining);
            }
        }
Example #9
0
 void Start()
 {
     Time.timeScale = 1;
     panel.SetActive(false);
     playerDamage = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerDamage>();
     panelText    = panel.GetComponentInChildren <Text>();
     foreach (GameObject go in GameObject.FindObjectsOfType(typeof(GameObject)))
     {
         if (go.name.Contains("Spawner"))
         {
             spawner.Add(new Spawners(go, true));
         }
     }
 }
Example #10
0
        /// <summary>
        /// Saves the XML document.
        /// </summary>
        public static void SaveXml()
        {
            using (XmlWriter writer = XmlWriter.Create(Paths.CreateOSPath("settings.xml"), XmlWriterSettings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Options");

                writer.WriteStartElement("General");

                writer.WriteElementString("AutoSave", AutoSave.ToString());
                writer.WriteElementString("AutoSaveSpeed", AutoSaveSpeed.ToString());
                writer.WriteElementString("AutoScroll", AutoScroll.ToString());
                writer.WriteElementString("Music", Music.ToString());
                writer.WriteElementString("NpcBar", NpcBar.ToString());
                writer.WriteElementString("NpcDamage", NpcDamage.ToString());
                writer.WriteElementString("NpcName", NpcName.ToString());
                writer.WriteElementString("PlayerBar", PlayerBar.ToString());
                writer.WriteElementString("PlayerDamage", PlayerDamage.ToString());
                writer.WriteElementString("PlayerName", PlayerName.ToString());
                writer.WriteElementString("SavedAccount", SavedAccount);
                writer.WriteElementString("SavedPassword", SavedPassword);
                writer.WriteElementString("Sound", Sound.ToString());
                writer.WriteElementString("SpeechBubbles", SpeechBubbles.ToString());
                writer.WriteElementString("Timestamps", Timestamps.ToString());
                writer.WriteElementString("ActiveSkin", ActiveSkin);
                writer.WriteElementString("LastClientUpdateTime", LastClientUpdateTime.ToBinary().ToString());
                writer.WriteElementString("LastGFXUpdateTime", LastGFXUpdateTime.ToBinary().ToString());

                writer.WriteEndElement();
                writer.WriteStartElement("ConnectionInfo");

                writer.WriteElementString("Port", ConnectionPort.ToString());
                writer.WriteElementString("Server", ConnectionIP);
                writer.WriteElementString("UpdateLink", UpdateAddress);
                writer.WriteElementString("SFXLink", SoundAddress);
                writer.WriteElementString("MusicLink", MusicAddress);

                writer.WriteEndElement();
                writer.WriteStartElement("Editor");

                writer.WriteElementString("MapGrid", MapGrid.ToString());
                writer.WriteElementString("DisplayAttributes", DisplayAttributes.ToString());
                writer.WriteElementString("DragAndPlace", DragAndPlace.ToString());

                writer.WriteEndElement();

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
        }
Example #11
0
    void OnTriggerEnter2D(Collider2D col)
    {
        Damageable dmgObj = null;

        if ((dmgObj = col.GetComponent <Damageable>()) != null)
        {
            PlayerDamage player = null;
            if ((player = (dmgObj as PlayerDamage)) != null)
            {
                player.SetKnockback(new Vector2(player.transform.position.x - transform.position.x, 1f));
            }
            dmgObj.Hurt(damage);
        }
    }
Example #12
0
        public void OnPlayerDeath(DiedEventArgs ev)
        {
            if (ev.Target.Role != RoleType.Spectator)
            {
                PlayerDamage data = new PlayerDamage
                {
                    eventName = "PlayerDeath",
                    victim    = PlyToUser(ev.Target),
                    attacker  = PlyToUser(ev.Killer),
                    damage    = (int)ev.HitInformations.Amount,
                    weapon    = ev.HitInformations.GetDamageName().ToString()
                };

                DamageTypes.DamageType type = ev.HitInformations.GetDamageType();
                if (type == DamageTypes.Tesla)
                {
                    data.eventName += "Tesla";
                }
                else if (type == DamageTypes.Decont)
                {
                    data.eventName += "Decont";
                }
                else if (type == DamageTypes.Falldown)
                {
                    data.eventName += "Fall";
                }
                else if (type == DamageTypes.Flying)
                {
                    data.eventName += "Flying";
                }
                else if (type == DamageTypes.Lure)
                {
                    data.eventName += "Lure";
                }
                else if (type == DamageTypes.Nuke)
                {
                    data.eventName += "Nuke";
                }
                else if (type == DamageTypes.Pocket)
                {
                    data.eventName += "Pocket";
                }
                else if (type == DamageTypes.Recontainment)
                {
                    data.eventName += "Recont";
                }

                tcp.SendData(data);
            }
        }
Example #13
0
    void Awake()
    {
        player    = GameObject.FindGameObjectWithTag("Player").transform;
        BarLength = Screen.width / 8;
        orcChase  = GetComponent <OrcChase>();
        orc       = GameObject.FindGameObjectWithTag("Orc");

        GUI.enabled = false;

        rigi         = GetComponent <Rigidbody>();
        animis       = GetComponent <Animator>();
        agent        = GetComponent <NavMeshAgent>();
        playerDamage = GetComponent <PlayerDamage>();
    }
Example #14
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        PlayerDamage player = other.GetComponent <PlayerDamage>();

        if (player != null)
        {
            player.TakeDamage(damage);
            DestroyProjectile();
        }
        else
        {
            DestroyProjectile();
        }
    }
Example #15
0
 private void MiniGameFailed(object sender, OnFailedEvent onFailedEvent)
 {
     if (playerDamage == null)
     {
         playerDamage = player.gameObject.GetComponent <PlayerDamage>();
     }
     if (playerDamage != null)
     {
         playerDamage.TakeDamage(onFailedEvent.damage);
     }
     else
     {
         Debug.LogError("Your player needs a player damage component");
     }
 }
Example #16
0
    public void Damage(Collision2D other)
    {
        PlayerDamage playerDamage = other.gameObject.GetComponent <PlayerDamage>();

        if (playerDamage != null && playerDamage.enabled == true)
        {
            if (killsInstantly)
            {
                playerDamage.PlayerDead();
            }
            else
            {
                playerDamage.ReceiveDamage();
            }
        }
    }
Example #17
0
 public override void TakeDamage(IList<PlayerDamage> damages)
 {
     //TODO: Rules clarification: Heroic action turns 9 into 10?
     var interceptorDamages = damages.SingleOrDefault(damage => damage.PlayerDamageType == PlayerDamageType.InterceptorsSingle);
     if (interceptorDamages != null)
     {
         var strongerInterceptorDamages = new PlayerDamage(
             9,
             PlayerDamageType.InterceptorsSingle,
             interceptorDamages.Range,
             interceptorDamages.ZoneLocations);
         damages.Remove(interceptorDamages);
         damages.Add(strongerInterceptorDamages);
         sittingDuck.KnockOutPlayers(new [] {StationLocation.Interceptor});
     }
     base.TakeDamage(damages);
 }
Example #18
0
        public override void Gain(GameObject player)
        {
            if (!hasBeenPickedUp)
            {
                base.Gain(player);
                hasBeenPickedUp = true;

                PlayerDamage damageScript = player.GetComponent <PlayerDamage>();

                if (damageScript.healthRemaining < damageScript.maxHealth)
                {
                    damageScript.healthRemaining += healthGain;
                }

                damageScript.healthBar.fillAmount = (float)damageScript.healthRemaining / (float)damageScript.maxHealth;
            }
        }
Example #19
0
        public override void TakeDamage(IList <PlayerDamage> damages)
        {
            var modifiedDamages    = damages.ToList();
            var interceptorDamages = modifiedDamages.SingleOrDefault(damage => damage.PlayerDamageType == PlayerDamageType.InterceptorsSingle);

            if (interceptorDamages != null)
            {
                var strongerInterceptorDamages = new PlayerDamage(interceptorDamages)
                {
                    Amount = interceptorDamages.Amount + 6
                };
                interceptorDamages.PerformingPlayer.KnockOutFromOwnAction();
                modifiedDamages.Remove(interceptorDamages);
                modifiedDamages.Add(strongerInterceptorDamages);
            }
            base.TakeDamage(modifiedDamages);
        }
Example #20
0
        public override void TakeDamage(IList <PlayerDamage> damages)
        {
            //TODO: Rules clarification: Heroic action turns 9 into 10?
            var interceptorDamages = damages.SingleOrDefault(damage => damage.PlayerDamageType == PlayerDamageType.InterceptorsSingle);

            if (interceptorDamages != null)
            {
                var strongerInterceptorDamages = new PlayerDamage(
                    9,
                    PlayerDamageType.InterceptorsSingle,
                    interceptorDamages.Range,
                    interceptorDamages.ZoneLocations);
                damages.Remove(interceptorDamages);
                damages.Add(strongerInterceptorDamages);
                sittingDuck.KnockOutPlayers(new [] { StationLocation.Interceptor });
            }
            base.TakeDamage(damages);
        }
Example #21
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         PlatformerCharacter2D characterScript = other.GetComponent <PlatformerCharacter2D>();
         PlayerDamage          damageScript    = other.GetComponent <PlayerDamage>();
         GameObject            player          = other.gameObject;
         Rigidbody2D           rb = other.GetComponent <Rigidbody2D>();
         if (rb.gravityScale != characterScript.startGravity)
         {
             rb.gravityScale = characterScript.startGravity;
             rb.velocity     = Vector2.zero;
             player.transform.Rotate(0f, 180f, 180f, Space.World);
             characterScript.m_JumpForce *= -1;
         }
         damageScript.TakeDamage(damage);
         characterScript.transform.position = characterScript.startPosition;
     }
 }
Example #22
0
 private void Awake()
 {
     canMove             = true;
     canShoot            = true;
     canSwitchWeapon     = true;
     skeletonAnimation   = GetComponent <SkeletonAnimation>();
     playerAmination     = GetComponent <PlayerAmination>();
     playerFsm           = GetComponent <PlayerFSM>();
     armsFsm             = GetComponent <ArmsFSM>();
     EventCenterInstance = GetComponent <EventCenter>();
     playerDamage        = GetComponent <PlayerDamage>();
     _inputMgr           = GetComponent <InputMgr>();
     playerDamage.PlayerPropertyInstance                         = this;
     playerAmination.PlayerPropertyInstance                      = this;
     GetComponent <PlayerAim>().PlayerPropertyInstance           = this;
     GetComponent <PlayerMove>().PlayerPropertyInstance          = this;
     GetComponent <PlayerShoot>().PlayerPropertyInstance         = this;
     GetComponent <PlayerSwitchWeapons>().PlayerPropertyInstance = this;
     GetComponent <SpineboyBodyTilt>().PlayerPropertyInstance    = this;
     GetComponent <PlayerCamera>().PlayerPropertyInstance        = this;
     arms    = ItemEnum.ItemType.missile;
     healthy = 100;
 }
Example #23
0
    void Damage(Transform player)
    {
        if (player.gameObject.name.Equals(objectToIgnore))
        {
            Debug.Log("same object");
            return;
        }
        if (score != null)
        {
            score.AddToScore(15);
        }
        PlayerDamage pd = player.GetComponent <PlayerDamage>();

        if (pd == null)
        {
            return;
        }
        pd.TakeDamage(damage, toScore);
        if (pd.health <= 0)
        {
            HitTarget();
        }
    }
    public static void updateScore(PlayerDamage scoringPlayer)
    {
        foreach (NetworkConnection client in NetworkServer.connections)
        {
            foreach (PlayerController player in client.playerControllers)
            {
                GameObject obj = player.gameObject;
                if (obj.GetComponent <PlayerDamage>() == scoringPlayer)
                {
                    switch (NetworkServer.connections.IndexOf(client))
                    {
                    case 0:
                        p1++;
                        break;

                    case 1:
                        p2++;
                        break;

                    case 2:
                        p3++;
                        break;

                    case 3:
                        p4++;
                        break;
                    }

                    /*print("p1: " + p1);
                    *  print("p2: " + p2);
                    *  print("p3: " + p3);
                    *  print("p4: " + p4);*/
                }
            }
        }
    }
    // Handle Controller Input for every (configured) button
    public void GetInput()
    {
        forwardInput = Input.GetAxis(inputSetting.FORWARD_AXIS);
        animator.SetBool("Run", !Mathf.Approximately(0, Input.GetAxisRaw(inputSetting.FORWARD_AXIS)));

        turnInput = Input.GetAxis(inputSetting.TURN_AXIS);
        dashInput = Input.GetAxis("left Trigger");

        if (Input.GetButtonDown("Attack"))
        {
            animator.SetTrigger("Slash");

            if (!playingHitSound)
            {
                StartCoroutine(HitSound());
            }
        }

        if (Input.GetButtonDown("Cancel"))
        {
            PlayerDamage playerDamage = GetComponent <PlayerDamage>();
            playerDamage.TakeDamage(playerDamage.health);
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Enemy"))
        {
            if (isInvincible == false)
            {
                PlayerDamage.PlayOneShot(PlayerDamage.clip);
                LoseHealth();
                StartCoroutine(SetInvulnerability());
            }
        }
        if (other.CompareTag("Heart"))
        {
            if (health < hearts.Length)
            {
                PickupHeart.PlayOneShot(PickupHeart.clip);

                health++;
                hearts[health - 1].sprite = FullHeart;
                Destroy(other.gameObject);
            }
        }
        if (other.CompareTag("Coin"))
        {
            if (PlayerPrefs.GetInt("CoinFirstUpgradeBool") == 0)
            {
                Score.CoinStorage += 1 * 1;
            }
            if (PlayerPrefs.GetInt("CoinFirstUpgradeBool") == 1)
            {
                Score.CoinStorage += 1 * (PlayerPrefs.GetInt("CoinMultiplier"));
            }
            PickupCoin.PlayOneShot(PickupCoin.clip);
            Destroy(other.gameObject);
        }
    }
Example #27
0
 public override bool CanBeTargetedBy(PlayerDamage damage)
 {
     Check.ArgumentIsNotNull(damage, "damage");
     return(damage.PlayerDamageType != PlayerDamageType.Rocket && base.CanBeTargetedBy(damage));
 }
Example #28
0
 public override bool CanBeTargetedBy(PlayerDamage damage)
 {
     return(damage.PlayerDamageType != PlayerDamageType.Rocket && base.CanBeTargetedBy(damage));
 }
Example #29
0
 public override bool CanBeTargetedBy(PlayerDamage damage)
 {
     return(damage.AffectedDistances.Contains(DistanceToShip));
 }
Example #30
0
    void Start()
    {
        GameObject player = GameObject.FindWithTag("Player");

        playerDamage = player.GetComponent <PlayerDamage>();
    }
Example #31
0
 public override bool CanBeTargetedBy(PlayerDamage damage)
 {
     return damage.PlayerDamageType != PlayerDamageType.Rocket && base.CanBeTargetedBy(damage);
 }
 public override bool CanBeTargetedBy(PlayerDamage damage)
 {
     return damage.Range != 3 && base.CanBeTargetedBy(damage);
 }
 public virtual bool IsPriorityTargetFor(PlayerDamage damage)
 {
     return(false);
 }
 public override bool CanBeTargetedBy(PlayerDamage damage)
 {
     return !stealthed && base.CanBeTargetedBy(damage);
 }
Example #35
0
 protected void AddNPCDamage(NPC NPC, Player Player, int Damage, bool crit = false)
 {
     List<PlayerDamage> damagelist = null;
     PlayerDamage playerdamage = null;
     double dmg;
     lock (__dictionaryMutex)
     {
         if (DamageDictionary.ContainsKey(NPC))
         {
             damagelist = DamageDictionary[NPC];
         }
         else
         {
             damagelist = new List<PlayerDamage>(1);
             DamageDictionary.Add(NPC, damagelist);
         }
     }
     lock (__NPCDamageMutex)
     {
         if ((playerdamage = damagelist.FirstOrDefault(i => i.player == Player)) == null)
         {
             playerdamage = new PlayerDamage() { player = Player };
             damagelist.Add(playerdamage);
         }
         if ((dmg = (crit ? 2 : 1) * Main.CalculateDamage(Damage, NPC.ichor ? NPC.defense - 20 : NPC.defense)) > NPC.life)
         {
             dmg = NPC.life;
         }
         playerdamage.damage += dmg;
         if (playerdamage.damage > NPC.lifeMax)
         {
             playerdamage.damage -= playerdamage.damage % NPC.lifeMax;
         }
     }
 }
 public override bool CanBeTargetedBy(PlayerDamage damage)
 {
     return !phantomMode && base.CanBeTargetedBy(damage);
 }
 public virtual bool CanBeTargetedBy(PlayerDamage damage)
 {
     var isInRange = damage.Range >= DistanceToShip;
     var gunCanHitCurrentZone = damage.ZoneLocations.Contains(CurrentZone);
     return isInRange && gunCanHitCurrentZone;
 }