Ejemplo n.º 1
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser user = await _userManager.FindAsync(model.UserName, model.Password);

                if (user != null)
                {
                    IAuthenticationManager authenticationManager = HttpContext.GetOwinContext().Authentication;
                    authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
                    ClaimsIdentity           identity = _userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
                    AuthenticationProperties props    = new AuthenticationProperties();
                    props.IsPersistent = model.RememberMe;
                    authenticationManager.SignIn(props, identity);
                    if (Url.IsLocalUrl(returnUrl))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction(Constant.Action_Index, Constant.Controller_Home));
                    }
                }
                else
                {
                    ModelState.AddModelError("", ResourceManagement.GetResourceText(Constant.Resource_LoginIncorrect));
                }
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult SendFeedback(FeedbackViewModel feedbackVM)
        {
            if (ModelState.IsValid)
            {
                var feedback = Mapper.Map <Feedback>(feedbackVM);
                feedback.CreatedDate = DateTime.Now;
                _feedbackService.Create(feedback);
                _feedbackService.Save();

                ViewData[Constant.ViewData_SuccessMsg] = ResourceManagement.GetResourceText(Constant.Resource_SendFeedbackSuccess);

                string content = System.IO.File.ReadAllText(Server.MapPath(Constant.Path_ContactTemplate));
                content = content.Replace("{{Name}}", feedbackVM.Name);
                content = content.Replace("{{Email}}", feedbackVM.Email);
                content = content.Replace("{{Message}}", feedbackVM.Message);
                var adminEmail = ConfigHelperUtility.GetByKey(Constant.AppSetting_AdminEmail);
                MailHelperUtility.SendMail(adminEmail, ResourceManagement.GetResourceText(Constant.Resource_ContactInformationFromWebsite), content);

                feedbackVM.Name    = string.Empty;
                feedbackVM.Message = string.Empty;
                feedbackVM.Email   = string.Empty;
            }
            feedbackVM.ContactDetail = GetDetail();

            return(View(Constant.Action_Index, feedbackVM));
        }
Ejemplo n.º 3
0
        public ApiMessage GetAgencyResources()
        {
            this.IniRequest();
            ApiMessage           message     = new ApiMessage();
            AgentAdminMenagement agentMgtMgr = new AgentAdminMenagement(User.Identity.Name);
            int agencyId = 0;

            int.TryParse(request["agencyId"], out agencyId);
            if (agencyId > 0)
            {
                List <BResource> rs = agentMgtMgr.FindAgentResources(agencyId);
                message.Status = "OK";
                message.Item   = rs;
            }
            else
            {
                ResourceManagement resourceMgr = new ResourceManagement(agentMgtMgr.CurrentLoginUser);
                int total           = 0;
                List <BResource> rs = resourceMgr.FindResources(0, null, 0, out total);
                message.Status = "OK";
                message.Item   = rs;
            }

            return(message);
        }
Ejemplo n.º 4
0
        public ApiMessage GetAgencyResourceTaocans()
        {
            this.IniRequest();
            ApiMessage           message     = new ApiMessage();
            AgentAdminMenagement agentMgtMgr = new AgentAdminMenagement(User.Identity.Name);
            int agencyId   = 0;
            int resourceId = 0;

            int.TryParse(request["agencyId"], out agencyId);
            int.TryParse(request["resourceId"], out resourceId);
            if (agencyId == 0 && resourceId == 0)
            {
                message.Status  = "ERROR";
                message.Item    = null;
                message.Message = "代理商编号和资源编号都不能为空";
                return(message);
            }
            List <BResourceTaocan> taocans = new List <BResourceTaocan>();

            if (resourceId > 0 && agencyId > 0)
            {
                taocans = agentMgtMgr.FindAgencyResourceTaocans(agencyId, resourceId);
            }
            else if (resourceId > 0 && agencyId <= 0)
            {
                ResourceManagement resourceMgr = new ResourceManagement(agentMgtMgr.CurrentLoginUser);
                taocans = resourceMgr.FindResourceTaocans(resourceId, 0, false);
            }

            message.Status = "OK";
            message.Item   = taocans;
            return(message);
        }
Ejemplo n.º 5
0
    public void LoadResources()
    {
        //Debug.Log("Loading Resources");
        tileSprite = new Dictionary <string, Sprite>();
        // treeSprites = new Dictionary<string,List<Sprite>>();
        //mogwaiSprites = new Dictionary<string,List<Sprite>>();

        treeData = new Dictionary <string, Tree>();

        worldPrefabDictionary = new Dictionary <string, GameObject>();

        Sprite[] tilesprites = Resources.LoadAll <Sprite>("Sprites/World/Tile");
        foreach (Sprite s in tilesprites)
        {
            tileSprite[s.name] = s;
        }
        //treeSprites = ResourceManagement.SetUpSpriteDictionary("Sprites/World/Nature/Trees",treeSprites);
        //mogwaiSprites = ResourceManagement.SetUpSpriteDictionary("Sprites/Character/Mogwai", mogwaiSprites);

        worldPrefabDictionary = ResourceManagement.SetUpPrefabDictionary("Prefabs/World");
        worldItemDictionary   = ResourceManagement.SetUpPrefabDictionary("Prefabs/Item");

        treeData = ResourceManagement.SetUpTreeDictionay("ScriptableObjects/World/Nature/Tree");

        stereopTypeBiome = Resources.LoadAll <Biome>("ScriptableObjects/World");

        //Debug.Log("biomes data loaded" + stereopTypeBiome[2]);
    }
Ejemplo n.º 6
0
    private void Dead()
    {
        ResourceManagement resourceManager = ResourceManagement.instance;

        //Nature Reduction
        resourceManager.naturePoints -= 1;

        //Give oxygen to the player
        if (fishType == FishTypes.Normal)
        {
            resourceManager.OxygenPoints += 1;
        }
        else
        {
            resourceManager.OxygenPoints += 2;
        }

        ResourceUI.instance.UpdateUI();

        StartCoroutine(PlayerAttack.instance.RemoveEntryFromAttackFishCollection(this.gameObject));

        this.gameObject.SetActive(false);

        //Spawn death particles
    }
Ejemplo n.º 7
0
        protected override void Initialize(RequestContext requestContext)
        {
            try
            {
                base.Initialize(requestContext);

                HttpCookie langCookie = Request.Cookies[Constant.Cookie_Language];
                var        langCode   = langCookie.Value;
                if (!ResourceManagement.languages.Contains(langCode))
                {
                    CookieHelper.SetCookieLanguageDefault();
                    langCode = App.AppLanguageDefault;
                }
                ViewBag.LanguageCurrent = langCode;
                ViewBag.CountInCart     = Session[Constant.Session_ShoppingCart] == null ? 0 : (Session[Constant.Session_ShoppingCart] as List <ShoppingCartViewModel>).Count;
                App.DicResources        = App.CacheProvider.Get <Dictionary <string, string> >(langCode);
                if (App.DicResources == null)
                {
                    App.DicResources = ResourceManagement.GetResourceByLang(langCode);
                    App.CacheProvider.Set(langCode, AppCachingAbsoluteExpiration.NoneExpiration, () => App.DicResources);
                }

                CultureInfo objCulture = CultureInfo.CreateSpecificCulture(App.Culture);
                objCulture.DateTimeFormat.ShortDatePattern     = App.DatePattern;
                objCulture.NumberFormat.NumberDecimalSeparator = ",";
                objCulture.NumberFormat.NumberGroupSeparator   = ".";
                Thread.CurrentThread.CurrentCulture            = objCulture;
                Thread.CurrentThread.CurrentUICulture          = objCulture;
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
        }
Ejemplo n.º 8
0
    public override void Setup()
    {
        base.Setup();

        treeAnimator = GetComponent <Animator>();

        sprites = ResourceManagement.SetUpSpriteDictionary("Sprites/World/Nature/Trees", sprites);
    }
Ejemplo n.º 9
0
    //CONSTRUCTORES
    public Inventario(int capacidadTotal, GameManager manager)
    {
        inventario          = new List <ResourceInfo>();
        this.capacidadTotal = capacidadTotal;
        this.manager        = manager;

        limiteInventario = new ResourceManagement(manager);
    }
Ejemplo n.º 10
0
        public ActionResult Charge(ChargeModel model)
        {
            if (ModelState.IsValid)
            {
                //ChargeBridge cb = new ChargeBridge();
                ChargeOrder order = new ChargeOrder()
                {
                    ChargeType = 0, AgencyId = 0, Id = 0, Province = model.Province, City = model.City, MobileSP = model.SPName, MobileNumber = model.Mobile, OutId = "", ResourceId = 0, ResourceTaocanId = model.ResourceTaocanId, RouteId = 0, CreatedTime = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now)
                };
                //
                OrderManagement    orderMgt    = new OrderManagement();
                ResourceManagement resourceMgr = new ResourceManagement(0);
                order = orderMgt.GenerateOrder(order);
                int total = 0;
                List <BResourceTaocan> taocans = resourceMgr.FindResourceTaocans(order.ResourceTaocanId, 0, 0, out total);
                if (taocans == null || taocans.Count == 0)
                {
                    ViewBag.Message = "当前套餐不可用";
                    return(View());
                }
                BResourceTaocan taocan = taocans[0];
                //Redirct to the payment page.
                //TBD
                //After the payment is done then process below steps
                AlipayConfig config = new AlipayConfig(System.IO.Path.Combine(Request.PhysicalApplicationPath, "Config\\AliPayConfig.xml"));
                Submit       submit = new Submit(config);

                SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                sParaTemp.Add("partner", config.Partner);
                sParaTemp.Add("seller_email", "*****@*****.**");
                sParaTemp.Add("_input_charset", config.Input_charset.ToLower());
                sParaTemp.Add("service", "create_direct_pay_by_user");
                sParaTemp.Add("payment_type", "1");
                sParaTemp.Add("notify_url", config.Notify_Url);
                sParaTemp.Add("return_url", config.Return_Url);
                sParaTemp.Add("out_trade_no", order.PaymentId.ToString());
                sParaTemp.Add("subject", string.Format("{0}M", taocan.Taocan.Quantity));
                sParaTemp.Add("total_fee", taocan.Taocan.Sale_price.ToString("0.00"));
                sParaTemp.Add("body", string.Format("{0}M", taocan.Taocan.Quantity));
                sParaTemp.Add("show_url", "");
                sParaTemp.Add("seller_id", config.Partner);
                //sParaTemp.Add("anti_phishing_key", "");
                //sParaTemp.Add("exter_invoke_ip", "");

                //建立请求
                string sHtmlText = submit.BuildRequest(sParaTemp, "get", "确认");
                //Response.Write("ok");
                Response.Clear();
                Response.Charset = "utf-8";
                Response.Write(sHtmlText);


                //ChargeResult result = cb.Charge(order);
                //ViewBag.Message = result.Message;
            }

            return(View());
        }
Ejemplo n.º 11
0
 private StandardOutputAsyncStreamReader(Process processToListenTo)
     : base(processToListenTo)
 {
     ProcessToListenTo.StartInfo.RedirectStandardOutput = true;
     if (!ResourceManagement.IsMonoRuntime())
     {
         ProcessToListenTo.ErrorDataReceived += HandleDataReceivedAsAsync;
     }
 }
Ejemplo n.º 12
0
    public void UpdateUI()
    {
        ResourceManagement resourceManager = ResourceManagement.instance;

        UpdateOxygenUI(resourceManager.oxygenPoints);
        UpdateHealthUI(resourceManager.health);
        UpdateNatureUI(resourceManager.naturePoints);
        UpdateResourcesUI(resourceManager.resourcePoints);
    }
Ejemplo n.º 13
0
    private void Start()
    {
        wfs = new WaitForSeconds(timeToReduceOxygen);

        resourceManager = ResourceManagement.instance;
        resourceUI      = ResourceUI.instance;

        StartCoroutine(reduceOxygen());
    }
Ejemplo n.º 14
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
 public void Listen()
 {
     //workaround for a bug in the mono process when attempting to read async from console output events
     // - link http://mono.1490590.n4.nabble.com/System-Diagnostic-Process-and-event-handlers-td3246096.html
     if (ResourceManagement.IsMonoRuntime())
     {
         ListenAsThread();
     }
     else
     {
         ListenAsAsync();
     }
 }
Ejemplo n.º 16
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var userByEmail = await _userManager.FindByEmailAsync(model.Email);

                if (userByEmail != null)
                {
                    ModelState.AddModelError(Constant.ModelError_Email, ResourceManagement.GetResourceText(Constant.Resource_UserExisted));
                    return(View(model));
                }
                var userByUserName = await _userManager.FindByNameAsync(model.UserName);

                if (userByUserName != null)
                {
                    ModelState.AddModelError(Constant.ModelError_Email, ResourceManagement.GetResourceText(Constant.Resource_UserExisted));
                    return(View(model));
                }
                var user = new ApplicationUser()
                {
                    UserName       = model.UserName,
                    Email          = model.Email,
                    EmailConfirmed = true,
                    Birthday       = DateTime.Now,
                    FullName       = model.FullName,
                    PhoneNumber    = model.PhoneNumber,
                    Address        = model.Address
                };

                await _userManager.CreateAsync(user, model.Password);


                var adminUser = await _userManager.FindByEmailAsync(model.Email);

                if (adminUser != null)
                {
                    await _userManager.AddToRolesAsync(adminUser.Id, new string[] { Constant.Role_User });
                }

                string content = System.IO.File.ReadAllText(Server.MapPath(Constant.Path_NewUserTemplate));
                content = content.Replace("{{UserName}}", adminUser.FullName);
                content = content.Replace("{{Link}}", ConfigHelperUtility.GetByKey(Constant.AppSetting_CurrentLink) + "dang-nhap.html");

                MailHelperUtility.SendMail(adminUser.Email, ResourceManagement.GetResourceText(Constant.Resource_RegisterSuccessfully), content);


                ViewData[Constant.ViewData_SuccessMsg] = ResourceManagement.GetResourceText(Constant.Resource_RegisterSuccessfully);
            }

            return(View());
        }
Ejemplo n.º 17
0
    private void Start()
    {
        resourceManager = ResourceManagement.instance;

        #region Maintain a single instance
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }
        #endregion
    }
Ejemplo n.º 18
0
    public void LoadMonsterData()
    {
        mogwaiData    = new Dictionary <string, Mogwai>();
        mogwaiPrefabs = new Dictionary <string, GameObject>();

        Mogwai[] mogwais = Resources.LoadAll <Mogwai>("ScriptableObjects/Character/Mogwai");
        foreach (Mogwai m in mogwais)
        {
            mogwaiData[m.name] = m;
        }


        mogwaiPrefabs = ResourceManagement.SetUpPrefabDictionary("Prefabs/Character/Mogwai");

        world = gameObject.GetComponent <World>();
    }
Ejemplo n.º 19
0
        private void ProcessIt(string command, int?timeoutMilliseconds)
        {
            using (var ffmpegProcess = new Process())
            {
                ffmpegProcess.StartInfo = new ProcessStartInfo
                {
                    FileName              = ResourceManagement.CommandConfiguration.FFmpegPath,
                    WorkingDirectory      = ResourceManagement.CommandConfiguration.TempPath,
                    Arguments             = command.Trim(),
                    CreateNoWindow        = true,
                    UseShellExecute       = false,
                    RedirectStandardError = true,
                };

                Log.Debug($"ffmpeg.exe MonoRuntime={ResourceManagement.IsMonoRuntime()} Args={ffmpegProcess.StartInfo.Arguments}");

                var stdErrorReader = StandardErrorAsyncStreamReader.AttachReader(ffmpegProcess);

                ffmpegProcess.Start();

                //workaround for a bug in the mono process when attempting to read async from console output events
                //   - link http://mono.1490590.n4.nabble.com/System-Diagnostic-Process-and-event-handlers-td3246096.html
                // we will wait a total of 10 seconds for the process to start, if nothing has happened in that time then we will
                // return a failure for the event.
                ffmpegProcess.WaitForProcessStart();

                stdErrorReader.Listen();

                var processStopped = ffmpegProcess.WaitForProcessStop(timeoutMilliseconds);
                if (!processStopped)
                {
                    throw new FFmpegTimeoutException(ffmpegProcess.StartInfo.Arguments);
                }

                stdErrorReader.Stop();

                StdOut = stdErrorReader.ToString();

                Log.Debug($"ffmpeg.exe MonoRuntime={ResourceManagement.IsMonoRuntime()}  Output={StdOut}.");

                var exitCode = ffmpegProcess.ExitCode;
                if (exitCode != 0)
                {
                    throw new FFmpegProcessingException(exitCode, StdOut);
                }
            }
        }
Ejemplo n.º 20
0
    public ResourceManagement GetClosestResource(Vector3 pos)
    {
        ResourceManagement tmpResource = _lResources[0];
        float dist = int.MaxValue;

        foreach (var resource in _lResources)
        {
            float newDist = Vector3.Distance(pos, resource.transform.position);
            if (newDist < dist && resource._currentLoad > 0)
            {
                dist        = newDist;
                tmpResource = resource;
            }
        }

        return(tmpResource);
    }
        // 初始化程序界面
        private void InitGui()
        {
            _dockmanager1 = new DockingManager(this.panelmain, Crownwood.DotNetMagic.Common.VisualStyle.Office2007Silver);
            _dockmanager1.InnerControl = this.axMapControl1;
            _WorkSpaceCtrl             = new MyMapContext(this);
            _WorkSpaceCtrl.Dock        = DockStyle.Fill;
            _workspaceContent          = _dockmanager1.Contents.Add(this._WorkSpaceCtrl);
            _dockmanager1.AddContentWithState(_workspaceContent, Crownwood.DotNetMagic.Docking.State.DockLeft);

            _dockmanager2 = new DockingManager(this.panelmain, Crownwood.DotNetMagic.Common.VisualStyle.Office2007Silver);
            _dockmanager2.InnerControl = this.axMapControl1;
            _Management        = new ResourceManagement(this);
            _Management.Dock   = DockStyle.Fill;
            _workspaceContent2 = _dockmanager2.Contents.Add(this._Management);
            _dockmanager2.AddContentWithState(_workspaceContent2, Crownwood.DotNetMagic.Docking.State.DockRight);
            IfControlEnabled();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Deletes the folder.
        /// </summary>
        /// <param name="destinationPath">The destination path.</param>
        /// <param name="deleteOnlyIfEmpty">if set to <c>true</c> [delete only if empty].</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        public static bool DeleteFolder(string destinationPath, bool deleteOnlyIfEmpty = false)
        {
            ResourceManagement rm = new ResourceManagement();

            try
            {
                if (rm.GetPathType(destinationPath) == ResourceManagement.ResourceType.Unc &&
                    rm.CheckUncPath(destinationPath, false))
                {
                    if (!rm.ConnectUncPath(Directory.GetParent(destinationPath).FullName))
                    {
                        return(false);
                    }
                }
                if (!Directory.Exists(destinationPath))
                {
                    CDFMonitor.LogOutputHandler("DeleteFolder:destination does not exist:" + destinationPath);
                    return(false);
                }

                if (deleteOnlyIfEmpty &&
                    (Directory.GetFiles(destinationPath).Length != 0 ||
                     Directory.GetDirectories(destinationPath).Length != 0))
                {
                    CDFMonitor.LogOutputHandler("DeleteFolder:destination is not empty:" + destinationPath);
                    return(false);
                }

                CDFMonitor.LogOutputHandler("DeleteFolder: deleting folder:" + destinationPath);
                Directory.Delete(destinationPath, true);
                return(true);
            }
            catch (Exception e)
            {
                CDFMonitor.LogOutputHandler("DeleteFolder:exception:" + e.ToString());
                return(false);
            }
            finally
            {
                if (rm.GetPathType(destinationPath) == ResourceManagement.ResourceType.Unc)
                {
                    rm.DisconnectUncPath(Directory.GetParent(destinationPath).FullName);
                }
            }
        }
Ejemplo n.º 23
0
    private void Start()
    {
        //Maintain Single entity
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        //Init
        inAir            = false;
        controllsEnabled = true;
        rb = GetComponent <Rigidbody2D>();
        resourceManager = ResourceManagement.instance;
    }
 public void Stop()
 {
     _stopped = true;
     _stopSignal.WaitOne(1000);
     if (ResourceManagement.IsMonoRuntime())
     {
         try
         {
             if (MonitoringThread.ThreadState != System.Threading.ThreadState.Stopped)
             {
                 MonitoringThread.Abort();
             }
         }
         catch (Exception e)
         {
             Log.Error("Unable to abort the monitoring thread", e);
         }
     }
 }
Ejemplo n.º 25
0
    // Update is called once per frame
    void Update()
    {
        searchCounter++;
        spawnCounter++;
        if (searchCounter == 1)
        {
            if (this.tag == "FactoryBuildingA")
            {
                Debug.Log("FindingA");
                resourceBuilding = GameObject.FindGameObjectWithTag("rbA");
                resourceInfo     = resourceBuilding.GetComponent <ResourceManagement>();
            }
            if (this.tag == "FactoryBuildingB")
            {
                Debug.Log("FindingB");
                resourceBuilding = GameObject.FindGameObjectWithTag("rbB");
                resourceInfo     = resourceBuilding.GetComponent <ResourceManagement>();
            }
            else
            {
                Debug.Log("Error in names");
            }
        }
        int temp = rnd.Next(0, 2);

        Debug.Log("In units amount: " + resourceInfo.ResourcesGenerated);
        if (spawnCounter % 300 == 0 && resourceInfo.ResourcesGenerated >= 50)
        {
            Debug.Log("Adding Units");
            switch (temp)
            {
            case 0:
                SpawnUnit("Ranged");
                break;

            case 1:
                SpawnUnit("Melee");
                break;
            }
            resourceInfo.ResourcesGenerated -= 25;
        }
    }
Ejemplo n.º 26
0
    public void Save(string filename, GameObject[] objects)
    {
        Debug.Log("Game Saved ");
        FileStream   outFile = new FileStream(filename, FileMode.Create, FileAccess.Write);
        StreamWriter writer  = new StreamWriter(outFile);

        foreach (GameObject obj in objects)
        {
            if (obj.tag == "TeamA" || obj.tag == "TeamB")
            {
                UnitAController unitInfo = obj.GetComponent <UnitAController>();
                writer.WriteLine(unitInfo.Save());
            }
            else if (obj.tag == "Wizard")
            {
                WizardController unitInfo = obj.GetComponent <WizardController>();
                writer.WriteLine(unitInfo.Save());
            }
            else if (obj.tag == "rbA" || obj.tag == "rbB")
            {
                ResourceManagement unitInfo     = obj.GetComponent <ResourceManagement>();
                BuildingInfo       buildingInfo = obj.GetComponent <BuildingInfo>();
                writer.WriteLine(unitInfo.Save() + buildingInfo.Save());
            }
            else if (obj.tag == "FactoryBuildingA" || obj.tag == "FactoryBuildingB")
            {
                BuildingInfo buildingInfo = obj.GetComponent <BuildingInfo>();
                writer.WriteLine(obj.tag + " " + obj.transform.position.x + " " + obj.transform.position.y + " " + obj.transform.position.z + " " + buildingInfo.Save());
            }
            else if (obj.tag == "Building")
            {
                SpawnWizard buildingSpawnInfo = obj.GetComponent <SpawnWizard>();
                writer.WriteLine(obj.tag + " " + buildingSpawnInfo.UnitAmount + " " + obj.transform.position.x + " " + obj.transform.position.y + " " + obj.transform.position.z);
            }
        }
        writer.Close();
        outFile.Close();
    }
Ejemplo n.º 27
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(this);
        }
        else
        {
            Destroy(this);
        }

        sc = gameObject.GetComponent <PlayerSpriteController>();

        maincamera       = FindObjectOfType <Camera>();
        playerAnimator   = GetComponent <Animator>();
        curScene         = SceneManagement.GetCurrentSceneName();
        weaponDictionary = ResourceManagement.SetUpWeaponDictionay("ScriptableObjects/Items/Equipable/Weapon");
        // CheckIfEquippedWeapon();



        switch (curScene)
        {
        case "CharacterCustomization":
            transform.position             = new Vector3(-5f, -1.5f, 0);
            SceneManagement.GameSceneLoad += PlayerBorn;
            break;

        case "GameScene":
            PlayerBorn();
            break;

        default:
            Debug.LogError("No default scene");
            break;
        }
    }
Ejemplo n.º 28
0
        /// <summary>
        /// Renames the file.
        /// </summary>
        /// <param name="oldFileName">Old name of the file.</param>
        /// <param name="newFileName">New name of the file.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        public static bool RenameFile(string oldFileName, string newFileName)
        {
            ResourceManagement rm = new ResourceManagement();

            if (rm.GetPathType(oldFileName) == ResourceManagement.ResourceType.Unc &&
                rm.CheckUncPath(oldFileName, false))
            {
                if (!rm.ConnectUncPath(oldFileName))
                {
                    return(false);
                }
            }
            try
            {
                CDFMonitor.LogOutputHandler(string.Format("RenameFile:file:{0}:{1}", oldFileName, newFileName));
                if (File.Exists(newFileName))
                {
                    File.Delete(newFileName);
                }

                File.Move(oldFileName, newFileName);
                return(true);
            }
            catch
            {
                CDFMonitor.LogOutputHandler(string.Format("RenameFile:exception renaming file:{0}", oldFileName));
                return(false);
            }
            finally
            {
                if (rm.GetPathType(oldFileName) == ResourceManagement.ResourceType.Unc)
                {
                    rm.DisconnectUncPath(oldFileName);
                }
            }
        }
        public static bool AuthenticateUser(Users user, ResourceManagement resourceManager = ResourceManagement.NoAction, string password = null)
        {
            Handlers.ResourceHandler resource = new Handlers.ResourceHandler();

            if (resourceManager == ResourceManagement.NoAction)
            {
                if (resource.GetUser(user.Name).Name == null)
                {
                    Logger.LogError("User Name not available");
                    return(false);
                }
                if (user.Name == resource.GetUser(user.Name).Name&& user.Pwd == password)
                {
                    Logger.LogInfo("Logged In Successfully");
                    return(true);
                }
                return(false);
            }

            Users currentUser = resource.GetUser(Login.CurrentUser);


            return(false);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Checks the path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="create">if set to <c>true</c> [create].</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        public static bool CheckPath(string path, bool create = false)
        {
            CDFMonitor.LogOutputHandler(string.Format("DEBUG:CheckPath: enter:{0}:{1}", path, create));

            try
            {
                if (string.IsNullOrEmpty(path))
                {
                    CDFMonitor.LogOutputHandler("CheckPath: empty path. returning false.");
                    return(false);
                }

                path = FileManager.GetFullPath(path);

                ResourceManagement rm = new ResourceManagement();
                ResourceManagement.ResourceType rt = rm.GetPathType(path);
                if (rm.CheckResourceCredentials(path) != ResourceManagement.CommandResults.Successful)
                {
                    // 131022 if multiple dirs in path do not exist above will fail.
                    if (!create | rm.DeterminePathObj(path) != ResourceManagement.DeterminePathObjType.Directory)
                    {
                        CDFMonitor.LogOutputHandler("CheckPath: checkresourcecredentials failed. returning false.");
                        return(false);
                    }
                }

                if (rt == ResourceManagement.ResourceType.Unc &&
                    rm.CheckUncPath(path, create))
                {
                    CDFMonitor.LogOutputHandler("CheckPath: able to access unc. returning true.");
                    return(true);
                }

                if (rt == ResourceManagement.ResourceType.Url)
                {
                    return(true);
                }

                ResourceManagement.DeterminePathObjType dt = rm.DeterminePathObj(path);

                if (dt == ResourceManagement.DeterminePathObjType.Directory)
                {
                    if (Directory.Exists(path))
                    {
                        return(true);
                    }

                    if (create)
                    {
                        Directory.CreateDirectory(path);
                        // reset creds in case they failed on non-existent dir above
                        if (rm.CheckResourceCredentials(path, true) != ResourceManagement.CommandResults.Successful)
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }

                    CDFMonitor.LogOutputHandler("DEBUG:CheckPath: directory doesnt exist and not configured to create. returning false:" + path);
                    return(false);
                }

                if (dt == ResourceManagement.DeterminePathObjType.File)
                {
                    if (File.Exists(path) | Directory.Exists(Path.GetDirectoryName(path)))
                    {
                        return(true);
                    }

                    if (create)
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(path));
                        return(true);
                    }

                    CDFMonitor.LogOutputHandler("CheckPath: file doesnt exist and directory cannot be created. returning false.");
                    return(false);
                }

                CDFMonitor.LogOutputHandler(string.Format("CheckPath: unknown object:{0}", dt));
                return(false);
            }
            catch (Exception e)
            {
                CDFMonitor.LogOutputHandler("CheckPath: exception:" + e.ToString());
                return(false);
            }
        }