상속: MonoBehaviour
예제 #1
0
    public override IEnumerator Perform()
    {
        Digger digger = Owner.GetComponent <Digger>();

        if (!digger.AutoDig)
        {
            setDestination(Position);

            while (!hasReachedTarget())
            {
                yield return(0);
            }

            Stop();
        }

        Owner.SendMessage("Dig", SendMessageOptions.DontRequireReceiver);

        LevelController.Instance.Dig((int)digPosition.x, (int)digPosition.y);

        yield return(new WaitForSeconds(digger.DigTime));

        Owner.SendMessage("DoneDigging", SendMessageOptions.DontRequireReceiver);

        Owner.SendMessage("ActionComplete");
    }
예제 #2
0
    private static void Main(string[] args)
    {
        // Inputs
        Console.WriteLine("Enter Path: ");
        string directory = Console.ReadLine();

        Console.WriteLine("Enter output file: ");
        string outputFile = Console.ReadLine();

        // Init our digger
        Digger FileDigger = new Digger();

        // Create file iterator
        IEnumerable <string> files = Digger.EnumerateFilesRecursively(directory);

        // Create Report
        XDocument doc = Digger.CreateReport(files);

        // Create and write to html file
        using (FileStream fs = new FileStream(outputFile, FileMode.Create))
        {
            using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
            {
                w.WriteLine(doc);
            }
        }
    }
예제 #3
0
        public void Visit(Digger digger)
        {
            log.Verbose("{actor} visit {item} with {stamina}", "Digger", "Camp", digger.Stamina);
            digger.Stamina = digger.MaxStamina;

            service.Send(new DiggerInCamp());
        }
        public virtual async Task <JsonResult> EditPopup(T item)
        {
            var r            = new JsonResultViewModel();
            var keyFieldName = Digger2.GetKeyFieldNameFirst(typeof(T));
            var v            = Digger.GetObjectValue(item, keyFieldName);

            if (v != null)
            {
                int.TryParse(v.ToString(), out _editId);
                if (_editId > 0)
                {
                    var org = Repo.GetItem(_editId);
                    var x   = await TryUpdateModelAsync(org);

                    OnEditSaveItem(org);
                    if (Repo.Edit(org))
                    {
                        r.Ok = true;
                        if (!EditJsAction.IsEmpty())
                        {
                            r.JsFunction = EditJsAction;
                        }
                    }
                    else
                    {
                        r.Error = MvcLogger.GetErrorMessage(ModelState);
                    }
                }
            }
            else
            {
                r.Error = "NOT FOUND";
            }
            return(Json(r));
        }
예제 #5
0
        public void DefaultStaminaInitialized()
        {
            var digger = new Digger();

            digger.Stamina.Should()
            .BeGreaterThan(0);
        }
 public virtual IActionResult Create(int keepEdit, T item)
 {
     OnCreateSaveItem(item);
     if (Repo.Create(item))
     {
         OnAfterCreateSaveItem(item);
         if (keepEdit == 0)
         {
             return(CreateReturnListUrl.IsEmpty()
                 ? (ActionResult)RedirectToAction("Index")
                 : Redirect(CreateReturnListUrl));
         }
         if (keepEdit == 1)
         {
             var keyFieldName = Digger2.GetKeyFieldNameFirst(typeof(T));
             var itemIdValue  = Digger.GetObjectValue(item, keyFieldName);
             return(RedirectToAction("Edit", new { id = itemIdValue }));
         }
         return(CreateSaveAndCreateUrl.IsEmpty()
             ? (ActionResult)RedirectToAction("Create")
             : Redirect(CreateSaveAndCreateUrl));
     }
     ViewBag.EditMode     = false;
     ViewBag.CreateAction = CreateAction;
     ViewBag.Title        = GetTitle(TitleType.Create);
     BuildCreateMenu();
     OnErrorCreateSaveItem(item);
     ViewBag.PageMenu = PageMenu;
     return(View(PopupEditor ? ViewCreatePopup : ViewCreate, item));
 }
예제 #7
0
 public override bool PreAI()
 {
     npc.active   = lead.active;
     npc.realLife = lead.type == mod.NPCType <Magnoliac_head>() ? lead.whoAmI : part.whoAmI;
     Digger.DiggerPartsAI(npc, part, mod.GetNPC <Magnoliac_head>().followSpeed, ref acc);
     return(true);
 }
    public Vector2Int[] GenerateRoomPositions()
    {
        Digger[]   diggers  = new Digger[dungeonData.numberOfDiggers];
        Vector2Int startPos = Vector2Int.zero;

        positionVisited.Add(startPos);
        for (int i = 0; i < diggers.Length; i++)
        {
            diggers[i] = new Digger(startPos);
        }

        int iterations = UnityEngine.Random.Range(dungeonData.minIterations, dungeonData.maxIterations);

        for (int i = 0; i < iterations; i++)
        {
            for (int j = 0; j < diggers.Length; j++)
            {
                Vector2Int newPos = diggers[j].Move(directionMouvementMap);
                if (!positionVisited.Contains(newPos))
                {
                    positionVisited.Add(newPos);
                }
            }
        }
        return(positionVisited.ToArray());
    }
예제 #9
0
        public override void GenerateImpl(int row, int col, Direction dir)
        {
            var topRow  = row;
            var leftCol = col;

            GetTopLeftCorner(ref topRow, ref leftCol, dir);

            var goalRow = row;
            var goalCol = col;

            RHelper.MoveInDirection(ref goalRow, ref goalCol, dir);

            var digArea = new Rectangle(leftCol + 1, topRow + 1, Width - 2, Height - 2);
            var digger  = new Digger(goalRow, goalCol, (int)((digArea.Width * digArea.Height) / 25d), Map);

            Map[row, col] = Map[row, col].Is(RCell.Important)
                ? RCell.Door | RCell.Important | RCell.Closed
                : RCell.Floor;
            digger.DigCell(row, col);
            digger.DigCell(row + 1, col);
            digger.DigCell(row - 1, col);
            digger.DigCell(row, col + 1);
            digger.DigCell(row, col - 1);
            digger.Dig();
        }
        public static object InspectDataFormat(object item, DataColumn field, string dataFormat = null)
        {
            if (field.EditorType == ColumnTypes.Link)
            {
                dataFormat = HttpUtility.UrlDecode(dataFormat);
            }

            if (string.IsNullOrWhiteSpace(dataFormat))
            {
                dataFormat = field.DataFormat;
            }
            if (string.IsNullOrWhiteSpace(dataFormat))
            {
                var fieldValue = ValueToLabel(field.ValueConverter, Digger.GetObjectValue(item, field.FieldName));
                return(fieldValue ?? string.Empty);
            }
            var val = dataFormat;

            var ma = RegexDataFormat.Matches(dataFormat);

            if (ma.Count > 0)
            {
                foreach (Match m in ma)
                {
                    if (m.Success)
                    {
                        var fieldName  = m.Groups[1].Value;
                        var fieldValue = Digger.GetObjectValue(item, fieldName);
                        if (field.FieldName == fieldName)
                        {
                            fieldValue = ValueToLabel(field.ValueConverter, fieldValue);
                        }
                        var fv = fieldValue != null?fieldValue.ToString() : string.Empty;

                        val = val.Replace(m.ToString(), fv);
                    }
                }
            }
            ma = RegexDataFormat2.Matches(dataFormat);
            if (ma.Count > 0)
            {
                foreach (Match m in ma)
                {
                    if (m.Success)
                    {
                        var fieldName  = m.Groups[1].Value;
                        var fieldValue = Digger.GetObjectValue(item, fieldName);
                        if (field.FieldName == fieldName)
                        {
                            fieldValue = ValueToLabel(field.ValueConverter, fieldValue);
                        }
                        var fv = fieldValue != null?fieldValue.ToString() : string.Empty;

                        val = val.Replace(m.ToString(), fv);
                    }
                }
            }
            return(val);
        }
예제 #11
0
 void Awake()
 {
     _digger = GetComponent <Digger>();
     if (_digger == null)
     {
         Debug.Log("inputdig has no digger", gameObject);
     }
 }
예제 #12
0
 void Start()
 {
     target         = playerTransform.position;
     digger         = GetComponent <Digger>();
     audioSource    = GetComponent <AudioSource>();
     digger.DigSize = 6;
     LoadWorm();
 }
        private static string RenderRow(IHtmlHelper helper, DataColumn[] columns, object item, DataGridOptions option)
        {
            var builder = new HtmlContentBuilder();
            var idx     = "";
            var idclass = "";

            if (option.RowFormatClass != null && !option.RowFormatFunction.IsEmpty())
            {
                var obj   = Activator.CreateInstance(option.RowFormatClass);
                var a     = option.RowFormatClass.GetMethod(option.RowFormatFunction);
                var sonuc = (string)a.Invoke(obj, new dynamic[1] {
                    item
                });
                idclass = $"class='{sonuc}'";
            }
            builder.AppendHtml($"<tr {idx} {idclass}>");
            if (string.IsNullOrWhiteSpace(_exportMode))
            {
                builder.AppendHtml(RenderRowButtons(helper, item, option));
                foreach (var column in columns.Where(d => d.Visible && d.DataColumnType == DataColumnTypes.CommandColumn))
                {
                    var val = Digger.GetObjectValue(item, column.FieldName);
                    if (val is List <DataGridCommand> )
                    {
                        builder.AppendHtml(RenderRowButtons(val as List <DataGridCommand>));
                    }
                }
            }

            foreach (var field in columns.Where(d => d.Visible && d.DataColumnType != DataColumnTypes.CommandColumn))
            {
                if (field.Width > 0)
                {
                    builder.AppendHtml($"<td width='{field.Width}'>");
                }
                else
                {
                    builder.AppendHtml("<td>");
                }
                if (string.IsNullOrWhiteSpace(field.ObjectValueFunction) || field.ObjectValueConverter == null)
                {
                    builder.AppendHtml(ValueConverter.GetValue(helper, item, field));
                }
                else
                {
                    var type  = field.ObjectValueConverter;
                    var obj   = Activator.CreateInstance(type);
                    var a     = type.GetMethod(field.ObjectValueFunction);
                    var sonuc = (string)a.Invoke(obj, new object[2] {
                        helper, item
                    });
                    builder.AppendHtml(sonuc);
                }
                builder.AppendHtml("</td>");
            }
            builder.AppendHtml("</tr>");
            return(builder.GetString());
        }
예제 #14
0
        public static void ToCsvEXport <T>(this IEnumerable <T> list, string fileName)
        {
            var excelDoc = new StreamWriter(fileName, false, Encoding.UTF8);
            var rowCount = 0;
            var rowData  = string.Empty;
            var type     = typeof(T);
            var props    = type.GetProperties();

            foreach (var prop in props)
            {
                rowData += prop.Name + ";";
            }
            excelDoc.WriteLine(rowData);
            foreach (T x in list)
            {
                rowData = string.Empty;
                rowCount++;
                foreach (var prop in props)
                {
                    var value = Digger.GetObjectValue(x, prop.Name);
                    if (value == null)
                    {
                        rowData += ";";
                        continue;
                    }
                    switch (prop.PropertyType.ToString())
                    {
                    case "System.DateTime":
                        var xmlDate = (DateTime)value;
                        rowData += xmlDate.ToString("yyyy-MM-dd") + ";";
                        break;

                    case "System.String":
                    case "System.Boolean":
                    case "System.Int16":
                    case "System.Int32":
                    case "System.Int64":
                    case "System.Byte":
                        rowData += value + ";";
                        break;

                    case "System.Decimal":
                        rowData += value.ToString().Replace(",", ".");
                        break;

                    case "System.Double":
                        rowData += (decimal.Parse(value.ToString()).ToString("N2").Replace(",", "."));
                        break;

                    default:
                        rowData += ";";
                        break;
                    }
                }
                excelDoc.WriteLine(rowData);
            }
            excelDoc.Close();
        }
예제 #15
0
파일: Tile.cs 프로젝트: VioletTape/DiggerRL
        public void Visit(Digger digger)
        {
            digger.Stamina -= StaminaPrice;
            log.Verbose("Stamina reduced on {staminaPrice}", StaminaPrice);
            log.Verbose("{actor} moved, stamina left {stamina}", "Digger", digger.Stamina);
            Building.Visit(digger);

            digger.GemBag.Add(Gem);
        }
예제 #16
0
 public void Initialize(ushort tileID, ushort wallID)
 {
     rand    = WorldGen.genRand.Next(7, 12);
     diggers = new Digger[rand];
     for (int i = 0; i < rand; i++)
     {
         diggers[i] = new Digger(25, tileID, wallID);
     }
 }
예제 #17
0
        private void btnSearch_Click_1(object sender, EventArgs e)
        {
            DirectoryInfo d      = new DirectoryInfo(txtDirectory.Text);
            SizeGetter    sg1    = new SizeGetter();
            TreeNode      t      = trvDirectories.Nodes.Add(d.FullName, d.Name + " (" + (int)sg1.GetDirectorySize(d.FullName) / 1000 + "K)");
            Digger        digger = new Digger();

            digger.Dig(d, this);
        }
예제 #18
0
        public void CantAddNullGem()
        {
            var digger = new Digger();

            digger.GemBag.Add(new NullGem());

            digger.GemBag.Gems.Count
            .Should()
            .Be(0);
        }
예제 #19
0
        public void ItShouldBePossible()
        {
            var digger = new Digger();

            digger.GemBag.Add(new Coal());

            digger.GemBag.Gems.Count
            .Should()
            .Be(1);
        }
예제 #20
0
        public override bool AllowEntrance(Digger digger)
        {
            if (Density <= 0)
            {
                return(true);
            }

            Density -= digger.Attack();

            return(false);
        }
예제 #21
0
        public void StaminaShouldDecrese()
        {
            var digger         = new Digger();
            var initialStamina = digger.Stamina;

            digger.Move(new EmptyTile());

            digger.Stamina
            .Should()
            .BeLessThan(initialStamina);
        }
예제 #22
0
        public FileExplorerConsole()
        {
            //String foldername = @"C:\Users\Tenurian\Tester";
            String foldername = @"C:\Users\Tenurian\Documents\Visual Studio 2015\Projects\FileExplorerConsole";
            Digger digger     = new Digger();

            spacers.Add(foldername, 1);
            DirectoryFound(new DirectoryInfo(foldername)); //this is here to ensure the top folder appears
            digger.Dig(new DirectoryInfo(foldername), this);
            Console.ReadLine();
        }
예제 #23
0
        public virtual async Task <IActionResult> Edit(int keepEdit, T item)
        {
            if (!OnEditAuthCheck())
            {
                return(new ForbidResult());
            }

            var keyFieldName = Digger2.GetKeyFieldNameFirst(typeof(T));
            var v            = Digger.GetObjectValue(item, keyFieldName);

            if (v != null)
            {
                int.TryParse(v.ToString(), out _editId);
                if (_editId > 0)
                {
                    var org = await GetEditSaveItem(_editId);

                    OnEditBeforeSaveItem(item, org);
                    await TryUpdateModelAsync(org);

                    if (OnEditSaveCheck(org))
                    {
                        try
                        {
                            OnEditSaveItem(org);
                            if (await Repo.EditAsync(org))
                            {
                                OnAfterEditSaveItem(org);
                                if (keepEdit == 0)
                                {
                                    return(EditReturnListUrl.IsEmpty() ? (ActionResult)RedirectToAction("Index") : Redirect(EditReturnListUrl));
                                }
                                return(RedirectToAction("Edit", new { id = _editId }));
                            }
                        }
                        catch (Exception ex)
                        {
                            ModelState.AddModelError(keyFieldName, MvcLogger.GetErrorMessage(ex));
                        }
                        ViewBag.EditMode   = true;
                        ViewBag.EditAction = EditAction;
                        ViewBag.Title      = GetTitle(TitleType.Editor);
                        BuildEditMenu();
                        ViewBag.PageMenu = PageMenu;
                        OnEditItem(org);
                        return(View(PopupEditor ? ViewEditPopup : ViewEdit, org));
                    }
                    return(new ForbidResult());
                }
            }
            return(NotFound());
        }
예제 #24
0
 private void Awake()
 {
     mc              = GetComponent <MovementController>();
     mc.OnLanding   += OnLanding;
     cam             = Camera.main;
     health          = GetComponent <Health>();
     health.OnDeath += OnDeath;
     fps             = cam.GetComponent <FirstPersonCamera>();
     digger          = GetComponent <Digger>();
     audioSource     = GetComponent <AudioSource>();
     grapplingHook   = GetComponent <GrapplingHook>();
     digger.DigSize  = DigSize;
 }
예제 #25
0
        public void GoldShouldBeSummedFromBag()
        {
            var digger = new Digger();

            digger.GemBag.Add(new Coal());

            var service = new StoreService();

            service.Handle(new DiggerInStore(digger));

            digger.Gold.Should()
            .Be(10);
            digger.GemBag.Gems.Should()
            .BeEmpty();
        }
예제 #26
0
    void Awake()
    {
        _digUI = GetComponentInChildren <Canvas>();
        if (_digUI == null)
        {
            Debug.Log("no canvas component in diggable children", gameObject);
        }

        _progressImage = _digUI.GetComponentInChildren <Image>();
        if (_progressImage == null)
        {
            Debug.Log("no image component in diggable canvas children", gameObject);
        }

        _workDone = 0;
        _digger   = null;
    }
예제 #27
0
파일: CaveBody.cs 프로젝트: sash-a/Orb
    public CaveBody(Digger d) : base(d)
    {
        //Debug.Log("creating cave body - adding to caves list");
        digger.neighbourCount = 0;
        digger.gradient       = 0;
        //Debug.Log("before: " + digger.master is CaveEntrance);
        digger.master = this;
        //ebug.Log("after: " + digger.master is CaveEntrance);
        center = Vector3.zero;
        CaveManager.caves.Add(this);
        digger.setScale(10);

        if (tier > 0)
        {
            Debug.Log("creating cave with tier = " + tier);
        }
    }
예제 #28
0
    private Digger digger;                                  // DiggerAgent objet that is going to build the dungeon

    public override void BuildDungeon()
    {
        AssertProperties();
        // Create dungeon grid
        dungeon = new Dungeon(dungeonHeight, dungeonWidth);
        dungeon.createDungeonGrid(dungeonTopLeftCellPosition, floorTileDimensions);
        // Initialise digger
        digger = new Digger(dungeon, corridorMinTilesLength, corridorMaxTilesLength, removeDirtyCorridors);
        // Place digger in a random dungeon cell leaving a margin on the right and the bottom parts of the grid for the first room
        digger.SetDiggerInitialPosition(roomMinTilesWidth, roomMinTilesHeight);
        // Create dungeon
        digger.DigDungeon(roomMinTilesWidth, roomMaxTilesWidth, roomMinTilesHeight, roomMaxTilesHeight, floorTileDimensions, floorMaterial, wallHeight, wallMaterial);
        // Set entrance and exit rooms
        dungeon.chooseEntranceRoomAndExitRoom(0, dungeon.getDungeonRooms().Count - 1);
        // Set the corridors and rooms to be children of the dungeon game object
        dungeon.setRoomsAndCorridorsAsDungeonChildren();
        // Set that the dungeon has finished building
        dungeonBuildingFinished = true;
    }
예제 #29
0
        public virtual async Task <IActionResult> Create(int keepEdit, T item)
        {
            if (!OnCreateAuthCheck())
            {
                return(new ForbidResult());
            }
            var keyFieldName = Digger2.GetKeyFieldNameFirst(typeof(T));

            try
            {
                OnCreateSaveItem(item);
                if (OnCreateSaveCheck(item))
                {
                    if (await Repo.CreateAsync(item))
                    {
                        OnAfterCreateSaveItem(item);
                        if (keepEdit == 0)
                        {
                            return(CreateReturnListUrl.IsEmpty() ? (ActionResult)RedirectToAction("Index") : Redirect(CreateReturnListUrl));
                        }
                        if (keepEdit == 1)
                        {
                            var itemIdValue = Digger.GetObjectValue(item, keyFieldName);
                            return(RedirectToAction("Edit", new { id = itemIdValue }));
                        }
                        return(CreateSaveAndCreateUrl.IsEmpty() ? (ActionResult)RedirectToAction("Create") : Redirect(CreateSaveAndCreateUrl));
                    }
                }
                return(new ForbidResult());
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(keyFieldName, MvcLogger.GetErrorMessage(ex));
            }
            ViewBag.EditMode     = false;
            ViewBag.CreateAction = CreateAction;
            ViewBag.Title        = GetTitle(TitleType.Create);
            BuildCreateMenu();
            OnErrorCreateSaveItem(item);
            ViewBag.PageMenu = PageMenu;
            return(View(PopupEditor ? ViewCreatePopup : ViewCreate, item));
        }
예제 #30
0
파일: CaveManager.cs 프로젝트: sash-a/Orb
 public void removeDigger(Digger d)
 {
     diggers.Remove(d);
     Destroy(d.gameObject);
     if (diggers.Count <= 0)
     {
         tiersLeft--;
         gatherCaveVoxels();
         //Debug.Log("finished cave tier " + (caveTiers - tiersLeft - 1));
         if (tiersLeft <= 0)
         {
             finishDigging();
         }
         else
         {//keep digging
             digNextTier();
         }
         //MapManager.SmoothVoxels();
     }
 }
예제 #31
0
 void Start()
 {
     dig = GameObject.FindGameObjectWithTag("Digger").GetComponent<Digger>();
     rm = GetComponent<Rooms_Manager>();
     mm = GetComponent<Map_Manager>();
     cm = GetComponent<Cleanup_Manager>();
     //StartCoroutine(StartGeneration(1f));
 }