Exemplo n.º 1
0
    public void OnProjectileHit(Projectile p, HitZone inHitZone)
    {
        if (CurrentVersion == Versions.Count - 1)
        {
            return;
        }

        DoDamage(p.Damage);
    }
Exemplo n.º 2
0
    private void Start()
    {
        // Indicator script init; \\
        indicatorLogic = GetComponentInChildren <IndicatorLogic>(true);
        // Nearest target (Point), nearests point color \\
        /// ummary>
        ///
        /// </summary>
        /// <returns></returns>

        cHZ   = indicatorLogic.GetCurrentHitzone();
        eBChS = GetComponent <BonyCharacter>();
    }
Exemplo n.º 3
0
 private void FixedUpdate()
 {
     if (hasTarget && priorityToTarget || hasObjective == false && hasTarget)
     {
         HitZone hitPoint = target.GetComponentInChildren <HitZone>();
         //if (transform.position.x > hitPoint.transform.position.x - 0.25 && transform.position.x < hitPoint.transform.position.x + 0.25
         //    && transform.position.z > hitPoint.transform.position.z - 0.25 && transform.position.z < hitPoint.transform.position.z + 0.25)
         //{
         //agent.isStopped = true;
         //}
         //else
         //{
         agent.SetDestination(hitPoint.transform.position);
         //agent.isStopped = false;
         //}
     }
 }
Exemplo n.º 4
0
    public void OnProjectileHit(Projectile inProjectile, HitZone inHitZone)
    {
        if (uLink.Network.isServer == false)
        {
            return;
        }

        if (m_HitPoints <= 0)
        {
            return;
        }

        m_HitPoints -= inProjectile.Damage * inHitZone.DamageModifier;
        if (m_HitPoints <= 0)
        {
            Break(inProjectile.Agent, inProjectile.WeaponID, E_ItemID.None);
        }
    }
Exemplo n.º 5
0
    internal void OnCollisionEnter(Collision collision)
    {
        //Debug.Log(name + " OnCollisionEnter " + collision.gameObject.name);

        if (IsInvoking("Explode") == false)
        {
            return;
        }

        // ignore collisions with owner and his transforms...
        if (Agent && collision.transform.IsChildOf(Agent.Transform))
        {
            return;
        }

        Agent      agent = collision.gameObject.GetComponent <Agent>();
        HitZone    hz    = collision.gameObject.GetComponent <HitZone>();
        AgentHuman human = agent as AgentHuman;

        if (human && human.BlackBoard.GrenadesExplodeOnHit == false)
        {
            if (m_PlayHitSound > 0)
            {
                m_PlayHitSound--;
                PlayHitSound(GetComponent <Collider>().gameObject.layer);
            }
        }
        else if (agent)
        {
            // grenade must explode immediately, if we hit player
            Explode();
        }
        else if (hz)
        {
            // grenade must explode immediately, if we hit player
            Explode();
        }
        else if (m_WaterVolume == null && m_PlayHitSound > 0)
        {
            m_PlayHitSound--;
            PlayHitSound(GetComponent <Collider>().gameObject.layer);
        }
    }
Exemplo n.º 6
0
    void OnCollisionEnter(Collision collision)
    {
        // ignore collisions with owner and his transforms...
        if (collision.transform.IsChildOf(Owner.Transform))
        {
            return;
        }

        if (uLink.Network.isClient)
        {
            if (WaterVolume == null && HitSoundsLeft > 0)
            {
                HitSoundsLeft--;

                ProjectileManager.Instance.PlayGrenadeHitSound(GetComponent <Collider>().gameObject.layer, Transform.position);
            }
        }

        if (uLink.Network.isServer)
        {
            Agent Agent = collision.gameObject.GetComponent <Agent>();

            HitZone HitZone = collision.gameObject.GetComponent <HitZone>();

            //AgentHuman human = agent as AgentHuman;

            // add team shit here

            /*if (human && human.BlackBoard.GrenadesExplodeOnHit == false)
             * {
             * }
             * else*/
            if (null != Agent)             // grenade must explode immediately, if we hit player
            {
                Explode();
            }
            else if (null != HitZone)
            {
                Explode();
            }
        }
    }
Exemplo n.º 7
0
    /// <summary>
    /// Attacking: Player to AI
    /// </summary>
    public void Attacking()
    {
        // Take current state. \\
        cHZ = indicatorLogic.GetCurrentHitzone();
        switch (cHZ.color)
        {
        // Miss;
        case HitZoneColor.RED:
            eBChS.TakeDamage(cHZ.hitzoneType, 0);
            indicatorLogic.ChangeIndicatorImage("Miss");
            break;

        case HitZoneColor.YELLOW:
            eBChS.TakeDamage(cHZ.hitzoneType, Random.Range(0.45f, 0.75f));
            break;

        // If you'er successful.
        case HitZoneColor.GREEN:
            eBChS.TakeDamage(cHZ.hitzoneType, 1f);
            break;
        }
    }
Exemplo n.º 8
0
    private void HandleCapture(GameObject other)
    {
        Player  player  = null;
        HitZone hitZone = other.GetComponent <HitZone>();

        if (hitZone && hitZone.owner)
        {
            player = hitZone.owner;
        }
        else
        {
            player = other.GetComponent <Player>();
        }

        if (player)
        {
            _rigidBody.velocity       = Vector3.zero;
            isCaptured                = true;
            capturedBy                = player;
            isInFlight                = false;
            _sphereCollider.isTrigger = true;
            capturedBy.SendMessage(GameMessages.DODGE_BALL_CAPTURED, this);
        }
    }
Exemplo n.º 9
0
 public HitZoneColumn(HitZone hitZone, int averageArmor, IEnumerable<HitLocation> locations)
 {
     HitZone = hitZone;
     AverageArmor = averageArmor;
     AssignZones(locations);
 }
Exemplo n.º 10
0
    public void OnExplosionHit(Agent attacker, float inDamage, Vector3 impulse, E_WeaponID weaponId, E_ItemID itemId, HitZone inHitZone)
    {
        if (uLink.Network.isServer == false)
        {
            return;
        }

        if (m_HitPoints <= 0)
        {
            return;
        }

        m_HitPoints -= inDamage * inHitZone.DamageModifier;
        if (m_HitPoints <= 0)
        {
            Break(attacker as AgentHuman, weaponId, itemId);
        }
    }
Exemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="hitZone">Enum HitZone</param>
 public void SetHitZone(HitZone hitZone)
 {
     currentHitZone = hitZone;
 }
Exemplo n.º 12
0
    // return size of beam in [m]
    float PerformLineHit(Vector3 inFrom, Vector3 inDir, float inMaxDistance)
    {
        float lng = inMaxDistance;

        RaycastHit[] hits = Physics.RaycastAll(inFrom, inDir, lng, RayCastMask);

        if (hits.Length > 1)
        {
            System.Array.Sort(hits, CollisionUtils.CompareHits);
        }

        Transform.position = inFrom + inDir * inMaxDistance;

        foreach (RaycastHit hit in hits)
        {
            if (hit.transform == Settings.IgnoreTransform)
            {
                continue;
            }

            //skip the Owner of this shot when his HitZone got hit
            HitZone zone = hit.transform.GetComponent <HitZone>();
            if (zone && (zone.HitZoneOwner is AgentHuman) && (zone.HitZoneOwner as AgentHuman).transform == Settings.IgnoreTransform)
            {
                continue;
            }

            Transform.position = hit.point;

            if (!ValidateHitAgainstEnemy(hit))
            {
                continue;
            }

            hit.transform.SendMessage("OnProjectileHit", this, SendMessageOptions.DontRequireReceiver);

            if (ignoreThisHit)
            {
                ignoreThisHit = false;
                continue;
            }

            if (hit.collider.isTrigger)
            {
                continue;
            }

            lng = hit.distance;

            if (spawnHitEffects)
            {
                PlayHitSound(hit.transform.gameObject.layer);
                CombatEffectsManager.Instance.PlayHitEffect(hit.transform.gameObject,
                                                            hit.point,
                                                            hit.normal,
                                                            ProjectileType,
                                                            Agent != null && Agent.IsOwner);
            }

            //Debug.DrawLine(Transform.position, Transform.position + hit.normal, Color.blue, 2.0f);

            // stop beem on static collision.
            if (hit.rigidbody == null || hit.rigidbody.isKinematic == false)
            {
                break;
            }
        }

        return(lng);
    }
Exemplo n.º 13
0
    public void OnExplosionHit(Agent attacker, float inDamage, Vector3 impulse, E_WeaponID weaponId, E_ItemID itemId, HitZone inHitZone)
    {
        if (CurrentVersion == Versions.Count - 1)
        {
            return;
        }

        DoDamage(inDamage);
    }
Exemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     hz = GameObject.FindWithTag("Player").GetComponent <HitZone>();
     rb = GetComponent <Rigidbody2D>();
 }
Exemplo n.º 15
0
    public virtual void ProjectileUpdate()
    {
        MFDebugUtils.Assert(IsFinished() == false);

        Timer += Time.deltaTime;

        if (Hit == true)
        {
            return;
        }

        if (Transform.localScale.z != 1)
        {
            Transform.localScale = new Vector3(1, 1, Mathf.Min(1, Transform.localScale.z + Time.deltaTime * 8));
        }

        float   dist   = Settings.Speed * Time.deltaTime;
        Vector3 newPos = Pos + Dir * dist;

        RaycastHit[] hits = Physics.RaycastAll(Pos, Dir, dist, RayCastMask);

        if (hits.Length > 1)
        {
            System.Array.Sort(hits, CollisionUtils.CompareHits);
        }

        foreach (RaycastHit hit in hits)
        {
            //Debug.Log (Time.timeSinceLevelLoad + "Test: " + hit.transform.name);

            if (hit.transform == Settings.IgnoreTransform)
            {
                continue;
            }

            //skip the Owner of this shot when his HitZone got hit
            HitZone zone = hit.transform.GetComponent <HitZone>();
            if (zone && (zone.HitZoneOwner is AgentHuman) && (zone.HitZoneOwner as AgentHuman).transform == Settings.IgnoreTransform)
            {
                continue;
            }

            //Debug.Log (Time.timeSinceLevelLoad + "HIT: " + hit.transform.name);
//			Debug.DrawLine(Transform.position, Transform.position + hit.normal, Color.blue, 4.0f);
//			Debug.DrawLine(Transform.position, hit.point, Color.red, 3.0f);

            Transform.position = hit.point;

            //HACK The projectile belongs to the "Default" collision layer.
            //This is probably bug but we do not want to modify the data at the moment.
            //The only chance now is to ignore such hits
            if (hit.transform.gameObject.name.StartsWith("Projectile"))
            {
                continue;
            }

            if (!ValidateHitAgainstEnemy(hit))
            {
                continue;
            }

            hit.transform.SendMessage("OnProjectileHit", this, SendMessageOptions.DontRequireReceiver);

            if (ignoreThisHit)
            {
                ignoreThisHit = false;
                continue;
            }

            if (uLink.Network.isClient)
            {
#if UNITY_MFG && UNITY_EDITOR //we don't have FluidSurface in WebPlayer
                FluidSurface fluid = hit.collider.GetComponent <FluidSurface>();
                if (fluid != null)
                {
                    fluid.AddDropletAtWorldPos(hit.point, 0.3f, 0.15f);
                }
#endif
                //	else if (hit.rigidbody)
                //	{
                //		// TODO: potrebujem poladit korektni hodnotu impulzu per-zbran
                //		float force = Vector3.Dot(-hit.normal,Transform.forward) * 30;
                //
                //		hit.rigidbody.AddForceAtPosition(Transform.forward * force,hit.point);
                //	}
            }

            if (hit.collider.isTrigger)
            {
                continue;
            }

            newPos = hit.point;

            if (ricochetThisHit)
            {
                ricochetThisHit = false;

                Transform.forward = hit.normal;
                m_Forward         = hit.normal;

                if (spawnHitEffects)
                {
                    PlayHitSound(29);
                    CombatEffectsManager.Instance.PlayHitEffect(hit.transform.gameObject,
                                                                29,
                                                                hit.point,
                                                                hit.normal,
                                                                ProjectileType,
                                                                Agent != null && Agent.IsOwner);
                }

                if ((m_ProjectileTrail != null) && UseTrail)
                {
                    m_ProjectileTrail.AddTrailPos(newPos);
                }
            }
            else
            {
                Hit = true;

                if (spawnHitEffects)
                {
                    PlayHitSound(hit.transform.gameObject.layer);
                    CombatEffectsManager.Instance.PlayHitEffect(hit.transform.gameObject,
                                                                hit.transform.gameObject.layer,
                                                                hit.point,
                                                                hit.normal,
                                                                ProjectileType,
                                                                Agent != null && Agent.IsOwner);
                }
            }

            if (GetComponent <Renderer>() != null)
            {
                GetComponent <Renderer>().enabled = false;
            }

            break;
        }

        Transform.position = newPos;

        if ((m_ProjectileTrail != null) && (UseTrail == true))
        {
            m_ProjectileTrail.UpdateTrailPos(newPos);
        }
    }
Exemplo n.º 16
0
 public HitZoneColumn(HitZone hitZone, int averageArmor, IEnumerable <HitLocation> locations)
 {
     HitZone      = hitZone;
     AverageArmor = averageArmor;
     AssignZones(locations);
 }
Exemplo n.º 17
0
    void ProceedHits(RaycastHit[] hits, bool softInit, Vector3 newPos)
    {
        // launched from cover (fast dirty solution)
        Cover cover      = null;
        bool  hitIsValid = false;

        if ((Agent != null) && (Agent.IsInCover == true) && (Agent.BlackBoard.Cover != null))
        {
            cover = Agent.BlackBoard.Cover;
        }

        // sort hits by distance
        if (hits.Length > 1)
        {
            System.Array.Sort(hits, CollisionUtils.CompareHits);
        }

        // process hits
        foreach (RaycastHit hit in hits)
        {
            //Debug.Log("ProjectileUpdate Hit" + hit.transform.name);
            if (hit.transform == Settings.IgnoreTransform)
            {
                continue;
            }

            //skip the Owner of this shot when his HitZone got hit
            HitZone zone = hit.transform.GetComponent <HitZone>();
            if (zone && (zone.HitZoneOwner is AgentHuman) && (zone.HitZoneOwner as AgentHuman).transform == Settings.IgnoreTransform)
            {
                continue;
            }

            //HACK The projectile belongs to the "Default" collision layer.
            //This is probably bug but we do not want to modify the data at the moment.
            //The only chance now is to ignore such hits
            if (hit.transform.gameObject.name.StartsWith("Projectile"))
            {
                continue;
            }

            //skip friends when the projectile should explode near the player (this solves the unwanted suicide when a friend suddenly enters the area in front of me)
            AgentHuman hitAgent = hit.transform.gameObject.GetFirstComponentUpward <AgentHuman>();
            if (Agent != null && hitAgent != null)
            {
                float dist = Vector3.Distance(Agent.Position, hitAgent.Position);
                if (dist < 3)                 //ignore only if the projectile is still within X m radius
                {
                    if (Agent.IsFriend(hitAgent))
                    {
                        continue;
                    }
                }
            }

            Transform.position = hit.point;

            if (hit.collider.isTrigger)
            {
                if (!softInit)
                {
                    hit.transform.SendMessage("OnProjectileHit", this, SendMessageOptions.DontRequireReceiver);
                    continue;
                }
            }

            if ((cover != null) && (cover.IsPartOfCover(hit.collider.gameObject) == true))
            {
                continue;
            }

            newPos = hit.point;

#if DEBUG
            DebugDraw.DepthTest   = true;
            DebugDraw.DisplayTime = 10.0f;
            DebugDraw.Diamond(Color.red, 0.02f, newPos);
#endif

            Hit        = true;
            HitNormal  = hit.normal;
            hitIsValid = ValidateHit(hit);

            break;
        }

        if (false == softInit)
        {
            Transform.position = newPos;
        }

        if (Hit)
        {
            if (hitIsValid)
            {
                HitReaction();
            }
            else
            {
                //This function probably has no effect here but I want to be sure that I did not miss anything important
                //This code is triggered on the server side and only in the case when attacker is cheating
                InvalidHitReaction();
            }
        }
    }