示例#1
0
    // Use this for initialization
    void Start()
    {
        //Because applySllow can happen before start, have initialTimeFactor variable (MUST BE A BETTER SOLUTION)
        if (initTimeFactor == 0)
        {
            initTimeFactor = 1;
        }

        curSpeed = SET_SPEED * initTimeFactor;

        if (GetComponentInParent <JumpArcherBehavior>().getTarget() == null)
        {
            throw new System.Exception("Error: Nothing to aim");
        }

        //Create direction
        Vector3 startingPos = GetComponentInParent <Transform>().position;
        Vector3 terminalPos = GetComponentInParent <JumpArcherBehavior>().getTarget().position;

        direction = SystemCalc.findDirection(startingPos, terminalPos);

        //Create Damage Package
        float damage = GetComponent <ProjectileStatus>().damage;

        dmgPackage = new DamagePackage(damage, direction * KNOCKBACK_VAL);

        //Time out variables
        curDistance = 0;

        //detach from parent while maintaining reference to source
        GetComponent <ProjectileStatus>().source = transform.root;
        transform.parent = null;
    }
示例#2
0
 public void SendDamageToItem()
 {
     while (ItemsOfInterest.Count > 0)
     {
         IItemOfInterest itemOfInterest = ItemsOfInterest.Dequeue();
         DamagePackage   packageCopy    = ObjectClone.Clone <DamagePackage>(ExplosionDamage);
         float           adjustedDamage = Mathf.Lerp(ExplosionDamage.DamageSent * ForceAtEdge, ExplosionDamage.DamageSent * ForceAtCenter, NormalizedRadius);
         packageCopy.DamageSent = adjustedDamage;
         packageCopy.ForceSent  = Mathf.Max(MinimumForce, packageCopy.ForceSent * NormalizedRadius);
         packageCopy.Point      = itemOfInterest.Position;
         packageCopy.Origin     = transform.position;
         packageCopy.Target     = itemOfInterest;
         //Debug.Log("Force: " + packageCopy.Force.ToString());
         DamageManager.Get.SendDamage(packageCopy);
         //characters and creatures are automatically stunned
         if (itemOfInterest.IOIType == ItemOfInterestType.WorldItem)
         {
             if (itemOfInterest.worlditem.Is <Creature>(out mCreatureCheck))
             {
                 mCreatureCheck.TryToStun(adjustedDamage);
             }
             else if (itemOfInterest.worlditem.Is <Character>(out mCharacterCheck))
             {
                 mCharacterCheck.TryToStun(adjustedDamage);
             }
         }
     }
 }
示例#3
0
    //Collision Enter checker: checks if collided with player
    void OnCollisionEnter(Collision collision)
    {
        Collider collider = collision.collider;

        //Checks if hit a player or another enemy
        if (collider.tag == "Player")
        {
            hitEnemy = true;

            //Set variables up to calculate knockback direction
            Vector3 victimPos = collider.bounds.center;
            Vector3 thisPos   = thisBody.position;

            //Create self-recoil package to self
            DamagePackage dmgPackage = new DamagePackage(0f);
            dmgPackage.setCentralizedKnockback(victimPos, thisPos, SELF_KNOCKBACK);
            getDamage(dmgPackage);      //Gives recoil

            //Create damage package to send to player
            dmgPackage.setCentralizedKnockback(thisPos, victimPos, KNOCKBACK);
            dmgPackage.setDamage(bodyDamage);

            //Send damagePackage
            collider.gameObject.SendMessage("getDamage", dmgPackage);
        }
    }
示例#4
0
 public virtual void ReceiveDamage(DamagePackage dmgPackage)
 {
     if (dmgPackage == null)
     {
         return;
     }
     if (OnDamage != null)
     {
         OnDamage(dmgPackage.sourceObject);
     }
     if (!dmgPackage.canDealFriendlyFire && dmgPackage.sourceTeam == GetTeam())
     {
         return;
     }
     foreach (var damage in dmgPackage.allDamage)
     {
         ProcessDamage(damage);
     }
     if (healthBarPrefab != null)
     {
         healthBarPrefab.SetFillAmount(hp / maxhp);
     }
     if (hp <= 0)
     {
         if (OnHPZero != null && !isInvincible)
         {
             OnHPZero(dmgPackage.sourceObject);
         }
         isInvincible = true;
     }
 }
    //Triggers shockwave damage to elements in affected
    //  Pre: targetTag must be either "Player" or "Enemy"
    private void triggerShockwave(Collider detonator)
    {
        //Creates new damage package to send
        DamagePackage dmgPackage = new DamagePackage(shockwaveDamage);

        //Establishes DSource
        Transform dSource = (detonator.tag == "EnemyAttack" && detonator.GetComponent <ProjectileStatus>().source != null) ? detonator.GetComponent <ProjectileStatus>().source : detonator.transform.root;

        //Sends knockback depending on each suspect and sends damagePackage if suspect is a target
        foreach (Collider suspect in effected)
        {
            if (suspect != null)                 //Checks if object hasn't been deleted
            //Reverses all time effects
            {
                if (suspect.tag == "Enemy" || suspect.tag == "EnemyAttack" || suspect.tag == "PausedProjectile")
                {
                    suspect.SendMessage("applySlow", 1 / SLOW_FACTOR);
                }

                //Applies damage to everyone in the field except the one who detonated it. Applies to players and enemies. Not attacks
                if (suspect.transform != dSource && (suspect.tag == "Player" || suspect.tag == "Enemy"))
                {
                    dmgPackage.setCentralizedKnockback(detonator.transform.position, suspect.transform.position, shockwaveKnockback);
                    suspect.SendMessage("getDamage", dmgPackage);
                }
            }
        }
    }
示例#6
0
 /// <summary>
 /// Heals the Player
 /// </summary>
 /// <param name="hp">DamagePackage.</param>
 public void HealUp(ref DamagePackage hp)
 {
     health += (int)Math.Floor(hp.damage);
     Debug.Log("Player recieved: " + hp.damage + " health");
     //Updates the healthbar
     CombatText._instance.PlayerTakesDamage((int)Math.Floor(hp.damage), hp.isCrit, true, hp.name, health);
 }
示例#7
0
    // Use this for initialization
    void Start()
    {
        if (GetComponentInParent <FlyShooterBehav>().getTarget() == null)
        {
            throw new System.Exception("Error: Nothing to aim");
        }

        //Create direction
        Vector3 startingPos = GetComponentInParent <Transform>().position;
        Vector3 terminalPos = GetComponentInParent <FlyShooterBehav>().getTarget().position;

        direction = SystemCalc.findDirection(startingPos, terminalPos);
        curSpeed  = SET_SPEED;

        //Create Damage Package
        float damage = GetComponent <ProjectileStatus>().damage;

        dmgPackage = new DamagePackage(damage, direction * KNOCKBACK_VAL);

        //Time out variables
        curDistance = 0;

        //detach from parent while maintaining reference to source
        GetComponent <ProjectileStatus>().source = transform.root;
        transform.parent = null;
    }
示例#8
0
    void OnTriggerEnter(Collider collider)
    {
        Rigidbody rig = Root.GetComponent <Rigidbody>();

        if (!rig)
        {
            return;
        }

        if (Root.Audiosource && ClashSound && rig.velocity.magnitude > VelocityThreshold)
        {
            Root.Audiosource.PlayOneShot(ClashSound);
        }

        DamagePackage dm = new DamagePackage();

        dm.Damage    = (byte)(ClashDamage * rig.velocity.magnitude);
        dm.Normal    = rig.velocity.normalized;
        dm.Direction = rig.velocity * 2;
        dm.Position  = this.transform.position;
        if (Root.Seats[0].passenger != null)
        {
            dm.ID = (int)Root.Seats[0].passenger.netId.Value;
        }
        else
        {
            dm.ID = -1;
        }
        dm.Team       = 3;
        dm.DamageType = 0;
        collider.gameObject.transform.root.SendMessage("DirectDamage", dm, SendMessageOptions.DontRequireReceiver);
    }
示例#9
0
 /// <summary>
 /// Effect attack on player
 /// </summary>
 /// <param name="dp">Dp.</param>
 public void EffectAttackPlayer(DamagePackage dp)
 {
     if (player.TakeDamage(ref dp))
     {
         Debug.Log("Player died!");
     }
 }
示例#10
0
    //Applies damage & knockback to enemy if attacked by player
    //  Pre: dmgPackage must be in dmgPackage format (Maybe turned into a class)
    public void getDamage(DamagePackage dmgPackage)
    {
        if (!invincibilityFrame.isRunning())
        {
            //Apply damagePackage to player
            health -= dmgPackage.getDamage();
            if (health < 0)
            {
                health = 0;
            }

            StartCoroutine(applyKnockback(dmgPackage.getKnockback()));
            GetComponent <MeshRenderer>().material = recoveryMat;

            //If health is 0, end game, else do hitstun
            if (health <= 0.0f)
            {
                death();
            }
            else
            {
                StartCoroutine(Hitstun());
            }
        }
    }
示例#11
0
 public override TakeDamageReturn TakeDamage(Skill skill, DamagePackage package, TakeDamageReturn lastReturn)
 {
     return(new TakeDamageReturn()
     {
         type = TakeDamageReturnType.NoDamage, value = 1f
     });
 }
 //Recoils back when it gets damaged
 void getDamage(DamagePackage dmgPackage)
 {
     if (!recovering)
     {
         StartCoroutine(recoilStun());
     }
 }
示例#13
0
        private int HealthAfterDamage(SkillReport report, Stats targetStats, DamagePackage damage)
        {
            Stats beforeStats = targetStats.GetCopy();
            Stats afterStats  = targetStats.GetCopy();
            int   tempArmour  = 0;

            if (damage.Type == DamageType.physical)
            {
                tempArmour  = targetStats.GetNonMuttableStat(StatType.Armour).Value;
                tempArmour -= damage.Piercing;
                if (tempArmour < 0)
                {
                    tempArmour = 0;
                }
            }
            if (damage.Type == DamageType.physical || damage.Type == DamageType.pure)
            {
                int tempDamage = damage.Damage;
                if (damage.Type == DamageType.physical)
                {
                    tempDamage -= tempArmour;
                    if (tempDamage < 0)
                    {
                        tempDamage = 0;
                    }
                }
                int oldHealth = targetStats.GetMutableStat(StatType.Health).Value;

                int newHealth = oldHealth - tempDamage;
                if (newHealth <= 0)
                {
                    // dat bibba dead
                    newHealth = 0;
                }

                DamageDisplay damageDisplay = new DamageDisplay();
                damageDisplay.value     = tempDamage;
                damageDisplay.character = (CharacterBoardEntity)targetStats.BoardEntity;
                if (damage.Type == DamageType.physical)
                {
                    damageDisplay.color = Color.red;
                }
                else
                {
                    damageDisplay.color = Color.magenta;
                }
                report.DamageDisplays.Add(damageDisplay);

                afterStats.SetMutableStat(StatType.Health, newHealth);
                report.targetAfter  = afterStats;
                report.targetBefore = beforeStats;

                return(newHealth);
            }
            else
            {
                return(targetStats.GetMutableStat(StatType.Health).Value);
            }
        }
示例#14
0
 public void OnHit(DamagePackage pack)
 {
     if (damageManage)
     {
         damageManage.ApplyDamage((int)((float)pack.Damage * DamageMult), pack.Direction, pack.ID, pack.Team);
     }
     ParticleFX(pack.Position, pack.Normal);
 }
示例#15
0
    //When damaged, move according to knockback
    private IEnumerator getDamage(DamagePackage dmgPackage)
    {
        rb.constraints = ~RigidbodyConstraints.FreezePositionY & ~RigidbodyConstraints.FreezePositionX;
        yield return(new WaitForSeconds(RECOIL_DURATION));

        rb.velocity    = Vector3.zero;
        rb.constraints = RigidbodyConstraints.FreezePosition | RigidbodyConstraints.FreezeRotation;
    }
示例#16
0
    private void NormalDamage(Collision collision)
    {
        DamagePackage dm = new DamagePackage();

        dm.Damage = Damage;
        dm.Owner  = Owner;
        collision.collider.gameObject.SendMessage("ApplyDamage", dm, SendMessageOptions.DontRequireReceiver);
    }
示例#17
0
 //If hit by player, activate the bomb
 public void getDamage(DamagePackage dmgPackage)
 {
     if (!activated)
     {
         activated = true;
         GetComponent <MeshRenderer>().material = activeMat;
         StartCoroutine(explode());
     }
 }
示例#18
0
 /// <summary>
 /// Effect attack on Enemy.
 /// </summary>
 /// <param name="dp">Dp.</param>
 public void EffectAttackEnemy(DamagePackage dp)
 {
     if (currentEnemy.TakeDamage(ref dp))
     {
         Debug.Log("Enemey Died!");
         VisualController._instance.RemoveEnemyVisual();
         currentDungeon.NextEncounter();
     }
 }
示例#19
0
        public override void EnterTile(Tile t)
        {
            DamagePackage package = new DamagePackage(1, DamageType.pure);

            battleCalculator.QuickDamage(boardEntity, new List <DamagePackage>()
            {
                package
            });
        }
示例#20
0
    void Start()
    {
        if (GetComponent <Collider>())
        {
            Physics.IgnoreCollision(GetComponent <Collider>(), Owner.GetComponent <Collider>());
            if (Owner.transform.root)
            {
                foreach (Collider col in Owner.transform.root.GetComponentsInChildren <Collider>())
                {
                    Physics.IgnoreCollision(GetComponent <Collider>(), col);
                }
            }
        }
        DamagePackage dm = new DamagePackage();

        dm.Damage = Damage;
        dm.Owner  = Owner;
        RaycastHit hit;
        GameObject explosion = null;

        startPosition = this.transform.position;

        if (Physics.Raycast(this.transform.position, this.transform.forward, out hit, Range))
        {
            AimPoint = hit.point;
            if (Explosion != null)
            {
                explosion = (GameObject)GameObject.Instantiate(Explosion, AimPoint, Explosion.transform.rotation);
            }
            hit.collider.gameObject.SendMessage("ApplyDamage", dm, SendMessageOptions.DontRequireReceiver);
        }
        else
        {
            AimPoint = this.transform.forward * Range;
            if (Explosion != null)
            {
                explosion = (GameObject)GameObject.Instantiate(Explosion, AimPoint, Explosion.transform.rotation);
            }
        }
        if (explosion)
        {
            DamageBase dmg = explosion.GetComponent <DamageBase> ();
            if (dmg)
            {
                dmg.TargetTag = TargetTag;
            }
        }


        if (Trail)
        {
            Trail.SetPosition(0, startPosition);
            Trail.SetPosition(1, this.transform.position + this.transform.forward * 10000);
        }
        Destroy(this.gameObject, LifeTime);
    }
示例#21
0
 public void OnHit(DamagePackage pack)
 {
     if (DamageManage) {
         DamageManage.ApplyDamage ((int)((float)pack.Damage * DamageMult),pack.Direction,pack.ID,pack.Team);
     }
     if (!Freeze) {
         this.transform.position += pack.Direction.normalized;
     }
     ParticleFX (pack.Position, pack.Normal);
 }
示例#22
0
    //If hit by player, destroy / respawn
    public void getDamage(DamagePackage dmgPackage)
    {
        //Set default characteristic
        slowed         = false;
        rb.useGravity  = true;
        gameObject.tag = "EnemyAttack";

        //Respawn
        spike.position = spawnPoint;
    }
示例#23
0
 /// <summary>
 /// Attacks the Player.
 /// </summary>
 /// <param name="dp">Dp.</param>
 public void AttackPlayer(DamagePackage dp)
 {
     if (player.TakeDamage(ref dp))
     {
         Debug.Log("Player died!");
     }
     else
     {
         TryEndTurn();
     }
 }
 public void OnHit(DamagePackage dm)
 {
     if (!hited)
     {
         if (UnitZ.NetworkGameplay && UnitZ.NetworkGameplay.environment.isServer)
         {
             Cuttree(dm.Position, dm.Damage);
             hited = true;
         }
     }
 }
示例#25
0
 /// <summary>
 /// Player attacks itself
 /// </summary>
 /// <param name="dp">Dp.</param>
 public void PlayerSelfDamage(DamagePackage dp)
 {
     if (player.TakeDamage(ref dp))
     {
         Debug.Log("Player died!");
     }
     else
     {
         //Says it is the players turn.
         TryEndTurn();
     }
 }
示例#26
0
 /// <summary>
 /// Enemy attacks itself.
 /// </summary>
 /// <param name="dp">Dp.</param>
 public void EnemySelfDamage(DamagePackage dp)
 {
     if (currentEnemy.TakeDamage(ref dp))
     {
         Debug.Log("Enemey Died!");
         VisualController._instance.RemoveEnemyVisual();
         currentDungeon.NextEncounter();
     }
     else
     {
         TryEndTurn();
     }
 }
示例#27
0
    void Start()
    {
        damagePerSecond    = isHero? DesignerTool.Instance.HeroDamagePerSecond : DesignerTool.Instance.MinionDamagePerSecond;
        attackDistance     = isHero ? 3.9f : 1.7f;
        intervalsPerSecond = 10;
        timeBetweenAttacks = 1f / intervalsPerSecond;
        myTeam             = GetComponent <GenericMoveController>().GetTeam();
        myDamage           = new DamagePackage(myTeam, gameObject);

        int damagePerHit = (int)(damagePerSecond / intervalsPerSecond);

        myDamage.AddDamage(new Damage(damagePerHit, DamageTypes.normal, false));
    }
示例#28
0
    // Use this for initialization
    void Start()
    {
        rb         = GetComponent <Rigidbody>();
        spike      = GetComponent <Transform>();
        spawnPoint = spike.position;

        //Setting default characteristics
        spikeDamage    = GetComponent <ProjectileStatus>().damage;
        dmgPackage     = new DamagePackage(spikeDamage, Vector3.zero);
        slowed         = false;
        rb.useGravity  = true;
        gameObject.tag = "EnemyAttack";
    }
示例#29
0
    void OnCollisionEnter(Collision collision)
    {
        if(Audiosource && ClashSound && GetComponent<Rigidbody>().velocity.magnitude>3){
            Audiosource.PlayOneShot(ClashSound);
        }

        DamagePackage dm = new DamagePackage();
        dm.Damage = (int)(ClashDamage * GetComponent<Rigidbody>().velocity.magnitude);
        dm.Normal = this.GetComponent<Rigidbody>().velocity.normalized;
        dm.Direction = this.GetComponent<Rigidbody>().velocity * 2;
        dm.Position = this.transform.position;

        if (Seats.Length > 0 && Seats [0].passenger) {
            dm.ID = Seats [0].passenger.character.ID;
            dm.Team = "car";
        }
        collision.collider.SendMessage ("DirectDamage", dm, SendMessageOptions.DontRequireReceiver);
    }
示例#30
0
 public void OnHit(DamagePackage dm)
 {
     if (!hited) {
         if (Network.isServer || (!Network.isClient && !Network.isServer)) {
             Cuttree (dm.Position, dm.Damage);
             hited = true;
         }
     }
 }
示例#31
0
 public void DirectDamage(DamagePackage pack)
 {
     ApplyDamage ((int)((float)pack.Damage), pack.Direction, pack.ID, pack.Team);
 }