void attack() { // 攻击 nowAttackTime += Time.deltaTime; if (nowAttackTime < Manager.attackTime) { return; } if (Input.GetKey(KeyCode.Space)) { nowAttackTime = 0; p.attack(); BasicPerson.sendMsg(gameObject); } }
public void PeopleEnum_Test() { BasicPerson[] peopleArray = new BasicPerson[3] { new BasicPerson("John", "Smith"), new BasicPerson("Jim", "Johnson"), new BasicPerson("Sue", "Rabon"), }; People peopleList = new People(peopleArray); foreach (BasicPerson p in peopleList) { Assert.AreNotEqual(p.FirstName + " " + p.LastName, ""); } }
protected void GridMemberships_RowCommand(object sender, GridViewCommandEventArgs e) { // TODO: Re-authorize? int index = Convert.ToInt32(e.CommandArgument); int viewingPersonId = Convert.ToInt32(HttpContext.Current.User.Identity.Name); int membershipId = Convert.ToInt32(this.gridMemberships.DataKeys[index].Value); Membership membership = Membership.FromIdentity(membershipId); BasicPerson person = Person.FromIdentity(membership.PersonId); switch (e.CommandName) { case "Extend": membership.Expires = membership.Expires.AddYears(1); PWLog.Write(Person.FromIdentity(viewingPersonId), PWLogItem.Person, person.Identity, PWLogAction.MembershipRenewed, "Membership in " + Organization.FromIdentity(membership.OrganizationId).NameShort + " extended manually.", "Membership was extended by " + Person.FromIdentity(viewingPersonId).Name + " (#" + viewingPersonId.ToString() + ") to last until " + membership.Expires.AddYears(1).ToString("yyyy-MMM-dd") + "."); Activizr.Logic.Support.PWEvents.CreateEvent(EventSource.PirateWeb, EventType.ExtendedMembership, viewingPersonId, membership.OrganizationId, person.GeographyId, membership.PersonId, membershipId, string.Empty); ReadMembershipList(); break; case "Terminate": Membership.FromIdentity(membershipId).Terminate(EventSource.PirateWeb, Person.FromIdentity(viewingPersonId), "Membership in " + Organization.FromIdentity(membership.OrganizationId).NameShort + " removed manually."); ReadMembershipList(); PopulateOrganizations(); CheckStillVisible(); break; default: throw new InvalidOperationException("Not supported: Command \"" + e.CommandName + "\""); } gridMemberships.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { Response.Expires = -1; bool localCall = false; string[] local = (Request.ServerVariables["LOCAL_ADDR"]).Split(new char[] { '.' }); string remoteaddr = (Request.ServerVariables["REMOTE_ADDR"]); string[] remote = remoteaddr.Split(new char[] { '.' }); if (local[0] == remote[0] && local[1] == remote[1]) { localCall = true; } redirectURL = Request["redirect"] != null ? Request["redirect"].ToString() : ""; redirectURLParams = ""; foreach (string s in Request.Form.Keys) { if (s != "redirect" && s != "username" && s != "password") { redirectURLParams += "&" + s + "=" + Server.UrlEncode(Request.Form[s]); } } string loginToken = Request["username"] != null ? Request["username"].ToString() : ""; string password = Request["password"] != null ? Request["password"].ToString() : ""; lock (lockObject) { if ((localCall == false) && lastcallers.ContainsKey(remoteaddr) && lastcallers[remoteaddr] > DateTime.Now) { lastcallers[remoteaddr] = DateTime.Now.AddSeconds(10); DoFail("4", "EPIC FAIL"); } else { lastcallers[remoteaddr] = DateTime.Now.AddSeconds(4); if (!string.IsNullOrEmpty(loginToken.Trim()) && !string.IsNullOrEmpty(password.Trim())) { try { BasicPerson authenticatedPerson = PirateWeb.Logic.Security.Authentication.Authenticate(loginToken, password); if (authenticatedPerson == null) { throw new Exception("Wrong UserId/Password"); } string ticket = Convert.ToBase64String(new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(Guid.NewGuid().ToByteArray())); Regex re = new Regex(@"[^a-z0-9]", RegexOptions.IgnoreCase); ticket = re.Replace(ticket, ""); InternalLoginTicket ticketObj = new InternalLoginTicket(); ticketObj.created = DateTime.Now; ticketObj.validatedUserID = authenticatedPerson.Identity; Dictionary <string, InternalLoginTicket> openTickets = new Dictionary <string, InternalLoginTicket>(); Application.Lock(); if (Application["SubSystem_LoginTickets"] != null) { openTickets = (Dictionary <string, InternalLoginTicket>)Application["SubSystem_LoginTickets"]; List <string> toremove = new List <string>(); foreach (string key in openTickets.Keys) { if (openTickets[key].created.AddMinutes(2) < DateTime.Now) { toremove.Add(key); } } foreach (string key in toremove) { openTickets.Remove(key); } } openTickets.Add(ticket, ticketObj); Application["SubSystem_LoginTickets"] = openTickets; Application.UnLock(); Response.Redirect(redirectURL + "?result=success&ticket=" + Server.UrlEncode(ticket.ToString()) + redirectURLParams, false); } catch (Exception exc) { DoFail("1", exc.Message); } } else { DoFail("2", "Invalid Parameter"); } } if (lastcallers.Count > 10) { string[] keys = (new List <string>(lastcallers.Keys)).ToArray(); foreach (string key in keys) { if (lastcallers[key] < DateTime.Now.AddMinutes(-5)) { lastcallers.Remove(key); } } } } Session.Abandon(); }
public ListPerson(BasicPerson b) : base(b) { }
internal static Person FromBasic(BasicPerson basic) { return(new Person(basic)); }
private static void MatchPerson(Dictionary <int, BasicPerson> result, Person p, BasicPerson sameperson) { int matches = 0; if (p.Name.Trim().ToLower() == sameperson.Name.Trim().ToLower()) { ++matches; } if (p.Phone.Trim() == sameperson.Phone.Trim()) { ++matches; } if (p.Mail.Trim().ToLower() == sameperson.Email.Trim().ToLower()) { ++matches; } if (matches > 1) { if (!result.ContainsKey(p.PersonId)) { result.Add(p.PersonId, p); } if (!result.ContainsKey(sameperson.PersonId)) { result.Add(sameperson.PersonId, sameperson); } } }