当前位置: 首页>>代码示例>>C#>>正文


C# Projectile.GetComponent方法代码示例

本文整理汇总了C#中Projectile.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Projectile.GetComponent方法的具体用法?C# Projectile.GetComponent怎么用?C# Projectile.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Projectile的用法示例。


在下文中一共展示了Projectile.GetComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Shoot

 public void Shoot()
 {
      Vector3 offset;
      laser = Instantiate(laserObject, transform.position, transform.rotation) as Projectile;
      laser.GetComponent<Rigidbody2D>().velocity = (direction * projectileSpeed);
      laserCD = 0;
 }
开发者ID:pmer,项目名称:zombie-ninja-attack-craft,代码行数:7,代码来源:Cyclops.cs

示例2: StateChanged

    protected override void StateChanged() {
        switch((EntityState)prevState) {
            case EntityState.Normal:
                CancelInvoke(activeFunc);
                //CancelInvoke(fireStartFunc);
                mFiring = false;

                Blink(0);
                if(projInactiveInvul) stats.isInvul = false;
                bodySpriteCtrl.StopOverrideClip();
                break;
        }

        base.StateChanged();

        switch((EntityState)state) {
            case EntityState.Normal:
                CancelInvoke(activeFunc);
                //CancelInvoke(fireStartFunc);
                mFiring = false;

                if(!mRock) {
                    Vector3 rockPos = transform.position;
                    rockPos.y += rockYOfs;
                    mRock = Projectile.Create(projGroup, rockProjType, rockPos, Vector3.zero, null);

                    mRockCtrl = mRock.GetComponent<PlatformerController>();
                    mRockBlinkDelay = mRock.GetComponent<EntityBlinkDelay>();

                    bodySpriteCtrl.controller = mRockCtrl;

                    if(rollerDieDelayOverride) {
                        mRock.dieBlink = false;
                        mRock.dieDelay = 0.0f;
                    }
                }

                mRockCtrl.dirHolder = transform;
                mRockCtrl.moveSideLock = true;
                mRockCtrl.moveSide = defaultMoveSide;

                if(mRockBlinkDelay)
                    mRockBlinkDelay.enabled = false;

                if(mSensor) {
                    mSensor.Activate(true);
                }

                if(!string.IsNullOrEmpty(projType)) {
                    if(mPlayers == null)
                        mPlayers = GameObject.FindGameObjectsWithTag("Player");

                    InvokeRepeating(activeFunc, 0, projActiveCheckDelay);

                    if(projInactiveInvul) stats.isInvul = true;
                    if(!string.IsNullOrEmpty(projInactiveClip))
                        bodySpriteCtrl.PlayOverrideClip(projInactiveClip);
                }
                    //Invoke(fireStartFunc, projStartDelay);
                break;

            case EntityState.Stun:
                mRockCtrl.moveSide = 0.0f;
                break;

            case EntityState.Dead:
                if(mRock && mRock.isAlive) {
                    if(rollerDieDelayOverride) {
                        if(mRockBlinkDelay) {
                            mRockBlinkDelay.delay = rollerDieDelay - rollerDieBlinkDelay;
                            mRockBlinkDelay.enabled = true;
                        }
                        else {
                            mRock.dieBlink = true;
                        }

                        mRock.dieDelay = rollerDieDelay;
                    }

                    if(mRock.stats)
                        mRock.stats.curHP = 0;
                    else
                        mRock.state = (int)Projectile.State.Dying;

                    mRock = null;
                }

                if(mSensor) {
                    mSensor.Activate(false);
                }

                bodySpriteCtrl.controller = null;
                break;

            case EntityState.RespawnWait:
                if(mRock && !mRock.isReleased) {
                    mRock.Release();
                    mRock = null;
                    mRockCtrl = null;
                    mRockBlinkDelay = null;
//.........这里部分代码省略.........
开发者ID:PushoN,项目名称:game-off-2013,代码行数:101,代码来源:EnemyCatRoller.cs


注:本文中的Projectile.GetComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。