public async Task <ActionResult> Index(string categoryAlias = "", string alias = "", bool isPost = false, FormCollection form = null) { try { Log.Verbose($"Prepping \"{this.CurrentPageUrl}\"."); var model = this.GetContents(categoryAlias, alias, isPost, form); if (model == null) { Log.Error($"Could not serve the url \"{this.CurrentPageUrl}\" because the model was null."); return(this.View(GetLayoutPath() + "404.cshtml")); } Log.Verbose($"Parsing custom content extensions for \"{this.CurrentPageUrl}\"."); model.Contents = ContentExtensions.ParseHtml(this.Tenant, model.Contents); Log.Verbose($"Parsing custom form extensions for \"{this.CurrentPageUrl}\"."); model.Contents = await FormsExtension.ParseHtml(model.Contents, isPost, form); model.Contents = HitHelper.Add(model.Contents); return(this.View(this.GetRazorView <AreaRegistration>("Index/Index.cshtml"), model)); } catch (NpgsqlException ex) { Log.Error( "An exception was encountered while trying to get content. More info:\nCategory alias: {categoryAlias}, alias: {alias}, is post: {isPost}, form: {form}. Exception\n{ex}.", categoryAlias, alias, isPost, form, ex); return(new HttpNotFoundResult()); } }
// Use this for initialization void Start() { _hitHelper = new HitHelper(); keywords.Add("Restart game", () => { SceneManager.LoadScene(0); // Call the OnReset method on every descendant object. //this.BroadcastMessage("OnReset"); }); keywords.Add("Pause game", () => { Time.timeScale = 0.01f; }); keywords.Add("Resume game", () => { Time.timeScale = 1.0f; }); // for placing towers keywords.Add("Tower", PlaceTower); keywords.Add("Build", PlaceTower); keywords.Add("Place", PlaceTower); keywords.Add("Destroy", DestroyTower); keywords.Add("Upgrade", UpgradeTower); keywords.Add("Menue", OpenMenue); keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray()); keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized; keywordRecognizer.Start(); }
public void GetHitStep3() { var correction = 1; correction = HitHelper.GetHitStep3(correction); Assert.AreEqual(HitHelper.GetHitStep3CorrectionMin, correction); correction = 100; correction = HitHelper.GetHitStep3(correction); Assert.AreEqual(HitHelper.GetHitStep3CorrectionMax, correction); }
public void GetHitStep4() { var correction = 1; var lowLimitChance = 100; Assert.IsFalse(HitHelper.GetHitStep4(lowLimitChance, correction)); correction = 100; lowLimitChance = 1; Assert.IsTrue(HitHelper.GetHitStep4(lowLimitChance, correction)); }
public void GetHitStep1() { var attackerLevel = 1; var defenderLevel = 1 + Math.Abs(HitHelper.GetHitStep1LevelDiffMin); Assert.AreEqual(HitHelper.GetHitStep1CorrectionMin, HitHelper.GetHitStep1(attackerLevel, defenderLevel)); attackerLevel = 1 + Math.Abs(HitHelper.GetHitStep1LevelDiffMax); defenderLevel = 1; Assert.AreEqual(HitHelper.GetHitStep1CorrectionMax, HitHelper.GetHitStep1(attackerLevel, defenderLevel)); }
/// <summary> /// Implements the CompareTo method of the IComparable interface. /// Allows an easy sort by the document rating /// </summary> /// <param name="obj">object to compare</param> /// <returns>0 ... equal, -1 ... this instance is less than obj, 1 ... this instance is greater than obj</returns> public int CompareTo(object obj) { if (obj is HitHelper) { HitHelper hObj = (HitHelper)obj; return(this.Rating.CompareTo(hObj.Rating)); } return(-1); }
/// <summary> /// Eliminates all search hits where not all of the words have been found /// </summary> /// <param name="hit">hithelper instance to check</param> /// <param name="wordsInPhrase">word list</param> private bool CheckHit(HitHelper hit, string[] wordsInPhrase) { for (int i = 0; i < wordsInPhrase.Length; i++) { if ((hit.PartialRating[wordsInPhrase[i]] == null) || (((double)(hit.PartialRating[wordsInPhrase[i]])) == 0.0)) { return(false); } } return(true); }
public void GetHitStep2() { var attackerHit = 1; var defenderHit = 100; var correction = HitHelper.GetHitStep2(attackerHit, defenderHit); Assert.AreEqual(HitHelper.GetHitStep2AdditionalCorrectionMin, correction); attackerHit = 100; defenderHit = 1; correction = HitHelper.GetHitStep2(attackerHit, defenderHit); Assert.AreEqual(HitHelper.GetHitStep2AdditionalCorrectionMax, correction); }
public Village(Players owner, Vector2 pos, float rot, int gridSize) : base(ModelManager.GetInstance().Village, UnitTypes.Village, owner, pos, rot, gridSize, GetBlockedFields(), GetPassableFields()) { MaxHealth = (int)BaseStats.sUnitStats[UnitType][StatNames.Health]; mHitHelper = new HitHelper(this, MaxHealth); }
public Gate(Players owner, Vector2 pos, float rot, int gridSize) : base(null, UnitTypes.Gate, owner, pos, rot, gridSize, GetBlockedFields(), GetPassableFields()) { IsOpen = true; MaxHealth = (int)BaseStats.sUnitStats[UnitType][StatNames.Health]; mHitHelper = new HitHelper(this, MaxHealth); }
public void IsHit() { var attackerLevel = 1; var attackerHit = 100; var defenderLevel = 1; var defenderHit = 100; var chance = 100; var correction = HitHelper.GetHitStep1(attackerLevel, defenderLevel); correction += HitHelper.GetHitStep2(attackerHit, defenderHit); correction = HitHelper.GetHitStep3(correction); var hit = HitHelper.GetHitStep4(chance, correction); Assert.AreEqual(hit, HitHelper.IsHit(attackerLevel, attackerHit, defenderLevel, defenderHit, chance)); }
private void Start() { hitHelper = GameObject.FindObjectOfType <HitHelper>(); monsterHelper = GameObject.FindObjectOfType <MonsterHelper>(); playerHelper = GameObject.FindObjectOfType <PlayerHelper>(); gameHelper = GameObject.FindObjectOfType <GameHelper>(); monsterBarHelper = GameObject.FindObjectOfType <MonsterBarHelper>(); foreach (Skill skill in skills) { skill.currentCoolDown = skill.coolDown; } PlayerPrefs.SetInt("HPBottle", byttlePlayerHp); PlayerPrefs.SetInt("EnergyBottle", byttlePlayerEnergy); }
void Update() { if (hitHelper == null) { hitHelper = GameObject.FindObjectOfType <HitHelper>(); } else { transform.position = Vector2.MoveTowards(transform.position, hitHelper.transform.position, Time.deltaTime * 100); if (Vector2.Distance(transform.position, hitHelper.transform.position) < 0.1f) { //Popal hitHelper.GetHitPlayer(); Destroy(gameObject); } } }
protected void HitCheck() { if (GetItemBase() == null) { return; } excludeIds[0] = GetItemBase().GetItemInfo().m_HavenUser; excludeIds[1] = m_weaponId; List <Collider> hits = HitHelper.HitTestProjectile(m_collider, m_prePos, m_vDir, WeaponInfo.fProjectileSpeed * Time.deltaTime, false, false, excludeIds); if (hits != null && hits.Count > 0) { OnTriggerEnter(hits[0]); } Debug.DrawLine(m_prePos, transform.position, Color.blue); m_prePos = transform.position; }
public Wall(Players owner, Vector2 pos, float rot, int gridSize) : base(ModelManager.GetInstance().Wall, UnitTypes.Wall, owner, pos, rot, gridSize) { MaxHealth = (int)BaseStats.sUnitStats[UnitType][StatNames.Health]; mHitHelper = new HitHelper(this, MaxHealth); }
/// <summary> /// Decodes the s/r encoded WordCodeList (=wcl) and creates hit entries /// </summary> /// <param name="wclBytes">wcl encoded byte array</param> /// <param name="MaxHits">maximal hits</param> /// <param name="word">the word to find</param> private void DecodeWCL(byte[] wclBytes, int MaxHits, string word) { byte[] wclBits = new byte[wclBytes.Length * 8]; int nBitIdx = 0; for (int i = 0; i < wclBytes.Length; i++) { for (int j = 0; j < 8; j++) { wclBits[nBitIdx] = ((byte)(wclBytes[i] & ((byte)((byte)0x1 << (7 - j))))) > (byte)0 ? (byte)1 : (byte)0; nBitIdx++; } } nBitIdx = 0; int nDocIdx = 0; // delta encoded while (nBitIdx < wclBits.Length) { nDocIdx += BinaryReaderHelp.ReadSRItem(wclBits, _header.ScaleDocumentIndex, _header.RootDocumentIndex, ref nBitIdx); int nCodeCnt = BinaryReaderHelp.ReadSRItem(wclBits, _header.ScaleCodeCount, _header.RootCodeCount, ref nBitIdx); int nWordLocation = 0; // delta encoded for (int locidx = 0; locidx < nCodeCnt; locidx++) { nWordLocation += BinaryReaderHelp.ReadSRItem(wclBits, _header.ScaleLocationCodes, _header.RootLocationCodes, ref nBitIdx); } // apply padding while ((nBitIdx % 8) != 0) { nBitIdx++; } // Record hit HitHelper hitObj = DocumentHit(nDocIdx); if (hitObj == null) { if (_hitsHelper.Count > MaxHits) { return; } hitObj = new HitHelper(nDocIdx, ((TopicEntry)(_associatedFile.TopicsFile.TopicTable[nDocIdx])).Title, ((TopicEntry)(_associatedFile.TopicsFile.TopicTable[nDocIdx])).Locale, _associatedFile.CompileFile, ((TopicEntry)(_associatedFile.TopicsFile.TopicTable[nDocIdx])).URL, 0.0); for (int k = 0; k < nCodeCnt; k++) { hitObj.UpdateRating(word); } _hitsHelper.Add(hitObj); } else { for (int k = 0; k < nCodeCnt; k++) { hitObj.UpdateRating(word); } } } }
/// <summary> /// Performs a fulltext search of a single file. /// </summary> /// <param name="search">word(s) or phrase to search</param> /// <param name="MaxHits">max hits. If this number is reached, the search will be interrupted</param> /// <param name="partialMatches">true if partial word should be matched also /// ( if this is true a search of 'support' will match 'supports', otherwise not )</param> /// <param name="titleOnly">true if only search in titles</param> /// <remarks>Hits are available through the <see cref="Hits">Hists property</see>.</remarks> public bool Search(string search, int MaxHits, bool partialMatches, bool titleOnly) { if (CanSearch) { string searchString = search; // Check if this is a quoted string bool IsQuoted = (search.IndexOf("\"") > -1); if (IsQuoted) { searchString = search.Replace("\"", ""); // remove the quotes during search } bool bRet = true; _hitsHelper = null; _hitsHelper = new List <HitHelper>(); _hits = null; CreateHitsTable(); string[] words = searchString.Split(new char[] { ' ' }); for (int i = 0; i < words.Length; i++) { bRet &= SearchSingleWord(words[i], MaxHits, partialMatches, titleOnly); if (_hitsHelper.Count >= MaxHits) { break; } } if (bRet && IsQuoted) { FinalizeQuoted(search); } if (bRet) { _hitsHelper.Sort(); int nhCount = MaxHits; if (MaxHits < 0) { nhCount = _hitsHelper.Count; } if (nhCount > _hitsHelper.Count) { nhCount = _hitsHelper.Count; } // create hits datatable for (int i = nhCount; i > 0; i--) { HitHelper curHlp = _hitsHelper[i - 1]; DataRow newRow = _hits.NewRow(); newRow["Rating"] = curHlp.Rating; newRow["Title"] = curHlp.Title; newRow["Locale"] = curHlp.Locale; newRow["Location"] = curHlp.Location; newRow["URL"] = curHlp.URL; _hits.Rows.Add(newRow); } } return(bRet); } return(false); }
// Use this for initialization void Start() { // Grab the mesh renderer that's on the same object as this script. meshRenderer = this.gameObject.GetComponentInChildren <MeshRenderer>(); hitHelper = new HitHelper(); }
// Use this for initialization void Start() { hitHelper = new HitHelper(); }