private PunchState() { if (instance != null) { return; } instance = this; }
static void ImportModules(PunchState punchState, Stream moduleStream) { Assembly assembly = Assembly.GetExecutingAssembly(); StreamReader keyReader = new StreamReader(assembly.GetManifestResourceStream("PSPunch.Modules.key.txt")); string key = keyReader.ReadToEnd(); MemoryStream decMem = FileTools.DecryptFile(moduleStream, key); punchState.cmd = Encoding.Unicode.GetString(decMem.ToArray()); Processing.PSExec(punchState); }
static void Main(string[] args) { PunchState punchState = PSInit(); while (true) { punchState.keyInfo = Console.ReadKey(); punchState = Processing.CommandProcessor(punchState); Display.Output(punchState); } }
public static void Output(PunchState punchState) { if (punchState.cmdComplete) { Console.WriteLine("\n" + punchState.output); Prompt(); } int consoleTopPos = Console.CursorTop; Console.SetCursorPosition(prompt.Length, consoleTopPos); Console.Write(new string(' ', Console.WindowWidth)); Console.SetCursorPosition(prompt.Length, consoleTopPos); Console.Write(punchState.displayCmd); }
public virtual void Punch() { Vector2 weaponSize = Weapon.WeaponSize; RectangleF weaponMask = new RectangleF(Human.Position + GetFacingVector(Human.Facing) * 8 + GetFacingVector(Human.Facing) * (weaponSize.X / 2) + new Vector2(0, 1) - weaponSize / 2f, weaponSize); Human.SwingWeapon(weaponMask, Weapon.Damage); PunchVisual(); PunchAction = PunchState.PunchEnd; //new RectangleDebug(Human.World, weaponMask, Color.Red, 10); }
internal override void Awake() { base.Awake(); var playerAnimator = GetComponent <Animator>(); var playerRigidBody = GetComponent <Rigidbody>(); var playerCollider = GetComponent <Collider>(); Punch = new PunchState(playerAnimator, actorAnimations.ActorAttacking, DonePunching); Idle = new IdleState(playerAnimator, actorAnimations.ActorIdle); Grounded = new GroundedState(); Jump = new JumpState(playerCollider, playerRigidBody, JumpSpeed, EvalJumpData); DiveKick = new DiveKickState(playerRigidBody, 20f, ActorLookingRight); Knockback = new KnockbackState(playerCollider, 5f, ActorLookingRight, EvalKnockbackResult); actionState.ChangeState(Idle); movementState.ChangeState(Grounded); }
void punchStates() { switch (punchState) { case PunchState.Ready: punchState = PunchState.Punching; Instantiate(bullet, spawnPoint.position, spawnPoint.rotation); Instantiate(bullet, spawnPoint.position, spawnPoint.rotation); Instantiate(bullet, spawnPoint.position, spawnPoint.rotation); // SoundManagerScript.PlaySound("Wally_Dash"); Debug.Log("I am punching"); break; case PunchState.Punching: punchTimer += Time.deltaTime * 3; Debug.Log("I punched"); if (punchTimer >= maxDash1) { punchTimer = maxDash1; punchState = PunchState.Cooldown; } break; case PunchState.Cooldown: Debug.Log("Iam waiting to punch"); punchTimer -= Time.deltaTime; if (punchTimer <= 0) { punchTimer = 0; punchState = PunchState.Ready; } break; } }
void punchStates() { switch (punchState) { case PunchState.Ready: punchState = PunchState.Punching; // SoundManagerScript.PlaySound("Wally_Dash"); StartCoroutine(DoAttack()); Debug.Log("I am punching"); break; case PunchState.Punching: punchTimer += Time.deltaTime * 3; Debug.Log("I punched"); if (punchTimer >= maxDash) { punchTimer = maxDash; punchState = PunchState.Cooldown; } break; case PunchState.Cooldown: Debug.Log("Iam waiting to punch"); punchTimer -= Time.deltaTime; if (punchTimer <= 0) { punchTimer = 0; punchState = PunchState.Ready; } break; } }
public async void Initialize() { _unitOfWork.ApplicationDataContext.Database.EnsureCreated(); // Look for any users. if (_unitOfWork.ApplicationDataContext.AppUsers.Any()) { return; // DB has been seeded } var userDict = new Dictionary <int, AppUser>(); var dayDict = new Dictionary <int, DayPunch>(); var weekDict = new Dictionary <int, WeekPunch>(); var monthDict = new Dictionary <int, MonthPunch>(); var yearDict = new Dictionary <int, YearPunch>(); var stateDict = new Dictionary <StatusAdminDtoStatus, PunchState>(); await _appUserManager.CreateRole(JwtClaims.ApiAccess); await _appUserManager.CreateRole(JwtClaims.ApiAccessPower); await _appUserManager.CreateRole(JwtClaims.ApiAccessAdmin); // Create PunchStates foreach (var val in Enum.GetValues(typeof(StatusAdminDtoStatus))) { string name = Enum.GetName(typeof(StatusAdminDtoStatus), val); var punchState = new PunchState { State = name }; stateDict.Add((StatusAdminDtoStatus)val, punchState); _unitOfWork.PunchStates.Add(punchState); } // create some users var users = new[] { new Controllers.RegisterDto { Firstname = "Hans", Name = "Tschan", Email = "*****@*****.**", Username = "******" }, new Controllers.RegisterDto { Firstname = "Hanspeter", Name = "Gysin", Email = "*****@*****.**", Username = "******" }, new Controllers.RegisterDto { Firstname = "Matthias", Name = "Höhner", Email = "*****@*****.**", Username = "******" }, new Controllers.RegisterDto { Firstname = "Alexander", Name = "Hilty", Email = "*****@*****.**", Username = "******" }, new Controllers.RegisterDto { Firstname = "Angelo", Name = "Spatharis", Email = "*****@*****.**", Username = "******" }, }; for (var i = 0; i < users.Length; i++) { var userIdentity = _mapper.Map <AppUser>(users[i]); await _appUserManager.CreateUser(userIdentity, "axil311", new List <string> { JwtClaims.ApiAccess }); userDict.Add(i, userIdentity); } var powerUser = new Controllers.RegisterDto { Firstname = "Power", Name = "Timepuncher", Email = "*****@*****.**" }; var powerUserIdentity = _mapper.Map <AppUser>(powerUser); await _appUserManager.CreateUser(powerUserIdentity, "axil311", new List <string> { JwtClaims.ApiAccess, JwtClaims.ApiAccessPower }); var adminUser = new Controllers.RegisterDto { Firstname = "Admin", Name = "Timepuncher", Email = "*****@*****.**" }; var adminUserIdentity = _mapper.Map <AppUser>(adminUser); await _appUserManager.CreateUser(adminUserIdentity, "axil311", new List <string> { JwtClaims.ApiAccessAdmin }); // create the punch dimensions for (var i = 1; i < 32; i++) { var d = new DayPunch { Day = i }; dayDict.Add(i, d); _unitOfWork.DayPunches.Add(d); } for (var i = 1; i < 54; i++) { var w = new WeekPunch { Week = i }; weekDict.Add(i, w); _unitOfWork.WeekPunches.Add(w); } for (var i = 1; i < 13; i++) { var m = new MonthPunch { Month = i }; monthDict.Add(i, m); _unitOfWork.MonthPunches.Add(m); } for (var i = START_YEAR; i < 2035; i++) { var y = new YearPunch { Year = i }; yearDict.Add(i, y); _unitOfWork.YearPunches.Add(y); } // create some punches for every user for (var date = new DateTime(START_YEAR, 1, 1); date <= DateTime.Now - TimeSpan.FromDays(1); date += TimeSpan.FromDays(1)) { if (date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday) { continue; } var dateTimePrev = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0); for (var p = 1; p < 6; p++) // day punches { if (p > 4) // todo: excess punches { continue; } foreach (var u in userDict) { var timeInfo = GetPunchTime(dateTimePrev, date.Year, date.Month, date.Day, p); var punch = new Punch { Created = DateTime.Now, Updated = DateTime.MinValue, PunchTime = timeInfo.dt, TimeDec = timeInfo.dtDec, Direction = timeInfo.direction, DayPunch = dayDict[timeInfo.dt.Day], WeekPunch = weekDict[_timeService.GetWeekNumber(timeInfo.dt)], MonthPunch = monthDict[timeInfo.dt.Month], YearPunch = yearDict[timeInfo.dt.Year], User = u.Value }; dateTimePrev = timeInfo.dt; _unitOfWork.Punches.Add(punch); } } } _unitOfWork.Complete(); }
static PunchState PSInit() { //Display Loading Message Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(@" ___ _____ ___ _ _ | _ \/ _ \ \| _ \_ _ _ _ __| |_ | | | _/\__ \> > _/ || | ' \/ _| ' \|_| |_| |___/_/|_| \_,_|_||_\__|_||_(_) "); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("PS>Punch is loading..."); //Setup PS Host and runspace PunchState punchState = new PunchState(); punchState.host = new PSPunchHost(); Runspace runspace = RunspaceFactory.CreateRunspace(punchState.host); runspace.Open(); punchState.runspace = runspace; //Decrypt modules Assembly assembly = Assembly.GetExecutingAssembly(); string[] resources = assembly.GetManifestResourceNames(); foreach (string resource in resources) { if (resource.Contains(".enc")) { Console.WriteLine("Decrypting: " + resource.ToString()); Stream moduleStream = assembly.GetManifestResourceStream(resource); ImportModules(punchState, moduleStream); } } //Setup PS env punchState.cmd = "set-executionpolicy bypass -Scope process -Force"; Processing.PSExec(punchState); punchState.cmd = "function Test-Admin { $wid = [System.Security.Principal.WindowsIdentity]::GetCurrent(); $prp = New-Object System.Security.Principal.WindowsPrincipal($wid); $adm = [System.Security.Principal.WindowsBuiltInRole]::Administrator; $prp.IsInRole($adm);}; write-host 'Is Admin: '(test-admin)"; punchState = Processing.PSExec(punchState); //Setup Console Console.BackgroundColor = ConsoleColor.DarkBlue; Console.Clear(); // Display alpha warning Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(@" ############################################################ # # # PLEASE NOTE: This is an alpha release of PS>Punch. # # There are plenty of bugs and not a lot of functionality. # # # # For more info view the release notes at # # https://www.github.com/jaredhaight/pspunch/releases # # # ############################################################ "); // Display Version and build date: Console.ForegroundColor = ConsoleColor.DarkYellow; string version = typeof(Program).Assembly.GetName().Version.ToString(); string buildDate = new StreamReader(assembly.GetManifestResourceStream("PSPunch.Resources.BuildDate.txt")).ReadToEnd(); Console.WriteLine("Welcome to PS>Punch! This is version {0}. \nIt was built on {1}", version, buildDate); // Display Prompt punchState.loopPos = 0; punchState.cmdComplete = false; Display.Prompt(); return(punchState); }
public override void ParryReceive(IParryGiver giver) { PunchVisual(); PunchAction = PunchState.PunchEnd; }