コード例 #1
0
	public override void HandleOnTargetHit(ProjectileEntity source, EntityComponent target)
	{
		base.HandleOnTargetHit(source, target);
		
		target.Damage(Magnitude, MyEntityComponent);		
		target.BroadcastMessage("BeingAttacked", this.MyEntityComponent);
	}
コード例 #2
0
ファイル: Projectile.cs プロジェクト: pb0/ID0_Test
    public Projectile(GameInstance parent, float initX, float initY, FieldObjectEntity objectField, ProjectileEntity objectProjectile)
        : base(parent.Rect.point.layer, initX, objectField, parent.ToLeft)
    {
        Move(new Vector2(0, initY));

        this.objectProjectile = objectProjectile;
        this.parent = parent;
    }
コード例 #3
0
	public virtual void HandleOnTargetHit(ProjectileEntity source, EntityComponent target)
	{
		//Apply our attack effects.
		if (target != null && target.Alive)
		{
			foreach (EntityModifier modifier in actionModifiers.Values)
			{
				modifier.DeepClone().Attach(target);
			}
		}		
		
		//Let any listeners know
		if (OnTargetHitEvent != null)
			OnTargetHitEvent(MyEntityComponent, MyActionManager.myBehaviorManager.CurrentTarget);
	}
コード例 #4
0
	public override void HandleOnTargetHit(ProjectileEntity source, EntityComponent target)
	{
		base.HandleOnTargetHit(source, target);
		
		Collider[] colliders = Physics.OverlapSphere(target.transform.position, Radius, layerMask);
		
		//Loop through all resulting colliders, seeing if we can snatch an EntityComponent from them that is of our target type
		//Then damage it if that is the case!
		foreach (Collider collider in colliders)
		{
			EntityComponent entity = collider.gameObject.GetComponent<EntityComponent>();
			
			if (entity != null && entity.GetType() == myTargetType)
			{
				entity.Damage(Magnitude, MyEntityComponent);		
				entity.BroadcastMessage("BeingAttacked", this.MyEntityComponent);				
			}			
		}		
	}
コード例 #5
0
	void HandleOnTargetHit(ProjectileEntity source, EntityComponent target)
	{
		//If it was hit by a projectile then unsubscribe from its event.
		if (source != null)
		{
			source.OnProjectileHitTargetEvent -= HandleOnTargetHit;
		}
		
		if (audioInfo.audioClipNames.ContainsKey("attackHit"))
			SoundEffectManager.PlayClipAtLocation(audioInfo.audioClipNames["attackHit"], target.transform.position);
		
		if (target != null && target.Alive)
			target.Damage(attackDamage, myEntityComponent);		
		
		//Apply our attack effects.
		if (target != null && target.Alive)
		{
			foreach (EntityModifier modifier in attackModifiers.Values)
			{
				modifier.DeepClone().Attach(target);
			}
		}
		
		if (OnTargetHitEvent != null)
			OnTargetHitEvent(myEntityComponent, target);
	}
コード例 #6
0
	protected static void SetProjectileSettings(ProjectileEntity projectile, XmlNode node)
	{		
		float speed = 10f, minDistanceToTarget = 10f;
		Vector2 projectileOffset = Vector2.zero;
		
		if (node.SelectSingleNode("./speed") != null)
		{
			float.TryParse(node.SelectSingleNode("./speed").InnerText, NumberStyles.Float, CultureInfo.InvariantCulture, out speed);	
		}
		
		if (node.SelectSingleNode("./minDistanceToTarget") != null)
		{
			float.TryParse(node.SelectSingleNode("./minDistanceToTarget").InnerText, NumberStyles.Float, CultureInfo.InvariantCulture, out minDistanceToTarget);	
		}
		
		if (node.SelectSingleNode("./offset") != null)
		{			
			float x = 0, y = 0;	
			
			float.TryParse(node.SelectSingleNode("./offset").Attributes["x"].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out x);
			float.TryParse(node.SelectSingleNode("./offset").Attributes["y"].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out y);
			
			projectileOffset = new Vector2(x, y);
		}
		
		projectile.speed = speed;
		projectile.minDistanceToTarget = minDistanceToTarget;
		projectile.FiringOffset = projectileOffset;
	}
コード例 #7
0
ファイル: Projectile.cs プロジェクト: pb0/ID0_Test
    public ProjectileCustom(GameInstance parent, float initX, float initY, FieldObjectEntity objectField, ProjectileEntity objectProjectile, Action2 action)
        : base(parent, initX, initY, objectField, objectProjectile)
    {
        List<VectorEntity> pattern = VectorGenerator.Custom(objectProjectile.speed, objectProjectile.speedY, objectProjectile.gravity, parent.ToLeft);
        //pattern.Add(new LinearVelocity(parent.Velocity));
        SetMove(pattern);

        InitAction(action);
    }