Example #1
0
        private Entity BulletBase(int mX, int mY, float mDegrees, int mSpeed, string mTextureName, bool mEnemy)
        {
            var result = new Entity(_manager);

            var cBody = Body(new SSVector2I(mX, mY), 250, 250);
            var cMovement = Movement(cBody);
            var cRender = Render(cBody, mTextureName);

            cBody.Body.AddGroupsToCheck(Groups.Obstacle, Groups.Character);
            cBody.Body.AddGroupsToIgnoreResolve(Groups.Obstacle, Groups.Character);
            cBody.OnCollision += (mCollisionInfo) =>
                                 {
                                     var entity = (Entity) mCollisionInfo.UserData;
                                     var cHealth = entity.GetComponent<CHealth>();

                                     if (entity.HasTag(Tags.DamagedByAny))
                                     {
                                         cHealth.Health--;
                                         result.Destroy();
                                     }
                                     else if (result.HasTag(Tags.BulletFriendly) &&
                                              entity.HasTag(Tags.DamagedByFriendly))
                                     {
                                         cHealth.Health--;
                                         result.Destroy();
                                     }
                                     else if (result.HasTag(Tags.BulletEnemy) &&
                                              entity.HasTag(Tags.DamagedByEnemy))
                                     {
                                         cHealth.Health--;
                                         result.Destroy();
                                     }

                                     if (entity.HasTag(Tags.DestroysBullets)) result.Destroy();
                                 };

            cMovement.Angle = mDegrees;
            cMovement.Speed = mSpeed;

            cRender.Torque = 8;

            result.AddComponents(cBody, cMovement, cRender);
            result.AddTags(Tags.Bullet);

            return result;
        }
	public void AddDecal(Vector3 point, Vector3 normal, string tag, Entity target)
	{
		if(normal == Vector3.zero) { return; }

		if (tag == "Wall")
		{
			float size = 0.07f + Random.Range (0f, 0.02f);
			Quaternion q = Quaternion.LookRotation (-normal);

			particleBulletPool[nextParticleBullet].transform.position = point;
			particleBulletPool[nextParticleBullet].transform.eulerAngles = new Vector3(q.eulerAngles.x - 90f, q.eulerAngles.y, q.eulerAngles.z);
			particleBulletPool[nextParticleBullet].init();
			nextParticleBullet++;
			if(nextParticleBullet >= particleBulletPoolLength) { nextParticleBullet = 0; }

			q.eulerAngles = new Vector3 (q.eulerAngles.x, q.eulerAngles.y, q.eulerAngles.z + UnityEngine.Random.Range (0f, 360f));
			verts [nextPool * 4] = point + (q * (Vector3.left * size)) + (q * (Vector3.up * size)) + q * (Vector3.back * 0.01f);
			verts [nextPool * 4 + 1] = point + (q * (Vector3.right * size)) + (q * (Vector3.up * size)) + q * (Vector3.back * 0.01f);
			verts [nextPool * 4 + 2] = point + (q * (Vector3.left * size)) + (q * (Vector3.down * size)) + q * (Vector3.back * 0.01f);
			verts [nextPool * 4 + 3] = point + (q * (Vector3.right * size)) + (q * (Vector3.down * size)) + q * (Vector3.back * 0.01f);
			nextPool = nextPool >= poolLenght - 1 ? 0 : nextPool + 1;
			meshUpdated = true;
		} 
		else if(tag == "Obstacle")
		{
			Quaternion q = Quaternion.LookRotation(-normal);

			particleBulletPool[nextParticleBullet].transform.position = point;
			particleBulletPool[nextParticleBullet].transform.eulerAngles = new Vector3(q.eulerAngles.x - 90f, q.eulerAngles.y, q.eulerAngles.z);
			particleBulletPool[nextParticleBullet].init();
			nextParticleBullet++;
			if(nextParticleBullet >= particleBulletPoolLength) { nextParticleBullet = 0; }
		}
		else if((tag == "Body" || tag == "Head" || tag == "Limbs") && target.HasTag("Enemy"))
		{
			Quaternion q = Quaternion.LookRotation (-normal);
			particleBloodPool [nextParticleBlood].transform.position = point;
			particleBloodPool [nextParticleBlood].transform.eulerAngles = new Vector3 (q.eulerAngles.x - 90f, q.eulerAngles.y, q.eulerAngles.z);
			particleBloodPool [nextParticleBlood].init ();
			nextParticleBlood++;
			if (nextParticleBlood >= particleBloodPoolLength) { nextParticleBlood = 0; }
		}
	}
Example #3
0
        private Entity SporeBase(int mX, int mY, float mDegrees, int mSpeed, string mTextureName, bool mEnemy)
        {
            var result = new Entity(_manager);

            var cBody = Body(new SSVector2I(mX, mY), 250, 250);
            var cMovement = Movement(cBody);
            var cRender = Render(cBody, mTextureName);

            cBody.Body.AddGroupsToCheck(Groups.Obstacle, Groups.Character);
            cBody.Body.AddGroupsToIgnoreResolve(Groups.Obstacle, Groups.Character);
            cBody.OnCollision += (mCollisionInfo) =>
                                 {
                                     var entity = (Entity)mCollisionInfo.UserData;

                                     var cHealth = entity.GetComponent<CHealth>();

                                     if (result.HasTag(Tags.SporeBlack) && entity.HasTag(Tags.DamagedByWhite))
                                     {
                                         cHealth++;
                                         result.Destroy();
                                     }
                                     else if (result.HasTag(Tags.SporeWhite) && entity.HasTag(Tags.DamagedByBlack))
                                     {
                                         cHealth++;
                                         result.Destroy();
                                     }

                                     if (entity.HasTag(Tags.DestroysBullets)) result.Destroy();
                                 };

            cMovement.Angle = mDegrees;
            cMovement.Speed = mSpeed;
            cMovement.Acceleration = -0.1f;

            cRender.Torque = 8;

            result.AddComponents(cBody, cMovement, cRender);
            result.AddTags(Tags.Spore);

            cRender.Sprite.Color = new Color(255, 255, 255, 125);

            return result;
        }