Inheritance: MonoBehaviour
 public void Log(Level l, string s)
 {
     StringLogs.Add(s);
     LevelLogs.Add(l);
     LogEvent.Invoke(l, s);
     DebugMessageHandler.AssertCl("["+l.ToString().ToUpper()+"] " + s);
 }
        public void Initialize(int activeLevel)
        {
            headsUpDisplay.Initialize();

            Level = LevelFactory.LoadLevel("Content\\Levels\\Level " + activeLevel + ".xml");
            _camera = new Camera.Camera(Level.Player, _graphicsDeviceManager.GraphicsDevice.Viewport);
        }
Example #3
0
        /// <summary>
        /// Creates a completer to extend messages with validation data but not time-stamp.
        /// </summary>
        /// <remarks>
        /// The resulting completer does not add a time-stamp because it is either called by a time-marking authority itself or
        /// the message will be send to one.
        /// </remarks>
        /// <param name="level">The required level the completer must produce: T-Level, LT-Level or LTA-Level</param>
        /// <returns>The completer of the required level to be used by a time-mark authority</returns>
        public static ITmaDataCompleter CreateAsTimeMarkAuthority(Level level)
        {
            if (level == Level.B_Level) throw new NotSupportedException("Nothing to complete for B-level");
            if ((level & Level.T_Level) != Level.T_Level) throw new ArgumentException("This method should for a level that requires time marking");

            return new TripleWrapper(level, null, null, null, null);
        }
Example #4
0
 private void log(string message, Level currentLevel)
 {
     if (LevelComparator.pass(currentLevel, logLevel))
     {
         parentNode.forward(_name, currentLevel, message);
     }
 }
Example #5
0
        public static void Log(Level level, String message)
        {
            Config cfg = Config.Load();

            if (cfg.LogVerbosity <= level)
            {
                string line = String.Format("{0} [{1}] - {2}", DateTime.Now, level, message);

                if ((cfg.LogOutput & Outputs.Console) == Outputs.Console)
                {
                    if (level <= Level.Info)
                    {
                        Console.WriteLine(line);
                    } else
                    {
                        Console.Error.WriteLine(line);
                    }
                }

                if ((cfg.LogOutput & Outputs.File) == Outputs.File)
                {
                    Stream.WriteLine(line);
                    Stream.Flush();
                }
            }
        }
Example #6
0
 public HotkeyMessage(Message messageType, Level messageLevel, IntPtr hWnd, int Data)
 {
     Message = messageType;
     level = messageLevel;
     handle = hWnd;
     data = Data;
 }
Example #7
0
        public static void LogTo(Level level, Boolean fireEvent, String rawMessage)
        {
            String message = Regex.Replace(rawMessage, "cardno=[^&]*", "****************");

            switch (level)
            {
                case Level.INFO:
                     NLogger.Info(message);
                    break;
                case Level.TRACE:
                    NLogger.Trace(message);
                    break;
                case Level.DEBUG:
                     NLogger.Debug(message);
                    break;
                case Level.WARNING:
                     NLogger.Warn(message);
                    break;
                case Level.ERROR:
                    NLogger.Error(message);
                    break;
                case Level.FATAL:
                    NLogger.Fatal(message);
                    break;
            }

            if (fireEvent)
            {
                InvokeLogToGui(new GuiEventArgs(level, message));
            }
        }
Example #8
0
 public LavaBlock(Texture2D LavaBlock, Vector2 location, Level level)
 {
     this.IdleLavaBlock = LavaBlock;
     this.location = location;
     this.level = level;
     currentTexture = LavaBlock;
 }
 public static void UnityLog(int i, Level level = Level.DEBUG)
 {
     string s = i.ToString();
     switch (level) {
         case Level.DEBUG:
             s = "[DEBUG]" + s;
             Debug.Log(s);
             break;
         case Level.INFO:
             s = "[INFO]" + s;
             Debug.Log(s);
             break;
         case Level.WARNING:
             s = "[WARNING]" + s;
             Debug.LogWarning(s);
             break;
         case Level.ERROR:
             Debug.LogError(s);
             s = "[ERROR]" + s;
             break;
         default:
             s = "[DEFAULT]" + s;
             UnityLog("I was given a log level that doesn't exist.", Level.WARNING);
             break;
     }
 }
	public void DestroyCurrentLevel() {
		if (m_currentLevel != null) {
			GameObject.Destroy(m_currentLevel.gameObject);
		}

		m_currentLevel = null;
	}
Example #11
0
 public override bool interact(Level level, int xt, int yt, Player player, Item item, int attackDir)
 {
     if (item is ToolItem)
     {
         ToolItem tool = (ToolItem)item;
         if (tool.type == ToolType.shovel)
         {
             if (player.payStamina(4 - tool.level))
             {
                 level.setTile(xt, yt, Tile.hole, 0);
                 level.add(new ItemEntity(new ResourceItem(Resource.dirt), xt * 16 + random.nextInt(10) + 3, yt * 16 + random.nextInt(10) + 3));
                 Sound.monsterHurt.play();
                 return true;
             }
         }
         if (tool.type == ToolType.hoe)
         {
             if (player.payStamina(4 - tool.level))
             {
                 level.setTile(xt, yt, Tile.farmland, 0);
                 Sound.monsterHurt.play();
                 return true;
             }
         }
     }
     return false;
 }
Example #12
0
 public static byte[] GetBytes(Level data)
 {
     IFormatter formatter = new BinaryFormatter();
     MemoryStream stream = new MemoryStream();
     formatter.Serialize(stream, data);
     return stream.ToArray();
 }
Example #13
0
 public static void SaveToFile(Level data, string fileName)
 {
     IFormatter formatter = new BinaryFormatter();
     Stream stream = new FileStream(string.Format("{0}.level", fileName), FileMode.Create, FileAccess.Write, FileShare.Write);
     formatter.Serialize(stream, data);
     stream.Close();
 }
Example #14
0
 /**
  * It the local is permissive enougth we forward the message to the master.
  */
 public void forward(string caller, Level level, string message)
 {
     if (LevelComparator.pass(level, logLevel))
     {
         parentNode.forward(caller, level, message);
     }
 }
 public PanTool(Level pointer, Tool prevTool, Point startPoint)
     : base(pointer)
 {
     this.pointer = pointer;
     this.prevTool = prevTool;
     this.startPoint = startPoint;
 }
Example #16
0
    IEnumerator LoadLevel(Level level)
    {
        string path = PopBloopSettings.LevelAssetsUrl + "levels/";

        // First, we download all the entities, don't instantiate it yet
        foreach (Entity entity in level.Entities)
        {
            string bundle = path + entity.ObjectName;
            yield return AssetsManager.DownloadAssetBundle(bundle);
        }

        // Now, we have all the entities downloaded, instantiate them all
        foreach (Entity entity in level.Entities)
        {
            string bundle = path + entity.ObjectName;
            GameObject go = (GameObject)AssetsManager.Instantiate(AssetsManager.Bundles[bundle].assetBundle.mainAsset);

            if (go != null)
            {
                float3 pos = entity.Position;
                float3 rot = entity.Rotation;
                go.transform.position = new Vector3(pos.x, pos.y, pos.z);
                go.transform.rotation = Quaternion.Euler(new Vector3(rot.x, rot.y, rot.z));
            }
            else
            {
                Debug.Log("Instantiating " + bundle + " failed");
            }
        }
    }
Example #17
0
 public FunctionEntry(Level level, Label label, Types.RECORD formals, Types.Type result)
 {
     Level = level;
     Label = label;
     Formals = formals;
     Result = result;
 }
Example #18
0
    public void init(Level curLevel,Level nextLevel)
    {
        scaleBackGround();
        //textureWidth = Camera.mainCamera.orthographicSize *2* ((float)Screen.width/(float)Screen.height) +20;
        this.curLevel = curLevel;
        this.nextLevel = nextLevel;

        drawMap(curLevel);
        if(nextLevel != null)
        {
            drawMap(nextLevel);
        }
        drawDecor(curLevel);

        if(nextLevel != null && curLevel.chapter == nextLevel.chapter)
        {
            drawDecor(nextLevel);
        }

        drawBackMap(curLevel);

        if(nextLevel != null && (nextLevel.id-1)%4 == 0)
        {
            drawBackMap(nextLevel);
        }
    }
Example #19
0
 public override void Use(Level level, Character actor, Character target)
 {
     //Console.WriteLine("{0} is attacking {1} for {2} damage!", actor.Name, target.Name, actor.AttackDamage);
     var damage = (int)(actor.AttackDamage + level.rnd.Next(-2, 2));
     target.TakeDamage(damage);
     //actor.LastAction = string.Format("Attacked {0} for {1} damage!", target.Name, damage);
 }
 public FireMarioCrouchingSprite(int isMovingRight, Level level, Vector2 location)
 {
     this.isMovingRight = isMovingRight;
     this.level = level;
     this.texture = level.ContentLoad("Mario/Fire/FireCrouchingMario");
     this.location = location;
 }
Example #21
0
        /// <summary>
        /// Creates a new ClientConnection instance using a socket,
        /// additionally creating a player entity for the client in
        /// the specified level.
        /// </summary>
        /// <param name="socket">Socket connected to the client.</param>
        /// <param name="level">Level to create a player in.</param>
        public ClientConnection(TcpClient socket, Level level)
            : base(socket)
        {
            _socket = socket;
            Level = level;

            _visibility = level
                .Select(x => new RoomVisibility(x))
                .ToArray();

            Player = Entity.Create("player");
            Player.GetComponent<PlayerControl>().Client = this;

            var rooms = level
                .Where(x => x.Any(y => y.State == TileState.Floor))
                .ToArray();

            var room = rooms[(int)(DateTime.Now.Ticks % rooms.Length)];

            var tiles = room
                .Where(x => x.State == TileState.Floor)
                .ToArray();

            Player.Place(tiles[Tools.Random.Next(tiles.Length)]);
        }
Example #22
0
 public static void SendToLevel(Level l, string[] message)
 {
     for (int i = 0; i < message.Length; i++)
     {
         l.ChatLevel(message[i]);
     }
 }
Example #23
0
        /// <summary>
        /// 获取指定级别的日志是否可记录。
        /// </summary>
        /// <param name="level">级别</param>
        /// <returns>是否可记录</returns>
        public bool IsEnabledFor(Level level)
        {
            var cacheValue = this.Cache.Get<string>(Constants.LogerLevelCacheKey);

            if (string.IsNullOrWhiteSpace(cacheValue))
            {
                try
                {
                    cacheValue = this.SqlMapperManager[RW.Read].QueryForObject<string>(string.Format(StatementFormatter, this.SqlMapNamespace, "GetLoggerLevel"), null);

                    if (string.IsNullOrWhiteSpace(cacheValue))
                    {
                        cacheValue = "1";
                    }
                    else
                    {
                        this.Cache.Add(Constants.LogerLevelCacheKey, cacheValue);
                    }
                }
                catch
                {
                    cacheValue = "1";
                }
            }

            var iLevel = int.Parse(cacheValue);

            var minLevel = (Level)iLevel;

            return level >= minLevel;
        }
Example #24
0
 // EasyTraceEvent
 // Checks the keyword and level before emiting the event
 static internal void EasyTraceEvent(Keyword keywords, Level level, Event eventID)
 {
     if (IsEnabled(keywords, level))
     {
         EventProvider.TraceEvent(eventID, keywords, level);
     }
 }
Example #25
0
 static internal void EasyTraceEvent(Keyword keywords, Level level, Event eventID, object param1, object param2)
 {
     if (IsEnabled(keywords, Level.Info))
     {
         EventProvider.TraceEvent(eventID, keywords, Level.Info, param1, param2);
     }
 }
 public override void Tick(Level l)
 {
     if (l.GetBlock(X, Z, Y - 1) == Block.BlockList.AIR) {
         Add(l, new Active_Water(X, Z, Y - 1));
         Remove(l);
         //l.BlockChange((ushort)X, (ushort)Z, (ushort)(Y - 1), this);
     }
     else {
         if (l.GetBlock(X + 1, Z, Y) == Block.BlockList.AIR) {
             Add(l, new Active_Water(X + 1, Z, Y));
             //l.BlockChange((ushort)(X + 1), (ushort)Z, (ushort)Y, this);
         }
         if (l.GetBlock(X - 1, Z, Y) == Block.BlockList.AIR) {
             Add(l, new Active_Water(X - 1, Z, Y));
             //l.BlockChange((ushort)(X - 1), (ushort)Z, (ushort)Y, this);
         }
         if (l.GetBlock(X, Z + 1, Y) == Block.BlockList.AIR) {
             Add(l, new Active_Water(X, Z + 1, Y));
             //l.BlockChange((ushort)X, (ushort)(Z + 1), (ushort)Y, this);
         }
         if (l.GetBlock(X, Z - 1, Y) == Block.BlockList.AIR) {
             Add(l, new Active_Water(X, Z - 1, Y));
            // l.BlockChange((ushort)X, (ushort)(Z - 1), (ushort)Y, this);
         }
     }
 }
        /// <summary>
        /// Constructor for testing purposes
        /// </summary>
        /// <param name="game"></param>
        /// <param name="testConstructor"></param>
        public LevelManager(Game game, bool testConstructor)
            : base(game)
        {
            //updateCam = false;
            //curLevelInfo = 0;
            //levels = new List<LevelInfo>();
            //currentLevel = new Level();
            ////levels.Add(new LevelInfo("", 3, 72, 8, 1, 200, 0, 25, Constants.RED_PLATFORM));
            ////generator = new LevelGenerator(currentLevel, levels, 42, new ChunkType[,] { {ChunkType.FLOOR}, {ChunkType.STAIRS}, {ChunkType.FLOATING_PLATFORMS_SAFE},
            ////    {ChunkType.FLOATING_PLATFORMS_NOT_SAFE}, {ChunkType.MOUNTAIN_LEFT}, {ChunkType.MOUNTAIN_RIGHT}, {ChunkType.JAGGIES_LEFT}, {ChunkType.JAGGIES_RIGHT},
            ////    {ChunkType.TALL_GROUND}});
            //levels.Add(new LevelInfo("", 3, 8, 8, 0, 200, 0, 0, Constants.RED_PLATFORM));
            //generator = new LevelGenerator(currentLevel, levels, 42, new ChunkType[,] { {ChunkType.TALL_GROUND}});
            //currentLevel = generator.GenerateNewLevel(0, 1);
            //this.SetUpCameraDefault();
            //this.projectiles = new List<Projectile>();
            //this.expOrbs = new List<ExperienceOrb>();
            updateCam = false;
            curLevelInfo = 0;
            setUpLevels();

            currentLevel = new Level(levels[curLevelInfo].width, levels[curLevelInfo].height, 1);
            generator = new LevelGenerator(currentLevel, levels, new Random().Next());
            currentLevel = generator.GenerateNewLevel(curLevelInfo, 1);
            this.SetUpCameraDefault();
            this.projectiles = new List<Projectile>();
            this.expOrbs = new List<ExperienceOrb>();
        }
 public static LevelClearState? Get(WorldType world, Level level)
 {
     var key = MakeKey(world, level);
     if (!PlayerPrefs.HasKey(key))
         return null;
     return (LevelClearState)Enum.Parse(typeof (LevelClearState), PlayerPrefs.GetString(key));
 }
Example #29
0
 public void Message(string str, Level level)
 {
     string message = string.Format("{0}", str);
     switch (level)
     {
         case Level.Normal:
         {
             System.Console.WriteLine(message);
             Save(message);
             break;
         }
         case Level.Warning:
         {
             message = "[Warn]" + message;
             System.Console.WriteLine(message);
             Save(message);
             break;
         }
         case Level.Error:
         {
             message = "[Error]" + message;
             System.Console.WriteLine(message);
             Save(message);
             break;
         }
     }
 }
Example #30
0
 public void SendToLevel(Level l)
 {
     for (int i = 0; i < message.Length; i++)
     {
         l.ChatLevel(message[i]);
     }
 }
 /// <summary>
 /// Checks whether logging is enabled for the given logging Level.
 /// </summary>
 /// <param name="activeLogger">The active logger.</param>
 /// <param name="level">The level.</param>
 /// <returns><c>true</c> if enabled, <c>false</c> otherwise.</returns>
 protected override bool PerformIsLoggingEnabled(NullLogWrapper activeLogger, Level level)
 {
     return(false);
 }
Example #32
0
 public void Draw(Level level, BasicEffect basicEffect, AlphaTestEffect alphaTestEffect)
 {
     StaticRenderer.Draw(level, basicEffect, alphaTestEffect);
     DynamicRenderer.Draw(level, basicEffect, alphaTestEffect);
 }
Example #33
0
    public void createEnemies(Level level, Map map)
    {
        enemies = new GameObject[level.numTotalCreatures];

        int randX = 0;
        int randY = 0;

        // Create creature objects
        for (int i = 0; i < level.numTotalCreatures; i++)
        {
            bool goodSpawnLocation = false;

            // Spawn at random floor tile location
            while (!goodSpawnLocation)
            {
                randX = Random.Range(0, level.MapXSize);
                randY = Random.Range(0, level.MapYSize);
                Tile t = map.getTile(randX, randY);

                if (t.getTileType() == (int)Tile.TileTypes.FLOOR && !t.getName().Contains("entrance") && !t.tileEntityName.Contains("door"))
                {
                    goodSpawnLocation = true;
                }
            }

            //Spawn locations decided, now decide on a random creature to spawn there
            int whichCreature = Random.Range(0, level.creatures.Length);

            string creatureName = level.creatures[whichCreature].creatureName;

            if (creatureName == "Slime")
            {
                whichPrefab = slimePrefab;
            }
            else if (creatureName == "Face Hugger")
            {
                whichPrefab = faceHuggerPrefab;
            }

            // TEMPORARY UNITL ADDING MORE ENEMIES
            if (whichPrefab == null)
            {
                continue;
            }

            creatureClone = Instantiate(whichPrefab);
            creatureClone.transform.SetParent(this.transform);
            creatureClone.name = creatureName;

            creatureClone.transform.position = new Vector2(randX, randY);
            Enemy enemyScript = creatureClone.GetComponent <Enemy>();
            enemyScript.enemyID = i;
            enemyScript.currX   = randX;
            enemyScript.currY   = randY;

            //Debug.Log("Creating creature " + creatureName + " ID : " + enemyScript.enemyID + " at " + randX + "," + randY);

            //Keep an record of all the enemies in a level
            enemies[i] = creatureClone;
        }
    }
Example #34
0
 public static void setLevel(Level l)
 {
     level = l;
 }
Example #35
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the password:"******"                               ");
            Console.WriteLine("-------------------------------");
            Console.WriteLine("----Strategy Design Pattern: --");
            Console.WriteLine("-------------------------------");

            Context context;

            context = new Context(new StrengthLevel1());
            context.ContextInterface(password);

            context = new Context(new StrengthLevel2());
            context.ContextInterface(password);

            context = new Context(new StrengthLevel3());
            context.ContextInterface(password);


            /// <summary>
            /// Chain of responsibility Design Pattern.
            /// </summary>
            Console.WriteLine("                                       ");
            Console.WriteLine("---------------------------------------");
            Console.WriteLine("Chain of responsibility Design Pattern:");
            Console.WriteLine("---------------------------------------");
            Console.WriteLine("----------------Level 1----------------");

            // Setup Chain of Responsibility
            Requirement r1 = new RequirementMinLength();
            Requirement r2 = new RequirementContainsDigit();
            Requirement r3 = new RequirementConstainSpecialCharacter();
            Requirement r4 = new RequirementIsNotOnTheListForbiddenPasswords();


            r1.SetRequirement(r2);
            r2.SetRequirement(r3);
            r3.SetRequirement(r4);

            r1.HandleRequest(password);


            /// <summary>
            /// Builder Design Pattern.
            /// </summary>
            ///
            Console.WriteLine("                                       ");
            Console.WriteLine("---------------------------------------");
            Console.WriteLine("--------Builder Design Pattern---------");
            Console.WriteLine("---------------------------------------");

            Director    director = new Director();
            BuilderPass builder1 = new BuilderLevel1();
            BuilderPass builder2 = new BuilderLevel2();
            BuilderPass builder3 = new BuilderLevel3();

            //Level 1
            Console.WriteLine("----------------Level 1----------------");
            director.Construct(builder1, password);
            Level level1 = builder1.GetResult();

            level1.Show();

            //Level2
            Console.WriteLine("----------------Level 2----------------");
            director.Construct(builder2, password);
            Level level2 = builder2.GetResult();

            level2.Show();

            //Level3
            Console.WriteLine("----------------Level 3----------------");
            director.Construct(builder3, password);
            Level level3 = builder3.GetResult();

            level3.Show();



            Console.ReadKey();
        }
Example #36
0
        // ======================================
        //   (2) add alignments
        // ======================================
        void addAlignments(Extrusion pBox)
        {
            //
            // (1) we want to constrain the upper face of the column to the "Upper Ref Level"
            //

            // which direction are we looking at?
            //
            View pView = findElement(typeof(View), "Front") as View;

            // find the upper ref level
            // findElement() is a helper function. see below.
            //
            Level     upperLevel = findElement(typeof(Level), "Upper Ref Level") as Level;
            Reference ref1       = upperLevel.GetPlaneReference();

            // find the face of the box
            // findFace() is a helper function. see below.
            //
            PlanarFace upperFace = findFace(pBox, new XYZ(0.0, 0.0, 1.0)); // find a face whose normal is z-up.
            Reference  ref2      = upperFace.Reference;

            // create alignments
            //
            _doc.FamilyCreate.NewAlignment(pView, ref1, ref2);

            //
            // (2) do the same for the lower level
            //

            // find the lower ref level
            // findElement() is a helper function. see below.
            //
            Level     lowerLevel = findElement(typeof(Level), "Lower Ref. Level") as Level;
            Reference ref3       = lowerLevel.GetPlaneReference();

            // find the face of the box
            // findFace() is a helper function. see below.
            PlanarFace lowerFace = findFace(pBox, new XYZ(0.0, 0.0, -1.0)); // find a face whose normal is z-down.
            Reference  ref4      = lowerFace.Reference;

            // create alignments
            //
            _doc.FamilyCreate.NewAlignment(pView, ref3, ref4);

            //
            // (3)  same idea for the Right/Left/Front/Back
            //
            // get the plan view
            // note: same name maybe used for different view types. either one should work.
            View pViewPlan = findElement(typeof(ViewPlan), "Lower Ref. Level") as View;

            // find reference planes
            ReferencePlane refRight = findElement(typeof(ReferencePlane), "Right") as ReferencePlane;
            ReferencePlane refLeft  = findElement(typeof(ReferencePlane), "Left") as ReferencePlane;
            ReferencePlane refFront = findElement(typeof(ReferencePlane), "Front") as ReferencePlane;
            ReferencePlane refBack  = findElement(typeof(ReferencePlane), "Back") as ReferencePlane;

            // find the face of the box
            PlanarFace faceRight = findFace(pBox, new XYZ(1.0, 0.0, 0.0));
            PlanarFace faceLeft  = findFace(pBox, new XYZ(-1.0, 0.0, 0.0));
            PlanarFace faceFront = findFace(pBox, new XYZ(0.0, -1.0, 0.0));
            PlanarFace faceBack  = findFace(pBox, new XYZ(0.0, 1.0, 0.0));

            // create alignments
            //
            _doc.FamilyCreate.NewAlignment(pViewPlan, refRight.GetReference(), faceRight.Reference);
            _doc.FamilyCreate.NewAlignment(pViewPlan, refLeft.GetReference(), faceLeft.Reference);
            _doc.FamilyCreate.NewAlignment(pViewPlan, refFront.GetReference(), faceFront.Reference);
            _doc.FamilyCreate.NewAlignment(pViewPlan, refBack.GetReference(), faceBack.Reference);
        }
 /// <summary>
 /// Checks whether logging is enabled for the given logging Level.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <returns><c>true</c> if enabled, <c>false</c> otherwise.</returns>
 protected override bool PerformIsLoggingEnabled(Level level)
 {
     return(PerformIsLoggingEnabled(this, level));
 }
Example #38
0
 public bool IsEnabledFor(Level a)
 {
     return(false);
 }
Example #39
0
 public SmartAI(Level level) : base(level)
 {
 }
Example #40
0
 public void Log(Type a, Level b, object c, Exception d)
 {
 }
Example #41
0
 public void setLevel(Level level)
 {
     this.level = level;
 }
 public void OnLevelChanged(Level level)
 {
     _vm.Level     = level.Description;
     _vm.TotalGate = level.GateNumber.ToString();
     _vm.Gate      = "1";
 }
Example #43
0
 public override void Process(Level level)
 {
 }
Example #44
0
        public override void Use(Player p, string message)
        {
            byte b; Int64 seconds; Player who; Player.UndoPos Pos; int CurrentPos = 0;

            if (p != null)
            {
                p.RedoBuffer.Clear();
            }

            if (message == "")
            {
                message = p.name + " 30";
            }

            if (message.Split(' ').Length == 2)
            {
                if (message.Split(' ')[1].ToLower() == "all" && p.group.Permission > LevelPermission.Operator)
                {
                    seconds = 500000;
                }
                else
                {
                    try
                    {
                        seconds = Int64.Parse(message.Split(' ')[1]);
                    }
                    catch
                    {
                        Player.SendMessage(p, "Invalid seconds.");
                        return;
                    }
                }
            }
            else
            {
                try
                {
                    seconds = int.Parse(message);
                    if (p != null)
                    {
                        message = p.name + " " + message;
                    }
                }
                catch
                {
                    seconds = 30;
                    message = message + " 30";
                }
            }

            //if (message.Split(' ').Length == 1) if (char.IsDigit(message, 0)) { message = p.name + " " + message; } else { message = message + " 30"; }

            //try { seconds = Convert.ToInt16(message.Split(' ')[1]); } catch { seconds = 2; }
            if (seconds == 0)
            {
                seconds = 5400;
            }

            who = Player.Find(message.Split(' ')[0]);
            if (who != null)
            {
                if (p != null)
                {
                    if (who.group.Permission > p.group.Permission && who != p)
                    {
                        Player.SendMessage(p, "Cannot undo a user of higher or equal rank"); return;
                    }
                    if (who != p && p.group.Permission < LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "Only an OP+ may undo other people's actions"); return;
                    }

                    if (p.group.Permission < LevelPermission.Builder && seconds > 120)
                    {
                        Player.SendMessage(p, "Guests may only undo 2 minutes."); return;
                    }
                    else if (p.group.Permission < LevelPermission.AdvBuilder && seconds > 300)
                    {
                        Player.SendMessage(p, "Builders may only undo 300 seconds."); return;
                    }
                    else if (p.group.Permission < LevelPermission.Operator && seconds > 1200)
                    {
                        Player.SendMessage(p, "AdvBuilders may only undo 600 seconds."); return;
                    }
                    else if (p.group.Permission == LevelPermission.Operator && seconds > 5400)
                    {
                        Player.SendMessage(p, "Operators may only undo 5400 seconds."); return;
                    }
                }

                for (CurrentPos = who.UndoBuffer.Count - 1; CurrentPos >= 0; --CurrentPos)
                {
                    try
                    {
                        Pos = who.UndoBuffer[CurrentPos];
                        Level foundLevel = Level.FindExact(Pos.mapName);
                        b = foundLevel.GetTile(Pos.x, Pos.y, Pos.z);
                        if (Pos.timePlaced.AddSeconds(seconds) >= DateTime.Now)
                        {
                            if (b == Pos.newtype || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                            {
                                foundLevel.Blockchange(Pos.x, Pos.y, Pos.z, Pos.type, true);

                                Pos.newtype = Pos.type; Pos.type = b;
                                if (p != null)
                                {
                                    p.RedoBuffer.Add(Pos);
                                }
                                who.UndoBuffer.RemoveAt(CurrentPos);
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    catch { }
                }

                if (p != who)
                {
                    Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + "'s actions for the past &b" + seconds + " seconds were undone.", false);
                }
                else
                {
                    Player.SendMessage(p, "Undid your actions for the past &b" + seconds + Server.DefaultColor + " seconds.");
                }
                return;
            }
            else if (message.Split(' ')[0].ToLower() == "physics")
            {
                if (p.group.Permission < LevelPermission.AdvBuilder)
                {
                    Player.SendMessage(p, "Reserved for Adv+"); return;
                }
                else if (p.group.Permission < LevelPermission.Operator && seconds > 1200)
                {
                    Player.SendMessage(p, "AdvBuilders may only undo 1200 seconds."); return;
                }
                else if (p.group.Permission == LevelPermission.Operator && seconds > 5400)
                {
                    Player.SendMessage(p, "Operators may only undo 5400 seconds."); return;
                }

                Command.all.Find("pause").Use(p, "120");
                Level.UndoPos uP;
                ushort        x, y, z;

                if (p.level.UndoBuffer.Count != Server.physUndo)
                {
                    for (CurrentPos = p.level.currentUndo; CurrentPos >= 0; CurrentPos--)
                    {
                        try
                        {
                            uP = p.level.UndoBuffer[CurrentPos];
                            b  = p.level.GetTile(uP.location);
                            if (uP.timePerformed.AddSeconds(seconds) >= DateTime.Now)
                            {
                                if (b == uP.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                                {
                                    p.level.IntToPos(uP.location, out x, out y, out z);
                                    p.level.Blockchange(p, x, y, z, uP.oldType, true);
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        catch { }
                    }
                }
                else
                {
                    for (CurrentPos = p.level.currentUndo; CurrentPos != p.level.currentUndo + 1; CurrentPos--)
                    {
                        try
                        {
                            if (CurrentPos < 0)
                            {
                                CurrentPos = p.level.UndoBuffer.Count - 1;
                            }
                            uP = p.level.UndoBuffer[CurrentPos];
                            b  = p.level.GetTile(uP.location);
                            if (uP.timePerformed.AddSeconds(seconds) >= DateTime.Now)
                            {
                                if (b == uP.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                                {
                                    p.level.IntToPos(uP.location, out x, out y, out z);
                                    p.level.Blockchange(p, x, y, z, uP.oldType, true);
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        catch { }
                    }
                }

                Command.all.Find("pause").Use(p, "");
                Player.GlobalMessage("Physics were undone &b" + seconds + Server.DefaultColor + " seconds");
            }
            else
            {
                if (p != null)
                {
                    if (p.group.Permission < LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "Reserved for OP+"); return;
                    }
                    if (seconds > 5400 && p.group.Permission == LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "Only SuperOPs may undo more than 90 minutes."); return;
                    }
                }

                bool FoundUser = false;

                try
                {
                    DirectoryInfo di;
                    string[]      fileContent;

                    p.RedoBuffer.Clear();

                    if (Directory.Exists("extra/undo/" + message.Split(' ')[0]))
                    {
                        di = new DirectoryInfo("extra/undo/" + message.Split(' ')[0]);

                        for (int i = di.GetFiles("*.undo").Length - 1; i >= 0; i--)
                        {
                            fileContent = File.ReadAllText("extra/undo/" + message.Split(' ')[0] + "/" + i + ".undo").Split(' ');
                            if (!undoBlah(fileContent, seconds, p))
                            {
                                break;
                            }
                        }
                        FoundUser = true;
                    }

                    if (Directory.Exists("extra/undoPrevious/" + message.Split(' ')[0]))
                    {
                        di = new DirectoryInfo("extra/undoPrevious/" + message.Split(' ')[0]);

                        for (int i = di.GetFiles("*.undo").Length - 1; i >= 0; i--)
                        {
                            fileContent = File.ReadAllText("extra/undoPrevious/" + message.Split(' ')[0] + "/" + i + ".undo").Split(' ');
                            if (!undoBlah(fileContent, seconds, p))
                            {
                                break;
                            }
                        }
                        FoundUser = true;
                    }

                    if (FoundUser)
                    {
                        Player.GlobalChat(p, Server.FindColor(message.Split(' ')[0]) + message.Split(' ')[0] + Server.DefaultColor + "'s actions for the past &b" + seconds + Server.DefaultColor + " seconds were undone.", false);
                    }
                    else
                    {
                        Player.SendMessage(p, "Could not find player specified.");
                    }
                }
                catch (Exception e)
                {
                    Server.ErrorLog(e);
                }
            }
        }
Example #45
0
 public GhostRunAwayBehaviour(Pacman pacman, Level level) : base(pacman, level)
 {
 }
Example #46
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }

            try
            {
                Level foundLevel = Level.Find(message);
                if (foundLevel != null)
                {
                    Level startLevel = p.level;

                    GC.Collect();

                    if (p.activeCuboids > 0)
                    {
                        startLevel.unload = false;
                    }

                    if (p.group.Permission < LevelPermission.Operator && foundLevel.name != Server.HomePrefix + p.name.ToLower() && p.level.name != Server.HomePrefix + p.name.ToLower())
                    {
                        if (foundLevel.locked == true && p.level != foundLevel)
                        {
                            Player.SendMessage(p, "This map is currently locked!"); return;
                        }
                        if (p.level.locked == true && p.level != foundLevel)
                        {
                            Player.SendMessage(p, "This map is currently locked!"); return;
                        }
                    }
                    if (p.level.zombiegame == true && p.level != foundLevel)
                    {
                        Player.SendMessage(p, "You can't leave an Infection game!"); return;
                    }
                    if (foundLevel.zombiegame == true && p.level != foundLevel)
                    {
                        Player.SendMessage(p, "Infection is active on that map, you can't go to it!"); return;
                    }
                    if (p.level.spleefstarted == true && p.level != foundLevel)
                    {
                        Player.SendMessage(p, "You can't leave a Spleef game!"); return;
                    }
                    if (foundLevel.spleefstarted == true && p.level != foundLevel)
                    {
                        Player.SendMessage(p, "Spleef is active on that map, you can't go to it!"); return;
                    }
                    if (p.level == foundLevel)
                    {
                        Player.SendMessage(p, "You are already in \"" + foundLevel.name + "\"."); return;
                    }
                    if (!p.ignorePermission)
                    {
                        if (p.group.Permission < foundLevel.permissionvisit)
                        {
                            Player.SendMessage(p, "You're not allowed to go to " + foundLevel.name + "."); return;
                        }
                    }

                    p.Loading = true;
                    foreach (Player pl in Player.players)
                    {
                        if (p.level == pl.level && p != pl)
                        {
                            p.SendDie(pl.id);
                        }
                    }
                    foreach (PlayerBot b in PlayerBot.playerbots)
                    {
                        if (p.level == b.level)
                        {
                            p.SendDie(b.id);
                        }
                    }

                    Player.GlobalDie(p, true);
                    p.level = foundLevel; p.SendUserMOTD(); p.SendMap();

                    GC.Collect();

                    ushort x = (ushort)((0.5 + foundLevel.spawnx) * 32);
                    ushort y = (ushort)((1 + foundLevel.spawny) * 32);
                    ushort z = (ushort)((0.5 + foundLevel.spawnz) * 32);

                    if (!p.hidden)
                    {
                        Player.GlobalSpawn(p, x, y, z, foundLevel.rotx, foundLevel.roty, true);
                    }
                    else
                    {
                        unchecked { p.SendPos((byte)-1, x, y, z, foundLevel.rotx, foundLevel.roty); }
                    }

                    foreach (Player pl in Player.players)
                    {
                        if (pl.level == p.level && p != pl && !pl.hidden)
                        {
                            p.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]);
                        }
                    }

                    foreach (PlayerBot b in PlayerBot.playerbots)
                    {
                        if (b.level == p.level)
                        {
                            p.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
                        }
                    }

                    if (!p.hidden)
                    {
                        Player.GlobalChat(p, p.color + p.name + Server.DefaultColor + " went to &b" + foundLevel.name, false);
                        if (Server.womText)
                        {
                            Player.WomGlobalMessage(p.color + p.name + Server.DefaultColor + " went to &b" + foundLevel.name);
                        }
                    }

                    p.Loading = false;

                    bool skipUnload = false;
                    if (startLevel.unload && !startLevel.name.Contains("&cMuseum "))
                    {
                        foreach (Player pl in Player.players)
                        {
                            if (pl.level == startLevel)
                            {
                                skipUnload = true;
                            }
                        }
                        if (!skipUnload && Server.AutoLoad)
                        {
                            if (p.hidden)
                            {
                                startLevel.Unload(true);
                            }
                            else
                            {
                                startLevel.Unload();
                            }
                        }
                    }
                }
                else if (Server.AutoLoad)
                {
                    Command.all.Find("load").Use(p, message);
                    foundLevel = Level.Find(message);
                    if (foundLevel != null)
                    {
                        Use(p, message);
                    }
                }
                else
                {
                    Player.SendMessage(p, "There is no level \"" + message + "\" loaded.");
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }
Example #47
0
 protected internal virtual void SetLogMessage(Level level, string message)
 {
     this.level   = level;
     this.message = message;
     this.time    = DateTime.Now.ToString(LOG_DEFAULT_DATE);
 }
Example #48
0
        public override void Use(Player p, string message)
        {
            if (message == "" || message.IndexOf(' ') == -1)
            {
                Help(p); return;
            }

            byte foundBlock = Block.Byte(message.Split(' ')[0]);

            if (foundBlock == Block.Zero)
            {
                Player.SendMessage(p, "Could not find block entered"); return;
            }
            LevelPermission newPerm = Level.PermissionFromName(message.Split(' ')[1]);

            if (newPerm == LevelPermission.Null)
            {
                Player.SendMessage(p, "Could not find rank specified"); return;
            }
            if (p != null && newPerm > p.group.Permission)
            {
                Player.SendMessage(p, "Cannot set to a rank higher than yourself."); return;
            }

            if (p != null && !Block.canPlace(p, foundBlock))
            {
                Player.SendMessage(p, "Cannot modify a block set for a higher rank"); return;
            }

            Block.Blocks newBlock = Block.BlockList.Find(bs => bs.type == foundBlock);
            newBlock.lowestRank = newPerm;

            Block.BlockList[Block.BlockList.FindIndex(bL => bL.type == foundBlock)] = newBlock;

            Block.SaveBlocks(Block.BlockList);

            Player.GlobalMessage("&d" + Block.Name(foundBlock) + Server.DefaultColor + "'s permission was changed to " + Level.PermissionToName(newPerm));
        }
Example #49
0
 public RemoveStructTile(EditroidUndoRedoQueue q, Level level, int structIndex, int x, int y)
     : base(q, level, structIndex, new StructTileEdit(x, y, Structure.EmptyTile))
 {
 }
Example #50
0
 void OnEnable()
 {
     level = target as Level;
 }
Example #51
0
        public override void LoadContent()
        {
            base.LoadContent();

            camera      = new Camera2D(Vector2.Zero);
            camera.Zoom = 1.5f;

            font           = content.Load <SpriteFont>("Font");
            tilemapTexture = this.content.Load <Texture2D>("SpriteSheet");

            MediaPlayer.Volume = 0.3f;
            MediaPlayer.Play(Globals.MenuSong);
            MediaPlayer.IsRepeating = true;

            diveButton = new Trigger(Graphics.PreferredBackBufferWidth / 2 - 128 / 2, Graphics.PreferredBackBufferHeight - 48 - 32, 128f, 48f, "dive");  //Graphics.PreferredBackBufferWidth / 2 - 128 / 2, Graphics.PreferredBackBufferHeight - 48 - 32, 128, 48

            /*
             * Level init
             */
            XMLLevelLoader XMLloader = new XMLLevelLoader();

            // se o load do mapa falhar, well shit. vai para o menu.
            try
            {
                level = XMLloader.LoadLevel(this, @"Content\Menu.tmx", tilemapTexture);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error Loading Map. Error message: " + e.Message);

                StateManager.Instance.StartGameState("MenuState");
            }

            level.SetCollisionTiles(new int[] { 2, 33, 34, 35, 47, 66, 15, 79 });

            /*
             * parse objects
             */
            foreach (TiledObject obj in level.Objects)
            {
                Console.WriteLine("parsing " + obj.Name);

                if (obj.Name.ToLower() == "jellyfish")
                {
                    Vector2 center = new Vector2(obj.X + obj.Width / 2, obj.Y + obj.Height / 2);
                    Vector2 radius = new Vector2(obj.Width / 2, obj.Height / 2);

                    float speed = float.Parse(obj.GetProperty("speed"));

                    JellyFish j = new JellyFish(this, tilemapTexture, Vector2.Zero, 16, 32, center, radius, speed);

                    Karma.maxKarma += j.Health;

                    // make it start on the right side of its path
                    if (obj.GetProperty("start_rotation") == "right")
                    {
                        j.FacingDirection = 1;
                    }
                    else
                    {
                        j.FacingDirection = -1;
                    }

                    Console.WriteLine(obj.GetProperty("start_rotation"));

                    enemies.Add(j);
                }
                else if (obj.Name.ToLower() == "pufferfish")
                {
                    Vector2 position = new Vector2(obj.X, obj.Y);

                    float speed = float.Parse(obj.GetProperty("speed"));

                    PufferFish p = new PufferFish(this, tilemapTexture, position, 32, 32, obj.Width, speed);

                    for (int i = 0; i < p.Bullets.Count; i++)
                    {
                        p.Bullets[i].Alive   = true;
                        p.Bullets[i].Visible = false;
                    }

                    Karma.maxKarma += p.Health;

                    // make it start on the right side of its path
                    if (obj.GetProperty("start_side") == "right")
                    {
                        p.Body.X          = obj.X + obj.Width;
                        p.CurrentDistance = obj.Width - 33;
                    }

                    enemies.Add(p);
                }
                else if (obj.Name.ToLower() == "turtlex")
                {
                    Vector2 position = new Vector2(obj.X, obj.Y);

                    float speed = float.Parse(obj.GetProperty("speed"));

                    TurtleX p = new TurtleX(this, tilemapTexture, position, 32, 32, 64, obj.Width, speed);
                    p.Animations.CurrentFrame = new Frame(96, 112, 32, 32);

                    Karma.maxKarma += p.Health;

                    // make it start on the right side of its path
                    if (obj.GetProperty("start_side") == "right")
                    {
                        p.Body.X          = obj.X + obj.Width;
                        p.CurrentDistance = obj.Width - 33;
                    }

                    enemies.Add(p);
                }
                else if (obj.Name.ToLower() == "goldfish")
                {
                    goldenFishs.Add(new GoldFish(this, tilemapTexture, new Vector2(obj.X, obj.Y), 16, 16));
                }
                else if (obj.Name.ToLower() == "particles")
                {
                    if (obj.GetProperty("type") == "dark_ambient")
                    {
                        ParticleEmitter particleEmitter = new ParticleEmitter(this, obj.X, obj.Y, 256);
                        particleEmitter.EmitterBox.Resize(obj.Width, obj.Height);

                        particleEmitter.MakeRandomParticles(tilemapTexture, new Rectangle[]
                        {
                            new Rectangle(128, 257, 3, 3),
                            new Rectangle(132, 257, 3, 3),
                            new Rectangle(136, 257, 3, 3)
                        });

                        particleEmitter.ParticleVelocity = new Vector2(0, 0);
                        particleEmitter.SetAcceleration(0, 0);
                        particleEmitter.XVelocityVariationRange = new Vector2(-20f, 20f);
                        particleEmitter.YVelocityVariationRange = new Vector2(-20f, 20f);
                        particleEmitter.SpawnRate = 100f;
                        particleEmitter.ParticleLifespanMilliseconds          = 5000f;
                        particleEmitter.ParticleLifespanVariationMilliseconds = 1000f;
                        particleEmitter.InitialScale = 1.5f;
                        particleEmitter.FinalScale   = 0.5f;

                        backgroundParticles.Add(particleEmitter);
                    }
                    else
                    {
                        ParticleEmitter particleEmitter = new ParticleEmitter(this, obj.X, obj.Y, 256);
                        particleEmitter.EmitterBox.Resize(obj.Width, obj.Height);
                        particleEmitter.MakeParticles(tilemapTexture, 16, 16);
                        particleEmitter.ParticleVelocity = new Vector2(0, -0.01f);
                        particleEmitter.SetAcceleration(0, -0.005f);
                        particleEmitter.XVelocityVariationRange = new Vector2(-20f, 20f);
                        particleEmitter.YVelocityVariationRange = new Vector2(-20f, 0f);
                        particleEmitter.SetTextureCropRectangle(new Rectangle(0, 78, 16, 16));
                        particleEmitter.SpawnRate = 250f;
                        particleEmitter.ParticleLifespanMilliseconds          = 5000f;
                        particleEmitter.ParticleLifespanVariationMilliseconds = 1000f;
                        particleEmitter.InitialScale = 0.1f;
                        particleEmitter.FinalScale   = 1.5f;

                        particleEmitter.ForEachParticle(ChangeSpriteTintBlue);

                        backgroundParticles.Add(particleEmitter);
                    }
                }
                else if (obj.Name.ToLower() == "player_spawn")
                {
                    //player.Body.X = obj.X;
                    //player.Body.Y = obj.Y;
                }
                else if (obj.Name.ToLower() == "change_state_trigger")
                {
                    triggers.Add(new Trigger(obj.X, obj.Y, obj.Width, obj.Height, obj.GetProperty("value")));
                }
                else if (obj.Name.ToLower() == "speedbox")
                {
                    SpeedBox s = new SpeedBox(obj.X, obj.Y, obj.Width, obj.Height, float.Parse(obj.GetProperty("speedX")), float.Parse(obj.GetProperty("speedY")));

                    ParticleEmitter particleEmitter = new ParticleEmitter(this, obj.X, obj.Y, 512);
                    particleEmitter.EmitterBox.Resize(obj.Width, obj.Height);
                    particleEmitter.MakeRandomParticles(tilemapTexture, new Rectangle[]
                    {
                        new Rectangle(128, 257, 3, 3),
                        new Rectangle(132, 257, 3, 3),
                        new Rectangle(136, 257, 3, 3),
                        new Rectangle(128 - 16, 257, 3, 3),
                        new Rectangle(132 - 16, 257, 3, 3),
                        new Rectangle(136 - 16, 257, 3, 3)
                    });
                    particleEmitter.ParticleVelocity        = new Vector2(s.SpeedIncrease.X * 10, s.SpeedIncrease.Y * 10);
                    particleEmitter.XVelocityVariationRange = new Vector2(-20f, 20f);
                    particleEmitter.YVelocityVariationRange = new Vector2(-20f, 20f);

                    particleEmitter.SpawnRate = 60f;
                    particleEmitter.ParticleLifespanMilliseconds          = 5000f;
                    particleEmitter.ParticleLifespanVariationMilliseconds = 1000f;
                    particleEmitter.InitialScale = 1.0f;
                    particleEmitter.FinalScale   = 0.5f;


                    backgroundParticles.Add(particleEmitter);
                    speedBoxes.Add(s);
                }

                Console.WriteLine("added " + obj.Name);
            }

            topWaterTiles = level.GetTilesListByID(new int[] { 97, 98, 99 });

            /*
             * Build Background Gradient
             */
            backgroundWaterGradientStrip = new Texture2D(Graphics.GraphicsDevice, 1, level.Height * level.TileHeight);

            Color startColor  = new Color(57, 92, 181);
            Color finishColor = new Color(17, 43, 104);
            Color currentColor;

            for (int i = 0; i < backgroundWaterGradientStrip.Height; i++)
            {
                float ratio = Math2.Map(i, 0f, backgroundWaterGradientStrip.Height, 0f, 1.0f);

                currentColor = Color.Lerp(startColor, finishColor, ratio);
                DrawMe.Pixel(backgroundWaterGradientStrip, 0, i, currentColor);
            }

            /*
             * Build Background Gradient
             */
            backgroundSkyGradientStrip = new Texture2D(Graphics.GraphicsDevice, 1, Graphics.PreferredBackBufferHeight / 2);

            startColor  = new Color(61, 28, 111);
            finishColor = new Color(158, 98, 123);
            for (int i = 0; i < backgroundSkyGradientStrip.Height; i++)
            {
                float ratio = Math2.Map(i, 0f, backgroundSkyGradientStrip.Height, 0f, 1.0f);

                currentColor = Color.Lerp(startColor, finishColor, ratio);
                DrawMe.Pixel(backgroundSkyGradientStrip, 0, i, currentColor);
            }

            ContentLoaded = true;
        }
Example #52
0
 protected internal LogMessage(Level level, string message)
 {
     SetLogMessage(level, message);
 }
Example #53
0
 public void Load(Level level)
 {
     text.text = level?.Meta.title ?? "Unknown";
 }
Example #54
0
 public EditStructTile(EditroidUndoRedoQueue q, Level level, int structIndex, StructTileEdit edit)
     : base(q, level, structIndex)
 {
     edit.oldValue = GetStruct().Data[edit.x, edit.y];
     edits         = new StructTileEdit[] { edit };
 }
Example #55
0
        public override void Process(Level level)
        {
            if (m_vAllianceName == null)
            {
                m_vAllianceName = "Clan";
            }

            if (m_vAllianceName.Length < 16 || m_vAllianceName.Length < 1)
            {
                if (m_vAllianceDescription.Length < 259 || m_vAllianceDescription.Length < 0)
                {
                    if (m_vAllianceBadgeData < 1 || m_vAllianceBadgeData < 10000000000)
                    {
                        if (m_vAllianceType < 0 || m_vAllianceType < 10)
                        {
                            if (m_vRequiredScore < 0 || m_vRequiredScore < 4201)
                            {
                                if (m_vWarFrequency < 0 || m_vWarFrequency < 10)
                                {
                                    if (m_vAllianceOrigin < 0 || m_vAllianceOrigin < 42000000)
                                    {
                                        if (m_vWarAndFriendlyStatus < 0 || m_vWarAndFriendlyStatus < 5)
                                        {
                                            Alliance alliance = ObjectManager.CreateAlliance(0);
                                            alliance.SetAllianceName(m_vAllianceName);
                                            alliance.SetAllianceDescription(m_vAllianceDescription);
                                            alliance.SetAllianceType(m_vAllianceType);
                                            alliance.SetRequiredScore(m_vRequiredScore);
                                            alliance.SetAllianceBadgeData(m_vAllianceBadgeData);
                                            alliance.SetAllianceOrigin(m_vAllianceOrigin);
                                            alliance.SetWarFrequency(m_vWarFrequency);
                                            alliance.SetWarAndFriendlytStatus(m_vWarAndFriendlyStatus);
                                            level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId());

                                            AllianceMemberEntry member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId());
                                            member.SetRole(2);
                                            alliance.AddAllianceMember(member);

                                            JoinedAllianceCommand b = new JoinedAllianceCommand();
                                            b.SetAlliance(alliance);

                                            AllianceRoleUpdateCommand d = new AllianceRoleUpdateCommand();
                                            d.SetAlliance(alliance);
                                            d.SetRole(2);
                                            d.Tick(level);

                                            AvailableServerCommandMessage a = new AvailableServerCommandMessage(Client);
                                            a.SetCommandId(1);
                                            a.SetCommand(b);

                                            AvailableServerCommandMessage c = new AvailableServerCommandMessage(Client);
                                            c.SetCommandId(8);
                                            c.SetCommand(d);

                                            PacketProcessor.Send(a);
                                            PacketProcessor.Send(c);
                                        }
                                        else
                                        {
                                            ResourcesManager.DisconnectClient(Client);
                                        }
                                    }
                                    else
                                    {
                                        ResourcesManager.DisconnectClient(Client);
                                    }
                                }
                                else
                                {
                                    ResourcesManager.DisconnectClient(Client);
                                }
                            }
                            else
                            {
                                ResourcesManager.DisconnectClient(Client);
                            }
                        }
                        else
                        {
                            ResourcesManager.DisconnectClient(Client);
                        }
                    }
                    else
                    {
                        ResourcesManager.DisconnectClient(Client);
                    }
                }
                else
                {
                    ResourcesManager.DisconnectClient(Client);
                }
            }
            else
            {
                ResourcesManager.DisconnectClient(Client);
            }
        }
Example #56
0
 public void Configure(XmlElement element)
 {
     if ((element != null) && (this.m_hierarchy != null))
     {
         if (element.LocalName != "log4net")
         {
             LogLog.Error(declaringType, "Xml element is - not a <log4net> element.");
         }
         else
         {
             if (!LogLog.EmitInternalMessages)
             {
                 string argValue = element.GetAttribute("emitDebug");
                 LogLog.Debug(declaringType, "emitDebug attribute [" + argValue + "].");
                 if ((argValue.Length > 0) && (argValue != "null"))
                 {
                     LogLog.EmitInternalMessages = OptionConverter.ToBoolean(argValue, true);
                 }
                 else
                 {
                     LogLog.Debug(declaringType, "Ignoring emitDebug attribute.");
                 }
             }
             if (!LogLog.InternalDebugging)
             {
                 string argValue = element.GetAttribute("debug");
                 LogLog.Debug(declaringType, "debug attribute [" + argValue + "].");
                 if ((argValue.Length > 0) && (argValue != "null"))
                 {
                     LogLog.InternalDebugging = OptionConverter.ToBoolean(argValue, true);
                 }
                 else
                 {
                     LogLog.Debug(declaringType, "Ignoring debug attribute.");
                 }
                 string str4 = element.GetAttribute("configDebug");
                 if ((str4.Length > 0) && (str4 != "null"))
                 {
                     LogLog.Warn(declaringType, "The \"configDebug\" attribute is deprecated.");
                     LogLog.Warn(declaringType, "Use the \"debug\" attribute instead.");
                     LogLog.InternalDebugging = OptionConverter.ToBoolean(str4, true);
                 }
             }
             ConfigUpdateMode merge     = ConfigUpdateMode.Merge;
             string           attribute = element.GetAttribute("update");
             if ((attribute != null) && (attribute.Length > 0))
             {
                 try
                 {
                     merge = (ConfigUpdateMode)OptionConverter.ConvertStringTo(typeof(ConfigUpdateMode), attribute);
                 }
                 catch
                 {
                     LogLog.Error(declaringType, "Invalid update attribute value [" + attribute + "]");
                 }
             }
             LogLog.Debug(declaringType, "Configuration update mode [" + merge.ToString() + "].");
             if (merge == ConfigUpdateMode.Overwrite)
             {
                 this.m_hierarchy.ResetConfiguration();
                 LogLog.Debug(declaringType, "Configuration reset before reading config.");
             }
             IEnumerator enumerator = element.ChildNodes.GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     XmlNode current = (XmlNode)enumerator.Current;
                     if (current.NodeType == XmlNodeType.Element)
                     {
                         XmlElement loggerElement = (XmlElement)current;
                         if (loggerElement.LocalName == "logger")
                         {
                             this.ParseLogger(loggerElement);
                             continue;
                         }
                         if (loggerElement.LocalName == "category")
                         {
                             this.ParseLogger(loggerElement);
                             continue;
                         }
                         if (loggerElement.LocalName == "root")
                         {
                             this.ParseRoot(loggerElement);
                             continue;
                         }
                         if (loggerElement.LocalName == "renderer")
                         {
                             this.ParseRenderer(loggerElement);
                             continue;
                         }
                         if (loggerElement.LocalName != "appender")
                         {
                             this.SetParameter(loggerElement, this.m_hierarchy);
                         }
                     }
                 }
             }
             finally
             {
                 IDisposable disposable = enumerator as IDisposable;
                 if (disposable != null)
                 {
                     disposable.Dispose();
                 }
             }
             string str6 = element.GetAttribute("threshold");
             LogLog.Debug(declaringType, "Hierarchy Threshold [" + str6 + "]");
             if ((str6.Length > 0) && (str6 != "null"))
             {
                 Level level = (Level)this.ConvertStringTo(typeof(Level), str6);
                 if (level != null)
                 {
                     this.m_hierarchy.Threshold = level;
                 }
                 else
                 {
                     LogLog.Warn(declaringType, "Unable to set hierarchy threshold using value [" + str6 + "] (with acceptable conversion types)");
                 }
             }
         }
     }
 }
Example #57
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (GUILayout.Button("Save level"))
        {
            // 1
            Level level = (Level)target;
            level.transform.position = Vector3.zero;
            level.transform.rotation = Quaternion.identity;
            // 2
            var levelRoot = GameObject.Find("Level");
            // 3
            var ldr        = new LevelDataRepresentation();
            var levelItems = new List <LevelItemRepresentation>();
            foreach (Transform t in levelRoot.transform)
            {
                // 4
                var sr = t.GetComponent <SpriteRenderer>();
                var li = new LevelItemRepresentation()
                {
                    position = t.position,
                    rotation = t.rotation.eulerAngles,
                    scale    = t.localScale
                };
                // 5
                if (t.name.Contains(" "))
                {
                    li.prefabName = t.name.Substring(0, t.name.IndexOf(" "));
                }
                else
                {
                    li.prefabName = t.name;
                }
                // 6
                if (sr != null)
                {
                    li.spriteLayer = sr.sortingLayerName;
                    li.spriteColor = sr.color;
                    li.spriteOrder = sr.sortingOrder;
                }
                // 7
                levelItems.Add(li);
                // 8
                ldr.levelItems          = levelItems.ToArray();
                ldr.playerStartPosition =
                    GameObject.Find("SoyBoy").transform.position;
                // 9
                var currentCamSettings = FindObjectOfType <CameraLerpToTransform>();
                if (currentCamSettings != null)
                {
                    ldr.cameraSettings = new CameraSettingsRepresentation()
                    {
                        cameraTrackTarget = currentCamSettings.camTarget.name,
                        //cameraZDepth = currentCamSettings.cameraZDepth,
                        minX          = currentCamSettings.minX,
                        minY          = currentCamSettings.minY,
                        maxX          = currentCamSettings.maxX,
                        maxY          = currentCamSettings.maxY,
                        trackingSpeed = currentCamSettings.trackingSpeed
                    };
                }
                var levelDataToJson = JsonUtility.ToJson(ldr);
                var savePath        = System.IO.Path.Combine(Application.dataPath,
                                                             level.levelName + ".json");
                System.IO.File.WriteAllText(savePath, levelDataToJson);
                Debug.Log("Level saved to " + savePath);
            }
        }
    }
Example #58
0
 /// <summary>
 /// Creates a new logging event and logs the event without further checks.
 /// </summary>
 /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
 /// the stack boundary into the logging system for this call.</param>
 /// <param name="level">The level of the message to be logged.</param>
 /// <param name="message">The message object to log.</param>
 /// <param name="exception">The exception to log, including its stack trace.</param>
 /// <remarks>
 /// <para>
 /// Generates a logging event and delivers it to the attached
 /// appenders.
 /// </para>
 /// </remarks>
 virtual protected void ForcedLog(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
 {
     CallAppenders(new LoggingEvent(callerStackBoundaryDeclaringType, Hierarchy, Name, level, message, exception));
 }
Example #59
0
 public VerborgenKamer1(Level level, Point offsetPosition, Size size)
     : base(level, offsetPosition, size)
 {
     MaakHindernissen();
 }
Example #60
0
 virtual public bool IsLogging(Level level)
 {
     return(true);
 }