Ejemplo n.º 1
0
 public void subscribeOnTriggerExit(PlayerTrigger aCallback)
 {
     if (aCallback != null)
     {
         onTriggerExit += aCallback;
     }
 }
Ejemplo n.º 2
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform     transform = entity.GetOrCreate <Transform>("Transform");
            PlayerTrigger trigger   = entity.GetOrCreate <PlayerTrigger>("PlayerTrigger");

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main).EditorProperties();

            MapExit mapExit = entity.GetOrCreate <MapExit>("MapExit");

            trigger.Add(new TwoWayBinding <Vector3>(transform.Position, trigger.Position));
            trigger.Add(new CommandBinding(trigger.PlayerEntered, (Action)mapExit.Go));

            trigger.EditorProperties();
            entity.Add("OnEnter", trigger.PlayerEntered);
            entity.Add("Enable", trigger.Enable);
            entity.Add("Enabled", trigger.Enabled);
            entity.Add("Disable", trigger.Disable);
            entity.Add("NextMap", mapExit.NextMap, new PropertyEntry.EditorData
            {
                Options = FileFilter.Get(main, main.MapDirectory, null, MapLoader.MapExtension, delegate()
                {
                    return(new[] { Main.MenuMap });
                }),
            });
            entity.Add("StartSpawnPoint", mapExit.StartSpawnPoint);
        }
Ejemplo n.º 3
0
        public override void AttachEditorComponents(Entity entity, Main main)
        {
            base.AttachEditorComponents(entity, main);

            VoxelAttachable.AttachEditorComponents(entity, main, entity.Get <Model>().Color);
            PlayerTrigger.AttachEditorComponents(entity, main, entity.Get <Model>().Color);
        }
Ejemplo n.º 4
0
 public void unsubscribeOnTriggerStay(PlayerTrigger aCallback)
 {
     if (aCallback != null)
     {
         onTriggerStay -= aCallback;
     }
 }
Ejemplo n.º 5
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            entity.CannotSuspend = true;

            Transform transform = entity.GetOrCreate <Transform>("Transform");

            PlayerTrigger trigger = entity.GetOrCreate <PlayerTrigger>("Trigger");

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            base.Bind(entity, main, creating);

            TargetFactory.Positions.Add(transform);
            entity.Add(new CommandBinding(entity.Delete, delegate()
            {
                TargetFactory.Positions.Remove(transform);
            }));

            trigger.Add(new Binding <Vector3>(trigger.Position, transform.Position));

            trigger.Add(new CommandBinding(trigger.PlayerEntered, delegate()
            {
                entity.Add(new Animation(new Animation.Execute(entity.Delete)));
            }));
            trigger.Add(new Binding <bool>(trigger.Enabled, transform.Enabled));
            trigger.EditorProperties();
            attachable.EditorProperties();

            entity.Add("Enabled", transform.Enabled);

            entity.Add("Enable", transform.Enable);
            entity.Add("Disable", transform.Disable);
            entity.Add("Reached", trigger.PlayerEntered);
        }
Ejemplo n.º 6
0
 public void unsubscribeOnTriggerEnter(PlayerTrigger aCallback)
 {
     if (aCallback != null)
     {
         onTriggerEnter -= aCallback;
     }
 }
Ejemplo n.º 7
0
    public void EndMiniGame(int winnerBoxId, MiniGame type, bool isOnlyWinner)
    {
        MapTriggerBox box = MapEntityMetadataStorage.GetTriggerBox(Field.MapId, winnerBoxId);

        if (box is null)
        {
            return;
        }

        foreach (IFieldObject <Player> player in Field.State.Players.Values)
        {
            if (!FieldManager.IsPlayerInBox(box, player))
            {
                continue;
            }

            switch (type)
            {
            case MiniGame.LudibriumEscape:
                PlayerTrigger trigger = player.Value.Triggers.FirstOrDefault(x => x.Key == "gameStart");
                player.Value.Triggers.Remove(trigger);
                player.Value.Session.Send(ResultsPacket.Rounds(1, 1));
                break;

            case MiniGame.OXQuiz:
                player.Value.Session.Send(ResultsPacket.Rounds(10, 10));
                break;
            }
        }
    }
Ejemplo n.º 8
0
    void Start()
    {
        if(EnemyManager.Instance.target != null)
            playerTriggerRef = EnemyManager.Instance.target.GetComponentInChildren<PlayerTrigger>();

        if(EnemyManager.Instance.target != null)
            deviationX = Random.Range(-(playerTriggerRef.collider as SphereCollider).radius, (playerTriggerRef.collider as SphereCollider).radius);
            deviationZ = Random.Range(-(playerTriggerRef.collider as SphereCollider).radius, (playerTriggerRef.collider as SphereCollider).radius);
    }
Ejemplo n.º 9
0
 protected override void DoTheThing(PlayerTrigger trigger)
 {
     if (!TargetRotation)
     {
         return;
     }
     startQuaternion = transform.rotation;
     lerp            = true;
     alpha           = 0;
 }
Ejemplo n.º 10
0
 // Use this for initialization
 void Start()
 {
     renderer         = otherObject.GetComponent <SpriteRenderer>();
     this.baseAttack  = 1.0f;
     this.attackSpeed = 4.0f;
     otherAnimator    = otherObject.GetComponent <Animator> ();
     pt = gameObject.GetComponentInChildren <PlayerTrigger> ();
     dg = GameObject.FindWithTag("displayGUI").GetComponent <displayGUI>();
     this.gameOverScreenDisplaying = false;
 }
 void Awake()
 {
     _spriteRenderer = GetComponent <SpriteRenderer>();
     _rigidbody      = GetComponent <Rigidbody2D>();
     _Trigger        = GetComponentInChildren <PlayerTrigger>();
     isPickingBall   = false;
     localPlayerIndicator.transform.localScale = gameObject.transform.localScale * 4;
     _animator = GetComponent <Animator>();
     //FaceLeft = false;
 }
Ejemplo n.º 12
0
        public override void AttachEditorComponents(Entity entity, Main main)
        {
            base.AttachEditorComponents(entity, main);
            Model editorModel = entity.Get <Model>("EditorModel");

            editorModel.Add(new Binding <bool>(editorModel.Enabled, () => Editor.EditorModelsVisible && !entity.EditorSelected, entity.EditorSelected, Editor.EditorModelsVisible));

            VoxelAttachable.AttachEditorComponents(entity, main, editorModel.Color);
            PlayerTrigger.AttachEditorComponents(entity, main, editorModel.Color);
        }
Ejemplo n.º 13
0
 // Start is called before the first frame update
 void Start()
 {
     invCanvas.gameObject.SetActive(false);
     currentHealth = maxHealth;
     healthbar.setMaxHealth(maxHealth);
     
     rb = GetComponent<Rigidbody2D>();
     anim = GetComponent<Animator>();
     trigger = FindObjectOfType<PlayerTrigger>();
     
 }
        public static bool Prefix(PlayerTrigger __instance, string name, ref int __result)
        {
            int id = TileRegistry.GetIDByPropName(name.Replace("(Clone)", ""));

            if (id >= 0)
            {
                __result = id;
                return(false);
            }
            return(true);
        }
Ejemplo n.º 15
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            entity.CannotSuspendByDistance = true;

            PlayerTrigger   trigger    = entity.GetOrCreate <PlayerTrigger>("Trigger");
            PlayerSpawn     spawn      = entity.GetOrCreate <PlayerSpawn>("PlayerSpawn");
            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            this.SetMain(entity, main);

            attachable.EditorProperties();

            if (main.EditorEnabled)
            {
                entity.Add("Spawn Here", new Command
                {
                    Action = delegate()
                    {
                        main.Spawner.StartSpawnPointGUID.Value = entity.GUID;
                        Action go = delegate()
                        {
                            main.EditorEnabled.Value = false;
                            IO.MapLoader.Load(main, main.MapFile);
                        };

                        Editor editor = main.Get("Editor").First().Get <Editor>();
                        if (editor.NeedsSave)
                        {
                            editor.SaveWithCallback(go);
                        }
                        else
                        {
                            go();
                        }
                    },
                }, Command.Perms.Executable);
            }

            spawn.Add(new TwoWayBinding <Vector3>(transform.Position, spawn.Position));
            spawn.Add(new Binding <float, Quaternion>(spawn.Rotation, delegate(Quaternion value)
            {
                Vector3 x = Vector3.Transform(Vector3.Forward, value);
                return(((float)Math.PI * -0.5f) - (float)Math.Atan2(x.Z, x.X));
            }, transform.Quaternion));
            spawn.EditorProperties();

            trigger.Enabled.Value = true;
            trigger.Add(new TwoWayBinding <Vector3>(transform.Position, trigger.Position));
            trigger.Add(new CommandBinding(trigger.PlayerEntered, spawn.Activate));

            trigger.EditorProperties();
        }
Ejemplo n.º 16
0
 private void Evaluate(PlayerTrigger trigger)
 {
     for (int i = 0; i < validTriggers.Length; i++)
     {
         if (validTriggers[i] != trigger)
         {
             continue;
         }
         DoTheThing(trigger);
         return;
     }
 }
        public void SetUserValue(int triggerId, string key, int value)
        {
            PlayerTrigger playerTrigger = new PlayerTrigger(key)
            {
                TriggerId = triggerId,
                Value     = value
            };

            foreach (IFieldObject <Player> player in Field.State.Players.Values)
            {
                player.Value.Triggers.Add(playerTrigger);
            }
        }
 public static bool Prefix(PlayerTrigger __instance, int id, ref IEnumerator __result)
 {
     if (TileRegistry.GetSingleton().HasEntry(id))
     {
         TileInfo    tile   = TileRegistry.GetSingleton().GetEntry(id);
         IEnumerator result = tile.Interact();
         if (result != null)
         {
             __result = result;
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 19
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform     transform = entity.GetOrCreate <Transform>("Transform");
            PlayerTrigger trigger   = entity.GetOrCreate <PlayerTrigger>("PlayerTrigger");

            trigger.Serialize = false;

            VoxelAttachable attachable  = VoxelAttachable.MakeAttachable(entity, main);
            Collectible     collectible = entity.GetOrCreate <Collectible>("Collectible");

            trigger.Radius.Value = 3;
            trigger.Add(new Binding <Vector3>(trigger.Position, transform.Position));
            trigger.Add(new Binding <bool>(trigger.Enabled, x => !x, collectible.PickedUp));

            collectible.Add(new CommandBinding(trigger.PlayerEntered, collectible.PlayerTouched));

            Sound.AttachTracker(entity, trigger.Position);

            PointLight light = entity.Create <PointLight>();

            light.Serialize         = false;
            light.Attenuation.Value = 10.0f;
            light.Color.Value       = new Vector3(1.25f, 1.75f, 2.0f);
            light.Add(new Binding <Vector3>(light.Position, transform.Position));
            light.Add(new Binding <bool>(light.Enabled, x => !x, collectible.PickedUp));

            ParticleEmitter distortionEmitter = entity.GetOrCreate <ParticleEmitter>("DistortionEmitter");

            distortionEmitter.Serialize = false;
            distortionEmitter.Add(new Binding <Vector3>(distortionEmitter.Position, trigger.Position));
            distortionEmitter.ParticleType.Value       = "Distortion";
            distortionEmitter.ParticlesPerSecond.Value = 4;
            distortionEmitter.Jitter.Value             = new Vector3(0.5f);
            distortionEmitter.Add(new Binding <bool>(distortionEmitter.Enabled, x => !x, collectible.PickedUp));

            Model model = entity.GetOrCreate <Model>("Model");

            model.Filename.Value = "Models\\sphere";
            model.Serialize      = false;
            model.Scale.Value    = new Vector3(0.5f);
            model.Add(new Binding <Matrix>(model.Transform, transform.Matrix));
            model.Add(new Binding <bool>(model.Enabled, x => !x, collectible.PickedUp));

            this.SetMain(entity, main);

            attachable.EditorProperties();
            entity.Add("Collected", collectible.PlayerTouched);
        }
Ejemplo n.º 20
0
        public override void AttachEditorComponents(Entity entity, Main main)
        {
            ModelAlpha model = new ModelAlpha();

            model.Filename.Value = "AlphaModels\\light";
            model.Color.Value    = this.Color;
            model.Serialize      = false;

            entity.Add("EditorModel", model);

            model.Add(new Binding <Matrix>(model.Transform, entity.Get <Transform>().Matrix));
            model.Add(new Binding <bool>(model.Enabled, Editor.EditorModelsVisible));

            PlayerTrigger.AttachEditorComponents(entity, main, this.Color);
            VoxelAttachable.AttachEditorComponents(entity, main);
        }
Ejemplo n.º 21
0
    void Awake()
    {
        OnHealthZero += () =>
        {
            if (regenRoutine != null)
            {
                StopCoroutine(regenRoutine);
            }
        };

        if (healthRegenerates)
        {
            StartRegenRoutine();
        }

        myPlayerTrigger = GetComponentInChildren <PlayerTrigger>();
    }
Ejemplo n.º 22
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform     transform = entity.GetOrCreate <Transform>("Transform");
            PlayerTrigger trigger   = entity.GetOrCreate <PlayerTrigger>("PlayerTrigger");

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main).EditorProperties();

            trigger.Add(new TwoWayBinding <Vector3>(transform.Position, trigger.Position));

            entity.Add("Enable", trigger.Enable);
            entity.Add("Disable", trigger.Disable);
            entity.Add("Enabled", trigger.Enabled);
            entity.Add("PlayerEntered", trigger.PlayerEntered);
            entity.Add("PlayerExited", trigger.PlayerExited);
            entity.Add("Radius", trigger.Radius, "Radius of the trigger");
            entity.Add("DeleteOnTrigger", trigger.DeleteOnTrigger);
        }
Ejemplo n.º 23
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform     transform = entity.GetOrCreate <Transform>("Transform");
            PlayerTrigger trigger   = entity.GetOrCreate <PlayerTrigger>();
            Model         model     = entity.GetOrCreate <Model>("Model");

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            this.SetMain(entity, main);
            model.Serialize      = false;
            model.Filename.Value = "Models\\papers";
            model.Add(new Binding <Matrix>(model.Transform, transform.Matrix));

            Note note = entity.GetOrCreate <Note>("Note");

            trigger.Serialize = false;
            trigger.Add(new Binding <Vector3>(trigger.Position, transform.Position));
            trigger.Radius.Value = 3.5f;

            trigger.Add(new CommandBinding(trigger.PlayerEntered, delegate()
            {
                PlayerFactory.Instance.Get <Player>().Note.Value = entity;
            }));

            trigger.Add(new CommandBinding(trigger.PlayerExited, delegate()
            {
                if (PlayerFactory.Instance != null)
                {
                    PlayerFactory.Instance.Get <Player>().Note.Value = null;
                }
            }));

            entity.Add("Collected", note.Collected);
            entity.Add("Text", note.Text);
            entity.Add("Image", note.Image, new PropertyEntry.EditorData
            {
                Options = FileFilter.Get(main, main.Content.RootDirectory, new[] { "Images", Path.Combine(MapLoader.MapDirectory, "Images") }),
            });
            attachable.EditorProperties();
        }
        public void EndMiniGame(int winnerBoxId, MiniGame type, bool isOnlyWinner)
        {
            MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, winnerBoxId);
            List <IFieldObject <Player> > players = new List <IFieldObject <Player> >();

            foreach (IFieldObject <Player> player in Field.State.Players.Values)
            {
                if (FieldManager.IsPlayerInBox(box, player))
                {
                    if (type == MiniGame.LudibriumEscape)
                    {
                        PlayerTrigger trigger = player.Value.Triggers.FirstOrDefault(x => x.Key == "gameStart");
                        player.Value.Triggers.Remove(trigger);
                        player.Value.Session.Send(ResultsPacket.Rounds(1, 1));
                    }
                    else if (type == MiniGame.OXQuiz)
                    {
                        player.Value.Session.Send(ResultsPacket.Rounds(10, 10));
                    }
                }
            }
        }
Ejemplo n.º 25
0
        protected static void bindTriggerLeave(string id, Action callback, bool oneTimeOnly = false)
        {
            Entity triggerEntity = ScriptBase.get(id);

            if (triggerEntity == null)
            {
                Log.d("Entity " + id + " not found!");
                return;
            }
            PlayerTrigger trigger = triggerEntity.Get <PlayerTrigger>();

            Action[] callbacks;
            if (oneTimeOnly)
            {
                callbacks = new[] { callback, delegate() { trigger.Enabled.Value = false; } }
            }
            ;
            else
            {
                callbacks = new[] { callback }
            };
            triggerEntity.Add(new CommandBinding(trigger.PlayerExited, callbacks));
        }
Ejemplo n.º 26
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            this.SetMain(entity, main);

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main, true, false);

            attachable.Offset.Value  = 1;
            attachable.Enabled.Value = true;

            PowerBlockSocket socket = entity.GetOrCreate <PowerBlockSocket>("PowerBlockSocket");

            socket.Add(new Binding <Voxel.Coord>(socket.Coord, attachable.Coord));
            socket.Add(new Binding <Entity.Handle>(socket.AttachedVoxel, attachable.AttachedVoxel));

            const float maxLightAttenuation = 15.0f;
            PointLight  light = entity.Create <PointLight>();

            light.Attenuation.Value = maxLightAttenuation;
            light.Add(new Binding <Vector3>(light.Position, transform.Position));
            light.Add(new Binding <Vector3, Voxel.t>(light.Color, delegate(Voxel.t t)
            {
                switch (t)
                {
                case Voxel.t.GlowBlue:
                    return(new Vector3(0.8f, 0.9f, 1.2f));

                case Voxel.t.GlowYellow:
                    return(new Vector3(1.2f, 1.2f, 0.8f));

                default:
                    return(Vector3.One);
                }
            }, socket.Type));
            light.Add(new Binding <bool>(light.Enabled, socket.Powered));

            PointLight animationLight = entity.Create <PointLight>();

            animationLight.Add(new Binding <Vector3>(animationLight.Position, light.Position));
            animationLight.Add(new Binding <Vector3>(animationLight.Color, light.Color));
            animationLight.Enabled.Value = false;

            PlayerTrigger trigger = entity.GetOrCreate <PlayerTrigger>("PlayerTrigger");

            trigger.Radius.Value = 7;
            trigger.Add(new Binding <Vector3>(trigger.Position, transform.Position));
            const float minimumChangeTime = 1.5f;
            float       lastChange        = -minimumChangeTime;

            trigger.Add(new CommandBinding(trigger.PlayerEntered, delegate()
            {
                if (main.TotalTime - lastChange > minimumChangeTime)
                {
                    BlockCloud cloud = PlayerFactory.Instance.Get <BlockCloud>();

                    bool changed    = false;
                    Voxel sockVoxel = attachable.AttachedVoxel.Value.Target.Get <Voxel>();
                    if (!socket.Powered && cloud.Type.Value == socket.Type.Value)
                    {
                        // Plug in to the socket
                        List <Voxel.Coord> coords = new List <Voxel.Coord>();
                        Queue <Voxel.Coord> queue = new Queue <Voxel.Coord>();
                        queue.Enqueue(sockVoxel.GetCoordinate(transform.Position));
                        while (queue.Count > 0)
                        {
                            Voxel.Coord c = queue.Dequeue();
                            coords.Add(c);
                            if (coords.Count >= cloud.Blocks.Length)
                            {
                                break;
                            }

                            Voxel.CoordDictionaryCache[c] = true;
                            foreach (Direction adjacentDirection in DirectionExtensions.Directions)
                            {
                                Voxel.Coord adjacentCoord = c.Move(adjacentDirection);
                                if (!Voxel.CoordDictionaryCache.ContainsKey(adjacentCoord))
                                {
                                    Voxel.t adjacentID = sockVoxel[adjacentCoord].ID;
                                    if (adjacentID == Voxel.t.Empty)
                                    {
                                        queue.Enqueue(adjacentCoord);
                                    }
                                }
                            }
                        }
                        Voxel.CoordDictionaryCache.Clear();

                        EffectBlockFactory factory = Factory.Get <EffectBlockFactory>();
                        int i = 0;
                        foreach (Entity block in cloud.Blocks)
                        {
                            Entity effectBlockEntity = factory.CreateAndBind(main);
                            Voxel.States.All[cloud.Type].ApplyToEffectBlock(effectBlockEntity.Get <ModelInstance>());
                            EffectBlock effectBlock      = effectBlockEntity.Get <EffectBlock>();
                            effectBlock.DoScale          = false;
                            Transform blockTransform     = block.Get <Transform>();
                            effectBlock.StartPosition    = blockTransform.Position;
                            effectBlock.StartOrientation = blockTransform.Quaternion;
                            effectBlock.TotalLifetime    = (i + 1) * 0.04f;
                            effectBlock.Setup(sockVoxel.Entity, coords[i], cloud.Type);
                            main.Add(effectBlockEntity);
                            block.Delete.Execute();
                            i++;
                        }
                        cloud.Blocks.Clear();
                        cloud.Type.Value     = Voxel.t.Empty;
                        socket.Powered.Value = true;
                        changed = true;
                    }
                    else if (socket.Powered && cloud.Type.Value == Voxel.t.Empty && !socket.PowerOnOnly)
                    {
                        // Pull blocks out of the socket
                        SceneryBlockFactory factory = Factory.Get <SceneryBlockFactory>();
                        Quaternion quat             = Quaternion.CreateFromRotationMatrix(sockVoxel.Transform);
                        cloud.Type.Value            = socket.Type;
                        List <Voxel.Coord> coords   = sockVoxel.GetContiguousByType(new[] { sockVoxel.GetBox(transform.Position) }).SelectMany(x => x.GetCoords()).ToList();
                        sockVoxel.Empty(coords, true);
                        sockVoxel.Regenerate();
                        ParticleSystem particles = ParticleSystem.Get(main, "WhiteShatter");
                        foreach (Voxel.Coord c in coords)
                        {
                            Vector3 pos = sockVoxel.GetAbsolutePosition(c);
                            for (int j = 0; j < 20; j++)
                            {
                                Vector3 offset = new Vector3((float)this.random.NextDouble() - 0.5f, (float)this.random.NextDouble() - 0.5f, (float)this.random.NextDouble() - 0.5f);
                                particles.AddParticle(pos + offset, offset);
                            }
                            Entity block                    = factory.CreateAndBind(main);
                            Transform blockTransform        = block.Get <Transform>();
                            blockTransform.Position.Value   = pos;
                            blockTransform.Quaternion.Value = quat;
                            SceneryBlock sceneryBlock       = block.Get <SceneryBlock>();
                            sceneryBlock.Type.Value         = socket.Type;
                            sceneryBlock.Scale.Value        = 0.5f;
                            cloud.Blocks.Add(block);
                            main.Add(block);
                        }
                        socket.Powered.Value = false;
                        changed = true;
                    }

                    if (changed)
                    {
                        lastChange = main.TotalTime;
                        animationLight.Enabled.Value     = true;
                        animationLight.Attenuation.Value = 0.0f;
                        entity.Add(new Animation
                                   (
                                       new Animation.FloatMoveTo(animationLight.Attenuation, maxLightAttenuation, 0.25f),
                                       new Animation.FloatMoveTo(animationLight.Attenuation, 0.0f, 2.0f),
                                       new Animation.Set <bool>(animationLight.Enabled, false)
                                   ));
                    }
                }
            }));

            entity.Add("Type", socket.Type);
            entity.Add("Powered", socket.Powered, new PropertyEntry.EditorData {
                Readonly = true
            });
            entity.Add("PowerOnOnly", socket.PowerOnOnly);
            entity.Add("OnPowerOn", socket.OnPowerOn);
            entity.Add("OnPowerOff", socket.OnPowerOff);
        }
Ejemplo n.º 27
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform     transform = entity.GetOrCreate <Transform>("Transform");
            PlayerTrigger trigger   = entity.GetOrCreate <PlayerTrigger>("PlayerTrigger");

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            attachable.Enabled.Value = true;

            this.SetMain(entity, main);

            VoxelAttachable.BindTarget(entity, trigger.Position);

            PointLight light = entity.GetOrCreate <PointLight>();

            light.Add(new Binding <Vector3>(light.Position, trigger.Position));
            light.Color.Value = new Vector3(1.0f, 0.5f, 1.7f);

            Property <float> lightBaseRadius = new Property <float> {
                Value = 10.0f
            };

            Updater updater = new Updater
                              (
                delegate(float dt)
            {
                light.Attenuation.Value = lightBaseRadius.Value * (1.0f + (((float)this.random.NextDouble() - 0.5f) * 0.1f));
            }
                              );

            updater.EnabledInEditMode = true;
            entity.Add(updater);

            SignalTower tower = entity.GetOrCreate <SignalTower>("SignalTower");

            Animation enterAnimation = null;

            trigger.Add(new CommandBinding(trigger.PlayerEntered, delegate()
            {
                if (!string.IsNullOrEmpty(tower.Initial) && (enterAnimation == null || !enterAnimation.Active))
                {
                    enterAnimation = new Animation
                                     (
                        new Animation.FloatMoveTo(lightBaseRadius, 20.0f, 0.25f),
                        new Animation.FloatMoveTo(lightBaseRadius, 10.0f, 0.5f)
                                     );
                    entity.Add(enterAnimation);
                }
            }));

            tower.Add(new CommandBinding(trigger.PlayerEntered, tower.PlayerEnteredRange));
            tower.Add(new CommandBinding(trigger.PlayerExited, tower.PlayerExitedRange));
            tower.Add(new Binding <Entity.Handle>(tower.Player, trigger.Player));

            Sound.AttachTracker(entity, trigger.Position);

            ParticleEmitter distortionEmitter = entity.GetOrCreate <ParticleEmitter>("DistortionEmitter");

            distortionEmitter.Serialize = false;
            distortionEmitter.Add(new Binding <Vector3>(distortionEmitter.Position, trigger.Position));
            distortionEmitter.ParticleType.Value       = "Distortion";
            distortionEmitter.ParticlesPerSecond.Value = 4;
            distortionEmitter.Jitter.Value             = new Vector3(0.5f);

            ParticleEmitter purpleEmitter = entity.GetOrCreate <ParticleEmitter>("PurpleEmitter");

            purpleEmitter.Serialize = false;
            purpleEmitter.Add(new Binding <Vector3>(purpleEmitter.Position, trigger.Position));
            purpleEmitter.ParticleType.Value       = "Purple";
            purpleEmitter.ParticlesPerSecond.Value = 30;
            purpleEmitter.Jitter.Value             = new Vector3(0.5f);

            entity.Add("AttachOffset", attachable.Offset);
            trigger.EditorProperties();
            entity.Add("Initial", tower.Initial);
        }
    IEnumerator InitNextObjective()
    {
        objectiveEdgeView.Hide();
        NotificationManager.instance.HideHelp();

        if (objectives.Count == 0)
        {
            Debug.LogError("No objectives to set up");
            yield break;
        }

        //some UI updates before the initial delay
        timerAnim.SetBool("Open", curObjective.timerActiveState);

        if (firstTime)
        {
            firstTime = false;
            yield return(new WaitForSeconds(curObjective.initialDelay));

            foreach (NotificationManager.SplashData message in curObjective.startingSplashes)
            {
                NotificationManager.instance.ShowSplash(message);
            }
            if (curObjective.startingSplashes.Count > 0)
            {
                SwipeManager.instance.EndSwipe();
            }
        }

        switch (curObjective.type)
        {
        case Objective.Type.Pickup:
            curObjective.objectiveObj.tag = "Pickup";
            Pickup pickup = curObjective.objectiveObj.GetComponent <Pickup> ();
            if (pickup != null)
            {
                pickup.isObjective = true;
            }
            break;

        case Objective.Type.Zone:
            PlayerTrigger trigger = curObjective.objectiveObj.AddComponent <PlayerTrigger> ();
            trigger.enterActions.AddListener(CompleteObjective);
            trigger.oneTime = true;
            break;

        case Objective.Type.Kills:
            StartCoroutine(CheckForEnemyDeaths());
            break;

        case Objective.Type.Vehicle:
            curObjective.objectiveObj.GetComponent <Rideable> ().SetupObjective();
            break;

        case Objective.Type.Camera:
            StartCoroutine(CameraEvent());
            break;

        case Objective.Type.Defend:
            timer = curObjective.time;
            break;
        }

        if (curObjective.animation != null && curObjective.type != Objective.Type.Camera)
        {
            curObjective.animation.SetTrigger("Play");
        }

        if (gameTimer != null)
        {
            gameTimer.enabled = curObjective.timerActiveState;
            if (curObjective.timerActiveState && curObjective.time > 0)
            {
                gameTimer.Init(curObjective.time);
            }
        }

        UpdateObjectiveUI();
    }
Ejemplo n.º 29
0
 protected abstract void DoTheThing(PlayerTrigger trigger);