public void Activate( Vector2 position, float angle, Space.Mutable space) { Position = position; Rotation = angle; brain = GetComponent <SpaceshipBrain>(); DebugUtils.Assert( brain != null, name + " does not have a brain!\n" + "Did you add the _SpaceshipTemplate_ to the scene " + "or forgot to add your brain script to the prefab?"); space.RegisterSpaceship(this, brain); name = brain.Name; // Set visuals. var imagesConfig = Game.spaceshipImages[brain.BodyType]; primaryImage.sprite = imagesConfig.primaryImage; secondaryImage.sprite = imagesConfig.secondaryImage; primaryColor = NormalizeColor(brain.PrimaryColor); primaryImage.color = primaryColor; var shieldColor = primaryColor / primaryColor.maxColorComponent; shieldColor.a = 0.3f; shieldImage.color = shieldColor; }
public BrainPool(SpaceshipBrain brain, Transform factory) { brains = new List <SpaceshipBrain>(1); brains.Add(brain); nextIndex = 0; this.factory = factory; }
private void Reset(SpaceshipBrain brain) { this.brain = brain; this.brain.Activate(this); health = INITIAL_HEALTH; energy = INITIAL_ENERGY; isShieldUp = false; shotCooldown = 0; turnsToRespawn = 0; }
public void Activate(Spaceship spaceship, SpaceshipBody body, SpaceshipBrain brain) { base.Activate(spaceship, body); this.obj.Reset(brain); var shipBody = (SpaceshipBody)obj.body; var main = shipBody.energyEmitter.main; main.maxParticles = 20; ShieldDown(); }
public void RegisterSpaceship(SpaceshipBody body, SpaceshipBrain brain) { var spaceship = Space.spaceshipsPool.Borrow(); var spaceshipMutable = Space.spaceshipMutablesPool.Borrow(); spaceshipMutable.Activate(spaceship, body, brain); DebugUtils.Log("RegisterSpaceship " + spaceship.Name); Space.spaceships.Add(spaceship); Space.spaceshipMutables.Add(spaceshipMutable); }