示例#1
0
        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;
        }
示例#2
0
 public BrainPool(SpaceshipBrain brain, Transform factory)
 {
     brains = new List <SpaceshipBrain>(1);
     brains.Add(brain);
     nextIndex    = 0;
     this.factory = factory;
 }
示例#3
0
 private void Reset(SpaceshipBrain brain)
 {
     this.brain = brain;
     this.brain.Activate(this);
     health         = INITIAL_HEALTH;
     energy         = INITIAL_ENERGY;
     isShieldUp     = false;
     shotCooldown   = 0;
     turnsToRespawn = 0;
 }
示例#4
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();
            }
示例#5
0
            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);
            }