Inheritance: MonoBehaviour
Exemplo n.º 1
0
        internal static void WarpBarrierKernel(
            GroupedIndex index,
            ArrayView <int> data)
        {
            var idx = index.GridIdx * Group.DimensionX + index.GroupIdx;

            Warp.Barrier();
            data[idx] = idx;
        }
Exemplo n.º 2
0
    public void ChangeWarp(int f, int t)
    {
        if (!Application.isPlaying)
        {
            return;
        }

        if (delay > 0.0f)
        {
            delay -= Time.deltaTime;
            return;
        }

        if (time <= switchtime)
        {
            time += Time.deltaTime;

            Warp from = warps[f];
            Warp to   = warps[t];

            float a = time / switchtime;
            if (a > 1.0f)
            {
                a           = 1.0f;
                currentwarp = t;
                t++;
                destwarp = t;
                if (destwarp >= warps.Count)
                {
                    destwarp = 0;
                }
                srcwarp = currentwarp;
                time    = 0.0f;
                delay   = 1.0f;
            }

            p11 = easeInOutSine(from.points[0], to.points[0], a);
            p12 = easeInOutSine(from.points[1], to.points[1], a);
            p13 = easeInOutSine(from.points[2], to.points[2], a);
            p14 = easeInOutSine(from.points[3], to.points[3], a);

            p21 = easeInOutSine(from.points[4], to.points[4], a);
            p22 = easeInOutSine(from.points[5], to.points[5], a);
            p23 = easeInOutSine(from.points[6], to.points[6], a);
            p24 = easeInOutSine(from.points[7], to.points[7], a);

            p31 = easeInOutSine(from.points[8], to.points[8], a);
            p32 = easeInOutSine(from.points[9], to.points[9], a);
            p33 = easeInOutSine(from.points[10], to.points[10], a);
            p34 = easeInOutSine(from.points[11], to.points[11], a);

            p41 = easeInOutSine(from.points[12], to.points[12], a);
            p42 = easeInOutSine(from.points[13], to.points[13], a);
            p43 = easeInOutSine(from.points[14], to.points[14], a);
            p44 = easeInOutSine(from.points[15], to.points[15], a);
        }
    }
Exemplo n.º 3
0
            /// <summary>
            /// Performs a shuffle operation. It returns the value of the variable
            /// in the context of the lane with the id current lane + delta.
            /// </summary>
            /// <param name="variable">The source variable to shuffle.</param>
            /// <param name="delta">The delta to add to the current lane.</param>
            /// <returns>The value of the variable in the scope of the desired lane.</returns>
            public unsafe long ShuffleDown(long variable, int delta)
            {
                var result = new Int2();
                var ptr    = (Int2 *)&variable;

                result.X = Warp.ShuffleDown(ptr->X, delta);
                result.Y = Warp.ShuffleDown(ptr->Y, delta);
                return(*(long *)&result);
            }
Exemplo n.º 4
0
 public void DisplayWarpTo(Warp warpObj, Aisling obj)
 {
     if (obj.WithinRangeOf(warpObj.Location.X, warpObj.Location.Y, 10))
     {
         obj.Show(Scope.Self, new ServerFormat29(
                      ServerContext.Config.WarpNumber,
                      warpObj.Location.X, warpObj.Location.Y));
     }
 }
Exemplo n.º 5
0
 public void DisplayWarpTo(Warp warpObj, Aisling obj)
 {
     if (obj.Position.WithinSquare(warpObj.Location, 10))
     {
         obj.Show(Scope.Self, new ServerFormat29(
                      295,
                      warpObj.Location.X, warpObj.Location.Y));
     }
 }
Exemplo n.º 6
0
        /* Following few are untested */
        public static void ManageWarp(ISender sender, ArgumentList args)
        {
            //remove/add players, delete warp
            bool   delete   = args.TryPop("delete");
            bool   remove   = args.TryPop("removeplayer");
            bool   add      = args.TryPop("addplayer");
            string username = args.GetString(0);

            int warpIndex;

            if (!WarpManager.ContainsWarp(username, out warpIndex))
            {
                throw new CommandError("No Warp by that name exists.");
            }

            if (delete)
            {
                WarpManager.WarpList.RemoveAt(warpIndex);
                sender.sendMessage("Warp successfully removed.");
            }
            else if (remove)
            {
                Warp warp = WarpManager.WarpList.ElementAt(warpIndex);

                int usrIndex;
                if (warp.ContainsUser(username, out usrIndex))
                {
                    warp.Users.RemoveAt(usrIndex);
                    WarpManager.UpdateWarp(warp);
                    sender.Message("{0} has been removed from {1}", username, warp.Name);
                }
                else
                {
                    throw new CommandError("No user exists.");
                }
            }
            else if (add)
            {
                Warp warp = WarpManager.WarpList.ElementAt(warpIndex);

                int usrIndex;
                if (!warp.ContainsUser(username, out usrIndex))
                {
                    warp.Users.Add(WarpManager.CleanUserName(username));
                    WarpManager.UpdateWarp(warp);
                    sender.Message("{0} has been added to {1}", username, warp.Name);
                }
                else
                {
                    throw new CommandError("User exists already.");
                }
            }
            else
            {
                throw new CommandError("No Manage Action defined.");
            }
        }
Exemplo n.º 7
0
 public void SetPareWarp(GameObject pareWarp)
 {
     this.pareWarpPrefab = pareWarp;
     this.exitWarp       = pareWarpPrefab.GetComponent <Warp>();
     StartCoroutine(DelayMethod(1f, () =>
     {
         SetUseAble();
         exitWarp.SetUseAble();
     }));
 }
Exemplo n.º 8
0
    void Awake()
    {
        warps = new Warp[warpCount];

        for (int i = 0; i < warps.Length; i++)
        {
            Warp warp = warps[i] = Instantiate <Warp>(warpPrefab);
            warp.transform.SetParent(transform, false);
        }
    }
Exemplo n.º 9
0
 private void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
 {
     if (SleepPrimed)
     {
         SleepPrimed = false;
         WarpBack    = new Warp(Game1.player.getTileX(), Game1.player.getTileY(), Game1.currentLocation.Name, Game1.player.getTileX(), Game1.player.getTileY(), false);
         Game1.player.warpFarmer(WarpThere);
         Game1.player.warpFarmer(WarpBack);
     }
 }
Exemplo n.º 10
0
        private bool IsRealPkInDb(SqlHelper sqlhelper, string tableName, string columnName)
        {
            var pkName = Warp.ShieldLogSql(() => GetPrimaryKey(sqlhelper, "", tableName));

            if (pkName == null)
            {
                return(false);
            }
            return(columnName == pkName.ToString());
        }
Exemplo n.º 11
0
        private bool IsRealPkInDb(SqlHelper sqlhelper, string tableName, string columnName)
        {
            var getconstraint = Warp.ShieldLogSql(() => GetPrimaryKey(sqlhelper, "", tableName));

            if (getconstraint == null)
            {
                return(false);
            }
            return(columnName.ToUpper() == getconstraint.ToString().ToUpper());
        }
Exemplo n.º 12
0
 public bool Equals(OverlayInfo other)
 {
     return(other != null && X == other.X && Y == other.Y &&
            Width == other.Width && Height == other.Height &&
            CropLeft == other.CropLeft && CropTop == other.CropTop &&
            CropRight == other.CropRight && CropBottom == other.CropBottom &&
            Angle == other.Angle && Warp.Equals(other.Warp) &&
            BaseWidth == other.BaseWidth && BaseHeight == other.BaseHeight &&
            SourceWidth == other.SourceWidth && SourceHeight == other.SourceHeight);
 }
Exemplo n.º 13
0
    void Update()
    {
        var closeness = Warp.closenessFactor(transform.position, Facts.asteroidShakeDistance);

        material.color = new Color(
            Mathf.Lerp(1.0f, proximityColor.r, closeness),
            Mathf.Lerp(1.0f, proximityColor.g, closeness),
            Mathf.Lerp(1.0f, proximityColor.b, closeness)
            );
    }
Exemplo n.º 14
0
        internal static void WarpBroadcastKernel(
            ArrayView1D <int, Stride1D.Dense> data,
            ArrayView1D <int, Stride1D.Dense> data2,
            int c)
        {
            var idx = Grid.GlobalIndex.X;

            data[idx]  = Warp.Broadcast(Group.IdxX, Warp.WarpSize - 1);
            data2[idx] = Warp.Broadcast(c, Warp.WarpSize - 2);
        }
Exemplo n.º 15
0
        public static T ExclusiveScan <T, TScanOperation>(T value)
            where T : unmanaged
            where TScanOperation : struct, IScanReduceOperation <T>
        {
            var inclusive = InclusiveScan <T, TScanOperation>(value);

            var exclusive = Warp.ShuffleUp(inclusive, 1);

            return(Warp.IsFirstLane ? default(TScanOperation).Identity : exclusive);
        }
Exemplo n.º 16
0
        public void SyncDbInfo(string key, string className, string tableName)
        {
            var sqlhelper = IntrospectionManager.GetSqlHelperByKey(key);


            if (IsNeedAddTable(sqlhelper, tableName))
            {
                #region Alter
                var columns = IntrospectionManager.GetColumnAttributes(className).OrderByDescending(x => x.Value.IsPrimaryKey);
                var cols    = Warp.ShieldLogSql(() => GetColumns(sqlhelper, sqlhelper.DataBaseName, tableName));

                var needRebuild = false;

                foreach (var column in columns)
                {
                    #region Alter
                    var memberType     = IntrospectionManager.GetMemberType(className, column.Key);
                    var columnType     = IntrospectionManager.GetColumnType(className, column.Key);
                    var columnName     = IntrospectionManager.GetColumnName(className, column.Key);
                    var length         = IntrospectionManager.GetColumnLength(className, column.Key);
                    var isAutoGrow     = IntrospectionManager.GetColumnIsAutoGrow(className, column.Key);
                    var isRealAutoGrow = IsRealAutoGrow(sqlhelper, tableName, columnName);
                    var isNullAble     = IntrospectionManager.GetColumnIsNullAble(className, column.Key);
                    var isPk           = IntrospectionManager.GetColumnIsPrimaryKey(className, column.Key);
                    var isRealPk       = IsRealPkInDb(sqlhelper, tableName, columnName);

                    var lastColumnType = GetColumnTypeByMebmberType(memberType, columnType.ToLower(), length);
                    if (cols.Any(x => x.name.ToUpper() == columnName.ToUpper()))
                    {
                        if (!IsNeedModiy(cols, memberType, columnName, lastColumnType, length, isNullAble, isPk, isRealPk, isAutoGrow, isRealAutoGrow))
                        {
                            continue;
                        }
                        needRebuild = true;
                        break;
                    }
                    else
                    {
                        needRebuild = true;
                        break;
                    }

                    #endregion
                }
                if (needRebuild)
                {
                    ModiyTable(sqlhelper, className, tableName);
                }
                #endregion
            }
            else
            {
                CreateTable(sqlhelper, null, className, tableName);
            }
        }
Exemplo n.º 17
0
        internal static void WarpShuffleKernel(
            Index1D index,
            ArrayView1D <int, Stride1D.Dense> data,
            ArrayView1D <int, Stride1D.Dense> data2,
            int c)
        {
            var targetIdx = Warp.WarpSize - 1;

            data[index]  = Warp.Shuffle(Warp.LaneIdx, targetIdx);
            data2[index] = Warp.Shuffle(c, targetIdx);
        }
Exemplo n.º 18
0
        public void TestParseSuccess()
        {
            var warp = new Warp(2)
            {
                [0] = new RectangleD(0, 0, -3, 0),
                [1] = new RectangleD(1000, 500, 3, 4.4)
            };

            Assert.IsTrue(Warp.TryParse(warp.ToString(), out var parsed));
            Assert.AreEqual(warp, parsed);
        }
Exemplo n.º 19
0
    void Start()
    {
        anim     = GetComponent <Animator>();
        rb2d     = GetComponent <Rigidbody2D>();
        sword    = GetComponent <Sword>();
        magic    = GameObject.FindGameObjectWithTag("GameManager").GetComponent <Magic>();
        cooldown = GameObject.FindGameObjectWithTag("CoolDown").GetComponent <CoolDown>();
        boss     = GameObject.FindGameObjectWithTag("Boss").GetComponent <ScriptBoss>();
        warp     = GameObject.FindGameObjectWithTag("Warp").GetComponent <Warp>();


        ShieldPotionMult = 1;
        TimePotionMult   = 1;
        LuckPotionMult   = 1;

        Debuff = false;

        maincamera.gameObject.SetActive(true);
        bosscamera.gameObject.SetActive(false);

        mapa1 = false;
        mapa2 = false;
        mapa3 = false;



        /*	Fazemos com que a variável "attackCollider" receba o Componente CircleCollider pertencente ao GameObject
         *               do "primeiro filho" do GameObject a qual esse script está inserido (que no caso é o Player).
         *               (Nós declaramos o primeiro filho pela linha de código "GetChild (0)". Em inglês essa linha se traduziria
         *               para algo como "Pegue o filho 0", sendo que "filho 0" nesse caso refere-se ao primeiro filho do Objeto Player)*/
        attackCollider = transform.GetChild(0).GetComponent <CircleCollider2D>();

        //shadow = transform.GetChild(3).GetComponent<SpriteRenderer>();
        //shadow.color =new Color(10, 10, 10, 103);

        /* Agora, após termos declarado a variável "attackCollider" acima, nós queremos que esse collider esteja inativo
         *              no início do jogo para evitar que o personagem cause dano em tudo á sua frente sem necessitar apertar a tecla
         *              de ataque, certo? Então, nós fazemos isso deixando como FALSA a informação de que a variável já esteja ativa.
         *              Inclusive estamos fazendo isso dentro do "Void Start" justamente para o jogo já começar com isso definido como desativado.*/
        attackCollider.enabled = false;

        /* Mas ter colocado a linha acima gera um problema... que é o seguinte:
         *      O collider já começa o jogo como falso, certo? Ok, mas então... COMO nós vamos fazer para ativar o collider
         *      no momento que o jogador realizar o ataque?
         *      Nós desativamos o collider no início do jogo, mas em nenhum momento nós pedimos para o script reativá-lo, ou seja,
         *      o jogador nunca vai atacar.
         *      É por esse motivo que nós vamos definir o momento certo para que esse Collider seja ativado. Nós o colocaremos embaixo
         *      da linha de código que atualiza a posição X e Y do collider conforme a direção que o personagem estiver olhando.
         */



        //	Camera.main.GetComponent<MainCamera>().SetBound(InitialMap);
    }
        public ScreenGenerator(byte[] options, bool applyFixes = false)
        {
            this.warp       = (Warp)options[0];
            this._base      = (Base)options[1];
            this.overlay_a  = (Overlay_A)options[2];
            this.overlay_b  = (Overlay_B)options[3];
            this.blend_mode = (Blend_Mode)options[4];

            ApplyFixes = applyFixes;
            TemplateGenerationValid = true;
        }
Exemplo n.º 21
0
    private void WarpShift()
    {
        Warp ws = warps[0];

        for (int i = 1; i < warps.Length; i++)
        {
            warps[i - 1] = warps[i];
        }

        warps[warps.Length - 1] = ws;
    }
Exemplo n.º 22
0
        private void DrawWarp(Graphics g, Warp warp, Point point)
        {
            var clientPoint = MapPointToScreenPoint(point);

            g.FillPolygon(new SolidBrush(Color.FromArgb(127, Color.Purple)), new Point[] {
                new Point(clientPoint.X, clientPoint.Y + Tileset.TileHeight / 2),
                new Point(clientPoint.X + Tileset.TileWidth / 2, clientPoint.Y + Tileset.TileHeight - 1),
                new Point(clientPoint.X + Tileset.TileWidth - 1, clientPoint.Y + Tileset.TileHeight / 2),
                new Point(clientPoint.X + Tileset.TileWidth / 2, clientPoint.Y)
            });
        }
Exemplo n.º 23
0
            /// <summary>
            /// Performs a shuffle operation. It returns the value of the variable
            /// in the context of the lane with the id current lane + delta.
            /// </summary>
            /// <param name="variable">The source variable to shuffle.</param>
            /// <param name="delta">The delta to add to the current lane.</param>
            /// <returns>The value of the variable in the scope of the desired lane.</returns>
            public long ShuffleDown(long variable, int delta)
            {
                var source = Unsafe.As <long, Int2>(ref variable);
                var result = new Int2()
                {
                    X = Warp.ShuffleDown(source.X, delta),
                    Y = Warp.ShuffleDown(source.Y, delta),
                };

                return(Unsafe.As <Int2, long>(ref result));
            }
        /// <summary>
        /// Generator instantiation for method specific shaders.
        /// </summary>
        public ScreenGenerator(Warp warp, Base _base, Overlay_A overlay_a, Overlay_B overlay_b, Blend_Mode blend_mode, bool applyFixes = false)
        {
            this.warp       = warp;
            this._base      = _base;
            this.overlay_a  = overlay_a;
            this.overlay_b  = overlay_b;
            this.blend_mode = blend_mode;

            ApplyFixes = applyFixes;
            TemplateGenerationValid = true;
        }
Exemplo n.º 25
0
        /// <summary>
        /// Explicitly grouped kernels receive an index type (first parameter) of type:
        /// <see cref="GroupedIndex"/>, <see cref="GroupedIndex2"/> or <see cref="GroupedIndex3"/>.
        /// Note that you can use warp-shuffle functionality only within
        /// explicitly-grouped kernels. Previously, it was required to use one of the predefined
        /// shuffle overloads. If the desired function was not available, you had to create a
        /// custom shuffle operation implementation. The current ILGPU version emits the required
        /// shuffle instructions (even for complex data types) automatically.
        /// </summary>
        /// <param name="index">The current thread index.</param>
        /// <param name="dataView">The view pointing to our memory buffer.</param>
        static void ShuffleDownKernel(
            ArrayView <int> dataView)          // A view to a chunk of memory (1D in this case)
        {
            // Use native shuffle-down functionality to shuffle the
            // given value by a delta of 2 lanes
            int value = Group.IdxX;

            value = Warp.ShuffleDown(value, 2);

            dataView[Grid.GlobalIndex.X] = value;
        }
        private async void HistoryListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            Warp history = (Warp)e.ClickedItem;

            if (this.HistoryEvent != null)
            {
                this.HistoryEvent(history, new EventArgs());
            }
            await Task.Delay(100);

            ((ListView)sender).SelectedItem = null;
        }
Exemplo n.º 27
0
        public void RegisterWarp(string warpName, Vector3 warpPosition)
        {
            var warp = new Warp
            {
                WarpName  = warpName,
                PositionX = warpPosition.x,
                PositionY = warpPosition.y,
                PositionZ = warpPosition.z
            };

            WarpsDatabase.CreateWarp(warp);
        }
        public static bool WarpIfInRange(GameLocation gameLocation, Warp warp)
        {
            Vector2 warpVector = new Vector2(warp.X * Game1.tileSize, warp.Y * Game1.tileSize);

            if (Vector2.Distance(warpVector, Game1.player.position.Value) < ClickToMoveHelper.WarpRange(gameLocation))
            {
                Game1.player.warpFarmer(warp);
                return(true);
            }

            return(false);
        }
Exemplo n.º 29
0
        public dynamic ResizeRotate(
            Clip clip,
            string resizeFunc, string rotateFunc,
            int width, int height, int angle = 0,
            RectangleD crop = default, Warp warp = default)
        {
            if (clip == null)
            {
                return(null);
            }
            var dynamic = clip.Dynamic();

            if (warp != null && !warp.IsEmpty)
            {
                dynamic = dynamic.Warp(warp.ToArray(), relative: true, resample: OverlayUtils.GetWarpResampleMode(resizeFunc));
            }

            var vi = clip.GetVideoInfo();

            if (crop.IsEmpty && width == vi.width && height == vi.height)
            {
                return(dynamic);
            }

            var intCrop = Rectangle.FromLTRB(
                (int)Math.Floor(crop.Left),
                (int)Math.Floor(crop.Top),
                (int)Math.Floor(crop.Right),
                (int)Math.Floor(crop.Bottom)
                );

            if (!intCrop.IsEmpty)
            {
                dynamic = dynamic.Crop(intCrop.Left, intCrop.Top, -intCrop.Right, -intCrop.Bottom);
                crop    = RectangleD.FromLTRB(
                    crop.Left - intCrop.Left,
                    crop.Top - intCrop.Top,
                    crop.Right - intCrop.Right,
                    crop.Bottom - intCrop.Bottom
                    );
            }
            if (crop.IsEmpty)
            {
                dynamic = dynamic.Invoke(resizeFunc, width, height);
            }
            else
            {
                dynamic = dynamic.Invoke(resizeFunc, width, height,
                                         src_left: crop.Left, src_top: crop.Top,
                                         src_width: -crop.Right, src_height: -crop.Bottom);
            }
            return(angle == 0 ? dynamic : dynamic.Invoke(rotateFunc, angle / 100.0));
        }
Exemplo n.º 30
0
        protected override XYZ GetValue(XYZ xyz)
        {
            if (xyz == default)
            {
                throw new ArgumentNullException(nameof(xyz));
            }

            var amp       = Bounding * Warp.Amptitude;
            var frequency = Warp.Frequency;

            return(Warp.Get(amp, frequency, xyz));
        }
Exemplo n.º 31
0
 public PowerUp getPowerUp(PowerUpList chosenPowerUpID)
 {
     PowerUp chosenPowerUp = null;
     switch (chosenPowerUpID) {
     case PowerUpList.SlowDown:
         chosenPowerUp = new SlowDown(10);
         break;
     case PowerUpList.SpeedUp:
         chosenPowerUp = new SpeedUp(10);
         break;
     case PowerUpList.Warp:
         chosenPowerUp = new Warp(10);
         break;
     case PowerUpList.IceyPlayer:
         chosenPowerUp = new IceyPlayer(10);
         break;
     case PowerUpList.ObjectSpawnPowerUp:
         chosenPowerUp = new ObjectSpawnPowerUp(10);
         break;
     case PowerUpList.Pull:
         chosenPowerUp = new Pull(10);
         break;
     case PowerUpList.Push:
         chosenPowerUp = new Push(10);
         break;
     case PowerUpList.Bigger:
         chosenPowerUp = new Bigger(10);
         break;
     case PowerUpList.Smaller:
         chosenPowerUp = new Smaller(10);
         break;
     case PowerUpList.OrbitingShield:
         chosenPowerUp = new OrbitingShield(10);
         break;
     }
     return chosenPowerUp;
 }
Exemplo n.º 32
0
        /// <summary>
        /// Create a new Hybrasyl map from an XMLMap object.
        /// </summary>
        /// <param name="mapElement"></param>
        public Map(XSD.Map newMap, World theWorld)
        {
            Init();
            World = theWorld;

            // TODO: refactor Map class to not do this, but be a partial which overlays
            // TODO: XmlMap (which would then just be Map)
            Id = newMap.Id;
            X = newMap.X;
            Y = newMap.Y;
            Name = newMap.Name;
            EntityTree = new QuadTree<VisibleObject>(0,0,X,Y);
            Music = newMap.Music;

            foreach (var warpElement in newMap.Warps)
            {
                var warp = new Warp(this);
                warp.X = warpElement.X;
                warp.Y = warpElement.Y;

                if (warpElement.MapTarget !=null)
                {
                    var maptarget = warpElement.MapTarget as XSD.WarpMaptarget;
                    // map warp
                    warp.DestinationMapName = maptarget.Value;
                    warp.WarpType = WarpType.Map;
                    warp.DestinationX = maptarget.X;
                    warp.DestinationY = maptarget.Y;
                }
                else
                {
                    var worldmaptarget = warpElement.WorldMapTarget as XSD.WorldMapPointTarget;
                    // worldmap warp
                    warp.DestinationMapName = worldmaptarget.Value;
                    warp.WarpType = WarpType.WorldMap;
                }

                warp.MinimumLevel = warpElement.Restrictions.Level.Min;
                warp.MaximumLevel = warpElement.Restrictions.Level.Max;
                warp.MinimumAbility = warpElement.Restrictions.Ab.Min;
                warp.MaximumAbility = warpElement.Restrictions.Ab.Max;
                warp.MobUse = warpElement.Restrictions.NoMobUse == null;
                Warps[new Tuple<byte, byte>(warp.X, warp.Y)] = warp;
            }

            foreach (var npcElement in newMap.Npcs)
            {
                var merchant = new Merchant
                {
                    X = npcElement.X,
                    Y = npcElement.Y,
                    Name = npcElement.Name,
                    Sprite = npcElement.Appearance.Sprite,
                    Direction = (Enums.Direction) npcElement.Appearance.Direction,
                    Portrait = npcElement.Appearance.Portrait,
                    // Wow this is terrible
                    Jobs = ((MerchantJob) (int) npcElement.Jobs)
                };
                InsertNpc(merchant);
            }

            foreach (var reactorElement in newMap.Reactors)
            {
                // TODO: implement reactor loading support
            }

            foreach (var postElement in newMap.Signposts.Items)
            {
                if (postElement is XSD.Signpost)
                {
                    var signpostElement = postElement as XSD.Signpost;
                    var signpost = new Objects.Signpost(signpostElement.X, signpostElement.Y, signpostElement.Message);
                    InsertSignpost(signpost);
                }
                else
                {
                    // TODO: Messageboards
                    Logger.InfoFormat("{0}: messageboard ignored", Name);                
                }
            }

            foreach (var spawnElement in newMap.Spawns)
            {
                // TODO: implement spawning
            }

            Load();
        }
Exemplo n.º 33
0
 public void WarpPlayer(object player, Warp warp)
 {
     TSPlayer p = GetPlayer(player);
     p.Teleport(warp.Position.X * 16, warp.Position.Y * 16);
 }
Exemplo n.º 34
0
 public void AddWarp()
 {
     Warp warp = new Warp();
     warp.SetWarp(this);
     warps.Add(warp);
 }
Exemplo n.º 35
0
		/// <summary>
		/// Handles the opening of the door (event handler for when the DOOR_OPEN packet is received)
		/// </summary>
		public void OnDoorOpened(byte x, byte y)
		{
			if (_door != null && _door.doorOpened)
			{
				_door.doorOpened = false;
				_door.backOff = false;
				_doorY = 0;
			}

			if ((_door = MapRef.WarpLookup[y, x]) != null)
			{
				if(World.Instance.SoundEnabled)
					((EOGame) Game).SoundManager.GetSoundEffectRef(SoundEffectID.DoorOpen).Play();
				_door.doorOpened = true;
				_doorY = y;
				_doorTimer.Change(3000, 0);
			}
		}
Exemplo n.º 36
0
		/// <summary>
		/// Sends the initial DOOR_OPEN packet to the server for a certain Warp. Sets the warpRef.backOff = true
		/// </summary>
		public void StartOpenDoor(Warp warpRef, byte x, byte y)
		{
			warpRef.backOff = true; //set flag to prevent hella door packets from the client
			if(!m_api.DoorOpen(x, y))
				((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
		}
Exemplo n.º 37
0
		public void SetActiveMap(MapFile newActiveMap)
		{
			m_drawingEvent.Wait();
			m_drawingEvent.Reset();

			if(MapRef != null && MapRef.AmbientNoise != 0)
				EOGame.Instance.SoundManager.StopLoopingSoundEffect(MapRef.AmbientNoise);
			
			MapRef = newActiveMap;

			if (m_miniMapRenderer == null)
				m_miniMapRenderer = new MiniMapRenderer(this);
			else
				m_miniMapRenderer.Map = MapRef;

			MapItems.Clear();
			lock (_rendererListLock)
			{
				otherRenderers.ForEach(_rend => _rend.Dispose());
				otherRenderers.Clear();
			}

			lock (_npcListLock)
			{
				npcList.ForEach(_npc => _npc.Dispose());
				npcList.Clear();
			}
			lock (_spikeTrapsLock)
				_visibleSpikeTraps.Clear();

			//need to reset door-related members when changing maps.
			if (_door != null)
			{
				_door.doorOpened = false;
				_door.backOff = false;
				_door = null;
				_doorY = 0;
				_doorTimer.Change(Timeout.Infinite, Timeout.Infinite);
			}

			m_mapLoadTime = DateTime.Now;
			m_transitionMetric = 1;
			if (!MapRef.MapAvailable)
				m_miniMapRenderer.Visible = false;

			if (MapRef.Name.Length > 0)
			{
				if (EOGame.Instance.Hud != null)
					EOGame.Instance.Hud.AddChat(ChatTabs.System, "", World.GetString(DATCONST2.STATUS_LABEL_YOU_ENTERED) + " " + MapRef.Name, ChatType.NoteLeftArrow);
				else
					m_needDispMapName = true;
			}

			PlayOrStopBackgroundMusic();
			PlayOrStopAmbientNoise();

			m_drawingEvent.Set();
		}
Exemplo n.º 38
0
 public void PlayerWarp(Warp warp)
 {
     foreach (Model model in ModelList)
     {
         if (model is MapModel)
         {
             MapModel mapModel = (MapModel)model;
             switch (warp)
             {
                 case Warp.LEFT:
                     if (mapModel.CurrentMap > 0) mapModel.CurrentMap--;
                     break;
                 case Warp.RIGHT:
                     mapModel.CurrentMap++;
                     break;
                 default:
                     break;
             }
             mapModel.Update();
         }
     }
 }
Exemplo n.º 39
0
        public override ModuleBase GetModule()
        {
            // check that has inputs
            for(int i = 0; i < inputs.Length; i++) {
            if(inputs[i] == null) {
                return null;
            }
            }

            // get module
            switch(type) {
            case OPERATORTYPE.ABS:
                module = new Abs(inputs[0].GetModule());
                break;
            case OPERATORTYPE.ADD:
                module = new Add(inputs[0].GetModule(), inputs[1].GetModule());
                break;
            case OPERATORTYPE.BLEND:
                module = new Blend(inputs[0].GetModule(), inputs[1].GetModule(), inputs[2].GetModule());
                break;
            case OPERATORTYPE.CLAMP:
                module = new Clamp(min, max, inputs[0].GetModule());
                break;
            case OPERATORTYPE.EXPONENT:
                module = new Exponent(exponent, inputs[0].GetModule());
                break;
            case OPERATORTYPE.INVERT:
                module = new Invert(inputs[0].GetModule());
                break;
            case OPERATORTYPE.MAX:
                module = new Max(inputs[0].GetModule(), inputs[1].GetModule());
                break;
            case OPERATORTYPE.MIN:
                module = new Min(inputs[0].GetModule(), inputs[1].GetModule());
                break;
            case OPERATORTYPE.MULTIPLY:
                module = new Multiply(inputs[0].GetModule(), inputs[1].GetModule());
                break;
            case OPERATORTYPE.POWER:
                module = new Power(inputs[0].GetModule(), inputs[1].GetModule());
                break;
            case OPERATORTYPE.SUBTRACT:
                module = new Subtract(inputs[0].GetModule(), inputs[1].GetModule());
                break;
            case OPERATORTYPE.TERRACE:
                module = new Terrace(min, max, power, inputs[0].GetModule());
                break;
            case OPERATORTYPE.TRANSLATE:
                module = new Translate(x, y, z, inputs[0].GetModule());
                break;
            case OPERATORTYPE.DIVIDE:
                module = new Divide(inputs[0].GetModule(), inputs[1].GetModule());
                break;
            case OPERATORTYPE.CURVE:
                if(curve == null) {
                    curve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
                    if(keyframes != null)
                        curve.keys = SerializableKeyframe.ToKeyframeArray(keyframes);
                }
                if(keyframes == null)
                    keyframes = SerializableKeyframe.FromKeyframeArray(curve.keys);
                module = new Curve(keyframes, inputs[0].GetModule());
                break;
            case OPERATORTYPE.WEIGHT:
                module = new Weight(inputs[0].GetModule(), min, max);
                break;
            case OPERATORTYPE.WARP:
                module = new Warp(power, inputs[0].GetModule(), inputs[1].GetModule());
                break;
            case OPERATORTYPE.SELECT:
                module = new Select(inputs[0].GetModule(), min, max);
                break;
            }

            SetOutputOptions();
            return this.module;
        }
Exemplo n.º 40
0
	// Use this for initialization
	void Start ()
	{
		warpObj = Resources.Load<GameObject> ("Prefabs/Warp");
		warp = ((GameObject)Instantiate (warpObj, transform.position, Quaternion.identity)).GetComponent<Warp> ();
		warp.transform.parent = transform;
	}
Exemplo n.º 41
0
	public void Retry()
	{
		Destroy (warp.gameObject);
		warp = ((GameObject)Instantiate (warpObj, transform.position, Quaternion.identity)).GetComponent<Warp> ();
		warp.transform.parent = transform;
	}
Exemplo n.º 42
0
    public void CreateBoard()
    {
        GhostSpawns = new Dictionary<int, IntVector2>();
        PlayerSpawns = new Dictionary<int, IntVector2>();
        Pellets = new Dictionary<IntVector2, List<BoardObject>>();
        WarpPoints = new Dictionary<int, Warp>();

        Debug.Log("Loading level: " + GameData.Instance.level);
        TextAsset boardAsset = (TextAsset) Resources.Load( "Levels/Level" + ((GameData.Instance.level % 2) + 1), typeof( TextAsset ) );

        string[] sboard = Regex.Split( boardAsset.text, "\r\n|\n" );
        string[][] sboardTokens = new string[sboard.Length][];

        for ( int i = 0; i < sboard.Length; i++ )
        {
            sboardTokens[i] = sboard[i].Split('\t');
        }

        // init closed spaces
        board = new bool[sboardTokens.Length, sboardTokens[0].Length];
        for ( int i = 0; i < board.GetLength(0); i++ )
        {
            for (int j = 0; j < board.GetLength(1); j++ )
            {
                string token = sboardTokens[sboardTokens.Length - 1 - i][j];
                if ( token.Equals( "1" ) )
                {
                    board[i,j] = true;
                }

            }
        }

        for ( int i = 0; i < board.GetLength(0); i++ )
        {
            for (int j = 0; j < board.GetLength(1); j++ )
            {
                string token = sboardTokens[sboardTokens.Length - 1 - i][j];
                // GHOST SPAWN
                if ( token.StartsWith( "G" ) )
                {
                    token = token.Substring( 1 );
                    int ghostNum = int.Parse( token );
                    GhostSpawns.Add( ghostNum, new IntVector2( j, i ) );
                }
                // PLAYER SPAWN
                else if ( token.StartsWith( "P" ) )
                {
                    token = token.Substring( 1 );
                    int playerNum = int.Parse( token );
                    PlayerSpawns.Add( playerNum, new IntVector2( j, i ) );
                }
                // WARP INPUT
                else if (token.StartsWith("W"))
                {
                    token = token.Substring(1);
                    int id = int.Parse(token[0] + "");
                    Warp warp;
                    if (!WarpPoints.ContainsKey(id)) {
                        warp = new Warp();
                        WarpPoints.Add(id, warp);
                    } else {
                        warp = WarpPoints[id];
                    }
                    warp.input = new IntVector2(j, i);
                }
                // WARP OUTPUT
                else if (token.StartsWith("O")) {
                    token = token.Substring(1);
                    int id = int.Parse(token[0] + "");
                    Warp warp;
                    if (!WarpPoints.ContainsKey(id)) {
                        warp = new Warp();
                        WarpPoints.Add(id, warp);
                    } else {
                        warp = WarpPoints[id];
                    }
                    warp.output = new IntVector2(j, i);
                    token = token.Substring(1);
                    warp.outDirection = Direction.getDirection(token);
                }
                else if ( Accessor.isOpen( j, i ) )
                {
                    // place pellets
                    foreach ( IntVector2 dir in Constants.directions )
                    {
                        createPellet( new BoardLocation( new IntVector2( j, i ), new IntVector2( 0, 0 ) ) );

                        // removed, only one pellet per tile
                        //IntVector2 check = new IntVector2( j, i ) + dir;

                        //if ( Accessor.isOpen( check.x, check.y ) )
                        //{
                            // pelet goes there
        //							createPellet( new BoardLocation( new IntVector2( j, i ), dir * ( 2 * Constants.BoardCellRadius / 3 ) ) );
                        //}
                    }
                }
            }
        }

        this.Height = board.GetLength(0);
        this.Width = board.GetLength(1);
    }
Exemplo n.º 43
0
        /// <summary>
        /// Sends a warp to the player.
        /// <param name="warp">The warp.</param>
        /// </summary>
        public void SendRaptorWarp(Warp warp)
        {
            if (!IsRaptor)
                return;

            lock (NetMessage.buffer[Index].writeBuffer)
            {
                int length = 0;

                using (var ms = new MemoryStream(NetMessage.buffer[Index].writeBuffer, true))
                {
                    using (var writer = new BinaryWriter(ms))
                    {
                        writer.BaseStream.Position = 4;

                        writer.Write((byte)PacketTypes.Placeholder);
                        writer.Write((byte)RaptorPacketTypes.Warp);

                        writer.Write(warp.Position.X);
                        writer.Write(warp.Position.Y);
                        writer.Write(warp.Name);

                        length = (int)writer.BaseStream.Position;
                        writer.BaseStream.Position = 0;
                        writer.Write(length - 4);
                    }
                }

                TShock.PacketBuffer.SendBytes(Netplay.serverSock[Index], NetMessage.buffer[Index].writeBuffer, 0, length);
            }
        }