// Use this for initialization void Awake() { Movement = GetComponent <MovementComponent>(); Shot = GetComponent <ShotComponent>(); Stats = GetComponent <StatsComponent>(); StatsComponent[] characters = FindObjectsOfType <StatsComponent>(); if (characters[0] != Stats) { OtherStats = characters[0]; } else { OtherStats = characters[1]; } }
private void createBulletEffect(ShotComponent bullet, Vector2 normal) { if (bullet == null) { return; } var effect = bullet.entity.scene.createEntity($"effect:playerComponent({getEffectsCount()})"); var sprite = effect.addComponent(new AnimatedSprite(_bullectEffectTexture, "default")); sprite.CreateAnimation("default", 0.08f, false); sprite.AddFrames("default", new List <Rectangle>() { new Rectangle(0, 0, 10, 17), new Rectangle(10, 0, 10, 17), new Rectangle(20, 0, 10, 17), }); var bulletSprite = bullet.getComponent <AnimatedSprite>(); sprite.spriteEffects = bulletSprite.spriteEffects; var collider = bullet.entity.getComponent <BoxCollider>(); effect.position = new Vector2(collider.bounds.center.X, collider.bounds.bottom - sprite.height / 2); effect.addComponent <SpriteEffectComponent>(); var rotation = (float)Math.Atan2(normal.Y, normal.X); effect.rotation = rotation; if (sprite.getDirection() > 0) { effect.rotation = -rotation; } if (normal.Y != 0.0f) { effect.position += 3 * Vector2.UnitY; } if (normal.X == -1.0f) { sprite.flipX = true; effect.position += new Vector2(3 * sprite.getDirection(), 2); } }
public void Awake() { Movement = GetComponent <MovementComponent>(); Shot = GetComponent <ShotComponent>(); }
protected override void Awake() { base.Awake(); Shot = GetComponent <ShotComponent>(); }
private void Start() { _shotComponent = GetComponentInChildren <ShotComponent>(); Debug.Assert(_shotComponent != null, "Object must have a gun"); }