コード例 #1
0
        public void Build(Main main, IEnumerable <BlockBuildOrder> blocks, Vector3 center, float delayMultiplier = 0.05f)
        {
            int index = 0;

            foreach (BlockBuildOrder entry in blocks)
            {
                if (EffectBlock.IsAnimating(new EffectBlock.Entry {
                    Voxel = entry.Voxel, Coordinate = entry.Coordinate
                }))
                {
                    continue;
                }

                Entity      entity      = this.CreateAndBind(main);
                EffectBlock effectBlock = entity.Get <EffectBlock>();
                entry.State.ApplyToEffectBlock(entity.Get <ModelInstance>());
                effectBlock.Offset.Value = entry.Voxel.GetRelativePosition(entry.Coordinate);

                Vector3 absolutePos = entry.Voxel.GetAbsolutePosition(entry.Coordinate);

                float distance = (absolutePos - center).Length();
                effectBlock.StartPosition    = absolutePos + new Vector3(0.05f, 0.1f, 0.05f) * distance;
                effectBlock.StartOrientation = Quaternion.CreateFromYawPitchRoll(0.15f * (distance + index), 0.15f * (distance + index), 0);
                effectBlock.TotalLifetime    = Math.Max(delayMultiplier, distance * delayMultiplier);
                effectBlock.CheckAdjacent    = true;
                effectBlock.Setup(entry.Voxel.Entity, entry.Coordinate, entry.State.ID);
                main.Add(entity);
                index++;
            }
        }
コード例 #2
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            entity.CannotSuspend = true;
            ModelInstance model = entity.GetOrCreate <ModelInstance>("Model");

            EffectBlock effectBlock = entity.GetOrCreate <EffectBlock>("EffectBlock");

            model.Add(new Binding <Matrix>(model.Transform, effectBlock.Transform));

            entity.Add(new CommandBinding(effectBlock.Delete, entity.Delete));

            this.SetMain(entity, main);
            IBinding offsetBinding = null;

            model.Add(new NotifyBinding(delegate()
            {
                if (offsetBinding != null)
                {
                    model.Remove(offsetBinding);
                }
                offsetBinding = new Binding <Vector3>(model.GetVector3Parameter("Offset"), effectBlock.Offset);
                model.Add(offsetBinding);
            }, model.FullInstanceKey));
            if (effectBlock.StateId != Voxel.t.Empty)
            {
                Voxel.States.All[effectBlock.StateId].ApplyToEffectBlock(model);
            }
        }
コード例 #3
0
 void TriggerOperating(bool isMove, EffectBlock eb)
 {
     cart.GetComponent <BullockCarts>().isMove = isMove;
     eb.enabled = false;
     eb.GetComponent <UnityEngine.AI.NavMeshObstacle>().enabled = false;
     eb.GetComponent <BoxCollider>().enabled = false;
 }
コード例 #4
0
ファイル: ShaderMixinCodeGen.cs プロジェクト: Aggror/Stride
            public override void Visit(EffectBlock effectBlock)
            {
                HasMixin = true;

                // Create a context associated with ShaderBlock
                currentContext = new ShaderBlockContext();
                effectBlock.SetTag(BlockContextTag, currentContext);

                foreach (Statement statement in effectBlock.Body.Statements)
                {
                    VisitDynamic(statement);
                }
                currentContext = null;
            }
コード例 #5
0
ファイル: ShaderMixinCodeGen.cs プロジェクト: Aggror/Stride
        /// <summary>
        /// Visits the specified shader block.
        /// </summary>
        /// <param name="effectBlock">The shader block.</param>
        public override void Visit(EffectBlock effectBlock)
        {
            WriteLinkLine(effectBlock);
            currentBlock = effectBlock;

            VariableAsParameterKey = false;

            // Clear ParameterKey and Mixin references
            parameterKeysReferenced.Clear();
            mixinsReferenced.Clear();

            // Use a single internal class for all shader mixins
            Write("internal static partial class ShaderMixins");
            {
                OpenBrace();
                Write("internal partial class");
                Write(" ");
                Write(effectBlock.Name);
                WriteSpace();
                Write(" : IShaderMixinBuilder");
                {
                    OpenBrace();
                    // Generate the main generate method for each shader block
                    Write("public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)");
                    {
                        OpenBrace();
                        // Create a context associated with ShaderBlock
                        foreach (Statement statement in effectBlock.Body.Statements)
                        {
                            VisitDynamic(statement);
                        }
                        CloseBrace();
                    }

                    WriteLine();
                    WriteLine("[ModuleInitializer]");
                    WriteLine("internal static void __Initialize__()");
                    {
                        OpenBrace();
                        Write("ShaderMixinManager.Register(\"").Write(effectBlock.Name).Write("\", new ").Write(effectBlock.Name).WriteLine("());");
                        CloseBrace();
                    }
                    CloseBrace();
                }
                CloseBrace();
            }

            VariableAsParameterKey = true;
            currentBlock           = null;
        }
コード例 #6
0
ファイル: BF_Summon.cs プロジェクト: moto2002/moba
    private void CreateSummonMonster(long monsterId)
    {
        EffectBlock eb = target.GetComponentInParent <EffectBlock>();

        for (int i = 0; i < skillNode.target_ceiling; i++)
        {
            MonsterData monsterData = new MonsterData(monsterId);
            monsterData.groupIndex = target.groupIndex;
            monsterData.state      = Modestatus.Monster;
            monsterData.lvl        = BattleUtil.IsHeroTarget(target) ? target.CharData.skill [skillId] : target.CharData.lvl;
            CharacterState mCs = SceneBaseManager.instance.CreateBattleMonster(monsterData, target.transform.parent.gameObject);
            mCs.transform.position = target.transform.position;
            mCs.gameObject.AddMissingComponent <Monster_AI>();
            mCs.transform.position += ((i / 2) % 2 == 0 ? target.transform.forward : target.transform.right) * 0.1f * (i % 2 == 0 ? 1 : -1);
            if (eb != null)
            {
                Resource.CreatPrefabs(((MonsterAttrNode)monsterData.attrNode).effect_sign, target.transform.parent.gameObject, mCs.transform.localPosition, GameLibrary.Effect_Spawn);
                eb.AddMonsterCount(1);
                mCs.OnDead += (mcs) => eb.ChangeCount();
            }
            mCurSummonCs.Add(mCs);
        }
    }
コード例 #7
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);
        }
コード例 #8
0
ファイル: VoxelRip.cs プロジェクト: schmittens/Lemma
        public static void Consolidate(Main main, DynamicVoxel voxel, Voxel targetVoxel, Voxel.Coord targetCoord, float interval = 1.0f)
        {
            if (targetVoxel != null)
            {
                // Combine this map with the other one

                Direction x = targetVoxel.GetRelativeDirection(voxel.GetAbsoluteVector(Vector3.Right));
                Direction y = targetVoxel.GetRelativeDirection(voxel.GetAbsoluteVector(Vector3.Up));
                Direction z = targetVoxel.GetRelativeDirection(voxel.GetAbsoluteVector(Vector3.Backward));

                if (x.IsParallel(y))
                {
                    x = y.Cross(z);
                }
                else if (y.IsParallel(z))
                {
                    y = x.Cross(z);
                }

                Voxel.Coord offset = new Voxel.Coord();
                float       closestCoordDistance = float.MaxValue;
                Vector3     closestCoordPosition = targetVoxel.GetAbsolutePosition(targetCoord);
                foreach (Voxel.Coord c in voxel.Chunks.SelectMany(c => c.Boxes).SelectMany(b => b.GetCoords()))
                {
                    float distance = (voxel.GetAbsolutePosition(c) - closestCoordPosition).LengthSquared();
                    if (distance < closestCoordDistance)
                    {
                        closestCoordDistance = distance;
                        offset = c;
                    }
                }
                Vector3 toLevitatingMap = voxel.Transform.Value.Translation - targetVoxel.GetAbsolutePosition(targetCoord);
                offset = offset.Move(voxel.GetRelativeDirection(-toLevitatingMap));

                Quaternion orientation = Quaternion.CreateFromRotationMatrix(voxel.Transform.Value);

                EffectBlockFactory blockFactory = Factory.Get <EffectBlockFactory>();

                int index = 0;
                List <Voxel.Coord> coords = voxel.Chunks.SelectMany(c => c.Boxes).SelectMany(b => b.GetCoords()).ToList();
                Voxel.Coord        camera = voxel.GetCoordinate(main.Camera.Position);
                foreach (Voxel.Coord c in coords.OrderBy(c2 => new Vector3(c2.X - camera.X, c2.Y - camera.Y, c2.Z - camera.Z).LengthSquared()))
                {
                    Voxel.Coord offsetFromCenter = c.Move(-offset.X, -offset.Y, -offset.Z);
                    Voxel.Coord targetCoord2     = new Voxel.Coord();
                    targetCoord2.SetComponent(x, offsetFromCenter.GetComponent(Direction.PositiveX));
                    targetCoord2.SetComponent(y, offsetFromCenter.GetComponent(Direction.PositiveY));
                    targetCoord2.SetComponent(z, offsetFromCenter.GetComponent(Direction.PositiveZ));
                    targetCoord2 = targetCoord2.Move(targetCoord.X, targetCoord.Y, targetCoord.Z);
                    if (targetVoxel[targetCoord2].ID == 0)
                    {
                        Entity blockEntity = blockFactory.CreateAndBind(main);
                        c.Data.ApplyToEffectBlock(blockEntity.Get <ModelInstance>());
                        EffectBlock effectBlock = blockEntity.Get <EffectBlock>();
                        effectBlock.Offset.Value     = targetVoxel.GetRelativePosition(targetCoord2);
                        effectBlock.DoScale          = false;
                        effectBlock.StartPosition    = voxel.GetAbsolutePosition(c);
                        effectBlock.StartOrientation = orientation;
                        effectBlock.TotalLifetime    = (0.05f + (index * 0.0075f)) * interval;
                        effectBlock.Setup(targetVoxel.Entity, targetCoord2, c.Data.ID);
                        main.Add(blockEntity);
                        index++;
                    }
                }

                // Delete the map
                voxel.Entity.Delete.Execute();
            }
        }
コード例 #9
0
ファイル: SpawnMonster.cs プロジェクト: moto2002/moba
    public void StartSpawn()
    {
        if (GameLibrary.dungeonId >= 30000)
        {
            if (spawnID > 99)
            {
                levelID = "" + spawnID;
            }
            else if (spawnID > 9)
            {
                levelID = "0" + spawnID;
            }
            else
            {
                levelID = "00" + spawnID;
            }

            if (!GameLibrary.SceneType(SceneType.TD) && !GameLibrary.SceneType(SceneType.MB1) && !GameLibrary.SceneType(SceneType.Dungeons_MB1))
            {
                levelID = GameLibrary.dungeonId.ToString() + levelID;
                config  = FSDataNodeTable <LevelConfigsNode> .GetSingleton().FindDataByType(Convert.ToUInt32(levelID));
            }

            if (null != config)
            {
                spawnQueue   = config.monsterID;
                monsterLevel = (int)config.monsterlvl;
                lvlRate      = config.monsterlvl;
                monsterScale = config.scale;
            }
        }
        if (spawnQueue == 0)
        {
            return;
        }

        if (transform.parent.GetComponent <EffectBlock>())
        {
            effect_Block = transform.parent.GetComponent <EffectBlock>();
        }

        if (transform.parent.GetComponent <BossChuChangField>())
        {
            effect_Boss = transform.parent.GetComponent <BossChuChangField>();
        }

        if (trigger != null)
        {
            trigger.OnTrigger += CreatMonster;
        }
        else if (distance > 0 && isKM)
        {
            InvokeRepeating("InvokeCheckDistance", 0f, 0.2f);
        }
        else if (spawnTimer > 0)
        {
            if (isTP)
            {
                InvokeRepeating("InvokeMonster", spawnTimer, interval);
            }
            else
            {
                Invoke("CreatMonster", spawnTimer);
            }
        }
        else
        {
            CreatMonster();
        }
    }
コード例 #10
0
        /// <summary>
        /// Deserializes the world blocks from an Everybody Edits world based on a <see cref="Message"/> object.
        /// </summary>
        /// <param name="m">The Message object that contains the data about the Everybody Edits world.</param>
        /// <param name="worldWidth">The width of the Everybody Edits world.</param>
        /// <param name="worldHeight">The height of the Everybody Edits world.</param>
        /// <returns>
        /// A 3-dimensional array of type <see cref="Block"/>. The first dimension represents layer, the second represents horizontal coordinate, and the third represents
        /// vertical coordinate.
        /// </returns>
        public static Block[,,] DeserializeBlocks(Message m, int worldWidth, int worldHeight)
        {
            if (!CanDeserializeBlocks(m))
            {
                throw new Exception($"Can not deserialize world blocks from \"{m.Type}\" message.");
            }

            Block[,,] worldBlocks = InitalizeWorldBlocksArray(2, worldWidth, worldHeight);
            uint currentBlockChunk = GetWorldStart(m) + 1;

            while (m[currentBlockChunk] as string != EverybodyEditsMessage.WorldEnd)
            {
                int    blockId       = m.GetInt(currentBlockChunk);
                int    layer         = m.GetInt(currentBlockChunk + 1);
                byte[] xPositions    = m.GetByteArray(currentBlockChunk + 2);
                byte[] yPositions    = m.GetByteArray(currentBlockChunk + 3);
                uint   chunkArgsRead = 4;

                for (int i = 0; i < xPositions.Length; i += 2)
                {
                    int x = (xPositions[i] << 8) | (xPositions[i + 1]);
                    int y = (yPositions[i] << 8) | (yPositions[i + 1]);

                    switch (blockId)
                    {
                    case 77:
                    case 83:
                    case 1520:
                    {
                        int soundId = m.GetInt(currentBlockChunk + 4);
                        worldBlocks[layer, x, y] = new MusicBlock(blockId, soundId);

                        chunkArgsRead = 5;
                    }
                    break;

                    case 113:
                    case 184:
                    case 185:
                    case 467:
                    case 1619:
                    case 1620:
                    case 1079:
                    case 1080:
                    {
                        uint switchId = m.GetUInt(currentBlockChunk + 4);
                        worldBlocks[layer, x, y] = new SwitchBlock(blockId, switchId);

                        chunkArgsRead = 5;
                    }
                    break;

                    case 242:
                    case 381:
                    {
                        int portalId   = m.GetInt(currentBlockChunk + 4);
                        int targetId   = m.GetInt(currentBlockChunk + 5);
                        int rotationId = m.GetInt(currentBlockChunk + 6);
                        worldBlocks[layer, x, y] = new PortalBlock(blockId, portalId, targetId, rotationId);

                        chunkArgsRead = 7;
                    }
                    break;

                    case 1582:
                    {
                        int spawnId = m.GetInt(currentBlockChunk + 4);
                        worldBlocks[layer, x, y] = new WorldPortalSpawnBlock(blockId, spawnId);

                        chunkArgsRead = 5;
                    }
                    break;

                    case 374:
                    {
                        string targetWorldId = m.GetString(currentBlockChunk + 4);
                        int    targetSpawn   = m.GetInt(currentBlockChunk + 5);
                        worldBlocks[layer, x, y] = new WorldPortalBlock(blockId, targetWorldId, targetSpawn);

                        chunkArgsRead = 6;
                    }
                    break;

                    case 385:
                    {
                        string text       = m.GetString(currentBlockChunk + 4);
                        int    rotationId = m.GetInt(currentBlockChunk + 5);
                        worldBlocks[layer, x, y] = new SignBlock(blockId, text, rotationId);

                        chunkArgsRead = 6;
                    }
                    break;

                    case 417:
                    case 418:
                    case 419:
                    case 420:
                    case 423:
                    case 453:
                    case 461:
                    case 1517:
                    case 1584:
                    {
                        int effectId = m.GetInt(currentBlockChunk + 4);
                        worldBlocks[layer, x, y] = new EffectBlock(blockId, effectId);

                        chunkArgsRead = 5;
                    }
                    break;

                    case 421:
                    case 422:
                    {
                        int duration = m.GetInt(currentBlockChunk + 4);
                        worldBlocks[layer, x, y] = new TimedEffectBlock(blockId, duration);

                        chunkArgsRead = 5;
                    }
                    break;

                    case 1550:
                    case 1551:
                    case 1552:
                    case 1553:
                    case 1554:
                    case 1556:
                    case 1557:
                    case 1558:
                    case 1571:
                    case 1572:
                    case 1573:
                    case 1576:
                    case 1579:
                    {
                        string   name     = m.GetString(currentBlockChunk + 4);
                        string[] messages = { m.GetString(currentBlockChunk + 5), m.GetString(currentBlockChunk + 6), m.GetString(currentBlockChunk + 7) };
                        worldBlocks[layer, x, y] = new NonPlayableCharacterBlock(blockId, name, messages);

                        chunkArgsRead = 8;
                    }
                    break;

                    case 273:
                    case 275:
                    case 276:
                    case 277:
                    case 279:
                    case 280:
                    case 327:
                    case 328:
                    case 329:
                    case 338:
                    case 339:
                    case 340:
                    case 361:
                    case 376:
                    case 377:
                    case 378:
                    case 379:
                    case 380:
                    case 438:
                    case 439:
                    case 440:
                    case 447:
                    case 448:
                    case 449:
                    case 451:
                    case 452:
                    case 456:
                    case 457:
                    case 458:
                    case 464:
                    case 465:
                    case 471:
                    case 499:
                    case 1001:
                    case 1002:
                    case 1003:
                    case 1004:
                    case 1116:
                    case 1117:
                    case 1118:
                    case 1119:
                    case 1120:
                    case 1121:
                    case 1122:
                    case 1123:
                    case 1124:
                    case 1125:
                    case 1041:
                    case 1042:
                    case 1043:
                    case 1052:
                    case 1053:
                    case 1054:
                    case 1055:
                    case 1056:
                    case 1092:
                    case 1134:
                    case 1135:
                    case 1140:
                    case 1141:
                    case 1500:
                    case 1502:
                    case 1506:
                    case 1507:
                    case 1535:
                    case 1536:
                    case 1537:
                    case 1538:
                    case 1155:
                    case 1160:
                    case 1581:
                    case 1587:
                    case 1588:
                    case 1592:
                    case 1593:
                    case 1594:
                    case 1595:
                    case 1596:
                    case 1597:
                    case 1605:
                    case 1606:
                    case 1607:
                    case 1608:
                    case 1609:
                    case 1610:
                    case 1611:
                    case 1612:
                    case 1613:
                    case 1614:
                    case 1615:
                    case 1616:
                    case 1617:
                    case 1633:
                    {
                        int morphId = m.GetInt(currentBlockChunk + 4);
                        worldBlocks[layer, x, y] = new MorphableBlock(blockId, morphId);

                        chunkArgsRead = 5;
                    }
                    break;

                    default:
                    {
                        worldBlocks[layer, x, y] = new Block(blockId);

                        chunkArgsRead = 4;
                    }
                    break;
                    }
                }

                currentBlockChunk += chunkArgsRead;
            }

            return(worldBlocks);
        }
コード例 #11
0
ファイル: SceneNewbieGuide.cs プロジェクト: moto2002/moba
    public override void InitScene()
    {
        instance = this;

        Globe.fightHero = new int[] { (int)GameLibrary.player, 201000300, 201001900, 201001100, 0, 0 };

        Resource.CreatPrefabs("HeroPosEmbattle", null, new Vector3(10, 1000, 0));

        guidePanel = NextGuidePanel.Single();
        guidePanel.transform.parent     = SceneUIManager.instance.transform;
        guidePanel.transform.localScale = Vector3.one;

        insGuangQuan = Resources.Load(GameLibrary.Effect_UI + "yd_guangq") as GameObject;
        yd_guangq    = NGUITools.AddChild(SceneUIManager.instance.gameObject, insGuangQuan);
        yd_guangq.SetActive(false);
        if (yd_guangq.transform.Find("guangquan"))
        {
            guangquan = yd_guangq.transform.Find("guangquan").gameObject;
        }

        YinDao_GuangQuan = transform.Find("BullockCarts").gameObject;
        insYinDao        = Resource.CreatPrefabs("UI_YinDao_GuangQuan_01", YinDao_GuangQuan, Vector3.zero, GameLibrary.Effect_UI);

        promptArrow1 = Resource.CreatPrefabs("UI_YinDao_XiangQian_01", gameObject, Vector3.zero, GameLibrary.Effect_UI);
        promptArrow2 = Resource.CreatPrefabs("UI_YinDao_XiangQian_01", gameObject, Vector3.zero, GameLibrary.Effect_UI);
        SetArrowState(promptArrow1);
        SetArrowState(promptArrow2);

        fightTouchIns = FightTouch._instance;
        fightTouchIns.HideAllFightBtn();
        fightTouchIns.OnTouchBtn     += HideGuide;
        fightTouchIns.OnBtnTargetNil += SummonTargetNil;

        touchMove         = SceneUIManager.instance.moveTouch;
        touchMove.OnMove += TouchMove;

        touchCollider = SceneUIManager.instance.moveTouch.GetComponent <BoxCollider>();

        EffectBlock[] eb = GetComponentsInChildren <EffectBlock>();
        for (int i = 0; i < eb.Length; i++)
        {
            eb[i].OnCloseWall += (int num) =>
            {
                if (num > 2)
                {
                    SetArrowState(promptArrow2, true, airWallPos.transform.position);
                }
            };

            if (null == block && eb[i].transform.childCount == 2)
            {
                block = eb[i];
            }
        }

        for (int i = 0; i < Globe.fightHero.Length; i++)
        {
            if (Globe.fightHero[i] != 0)
            {
                playerData.GetInstance().RefreshHeroToList(Globe.fightHero[i], 1, i == 0 ? 1 : 20);
            }
        }

        CreateMainHero();

        for (int i = 0; i < Globe.Heros().Length; i++)
        {
            if (null != Globe.Heros()[i] && Globe.Heros()[i].id != 0)
            {
                Globe.Heros()[i].useServerAttr = false;
                Globe.Heros()[i].RefreshAttr();
            }
        }

        defKey = TOUCH_KEY.Run;
        ShowGuide(touchMove.transform, true);
        ShowGuidePanel(1);
        StartSpawn();
        SetArrowState(promptArrow1, true, player.transform.position);

        for (int i = 0; i < spwanList.Count; i++)
        {
            spwanList[i].isKM = false;
            if (spwanList[i].tag == Tag.boss)
            {
                spwanList[i].OnCreatMonster += (GameObject go, CharacterData cd) =>
                {
                    bossCs = go.GetComponent <CharacterState>();
                    TaskBossBlood();
                    go.GetComponent <CharacterState>().OnDead += (CharacterState cs) => { BossDead(); };
                };
            }
        }

        ReadTask(500);
        EnterDungensTask();

        ThirdCamera.instance._flatAngle = FSDataNodeTable <SceneNode> .GetSingleton().FindDataByType(GameLibrary.dungeonId).flat_angle;

        mask = SceneUIManager.instance.transform.Find("GuideMask").gameObject;
    }
コード例 #12
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            PointLight light = entity.GetOrCreate <PointLight>("PointLight");

            light.Serialize = false;

            const float defaultLightAttenuation = 15.0f;

            light.Attenuation.Value = defaultLightAttenuation;

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

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

            if (!main.EditorEnabled)
            {
                Sound.AttachTracker(entity);
                SoundKiller.Add(entity, AK.EVENTS.STOP_GLOWSQUARE);
                entity.Add(new PostInitialization(delegate()
                {
                    AkSoundEngine.PostEvent(AK.EVENTS.PLAY_GLOWSQUARE, entity);
                    AkSoundEngine.SetRTPCValue(AK.GAME_PARAMETERS.SFX_GLOWSQUARE_PITCH, -1.0f, entity);
                }));
            }

            AI ai = entity.GetOrCreate <AI>("AI");

            ModelAlpha model = entity.GetOrCreate <ModelAlpha>();

            model.Add(new Binding <Matrix>(model.Transform, transform.Matrix));
            model.Filename.Value  = "AlphaModels\\box";
            model.Serialize       = false;
            model.DrawOrder.Value = 15;

            const float defaultModelScale = 1.0f;

            model.Scale.Value = new Vector3(defaultModelScale);

            model.Add(new Binding <Vector3, string>(model.Color, delegate(string state)
            {
                switch (state)
                {
                case "Alert":
                    return(new Vector3(1.5f, 1.5f, 0.5f));

                case "Chase":
                    return(new Vector3(1.5f, 0.5f, 0.5f));

                case "Explode":
                    return(new Vector3(2.0f, 1.0f, 0.5f));

                default:
                    return(new Vector3(1.0f, 1.0f, 1.0f));
                }
            }, ai.CurrentState));

            entity.Add(new Updater
                       (
                           delegate(float dt)
            {
                float source            = 1.0f + ((float)this.random.NextDouble() - 0.5f) * 2.0f * 0.05f;
                model.Scale.Value       = new Vector3(defaultModelScale * source);
                light.Attenuation.Value = defaultLightAttenuation * source;
            }
                       ));

            model.Add(new Binding <bool, string>(model.Enabled, x => x != "Exploding", ai.CurrentState));

            light.Add(new Binding <Vector3>(light.Color, model.Color));

            Agent agent = entity.GetOrCreate <Agent>();

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

            RaycastAIMovement movement = entity.GetOrCreate <RaycastAIMovement>("Movement");
            Exploder          exploder = entity.GetOrCreate <Exploder>("Exploder");

            AI.Task checkOperationalRadius = new AI.Task
            {
                Interval = 2.0f,
                Action   = delegate()
                {
                    bool shouldBeActive = (transform.Position.Value - main.Camera.Position).Length() < movement.OperationalRadius;
                    if (shouldBeActive && ai.CurrentState == "Suspended")
                    {
                        ai.CurrentState.Value = "Idle";
                    }
                    else if (!shouldBeActive && ai.CurrentState != "Suspended")
                    {
                        ai.CurrentState.Value = "Suspended";
                    }
                },
            };

            RaycastAI raycastAI = entity.GetOrCreate <RaycastAI>("RaycastAI");

            raycastAI.Add(new TwoWayBinding <Vector3>(transform.Position, raycastAI.Position));
            raycastAI.Add(new Binding <Quaternion>(transform.Quaternion, raycastAI.Orientation));

            AI.Task updatePosition = new AI.Task
            {
                Action = delegate()
                {
                    raycastAI.Update();
                },
            };

            ai.Add(new AI.AIState
            {
                Name  = "Suspended",
                Tasks = new[] { checkOperationalRadius, },
            });

            const float sightDistance   = 40.0f;
            const float hearingDistance = 0.0f;

            ai.Add(new AI.AIState
            {
                Name  = "Idle",
                Enter = delegate(AI.AIState previous)
                {
                    AkSoundEngine.SetRTPCValue(AK.GAME_PARAMETERS.SFX_GLOWSQUARE_PITCH, -1.0f, entity);
                },
                Tasks = new[]
                {
                    checkOperationalRadius,
                    updatePosition,
                    new AI.Task
                    {
                        Interval = 1.0f,
                        Action   = delegate()
                        {
                            raycastAI.Move(new Vector3(((float)this.random.NextDouble() * 2.0f) - 1.0f, ((float)this.random.NextDouble() * 2.0f) - 1.0f, ((float)this.random.NextDouble() * 2.0f) - 1.0f));
                        }
                    },
                    new AI.Task
                    {
                        Interval = 0.5f,
                        Action   = delegate()
                        {
                            Agent a = Agent.Query(transform.Position, sightDistance, hearingDistance, x => x.Entity.Type == "Player");
                            if (a != null)
                            {
                                ai.CurrentState.Value = "Alert";
                            }
                        },
                    },
                },
            });

            ai.Add(new AI.AIState
            {
                Name  = "Alert",
                Enter = delegate(AI.AIState previous)
                {
                    AkSoundEngine.PostEvent(AK.EVENTS.STOP_GLOWSQUARE, entity);
                },
                Exit = delegate(AI.AIState next)
                {
                    AkSoundEngine.PostEvent(AK.EVENTS.PLAY_GLOWSQUARE, entity);
                },
                Tasks = new[]
                {
                    checkOperationalRadius,
                    updatePosition,
                    new AI.Task
                    {
                        Interval = 1.0f,
                        Action   = delegate()
                        {
                            if (ai.TimeInCurrentState > 3.0f)
                            {
                                ai.CurrentState.Value = "Idle";
                            }
                            else
                            {
                                Agent a = Agent.Query(transform.Position, sightDistance, hearingDistance, x => x.Entity.Type == "Player");
                                if (a != null)
                                {
                                    ai.TargetAgent.Value  = a.Entity;
                                    ai.CurrentState.Value = "Chase";
                                }
                            }
                        },
                    },
                },
            });

            AI.Task checkTargetAgent = new AI.Task
            {
                Action = delegate()
                {
                    Entity target = ai.TargetAgent.Value.Target;
                    if (target == null || !target.Active)
                    {
                        ai.TargetAgent.Value  = null;
                        ai.CurrentState.Value = "Idle";
                    }
                },
            };

            ai.Add(new AI.AIState
            {
                Name  = "Chase",
                Enter = delegate(AI.AIState previous)
                {
                    AkSoundEngine.SetRTPCValue(AK.GAME_PARAMETERS.SFX_GLOWSQUARE_PITCH, 0.0f, entity);
                },
                Tasks = new[]
                {
                    checkOperationalRadius,
                    checkTargetAgent,
                    new AI.Task
                    {
                        Interval = 0.35f,
                        Action   = delegate()
                        {
                            raycastAI.Move(ai.TargetAgent.Value.Target.Get <Transform>().Position.Value - transform.Position);
                        }
                    },
                    new AI.Task
                    {
                        Action = delegate()
                        {
                            if ((ai.TargetAgent.Value.Target.Get <Transform>().Position.Value - transform.Position).Length() < 10.0f)
                            {
                                ai.CurrentState.Value = "Explode";
                            }
                        }
                    },
                    updatePosition,
                },
            });

            EffectBlockFactory factory = Factory.Get <EffectBlockFactory>();

            ai.Add(new AI.AIState
            {
                Name  = "Explode",
                Enter = delegate(AI.AIState previous)
                {
                    exploder.CoordQueue.Clear();

                    Entity voxelEntity = raycastAI.Voxel.Value.Target;
                    if (voxelEntity == null || !voxelEntity.Active)
                    {
                        ai.CurrentState.Value = "Alert";
                        return;
                    }

                    Voxel m = voxelEntity.Get <Voxel>();

                    Voxel.Coord c = raycastAI.Coord.Value;

                    Direction toSupport = Direction.None;

                    foreach (Direction dir in DirectionExtensions.Directions)
                    {
                        if (m[raycastAI.Coord.Value.Move(dir)].ID != 0)
                        {
                            toSupport = dir;
                            break;
                        }
                    }

                    if (toSupport == Direction.None)
                    {
                        ai.CurrentState.Value = "Alert";
                        return;
                    }

                    Direction up = toSupport.GetReverse();

                    exploder.ExplosionOriginalCoord.Value = raycastAI.Coord;

                    Direction right;
                    if (up.IsParallel(Direction.PositiveX))
                    {
                        right = Direction.PositiveZ;
                    }
                    else
                    {
                        right = Direction.PositiveX;
                    }
                    Direction forward = up.Cross(right);

                    for (Voxel.Coord y = c.Clone(); y.GetComponent(up) < c.GetComponent(up) + 3; y = y.Move(up))
                    {
                        for (Voxel.Coord x = y.Clone(); x.GetComponent(right) < c.GetComponent(right) + 2; x = x.Move(right))
                        {
                            for (Voxel.Coord z = x.Clone(); z.GetComponent(forward) < c.GetComponent(forward) + 2; z = z.Move(forward))
                            {
                                exploder.CoordQueue.Add(z);
                            }
                        }
                    }
                },
                Exit = delegate(AI.AIState next)
                {
                    exploder.CoordQueue.Clear();
                },
                Tasks = new[]
                {
                    checkOperationalRadius,
                    new AI.Task
                    {
                        Interval = 0.15f,
                        Action   = delegate()
                        {
                            if (exploder.CoordQueue.Length > 0)
                            {
                                raycastAI.MoveTo(exploder.CoordQueue[0]);

                                exploder.CoordQueue.RemoveAt(0);

                                Entity blockEntity = factory.CreateAndBind(main);
                                Voxel.States.Infected.ApplyToEffectBlock(blockEntity.Get <ModelInstance>());

                                Entity mapEntity = raycastAI.Voxel.Value.Target;
                                if (mapEntity != null && mapEntity.Active)
                                {
                                    EffectBlock effectBlock = blockEntity.Get <EffectBlock>();
                                    Voxel m = mapEntity.Get <Voxel>();

                                    effectBlock.Offset.Value = m.GetRelativePosition(raycastAI.Coord);

                                    Vector3 absolutePos = m.GetAbsolutePosition(raycastAI.Coord);

                                    effectBlock.StartPosition    = absolutePos + new Vector3(0.05f, 0.1f, 0.05f);
                                    effectBlock.StartOrientation = Quaternion.CreateFromYawPitchRoll(0.15f, 0.15f, 0);
                                    effectBlock.TotalLifetime    = 0.05f;
                                    effectBlock.Setup(raycastAI.Voxel.Value.Target, raycastAI.Coord, Voxel.t.Infected);
                                    main.Add(blockEntity);
                                }
                            }
                        }
                    },
                    new AI.Task
                    {
                        Action = delegate()
                        {
                            AkSoundEngine.SetRTPCValue(AK.GAME_PARAMETERS.SFX_GLOWSQUARE_PITCH, MathHelper.Lerp(0.0f, 1.0f, ai.TimeInCurrentState.Value / 2.0f), entity);
                            if (exploder.CoordQueue.Length == 0)
                            {
                                // Explode
                                ai.CurrentState.Value = "Exploding";
                            }
                        },
                    },
                    updatePosition,
                },
            });

            ai.Add(new AI.AIState
            {
                Name  = "Exploding",
                Enter = delegate(AI.AIState previous)
                {
                    exploder.Exploded.Value = false;
                    AkSoundEngine.PostEvent(AK.EVENTS.STOP_GLOWSQUARE, entity);
                },
                Exit = delegate(AI.AIState next)
                {
                    exploder.Exploded.Value = false;
                    AkSoundEngine.PostEvent(AK.EVENTS.PLAY_GLOWSQUARE, entity);
                },
                Tasks = new[]
                {
                    new AI.Task
                    {
                        Interval = 0.1f,
                        Action   = delegate()
                        {
                            const int radius = 9;

                            float timeInCurrentState = ai.TimeInCurrentState;
                            if (timeInCurrentState > 1.0f && !exploder.Exploded)
                            {
                                Entity mapEntity = raycastAI.Voxel.Value.Target;
                                if (mapEntity != null && mapEntity.Active)
                                {
                                    Explosion.Explode(main, mapEntity.Get <Voxel>(), raycastAI.Coord, radius, 18.0f);
                                }

                                exploder.Exploded.Value = true;
                            }

                            if (timeInCurrentState > 2.0f)
                            {
                                raycastAI.Move(new Vector3(((float)this.random.NextDouble() * 2.0f) - 1.0f, ((float)this.random.NextDouble() * 2.0f) - 1.0f, ((float)this.random.NextDouble() * 2.0f) - 1.0f));
                                ai.CurrentState.Value = "Alert";
                            }
                        },
                    },
                    updatePosition,
                },
            });

            this.SetMain(entity, main);

            entity.Add("OperationalRadius", movement.OperationalRadius);
        }