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


C# Projectile类代码示例

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


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

示例1: ProjectileAndAsteroidDisposedOnCollision

		public void ProjectileAndAsteroidDisposedOnCollision()
		{
			var projectile = new Projectile(new Vector2D(0.5f, 0.55f), 0);
			interactionLogic.CreateAsteroidsAtPosition(Vector2D.Half, 1, 1);
			AdvanceTimeAndUpdateEntities();
			Assert.IsFalse(projectile.IsActive);
		}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:7,代码来源:GameLogicTests.cs

示例2: CreateFromPositions

		public void CreateFromPositions()
		{
			var projectileFromPositions = new Projectile(Vector3D.Zero, Vector3D.UnitX,
				new PhysicalEntity3D());
			Assert.AreEqual(projectileFromPositions.Position, Vector3D.Zero);
			Assert.AreEqual(projectileFromPositions.Orientation, new Quaternion(-0.5f, 0.5f, 0.5f, 0.5f));
		}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:7,代码来源:ProjectileTests.cs

示例3: Get

 public Projectile Get(Projectile prefab)
 {
     Projectile p = CachePool<Projectile>.Instance.GetObjectOfType (prefab.GetType ().Name);
     if (p == null)
         p = Instantiate<Projectile> (prefab);
     return p;
 }
开发者ID:IAmEska,项目名称:PlanetShooter,代码行数:7,代码来源:ProjectileFactory.cs

示例4: CheckProjectile

    // Returns true on collision with a given bullet (regardless of owner)
    public new bool CheckProjectile(Projectile Bullet)
    {
        // Fast check: ignore all projectiles too far from the ship
        Vector2 turretBulletPos = Bullet.ProjectileSprite.GetPosition() - Position;
        if(turretBulletPos.magnitude > Sprite.GetGeometrySize().x)
            return false;

        // Second check: axis-align the bullet relative to the center of the ship

        // What is the rotation of the ship around the X-axis?
        float Theta = 0.0f;

        // Rotate (re-orient) the bullet position so that it is in the same coordinate-system
        // as the turret: using axis-alligned object transformation for simplified math
        // Essentially we are applying the reverse rotation, relative to the ship's rotational origin, so that
        // when we do the trivial "point in box" check, this is all axis-aligned
        Vector2 AlignedPos;
        AlignedPos.x = turretBulletPos.x * Mathf.Cos(-Theta) - turretBulletPos.y * Mathf.Sin(-Theta);
        AlignedPos.y = turretBulletPos.y * Mathf.Cos(-Theta) + turretBulletPos.x * Mathf.Sin(-Theta);

        // Get real-world turret size (note: turret position is the center of the volume, hence the div by 2)
        Vector2 turretSize = Sprite.GetGeometrySize();
        turretSize /= 2.0f;

        // Point-in-box check
        if(AlignedPos.x > -turretSize.x && AlignedPos.x < turretSize.x && AlignedPos.y < turretSize.y && AlignedPos.y > -turretSize.y)
            return true;
        else
            return false;
    }
开发者ID:nint22,项目名称:NovaLegacy,代码行数:31,代码来源:TurretBuilding.cs

示例5: Defeats

    public static bool Defeats(Projectile p1, Projectile p2)
    {
        ProjectileType type1 = p1.type;
        ProjectileType type2 = p2.type;

        return p1.caster != p2.caster && Defeats(type1, type2);
    }
开发者ID:RPITeamTree,项目名称:Spelleo_RGS2015,代码行数:7,代码来源:Projectile.cs

示例6: OnGUI

    void OnGUI()
    {
        MainWindowWidth = position.width;
        MainWindowHeight = position.height;
        GameObject selectedGameObject = Selection.activeGameObject;
        if (selectedGameObject == null)
        {
            Debug.LogWarning("No gameObject is selected.");
            return;
        }
        //Attach Projectile script button
        if (selectedGameObject.GetComponent<Projectile>() == null)
        {
            Rect newAIScriptButton = new Rect(0, 0, MainWindowWidth - 10, 30);
            if (GUI.Button(newAIScriptButton, "Attach Projectile script"))
            {
                selectedGameObject.AddComponent<Projectile>();
            }
            return;
        }
        Projectile = selectedGameObject.GetComponent<Projectile>();

        if (GUILayout.Button("Save object"))
        {
            EditorUtility.SetDirty(Projectile);
        }

        ScrollPosition = EditorGUILayout.BeginScrollView(ScrollPosition, false, true, null);
        EditProjectileObject();
        EditorGUILayout.EndScrollView();
    }
开发者ID:hiyouke,项目名称:colonist,代码行数:31,代码来源:ProjectileEditor.cs

示例7: Draw

	public override void Draw(SpriteBatch sb, Projectile p) {
		Vector2 pc = p.position+new Vector2(p.width/2f,p.height/2f);
		
		if (fired) {
			sb.End();
			sb.Begin(SpriteSortMode.Immediate,BlendState.Additive);
			
			foreach (Spark spark in sparks) spark.Draw(sb,p,this);
			for (int i = 0; i < sparks.Count; i++) if (sparks[i].dead) sparks.RemoveAt(i--);
			
			sb.End();
			sb.Begin();
			
			if (sparks.Count == 0) p.Kill();
		} else {
			fired = true;
			
			int r, g, b;
			Color c;
			float degrees;
			
			byte[] bytes = BitConverter.GetBytes(seed);
			Random rnd = new Random();
			
			degrees = (float)(rnd.NextDouble()*360d);
			HsvToRgb(bytes[0]*360f/255f,bytes[1]/255f,1f,out r,out g,out b);
			c = new Color(r,g,b);
			for (int i = 0; i < 20; i++) sparks.Add(new MySpark(pc,Util.Vector((float)(1.5f+rnd.NextDouble()*.75f),360f/20f*i+degrees),c,80+rnd.Next(40)));
			
			degrees = (float)(rnd.NextDouble()*360d);
			HsvToRgb(bytes[2]*360f/255f,bytes[3]/255f,1f,out r,out g,out b);
			c = new Color(r,g,b);
			for (int i = 0; i < 40; i++) sparks.Add(new MySpark(pc,Util.Vector((float)(3f+rnd.NextDouble()*1.5f),360f/40f*i+degrees),c,80+rnd.Next(40)));
		}
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:35,代码来源:FireworkTwoWave.cs

示例8: Spawn

 public static void Spawn(Projectile prefab, Vector3 pos,Vector2 force, Transform target)
 {
     Projectile t = Instantiate(prefab);
     t.transform.position = pos;
     t.GetComponent<Rigidbody2D>().AddForce(force);
     t.target = target;
 }
开发者ID:peperbol,项目名称:BuildingHorizon,代码行数:7,代码来源:Projectile.cs

示例9: LoadContent

        protected override void LoadContent(ContentManager theContentManager, GraphicsDevice theGraphicsDevice)
        {
            mPShipSprite = new PShip();
            mProjectileSprite = new Projectile();

            //Initialize and add the background images to the Scrolling background. You can change the
            //scroll area by passing in a different Viewport. The images will then scale and scroll within
            //that given Viewport.
            mScrollingBackground = new VerticallyScrollingBackground(theGraphicsDevice.Viewport);
            mScrollingBackground.AddBackground("Background1");
            mScrollingBackground.AddBackground("Background2");
            mScrollingBackground.AddBackground("Background3");
            mScrollingBackground.AddBackground("Background4");
            mScrollingBackground.AddBackground("Background5");
            mScrollingBackground.AddBackground("Background6");
            mScrollingBackground.AddBackground("Background7");
            mScrollingBackground.AddBackground("Background8");
            mScrollingBackground.AddBackground("Background9");

            //Load the content for the Scrolling background
            mScrollingBackground.LoadContent(theContentManager);

            mProjectileSprite.LoadContent(theContentManager);
            mPShipSprite.LoadContent(theContentManager);
        }
开发者ID:Gevil,项目名称:Projects,代码行数:25,代码来源:GameScreen.cs

示例10: CreateProjectile

    protected override Projectile CreateProjectile(int chargeInd, Transform seek) {
        if(chargeInd == starLargeIndex) {
            if(mLastLargeStar && !mLastLargeStar.isReleased) {
                mLastLargeStar.Release();
                mLastLargeStar = null;
            }

            string type = charges[chargeInd].projType;
            if(!string.IsNullOrEmpty(type)) {
                Vector3 _pt = starLargeAttach.position, _dir = dir;

                _pt.z = 0.0f;

                if(angle != 0.0f) {
                    _dir = Quaternion.Euler(new Vector3(0, 0, Mathf.Sign(_dir.x)*angle))*_dir;
                }

                mLastLargeStar = Projectile.Create(projGroup, type, _pt, _dir, seek);
                if(mLastLargeStar) {
                    mCurProjCount++;
                    mLastLargeStar.releaseCallback += OnProjRelease;
                }
            }

            return mLastLargeStar;
        }
        else {
            return base.CreateProjectile(chargeInd, seek);
        }
    }
开发者ID:PushoN,项目名称:game-off-2013,代码行数:30,代码来源:WeaponStarGazer.cs

示例11: Start

    void Start()
    {
        m_projectile = GetComponent<Projectile>();
        m_rigidbody = GetComponent<Rigidbody>();

        m_rigidbody.velocity = transform.forward * ShotSpeed;
    }
开发者ID:4026,项目名称:ld30,代码行数:7,代码来源:RocketController.cs

示例12: Player

            public Player(WurmsGame parent, Texture2D tex, Vector2 pos)
                : base(parent, pos)
            {
                this._worldPosition = pos;
                this._sprite = new Sprite(tex, this._parent._spriteBatch, this._worldPosition);
                this._inputEnabled = true;
                this._inputToggles = new Dictionary<string, bool>();
                this._inputToggles["move_left"] = true;
                this._inputToggles["move_right"] = true;
                this._inputToggles["jump"] = true;
                this._applyGravity = true;
                this._keyboardState = Keyboard.GetState();
                this._mouseState = Mouse.GetState();
                this._projectiles = new Dictionary<string, Projectile>();

                this._bulletAmmo = 10;
                this._rocketAmmo = 5;
                this._nextBullet = 0;
                this._nextRocket = 0;
                this._currentWeaponType = "BULLETS";

                for (int i = 0; i < this._bulletAmmo; i++)
                {
                    this._projectiles["BULLETS_" + i] = new Projectile(this._parent, this._parent.Content.Load<Texture2D>("Bullet"), new Vector2(-100.0f, -100.0f), 3, 5);
                }
                for (int i = 0; i < this._rocketAmmo; i++)
                {
                    this._projectiles["ROCKETS" + i]  = new Projectile(this._parent, this._parent.Content.Load<Texture2D>("Rocket"), new Vector2(-200.0f, -100.0f), 5, 3);
                }
                this._nextProjectile = this._projectiles["BULLETS_0"];
            }
开发者ID:Kmann180,项目名称:WormsRemake,代码行数:31,代码来源:Player.cs

示例13: CreateProjectile

    protected override Projectile CreateProjectile(int chargeInd, Transform seek) {
        if(chargeInd == 0) {
            if(mLastClone) {
                //detonate
                if(mLastClone.state == (int)Projectile.State.Active || mLastClone.state == (int)Projectile.State.Seek) {
                    if(mLastClone.stats)
                        mLastClone.stats.curHP = 0;
                    else
                        mLastClone.state = (int)Projectile.State.Dying;

                    mLastClone = null;
                    activeGO.SetActive(false);
                }
                return null;
            }
            else {
                mLastClone = base.CreateProjectile(chargeInd, seek);

                activeGO.SetActive(mLastClone != null);

                return mLastClone;
            }
        }

        return base.CreateProjectile(chargeInd, seek);
    }
开发者ID:PushoN,项目名称:game-off-2013,代码行数:26,代码来源:WeaponCloner.cs

示例14: Main

        public override IEnumerable<TickTimer> Main()
        {
            StartCooldown(EvalTag(PowerKeys.CooldownTime));
            UsePrimaryResource(EvalTag(PowerKeys.ResourceCost));
            int numProjectiles = Rune_B > 0 ? (int)ScriptFormula(4) : 1;
            for (int n = 0; n < numProjectiles; ++n)
            {
                if (Rune_B > 0)
                    yield return WaitSeconds(ScriptFormula(17));

                var proj = new Projectile(this,
                                          RuneSelect(107011, 107030, 107035, 107223, 107265, 107114),
                                          User.Position);
                proj.Position.Z += 3f;
                proj.OnCollision = (hit) =>
                {
                    // TODO: fix positioning of hit actors. possibly increase model scale? 
                    SpawnEffect(RuneSelect(112327, 112338, 112327, 112345, 112347, 112311), proj.Position);

                    proj.Destroy();

                    if (Rune_E > 0 && Rand.NextDouble() < ScriptFormula(11))
                        hit.PlayEffectGroup(107163);

                    if (Rune_A > 0)
                        WeaponDamage(hit, ScriptFormula(2), DamageType.Fire);
                    else
                        WeaponDamage(hit, ScriptFormula(0), DamageType.Poison);
                };
                proj.Launch(TargetPosition, 1f);
            }
        }
开发者ID:vrobel,项目名称:mooege,代码行数:32,代码来源:WitchDoctor.cs

示例15: hurt

 public void hurt(Projectile p)
 {
     base.blinkRed();
     health -= p.giveDamage();
     if(health <= 0)
         die(this.gameObject);
 }
开发者ID:TheFracker,项目名称:Wrahh,代码行数:7,代码来源:Lobster.cs


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