コード例 #1
0
ファイル: Player.cs プロジェクト: SirGFM/UnicornJoust
    /**
     * Try to hit this player
     *
     * This function may also be used to heal it
     *
     * @param  [ in]dmg Amount of damage to be dealt
     * @return          Whether the player was actually hit
     */
    public bool hit(BaseCollision col)
    {
        /* Check if collision did actually happen */
        if (this._curInvulnerability > 0.0f)
        {
            return(false);
        }
        if (col.damage == 0)
        {
            return(false);
        }
        /* Apply damage/heal */
        this._curHealth -= col.damage;
        /* Only set invulnerability on damage */
        if (col.damage > 0)
        {
            this._curInvulnerability += this.invulnerability;
        }
        /* If we were hit by a lance, pushback */
        if (col.CompareTag("lance"))
        {
            Rigidbody2D other = col.GetComponentInParent <Rigidbody2D>();
            if (other != null)
            {
                this.pushback(other.velocity);
            }
        }

        return(true);
    }
コード例 #2
0
    void OnTriggerStay(Collider other)
    {
        // Debug.Log(string.Format("Entity {0} touched other: {1}", this.collider.name, other.name));

        BaseCollision collision = other.GetComponent <BaseCollision>();

        // tell this entity that someone else touched it
        if (collision is EntityCollision)
        {
            EntityCollision entityCollision = (EntityCollision)collision;
            entity.TouchedByEntity(entityCollision.entity);
        }
        // tell this entity that some one else's weapon touched it
        else if (collision is WeaponCollision)
        {
            WeaponCollision weaponCollision = (WeaponCollision)collision;
            entity.TouchedByWeapon(weaponCollision.weapon);
        }
        else if (collision is WallCollision)
        {
            entity.TouchedByWall(other);
        }
        else if (collision is PotCollision)
        {
            PotCollision potCollision = (PotCollision)collision;
            entity.TouchedByPot(potCollision.pot);
        }
    }
コード例 #3
0
ファイル: Jump.cs プロジェクト: resultant-gamedev/honest-abe
 private void Start()
 {
     _collision      = GetComponent <BaseCollision>();
     _movement       = GetComponent <Movement>();
     _animator       = GetComponent <Animator>();
     _characterState = GetComponent <CharacterState>();
     SetState(State.Null);
 }
コード例 #4
0
 private void Awake()
 {
     _collision   = GetComponent <BaseCollision>();
     _collider    = GetComponent <BoxCollider2D>();
     _chainAttack = GetComponentInParent <ChainAttack>();
     _attack      = GetComponentInParent <Attack>();
     _player      = GameObject.Find("Player");
 }
コード例 #5
0
 private void Awake()
 {
     animator        = GetComponent <Animator> ();
     sound           = GetComponent <SoundPlayer>();
     _characterState = GetComponent <CharacterState>();
     _collision      = GetComponent <BaseCollision>();
     swipe           = GetComponentInChildren <Swipe>(true);
     lightDuration   = prepLightAttackTime + lightAttackTime + finishLightAttackTime;
     heavyDuration   = prepHeavyAttackTime + heavyAttackTime + finishHeavyAttackTime;
 }
コード例 #6
0
ファイル: Stun.cs プロジェクト: resultant-gamedev/honest-abe
 private void Awake()
 {
     _collision       = GetComponent <BaseCollision>();
     _characterState  = GetComponent <CharacterState>();
     _knockdown       = GetComponent <KnockDown>();
     _jump            = GetComponent <Jump>();
     _animator        = GetComponent <Animator>();
     genericAnimation = GetComponent <GenericAnimation>();
     random           = new System.Random();
 }
コード例 #7
0
 public override void Start()
 {
     timer                  = 0;
     duration               = 2.5f;
     player                 = GameObject.Find("Player");
     baseCollision          = self.GetComponent <BaseCollision> ();
     movement               = self.GetComponent <Movement> ();
     enemyFollow            = self.GetComponent <EnemyFollow> ();
     enemyFollow.targetType = EnemyFollow.TargetType.Null;
     camera                 = GameObject.Find("Main Camera").GetComponent <Camera>();
 }
コード例 #8
0
    override public void Start()
    {
        player                = GameObject.Find("Player");
        enemyFollow           = self.GetComponent <EnemyFollow> ();
        layerMask             = LayerMask.GetMask("Environment");
        baseCollision         = self.GetComponent <BaseCollision> ();
        movement              = self.GetComponent <Movement> ();
        diagonalMovementSpeed = (movement.horizontalMovementSpeed + movement.vericalMovementSpeed) / 2;

        // Stop following
        enemyFollow.targetType = EnemyFollow.TargetType.Null;
    }
コード例 #9
0
    private void Awake()
    {
        _animator   = GetComponent <Animator>();
        _movement   = GetComponent <Movement>();
        _movementAI = GetComponent <EnemyFollow>();

        _collision      = GetComponent <BaseCollision>();
        _characterState = GetComponent <CharacterState>();
        _knockDown      = GetComponent <KnockDown>();
        _myLayer        = gameObject.layer;
        _blackboard     = GetComponent <Blackboard> ();

        wasThrown = false;
    }
コード例 #10
0
    void OnCollisionEnter2D(Collision2D otherCol)
    {
        BaseCollision other = otherCol.collider.GetComponent <BaseCollision>();

        if (other != null)
        {
            this.self.hit(other);
            if (!this.self.isAlive())
            {
                //Play death animation 1 (explosion)
                self.die();
            }
            return;
        }
    }
コード例 #11
0
    public override void Start()
    {
        enemyFollow           = self.GetComponent <EnemyFollow> ();
        baseCollision         = self.GetComponent <BaseCollision> ();
        movement              = self.GetComponent <Movement> ();
        diagonalMovementSpeed = (movement.horizontalMovementSpeed + movement.vericalMovementSpeed) / 2;
        layerMask             = LayerMask.GetMask("Player");

        // Find my target and stop following it
        target = enemyFollow.target;
        if (target == null)
        {
            Debug.Log("Error: Called NavigateToPosition without a target position");
        }
        enemyFollow.targetType = EnemyFollow.TargetType.Null;
    }
コード例 #12
0
    void OnCollisionEnter2D(Collision2D otherCol)
    {
        BaseCollision other = otherCol.collider.GetComponent <BaseCollision>();

        if (other != null)
        {
            this.self.hit(other);
            if (!this.self.isAlive())
            {
                this.self.disableJount();
                this.detach();
            }

            return;
        }
    }
コード例 #13
0
 void Start()
 {
     _movement  = GetComponent <Movement>();
     _jump      = GetComponent <Jump>();
     _collision = GetComponent <BaseCollision>();
     _collision.OnCollisionEnter += OnCollisionStart;
     _collision.OnCollisionStay  += OnCollisionUpdate;
     _collision.OnCollisionExit  += OnCollisionEnd;
     _controls       = GetComponent <PlayerControls>();
     _playerAttack   = GetComponent <Attack>();
     _gameManager    = GameObject.Find("GameManager").GetComponent <GameManager>();
     _characterState = GetComponent <CharacterState>();
     _grabber        = GetComponent <Grabber>();
     _animator       = GetComponent <Animator>();
     isOnItem        = false;
     Initialize();
 }
コード例 #14
0
ファイル: PotCollision.cs プロジェクト: nsparisi/n3-games
    void OnTriggerStay(Collider other)
    {
        BaseCollision collision = other.GetComponent <BaseCollision>();

        if (collision is EntityCollision)
        {
            EntityCollision entityCollision = (EntityCollision)collision;
            pot.TouchedByEntity(entityCollision.entity);
        }

        else if (collision is WeaponCollision)
        {
            WeaponCollision weaponCollision = (WeaponCollision)collision;
            pot.TouchedByWeapon(weaponCollision.weapon);
        }

        else if (collision is WallCollision)
        {
            pot.TouchedByWall();
        }
    }
コード例 #15
0
ファイル: WeaponCollision.cs プロジェクト: nsparisi/n3-games
    void OnTriggerStay(Collider other)
    {
        // tell the this weapon's owner that another weapon touched it.
        BaseCollision collision = other.GetComponent <BaseCollision>();

        if (collision is WeaponCollision)
        {
            WeaponCollision weaponCollision = (WeaponCollision)collision;
            weapon.owner.WeaponTouchedByWeapon(weaponCollision.weapon);
        }

        // tell the this weapon's owner that someone touched it.
        else if (collision is EntityCollision)
        {
            EntityCollision entityCollision = (EntityCollision)collision;
            weapon.owner.WeaponTouchedByEntity(entityCollision.entity);
        }

        else if (collision is PotCollision)
        {
            PotCollision potCollision = (PotCollision)collision;
            weapon.owner.WeaponTouchedByPot(potCollision.pot);
        }
    }
コード例 #16
0
    public static void TraceAll(HitTest test, List <TraceInfo> traces, int layerMask = -5)
    {
        if (CFG.Setting.grass12)
        {
            layerMask &= CFG.Setting.grass ? -1073741825 : -5;
        }
        layerMask &= CFG.Setting.grass ? -8388609 : -5;
        layerMask &= CFG.Setting.grass ? -65537 : -5;

        if (CFG.Setting.grass ? test.HitMaterial != "Flesh" : true)
        {
            List <RaycastHit> list        = Facepunch.Pool.GetList <RaycastHit>();
            Vector3           origin      = test.AttackRay.origin;
            Vector3           direction   = test.AttackRay.direction;
            float             maxDistance = test.MaxDistance;
            float             radius      = test.Radius;
            if ((layerMask & 16384) != 0)
            {
                layerMask &= -16385;
                GamePhysics.TraceAllUnordered(new Ray(origin - direction * 5f, direction), radius, list, maxDistance + 5f, 16384, QueryTriggerInteraction.UseGlobal);
                for (int i = 0; i < list.Count; i++)
                {
                    RaycastHit raycastHit = list[i];
                    raycastHit.distance -= 5f;
                    list[i]              = raycastHit;
                }
            }
            GamePhysics.TraceAllUnordered(new Ray(origin, direction), radius, list, maxDistance, layerMask, QueryTriggerInteraction.UseGlobal);
            for (int j = 0; j < list.Count; j++)
            {
                RaycastHit hit      = list[j];
                Collider   collider = hit.GetCollider();
                if (!collider.isTrigger)
                {
                    ColliderInfo component = collider.GetComponent <ColliderInfo>();
                    if (!component || component.Filter(test))
                    {
                        BaseCollision component2 = collider.GetComponent <BaseCollision>();
                        if (component2 != null)
                        {
                            component2.TraceTest(test, traces);
                        }
                        else if (hit.distance > 0f)
                        {
                            TraceInfo traceInfo = default(TraceInfo);
                            traceInfo.valid    = true;
                            traceInfo.distance = hit.distance;
                            traceInfo.partID   = 0U;
                            traceInfo.point    = hit.point;
                            traceInfo.normal   = hit.normal;
                            traceInfo.collider = collider;
                            traceInfo.material = collider.GetMaterialAt(hit.point);
                            traceInfo.entity   = collider.gameObject.ToBaseEntity();
                            traceInfo.bone     = Model.GetTransform(collider.transform, hit.point, traceInfo.entity);
                            if (!traceInfo.entity || (traceInfo.entity.isClient && traceInfo.entity != test.ignoreEntity))
                            {
                                traces.Add(traceInfo);
                            }
                        }
                    }
                }
            }
            traces.Sort((TraceInfo a, TraceInfo b) => a.distance.CompareTo(b.distance));
            Facepunch.Pool.FreeList <RaycastHit>(ref list);
        }
    }
コード例 #17
0
 private void Start()
 {
     _collision = this.GetComponentInParent <BaseCollision>();
 }
コード例 #18
0
 void Awake()
 {
     collision = GetComponent <BaseCollision>();
     sound     = GetComponent <SoundPlayer>();
 }
コード例 #19
0
 private void Awake()
 {
     _characterState = GetComponent <CharacterState>();
     _collision      = GetComponent <BaseCollision>();
     SetDirection(direction, true);
 }
コード例 #20
0
 private void Awake()
 {
     _collision     = GetComponent <BaseCollision>();
     _damageElapsed = damageInterval;
 }
コード例 #21
0
 void Awake()
 {
     _collision = this.GetOrAddComponent <BaseCollision>();
     _child     = transform.GetChild(0);
 }
コード例 #22
0
ファイル: CharacterCore.cs プロジェクト: moien007/TeeSharp
 public virtual void Init(WorldCore worldCore, BaseCollision collision)
 {
     World     = worldCore;
     Collision = collision;
 }