示例#1
0
    // Use this for initialization
    void Awake()
    {
        m_boxCollider = GetComponent <BoxCollider2D>();
        m_character   = GetComponent <APCharacterController>();

        ClearRuntimeValues();
    }
示例#2
0
    // called when character is touching us with a ray
    override public bool OnCharacterTouch(APCharacterController launcher, APCharacterMotor.RayType rayType, RaycastHit2D hit,
                                          float penetration, APMaterial hitMaterial)
    {
        // ignore contacts for exploded crates
        if (IsDead())
        {
            return(false);
        }

        // check if we are touching with vertical down shift attack
        if (!m_shiftHit && launcher.IsShifting() && launcher.GetMotor().m_velocity.y < 0f)
        {
            // handle different penetration in function of ray type
            if ((rayType == APCharacterMotor.RayType.Ground && penetration < 0.1f) || (rayType != APCharacterMotor.RayType.Ground && penetration < 0f))
            {
                // defer hit (as this callback may be called for many rays)
                m_shiftHit = true;
            }
        }

        // ignore all contacts after a shift hit
        if (m_shiftHit)
        {
            return(false);
        }

        // always allow contact with crate
        return(true);
    }
    public void DrawStartPos(APAttack.AttackContext context, bool bDraw)
    {
        if (bDraw && context.m_enabled)
        {
            APCharacterController oController = (APCharacterController)target;
            Vector3 pointPos = oController.transform.TransformPoint(context.m_bulletStartPosition);
            Color   color    = Color.cyan;
            color.a       = 0.5f;
            Handles.color = color;
            Vector3 newPos = Handles.FreeMoveHandle(pointPos, Quaternion.identity, 0.1f, Vector3.zero, Handles.SphereHandleCap);
            if (GUI.changed)
            {
                Undo.RecordObject(oController, "Move Bullet Position");
                context.m_bulletStartPosition = oController.transform.InverseTransformPoint(newPos);

                // mark object as dirty
                EditorUtility.SetDirty(oController);
            }

            // draw direction arrow
            float   fAngle    = Mathf.Deg2Rad * context.m_bulletDirection;
            Vector2 v2MoveDir = new Vector2(Mathf.Cos(fAngle), -Mathf.Sin(fAngle));

            APCharacterMotor oMotor = oController.GetComponent <APCharacterMotor>();
            if (oMotor && ((oMotor.m_faceRight && v2MoveDir.x < 0f) || (!oMotor.m_faceRight && v2MoveDir.x > 0f)))
            {
                v2MoveDir.x = -v2MoveDir.x;
            }

            v2MoveDir = oController.transform.TransformDirection(v2MoveDir);

            Quaternion rot = Quaternion.LookRotation(v2MoveDir);
            Handles.ArrowHandleCap(0, pointPos, rot, 0.5f, EventType.Repaint);
        }
    }
示例#4
0
    public void Setup(APCharacterController launcher, Vector2 startPos, Vector2 moveDir)
    {
        m_anim          = GetComponent <Animator>();
        m_launcher      = launcher;
        m_alive         = true;
        m_spawnDuration = 0f;
        m_curVel        = moveDir * m_velocity;
        m_rigidBody     = GetComponent <Rigidbody2D>();
        if (m_rigidBody)
        {
            m_rigidBody.velocity = m_curVel;
        }

        // fix flipping
        if (launcher.GetMotor().FaceRight != m_faceRight)
        {
            Vector3 theScale = transform.localScale;
            theScale.x          *= -1;
            theScale.y          *= -1;
            transform.localScale = theScale;

            Quaternion localRot = transform.localRotation;
            Vector3    rot      = localRot.eulerAngles;
            rot.z *= -1;
            localRot.eulerAngles    = rot;
            transform.localRotation = localRot;
        }
    }
示例#5
0
    public void OnSceneGUI()
    {
        APCharacterController oController = (APCharacterController)target;

        // draw all melee attack zones and allow to move them when selecting controller
        if (oController.m_meleeAttacks.m_enabled)
        {
            foreach (APMeleeAttack curAttack in oController.m_meleeAttacks.m_attacks)
            {
                foreach (APHitZone curZone in curAttack.m_hitZones)
                {
                    if (curZone.m_active && curZone.gameObject.activeInHierarchy)
                    {
                        Vector3 pointPos = curZone.transform.position;
                        Color   color    = Color.green;
                        color.a       = 0.5f;
                        Handles.color = color;
                        Vector3 newPos = Handles.FreeMoveHandle(pointPos, Quaternion.identity, curZone.m_radius * 2f, Vector3.zero, Handles.SphereCap);
                        if (newPos != pointPos)
                        {
                            Undo.RecordObject(curZone.transform, "Move Hit Zone");
                            curZone.transform.position = newPos;

                            // mark object as dirty
                            EditorUtility.SetDirty(curZone);
                        }
                    }
                }
            }
        }
    }
示例#6
0
    public void FireBullet(APCharacterController launcher, AttackContext context)
    {
        if (CanFireBullet())
        {
            if (!m_infiniteAmmo)
            {
                m_ammoBox.AddAmmo(-1);
            }

            // make sure move horizontal direction is valid
            bool    bFaceRight = launcher.GetMotor().m_faceRight;
            float   fAngle     = Mathf.Deg2Rad * context.m_bulletDirection;
            Vector2 v2MoveDir  = new Vector2(Mathf.Cos(fAngle), -Mathf.Sin(fAngle));
            if (bFaceRight && v2MoveDir.x < 0f || !bFaceRight && v2MoveDir.x > 0f)
            {
                v2MoveDir.x = -v2MoveDir.x;
            }

            // spawn and launch bullet (add player velocity before spawn)
            Vector2 pointPos = launcher.transform.TransformPoint(context.m_bulletStartPosition);
            pointPos = pointPos + (Time.deltaTime * launcher.GetMotor().m_velocity);

            float      bulletSign = m_bullet.m_faceRight ? 1f : -1f;
            Quaternion rot        = Quaternion.Euler(0f, 0f, bFaceRight != m_bullet.m_faceRight ? bulletSign * context.m_bulletDirection : -bulletSign * context.m_bulletDirection);
            APBullet   newBullet  = (APBullet)UnityEngine.Object.Instantiate(m_bullet, pointPos, rot);
            newBullet.enabled = true;

            // init bullet
            v2MoveDir = launcher.transform.TransformDirection(v2MoveDir);
            newBullet.Setup(launcher, v2MoveDir);

            // launch listeners
            launcher.EventListeners.ForEach(e => e.OnAttackBulletFired(this, newBullet));
        }
    }
示例#7
0
    // Use this for initialization
    void Start()
    {
        m_player = GetComponent <APCharacterController>();
        m_anim   = GetComponent <Animator>();

        m_godMode     = false;
        m_godModeTime = 0f;
    }
    // called when character is entering this collectable
    public void OnTriggerEnter2D(Collider2D otherCollider)
    {
        APCharacterController character = otherCollider.GetComponent <APCharacterController>();

        if (character)
        {
            HandleCatch(character);
        }
    }
    // called when we have been hit by a melee attack
    override public bool OnMeleeAttackHit(APCharacterController character, APHitZone hitZone)
    {
        if (m_meleeAttackCanCatch)
        {
            HandleCatch(character);
        }

        // always ignore hit for now
        return(false);
    }
示例#10
0
 void Awake()
 {
     m_curMinPos = m_minPos;
     m_curMaxPos = m_maxPos;
     m_dynOffset = 0f;
     m_character = player.GetComponent <APCharacterController>();
     for (int i = 0; i < m_parallaxScrollings.Length; i++)
     {
         m_parallaxScrollings[i].Init(this);
     }
 }
示例#11
0
    private void Awake()
    {
        APcontroller = GetComponent <APCharacterController>();
        m_anim       = GetComponent <Animator>();

        if (!photonView.IsMine && GetComponent <APCharacterController>() != null)
        {
            Destroy(GetComponent <APCharacterController>());
            //Destroy Motor????
        }
    }
示例#12
0
 public AttackContext GetCurrentContext(APCharacterController character)
 {
     if (m_useAimAnimations)
     {
         // Check inputs and update animation according to this
         AttackContext ctx    = m_contextAimFront;
         bool          bFront = Mathf.Abs(character.m_inputs.m_axisX.GetValue()) > 0f;
         bool          bUp    = character.m_inputs.m_axisY.GetValue() > 0f;
         bool          bDown  = character.m_inputs.m_axisY.GetValue() < 0f;
         if (bFront)
         {
             if (bUp)
             {
                 ctx = m_contextAimFrontUp;
             }
             else if (bDown)
             {
                 ctx = m_contextAimFrontDown;
             }
         }
         else if (bUp)
         {
             ctx = m_contextAimUp;
         }
         else if (bDown)
         {
             ctx = m_contextAimDown;
         }
         return(ctx);
     }
     else
     {
         bool bCrouched = character.IsCrouched();
         if (bCrouched)
         {
             return(m_contextCrouched);
         }
         else if (character.IsOnGround())
         {
             if (!character.IsRunning())
             {
                 return(m_contextStand);
             }
             else
             {
                 return(m_contextRun);
             }
         }
         else
         {
             return(m_contextInAir);
         }
     }
 }
示例#13
0
    // Use this for initialization
    void Start()
    {
        // some initializations variables
        m_player = GetComponent <APCharacterController>();
        m_anim   = GetComponent <Animator>();

        m_godMode     = false;
        m_godModeTime = 0f;

        // save ref to our sample GUI here
        m_gui = GameObject.FindObjectOfType <APSampleGUI>();
    }
示例#14
0
 // called when we have been hit by a bullet
 override public bool OnBulletHit(APCharacterController character, APBullet bullet)
 {
     if (m_bulletCanCatch)
     {
         HandleCatch(character);
         return(true);            // destroy bullet
     }
     else
     {
         return(false);            // keep bullet alive
     }
 }
示例#15
0
    // called when we have been hit by a melee attack
    override public bool OnMeleeAttackHit(APCharacterController character, APHitZone hitZone)
    {
        // Do nothing if player is currently blinking
        APSamplePlayer samplePlayer = character.GetComponent <APSamplePlayer>();

        if (samplePlayer && samplePlayer.IsGodModeEnabled())
        {
            return(false);
        }

        return(AddHitDamage(hitZone.m_damage));
    }
    public void OnSceneGUI()
    {
        APCharacterController oController = (APCharacterController)target;

        // draw all melee attack zones and allow to move them when selecting controller
        if (oController.m_attacks != null && oController.m_attacks.m_enabled)
        {
            foreach (APAttack curAttack in oController.m_attacks.m_attacks)
            {
                foreach (APHitZone curZone in curAttack.m_hitZones)
                {
                    if (curZone.m_active && curZone.gameObject.activeInHierarchy)
                    {
                        Vector3 pointPos = curZone.transform.position;
                        Color   color    = Color.green;
                        color.a       = 0.5f;
                        Handles.color = color;
                        Vector3 newPos = Handles.FreeMoveHandle(pointPos, Quaternion.identity, curZone.m_radius * 2f, Vector3.zero, Handles.SphereHandleCap);
                        if (newPos != pointPos)
                        {
                            Undo.RecordObject(curZone.transform, "Move Hit Zone");
                            curZone.transform.position = newPos;

                            // mark object as dirty
                            EditorUtility.SetDirty(curZone);
                        }
                    }
                }
            }
        }

        // draw all ranged attack spawning bullets and allow to move them when selecting controller
        if (oController.m_attacks != null && oController.m_attacks.m_enabled && m_bShow)
        {
            for (int i = 0; i < oController.m_attacks.m_attacks.Length; i++)
            {
                APAttack curAttack = oController.m_attacks.m_attacks[i];
                DrawStartPos(curAttack.m_contextStand, m_bShowBulletSpawnsStand[i]);
                DrawStartPos(curAttack.m_contextRun, m_bShowBulletSpawnsRun[i]);
                DrawStartPos(curAttack.m_contextInAir, m_bShowBulletSpawnsInAir[i]);
                DrawStartPos(curAttack.m_contextCrouched, m_bShowBulletSpawnsCrouched[i]);

                DrawStartPos(curAttack.m_contextAimFront, m_bShowBulletSpawnsFront[i]);
                DrawStartPos(curAttack.m_contextAimDown, m_bShowBulletSpawnsUp[i]);
                DrawStartPos(curAttack.m_contextAimUp, m_bShowBulletSpawnsDown[i]);
                DrawStartPos(curAttack.m_contextAimFrontUp, m_bShowBulletSpawnsFrontUp[i]);
                DrawStartPos(curAttack.m_contextAimFrontDown, m_bShowBulletSpawnsFrontDown[i]);
            }
        }
    }
示例#17
0
    // called when character is entering this collectable
    public void OnTriggerEnter2D(Collider2D otherCollider)
    {
        // do nothing if not ebabled
        if (!enabled)
        {
            return;
        }

        if (m_playing)
        {
            // update playing state
            float fAnimTime = m_anim.GetCurrentAnimatorStateInfo(0).normalizedTime;
            if (fAnimTime >= 1f)
            {
                m_playing = false;
            }
            else
            {
                // do not allow impulse during play
                return;
            }
        }

        APCharacterController character = otherCollider.GetComponent <APCharacterController>();

        if (character != null)
        {
            m_playing = true;
            m_anim.Play(m_animHash, 0, 0f);

            // launch impulse/jump
            if (m_mode == EImpulseMode.Impulse)
            {
                float   fAngle       = -Mathf.Deg2Rad * m_impulseDirection;
                Vector2 v2ImpulseDir = new Vector2(Mathf.Cos(fAngle), -Mathf.Sin(fAngle));
                v2ImpulseDir = transform.TransformDirection(v2ImpulseDir);

                Vector2 charVel         = character.GetVelocity();
                float   velAlongImpulse = Vector2.Dot(charVel, v2ImpulseDir);
                charVel += v2ImpulseDir * (m_impulsePower - velAlongImpulse);
                character.SetVelocity(charVel);
            }
            else
            {
                character.Jump(m_jumpMinHeight, m_jumpMaxHeight);
            }
        }
    }
示例#18
0
    void ReleaseControl(ExitType EExitType)
    {
        if (m_controlled)
        {
            m_bPhysicAnim = false;

            // keep release time
            if (EExitType != ExitType.ClimbExit)
            {
                m_releaseTime = Time.time;
            }

            // Leave control
            m_controlled.EventListeners.ForEach(e => e.OnEdgeGrabEnd(this));
            m_controlled.IsControlled = false;

            // exit with small impulse
            if (EExitType == ExitType.Jump)
            {
                APCharacterMotor motor = m_controlled.GetMotor();
                motor.m_velocity = m_jumpExitPower;

                float horAxis = m_controlled.m_inputs.m_axisX.GetValue();
                motor.m_velocity.x *= horAxis;

                // make sure to exit in right side
                if ((motor.m_velocity.x > 0f && !motor.FaceRight) || (motor.m_velocity.x < 0f && motor.FaceRight))
                {
                    motor.Flip();
                }
            }
            else if (EExitType == ExitType.ClimbExit)
            {
                float fClampedInput = GetClampedInput();

                // inject exit character velocity
                float fGroundSpeed = m_controlled.ComputeMaxGroundSpeed();
                m_controlled.GetMotor().m_velocity = Vector2.right * fClampedInput * fGroundSpeed;

                // limit exit input
                m_controlled.m_inputs.m_axisX.ResetValue(fClampedInput);
            }

            m_controlled = null;
        }
    }
    // called when character motor ray is touching us
    override public bool OnCharacterTouch(APCharacterController character, APCharacterMotor.RayType rayType, RaycastHit2D hit, float penetration,
                                          APMaterial hitMaterial)
    {
        if (m_moving || m_hasTouched || penetration > 0.1f)
        {
            return(true);
        }

        // enable timer if player is touching us with feet only
        if (rayType == APCharacterMotor.RayType.Ground)
        {
            m_hasTouched = true;
            m_touchTime  = 0f;
        }

        // always keep contact
        return(true);
    }
示例#20
0
    // called when character motor ray is touching us
    override public void OnCharacterTouch(APCharacterController character, APCharacterMotor.RayType rayType)
    {
        // Do nothing if dead
        if (IsDead())
        {
            return;
        }

        // prevent checking hits too often
        if (Time.time < m_lastHitTime + m_minTimeBetweenTwoReceivedHits)
        {
            return;
        }

        // save current hit time
        m_lastHitTime = Time.time;

        // check if jumping on us
        APSamplePlayer samplePlayer = character.GetComponent <APSamplePlayer>();

        if (rayType == APCharacterMotor.RayType.Ground)
        {
            // make character jump
            float  fRatio      = m_jumpRatioInputReleased;
            string sJumpButton = character.m_jump.m_button;
            if (!string.IsNullOrEmpty(sJumpButton) && Input.GetButton(sJumpButton))
            {
                fRatio = m_jumpRatioInputPushed;
            }

            if (fRatio > 0f)
            {
                character.Jump(fRatio);
            }

            // add hit to us
            AddHitDamage(samplePlayer.m_jumpDamage);
        }
        else
        {
            // notify hit to character controller as Blob makes damage by touching it
            samplePlayer.OnHit(this);
        }
    }
示例#21
0
    void StartGrab(APCharacterController controlled, APAnimation anim, Vector2 grabHandle)
    {
        ClearRuntimeValues();

        m_controlled = controlled;
        m_controlled.IsControlled = true;

        // Init handle to grab
        m_curGrabHandle = transform.TransformPoint(grabHandle);
        MatchGrabAnchor();

        // start anim & reset velocity
        m_controlled.GetMotor().m_velocity = Vector2.zero;
        InitPhysAnimation(m_curGrabHandle);
        m_controlled.PlayAnim(anim);

        // launch events
        m_controlled.EventListeners.ForEach(e => e.OnEdgeGrabStart(this));
    }
示例#22
0
    // Catch this collectible
    void HandleCatch(APCharacterController character)
    {
        if (!m_catched)
        {
            m_catched = true;

            // update player data
            APSamplePlayer player = character.GetComponent <APSamplePlayer>();
            if (player != null)
            {
                player.AddLife(m_lifePoints);
                player.AddScore(m_scorePoints);
                player.AddAmmo(m_ammoPoints, m_rangedAttackIndex);
            }

            // destroy me
            Object.Destroy(gameObject);
        }
    }
    // Catch this collectible
    void HandleCatch(APCharacterController character)
    {
        if (!m_catched)
        {
            m_catched = true;

            // update player data
            APSamplePlayer player = character.GetComponent <APSamplePlayer>();
            if (player != null)
            {
                player.AddLife(m_lifePoints);
                player.AddScore(m_scorePoints);
                if (m_ammoBox != null)
                {
                    m_ammoBox.AddAmmo(m_ammoPoints);
                }
            }

            StartCoroutine(wait());
        }
    }
示例#24
0
    public bool TryTakeControl(APCharacterController controlled, Collider2D otherCollider)
    {
        if (enabled && !m_controlled)
        {
            // check grabbing mode
            if (otherCollider == m_colliderFromTop && m_grabFromTop.m_enabled && m_grabFromTop.m_button.IsSpecified())
            {
                // make sure correct input is pushed while in trigger
                if (m_grabFromTop.m_button.GetButton())
                {
                    // flip player if not facing correctly
                    if (controlled.IsFacingRight() != (m_direction == Direction.Right))
                    {
                        controlled.GetMotor().Flip();
                    }

                    StartGrab(controlled, m_grabFromTop.m_anim, m_grabFromTop.m_handle);
                    return(true);
                }
            }
            else if (otherCollider == m_colliderAligned && m_grabInAir.m_enabled)
            {
                // make sure we do not grab same edge too quickly while in air
                if (Time.time - m_releaseTime < controlled.m_edgeGrab.m_minTimeBetweenEdgeGrabs)
                {
                    return(false);
                }

                // check direction
                if (m_direction == Direction.Right && controlled.IsFacingRight() ||
                    m_direction == Direction.Left && !controlled.IsFacingRight())
                {
                    StartGrab(controlled, m_grabInAir.m_anim, m_grabInAir.m_handle);
                    return(true);
                }
            }
        }

        return(false);
    }
示例#25
0
    // called when we have been hit by a melee attack
    override public void OnMeleeAttackHit(APCharacterController character, APHitZone hitZone)
    {
        // do nothing if already dead
        if (IsDead())
        {
            return;
        }

        // prevent checking hits too often
        if (Time.time < m_lastHitTime + m_minTimeBetweenTwoReceivedHits)
        {
            return;
        }

        // save current hit time
        m_lastHitTime = Time.time;

        // reduce hit count
        m_hitCount -= 1;

        // handle death & callbacks
        if (m_hitCount <= 0)
        {
            m_hitCount = 0;

            // launch die animation
            if (m_anim)
            {
                m_anim.Play("explode", 0, 0f);
            }
        }
        else
        {
            // launch hit animation
            if (m_anim)
            {
                m_anim.Play("hit", 0, 0f);
            }
        }
    }
示例#26
0
    public void FireBullet(APCharacterController launcher, ContextId contextId)
    {
        if ((m_ammo > 0 || m_infiniteAmmo) && (m_bullet != null))
        {
            if (!m_infiniteAmmo)
            {
                m_ammo--;
            }

            AttackContext curContext = m_contextStand;
            switch (contextId)
            {
            case ContextId.eRun: curContext = m_contextRun; break;

            case ContextId.eInAir: curContext = m_contextInAir; break;

            case ContextId.eCrouched: curContext = m_contextCrouched; break;
            }

            // make sure move horizontal direction is valid
            float   fAngle    = Mathf.Deg2Rad * curContext.m_bulletDirection;
            Vector2 v2MoveDir = new Vector2(Mathf.Cos(fAngle), -Mathf.Sin(fAngle));
            if (launcher.GetMotor().m_faceRight&& v2MoveDir.x < 0f || !launcher.GetMotor().m_faceRight&& v2MoveDir.x > 0f)
            {
                v2MoveDir.x = -v2MoveDir.x;
            }

            // spawn and launch bullet (add player velocity before spawn)
            Vector2 pointPos = launcher.transform.TransformPoint(curContext.m_bulletStartPosition);
            pointPos = pointPos + (Time.deltaTime * launcher.GetMotor().m_velocity);
            APBullet newBullet = (APBullet)UnityEngine.Object.Instantiate(m_bullet, pointPos, Quaternion.identity);

            // init bullet
            v2MoveDir = launcher.transform.TransformDirection(v2MoveDir);
            newBullet.Setup(launcher, pointPos, v2MoveDir);

            // launch listeners
            launcher.EventListeners.ForEach(e => e.OnAttackBulletFired(this, newBullet));
        }
    }
示例#27
0
    // Start is called before the first frame update
    void Start()
    {
        APcontroller = GetComponent <APCharacterController>();
        m_ID         = GetComponent <PhotonView>().ViewID;

        this.myBackpack = FindObjectOfType <Inventory>();

        myUIManager = FindObjectOfType <UIManager>();

        //initialize player status
        invincibleTimer = 0;
        m_health        = 100;
        m_hunger        = 100;
        m_temperature   = 38;
        m_tiredness     = 100;

        m_status = PlayerStatus.DEFAULT;

        if (photonView.IsMine)
        {
            myUIManager.UpdateHealth(m_health);
            myUIManager.UpdateHunger(m_hunger);
            myUIManager.UpdateTemperature(m_temperature);
            myUIManager.UpdateTiredness(m_tiredness);

            InvokeRepeating("Digest", 30f, 4f);
            //InvokeRepeating("Working", 1f, 1f);
            InvokeRepeating("BodyTempCheckBasedOnTemp", 1f, 4f);
        }



        lastTempCheck = Time.time;

        if (HoldedItemSprite == null)
        {
            Debug.Log("Remember to attach holded item sprite");
        }
    }
示例#28
0
    public void RefreshAnimations(APCharacterController character)
    {
        AttackContext ctx = GetCurrentContext(character);

        if (ctx != null && ctx.m_enabled)
        {
            // Handle aim sub context properly
            AttackContextAim ctxAim = ctx as AttackContextAim;
            if (ctxAim != null)
            {
                character.PlayAnim(character.IsRunning() && ctxAim.m_animRun.IsValid() ? ctxAim.m_animRun : ctxAim.m_anim);
            }
            else
            {
                // keep default set of animation if not overrided by each attack
                if (ctx.m_anim.IsValid())
                {
                    character.PlayAnim(ctx.m_anim);
                }
            }
        }
    }
 public void SetCharacter(APCharacterController character)
 {
     m_character = character;
 }
示例#30
0
    // called when character motor ray is touching us
    override public bool OnCharacterTouch(APCharacterController character, APCharacterMotor.RayType rayType, RaycastHit2D hit, float penetration,
                                          APMaterial hitMaterial)
    {
        // Do nothing if dead
        if (IsDead())
        {
            return(false);
        }

        // Do nothing in godmode
        APSamplePlayer samplePlayer = character.GetComponent <APSamplePlayer>();

        if (samplePlayer && samplePlayer.IsGodModeEnabled())
        {
            return(false);
        }

        // check if jumping on us
        bool bHit = false;

        if ((rayType == APCharacterMotor.RayType.Ground) && (penetration <= m_jumpHitPenetrationTolerance))
        {
            // make character jump
            float fRatio = m_jumpRatioInputReleased;
            if (character.m_jump.m_button.IsSpecified() && character.m_jump.m_button.GetButton())
            {
                fRatio = m_jumpRatioInputPushed;
            }

            if (fRatio > 0f)
            {
                character.Jump(character.m_jump.m_minHeight * fRatio, character.m_jump.m_maxHeight * fRatio);
            }

            // add hit to NPC
            if (samplePlayer)
            {
                AddHitDamage(samplePlayer.m_jumpDamage);
            }

            bHit = true;
        }
        else if (penetration <= m_hitPenetrationTolerance)
        {
            // add hit to character
            if (samplePlayer)
            {
                samplePlayer.OnHit(m_touchDamage, transform.position);
            }

            bHit = true;
        }

        // prevent checking hits too often
        if (bHit)
        {
            if (Time.time < m_lastHitTime + m_minTimeBetweenTwoReceivedHits)
            {
                return(false);
            }

            // save current hit time
            m_lastHitTime = Time.time;
        }

        // always ignore contact
        return(false);
    }