public void Death(CharacterType type, Vector3 position, bool isReceivedData = false) { switch (type) { case CharacterType.Enemy: if (Enemy.GetInstance().hp > 60) { break; } Enemy.GetInstance().transform.position = position; Enemy.GetInstance().hp = 100; Enemy.GetInstance().hpText.text = Enemy.GetInstance().hp + ""; Enemy.GetInstance().hpBar.fillAmount = ((float)Enemy.GetInstance().hp) / 100f; ++kill; break; case CharacterType.Local: if (LocalCharacter.GetInstance().hp > 60) { break; } LocalCharacter.GetInstance().transform.position = position; LocalCharacter.GetInstance().hp = 100; LocalCharacter.GetInstance().hpText.text = LocalCharacter.GetInstance().hp + ""; LocalCharacter.GetInstance().hpBar.fillAmount = ((float)LocalCharacter.GetInstance().hp) / 100f; ++death; break; } GameObject.Find("KillDeathText").GetComponent <UnityEngine.UI.Text>().text = kill + "킬 " + death + "데스"; if (!isReceivedData) { ClientNetworkManager.GetInstance().SendDeath(type, position); } }
public static LocalCharacter GetInstance() { if (!instance) { instance = GameObject.FindObjectOfType <LocalCharacter>(); if (!instance) { Debug.LogError("There needs to be one active LocalCharacter script on a GameObject in your scene."); } } return(instance); }
private void sendPlayerCommand() { if (thisPlayerId != NO_ID && players.ContainsKey(thisPlayerId)) { Player localPlayer = players[thisPlayerId]; LocalCharacter character = (LocalCharacter)localPlayer.character; float delta = Time.deltaTime; List <EPlayerAction> actions = actionManager.getActions().ToList(); EDirection direction = character.direction; System.Numerics.Vector2 characterPosition = new System.Numerics.Vector2(character.transform.position.x, character.transform.position.y); PlayerCommand cmdData = new PlayerCommand(thisPlayerId, turnNumber, delta, characterPosition, direction, actions); ConnectionManager.GetInstance().sendPlayerCommand(cmdData); } }
private void OnCollisionEnter(Collision collision) { float distance = Vector3.Distance(LocalCharacter.GetInstance().gameObject.transform.position, transform.position); if (distance <= 2f && !onlyEffect) { GameMain.GetInstance().Attack(CharacterType.Local, (int)((4f - (distance + 2f)) * 40f)); } distance = Vector3.Distance(Enemy.GetInstance().gameObject.transform.position, transform.position); if (distance <= 2f && !onlyEffect) { GameMain.GetInstance().Attack(CharacterType.Enemy, (int)((4f - (distance + 2f)) * 40f)); } Instantiate(particle, transform.position, transform.rotation); Destroy(gameObject); }
public void onTouch(LocalCharacter tChar) { if (!TurnedToIce) { if (T == BlockID.Water) { if (tChar.TouchingGround == false && tChar.Mode != "freeze" && tChar.Mode != "hurt") { tChar.SetMode("water"); tChar.WaterTimer = 2; } else { tChar.TargetVel = tChar.TargetVel * 0.9; tChar.Traction = 0.1; } tChar.SafeSegX = X; tChar.SafeSegY = Y; tChar.SafeX = X * 30 + 15; tChar.SafeY = Y * 30 + 15; } else if (T == BlockID.Mine && FadeTime == 0) { HitChar(tChar); course.DeleteBlock(X, Y); } else if (T == BlockID.Net) { //if (tChar.SafeSegX != X || Y > tChar.SafeSegY || Y + 2 < tChar.SafeSegY) if (tChar.SafeSegX != X || tChar.SafeSegY < Y || tChar.SafeSegY > Y + 2) { tChar.Reappear(); } } } // Vanish blocks that are re-appearing should not fully re-appear while tChar are inside them TODO: (see Block.Vanish) if (T == BlockID.Vanish && Fade == INACTIVE && Y * 30 > tChar.Y - 60) { if (FadeTime > 0 && FadeTime < 10) { FadeTime += 1; } } }
// Update is called once per frame void Update() { timer += Time.deltaTime; if (timer >= LIMIT_TIME) { float distance = Vector3.Distance(LocalCharacter.GetInstance().gameObject.transform.position, transform.position); if (distance <= 4f && !onlyEffect) { GameMain.GetInstance().Attack(CharacterType.Local, (int)((8f - (distance + 4f)) * 20f)); } distance = Vector3.Distance(Enemy.GetInstance().gameObject.transform.position, transform.position); if (distance <= 4f && !onlyEffect) { GameMain.GetInstance().Attack(CharacterType.Enemy, (int)((8f - (distance + 4f)) * 20f)); } Instantiate(particle, transform.position, transform.rotation); Destroy(gameObject); } }
public void Attack(CharacterType type, int damage, bool isReceivedData = false) { bool onRepawn = false; switch (type) { case CharacterType.Enemy: onRepawn = Enemy.GetInstance().GetDamage(damage); break; case CharacterType.Local: onRepawn = LocalCharacter.GetInstance().GetDamage(damage); break; } if (!isReceivedData && !onRepawn) { ClientNetworkManager.GetInstance().SendAttack(type, damage); } }
// Bombs private void HitChar(LocalCharacter tChar) { double TestX = tChar.X; double TestY = tChar.Y; double _loc_3 = TestX - ((X * 30.0) + 15.0); double _loc_4 = TestY - (LocalCharacter.spaceY / 2.0) - ((Y * 30.0) + 15.0); double _loc_5 = Math.Atan2(_loc_4, _loc_3); double _loc_6 = Math.Cos(_loc_5) * 50.0; double _loc_7 = Math.Sin(_loc_5) * 50.0; tChar.GetHit(_loc_6, _loc_7); //System.Diagnostics.Debug.Print(_loc_3.ToString("R")); //System.Diagnostics.Debug.Print(_loc_4.ToString("R")); //System.Diagnostics.Debug.Print(_loc_5.ToString("R")); //System.Diagnostics.Debug.Print(_loc_6.ToString("R")); //System.Diagnostics.Debug.Print(_loc_7.ToString("R")); General.PlaySound(General.sound_path + "sound 962 (ExplosionSound).wav"); }
private void DangerzoneChanged(object sender, RoutedEventArgs e) { LocalCharacter selected = (LocalCharacter)CharactersList.SelectedItem; if (selected == null) { return; } var lc = EVEManager.LocalCharacters.FirstOrDefault(x => x.Name == selected.Name); if (lc == null) { return; } var idx = EVEManager.LocalCharacters.IndexOf(lc); CheckBox cb = (CheckBox)((DataGridCell)sender).Content; lc.DangerzoneActive = (bool)cb.IsChecked; lc.warningSystemsNeedsUpdate = true; EVEManager.LocalCharacters[idx] = lc; }
public bool OnScreen(LocalCharacter tChar) { // Rotation int YX = (int)tChar.X; int YY = (int)tChar.Y; int Temp = YX; if (tChar.RotateFrom == 90) { YX = YY; YY = -Temp; } else if (tChar.RotateFrom == 180 || tChar.RotateFrom == -180) { YX = -YX; YY = -YY; } else if (tChar.RotateFrom == -90) { YX = -YY; YY = Temp; } // What area of the screen is "on screen"? int MnX = YX - 300; int MnY = YY - 285; // approximation int MxX = YX + 301; int MxY = YY + 166; // If checking each of four directions if (X * 30 < MnX || X * 30 > MxX) { return(false); } if (Y * 30 < MnY || Y * 30 > MxY) { return(false); } // If none, return(true); }
public bool IsSolid(LocalCharacter c = null) { if (T != BlockID.Net && T != BlockID.Water && T != BlockID.Egg && T != 99 && (T < BlockID.P1 || T > BlockID.P4)) { // If it's vanish and faded away, or player has Top Hat, false if (T == BlockID.Vanish && (Fade == INACTIVE || (c != null && c.TopHat))) { return(false); } // Mines that aren't fully placed aren't solid if (T == BlockID.Mine && FadeTime != 0) { return(false); } return(true); } else { return(TurnedToIce); } }
// Touch block public void onStand(LocalCharacter tChar) { int BlocX = X * 30; int BlocY = Y * 30; // Rotate block coordinates (to determine where to place character) General.RotatePoint(ref BlocX, ref BlocY, tChar.Rotation); if (tChar.RotateFrom == -90 || tChar.RotateFrom == 180) { BlocY -= 30; } // Santa Freeze Can't freeze starts if ((!WasIced && tChar.SantaHat && !(T >= 11 && T <= 14))) { this.Freeze(); } if (T == BlockID.Ice || TurnedToIce) { tChar.Traction = 0.05; } else if (T == BlockID.Crumble) { int _loc_8 = (int)Math.Floor(tChar.velY * 2 + 0.5); _loc_8 = (int)Math.Floor((double)_loc_8 / 4); Health -= _loc_8; if (Health <= 0) { T = 99; course.DeleteBlock(X, Y); return; } } tChar.Y = BlocY + BumpY; tChar.velY = 0; tChar.TouchingGround = true; if (Safe) // TODO: Make this code nicer. { int SX = 15; int SY = 0; if (tChar.RotateFrom == 90) { SX = 0; SY = 15; } else if (tChar.RotateFrom == 180) { SX = 15; SY = 30; } else if (tChar.RotateFrom == -90) { SX = 30; SY = 15; } tChar.SafeX = X * 30 + SX; tChar.SafeY = Y * 30 + SY; tChar.SafeSegX = X; tChar.SafeSegY = Y; } if (GetArrowDir(tChar.RotateFrom) == BlockID.Down) { tChar.velY += 5; } else if (GetArrowDir(tChar.RotateFrom) == BlockID.Up) { if (!tChar.crouching) { tChar.velY -= 10; } } else if (GetArrowDir(tChar.RotateFrom) == BlockID.Left) { tChar.velX -= 3; } else if (GetArrowDir(tChar.RotateFrom) == BlockID.Right) { tChar.velX += 3; } if (!TurnedToIce) { if (T == BlockID.Mine && FadeTime == 0) { // Mine HitChar(tChar); course.DeleteBlock(X, Y); } else if (T == BlockID.Push) { GetPushed(0, 1, tChar); } else if (T == BlockID.Vanish) { Vanish(); } } }
public static List <RoutePoint> NavigateCapitals(string From, string To, double MaxLY, LocalCharacter lc, List <string> systemsToAvoid) { if (!(MapNodes.Keys.Contains(From)) || !(MapNodes.Keys.Contains(To)) || From == "" || To == "") { return(null); } double ExtraJumpFactor = 5.0; double AvoidFactor = 0.0; // clear the scores, values and parents from the list foreach (MapNode mapNode in MapNodes.Values) { mapNode.NearestToStart = null; mapNode.MinCostToStart = 0; mapNode.Visited = false; } MapNode Start = MapNodes[From]; MapNode End = MapNodes[To]; List <MapNode> OpenList = new List <MapNode>(); List <MapNode> ClosedList = new List <MapNode>(); MapNode CurrentNode = null; // add the start to the open list OpenList.Add(Start); while (OpenList.Count > 0) { // get the MapNode with the lowest F score double lowest = OpenList.Min(mn => mn.MinCostToStart); CurrentNode = OpenList.First(mn => mn.MinCostToStart == lowest); // add the list to the closed list ClosedList.Add(CurrentNode); // remove it from the open list OpenList.Remove(CurrentNode); // walk the connections foreach (JumpLink connection in CurrentNode.JumpableSystems) { if (connection.RangeLY > MaxLY) { continue; } MapNode CMN = MapNodes[connection.System]; if (CMN.Visited) { continue; } if (systemsToAvoid.Contains(connection.System)) { AvoidFactor = 10000; } else { AvoidFactor = 0.0; } if (CMN.MinCostToStart == 0 || CurrentNode.MinCostToStart + connection.RangeLY + ExtraJumpFactor + AvoidFactor < CMN.MinCostToStart) { CMN.MinCostToStart = CurrentNode.MinCostToStart + connection.RangeLY + ExtraJumpFactor + AvoidFactor; CMN.NearestToStart = CurrentNode; if (!OpenList.Contains(CMN)) { OpenList.Add(CMN); } } } CurrentNode.Visited = true; } // build the path List <string> Route = new List <string>(); CurrentNode = End; if (End.NearestToStart != null) { while (CurrentNode != null) { Route.Add(CurrentNode.Name); CurrentNode = CurrentNode.NearestToStart; } } List <RoutePoint> ActualRoute = new List <RoutePoint>(); for (int i = 0; i < Route.Count; i++) { RoutePoint RP = new RoutePoint(); RP.GateToTake = GateType.JumpTo; RP.LY = 0.0; RP.SystemName = Route[i]; if (i > 0) { RP.LY = EveManager.Instance.GetRangeBetweenSystems(Route[i], Route[i - 1]) / 9460730472580800.0; } ActualRoute.Add(RP); } ActualRoute.Reverse(); return(ActualRoute); }
private void RunAimbot(LocalCharacter local) { }
private void GetPushed(int pushX, int pushY, LocalCharacter tChar) { General.RotatePoint(ref pushX, ref pushY, -tChar.RotateFrom); course.PushBlock(this, pushX, pushY); }
public void mymethod() { LocalCharacter LocalPlayer = new LocalCharacter(this); }
public void HitRight(LocalCharacter tChar) { int BlocX = X * 30; int BlocY = Y * 30; // Rotate block coordinates (to determine where to place character) General.RotatePoint(ref BlocX, ref BlocY, tChar.Rotation); if (tChar.RotateFrom == 90 || tChar.RotateFrom == 180) { BlocX -= 30; } if (T == BlockID.Crumble) { // Crumble double _loc_8 = Math.Floor(-tChar.velX * 1.75 + 0.5); _loc_8 = Math.Floor(_loc_8 / 4); Health -= (int)_loc_8; if (Health <= 0) { T = 99; course.DeleteBlock(X, Y); return; } } tChar.X = BlocX + 30 + LocalCharacter.spaceX; if (tChar.velX < 0) { tChar.velX = tChar.velX * -0.05; } if (tChar.TargetVel < 0) { tChar.TargetVel = 0; } if (GetArrowDir(tChar.RotateFrom) == BlockID.Down) { tChar.velY += 5; } else if (GetArrowDir(tChar.RotateFrom) == BlockID.Up) { if (!tChar.crouching) { tChar.velY -= 1.2; } } else if (GetArrowDir(tChar.RotateFrom) == BlockID.Left) { tChar.velX -= 3; } else if (GetArrowDir(tChar.RotateFrom) == BlockID.Right) { tChar.velX += 3; } if (TurnedToIce) { return; } if (T == BlockID.Mine && FadeTime == 0) { // Mine HitChar(tChar); course.DeleteBlock(X, Y); } if (T == BlockID.Push) { GetPushed(-1, 0, tChar); } if (T == BlockID.Vanish) { Vanish(); } }
public void Bump(LocalCharacter tChar) { int BlocX = X * 30; int BlocY = Y * 30; // Rotate block coordinates (to determine where to place character) General.RotatePoint(ref BlocX, ref BlocY, tChar.Rotation); if (tChar.RotateFrom == -90 || tChar.RotateFrom == 180) { BlocY -= 30; } if (T == BlockID.Crumble) { double _loc_8 = Math.Floor(-tChar.velY + 0.5); _loc_8 = Math.Floor(_loc_8 / 4); Health -= (int)_loc_8; if (Health <= 0) { T = 99; course.DeleteBlock(X, Y); return; } } if (tChar.crouching) { tChar.Y = BlocY + 30 - BumpY + (LocalCharacter.spaceY / 2.0); } else { tChar.Y = BlocY + 30 + LocalCharacter.spaceY - BumpY; } tChar.velY *= -0.25; tChar.JumpVel = 0; if (!(T >= 5 && T <= 8)) { // Arrows are the only known non-bumpable. BumpVel = 15; // Only add ONE handler if (BumpY == 0) { course.AddBlockEvent(this, Map.EVENT_BUMP); } } General.PlaySound(General.sound_path + "sound 445 (ThumpSound).wav"); if (GetArrowDir(tChar.RotateFrom) == BlockID.Up) { if (!tChar.DownK && !tChar.crouching) { tChar.velY = -14; } else { tChar.velY = 0; } } else if (GetArrowDir(tChar.RotateFrom) == BlockID.Down) { tChar.velY += 5; } else if (GetArrowDir(tChar.RotateFrom) == BlockID.Left) { tChar.velX -= 3; } else if (GetArrowDir(tChar.RotateFrom) == BlockID.Right) { tChar.velX += 3; } if (TurnedToIce) { return; } if (T == BlockID.Brick) { course.DeleteBlock(X, Y); } else if (T == BlockID.Finish) { // If it's egg mode, nothing will happen. Who cares about that mode, right? if (course.gameMode.StartsWith("r") || course.gameMode.StartsWith("d")) { if (tChar.TimeStr == "") { tChar.Time = course.Frames; } } else if (course.gameMode.StartsWith("o")) { if (Health != 0) { Health = 0; tChar.finish_hit += 1; if (tChar.finish_hit == course.finish_count) { tChar.Time = course.Frames; } } } } else if (T == BlockID.Item) { if (!Used[tChar.tempID]) { Used[tChar.tempID] = true; tChar.GiveItem(); } } else if (T == BlockID.InfItem) { tChar.GiveItem(); } else if (T == BlockID.Happy) { if (!Used[tChar.tempID]) { Used[tChar.tempID] = true; tChar.SpStat += 5; tChar.AccStat += 5; tChar.JumpStat += 5; tChar.SetStats(); } } else if (T == BlockID.Sad) { if (!Used[tChar.tempID]) { Used[tChar.tempID] = true; tChar.SpStat -= 5; tChar.AccStat -= 5; tChar.JumpStat -= 5; tChar.SetStats(); } } else if (T == BlockID.Mine && FadeTime == 0) { HitChar(tChar); course.DeleteBlock(X, Y); } else if (T == BlockID.Push) { GetPushed(0, -1, tChar); } else if (T == BlockID.GravRight) { // Set mode (tChar.State) to freeze. (While frozen, the "Go" is nothing.) tChar.SetMode("freeze"); // tChar.Speed is set to 0 tChar.velY = 0; tChar.velX = 0; // Rotate! tChar.RotateTo = tChar.RotateFrom + 90; } else if (T == BlockID.GravLeft) { tChar.SetMode("freeze"); tChar.velY = 0; tChar.velX = 0; tChar.RotateTo = tChar.RotateFrom - 90; } else if (T == BlockID.Vanish) { Vanish(); } else if (T == BlockID.Time && !Used[tChar.tempID]) { if (course.max_time == 0) { course.Frames += 10 * 27; } else { course.max_time += 10; } Used[tChar.tempID] = true; } else if (T == BlockID.Heart) { if (!Used[tChar.tempID]) { Used[tChar.tempID] = true; tChar.HurtTimer = 27 * 5; // should use current frame rate, not 27 tChar.Invincible = true; } } }
private FPSCharacter FindBestTarget(LocalCharacter local) { return(null); }
public Itembls(LocalCharacter param1) { this.racer = param1; this.setReloadTime(10); this.setUses(1); }
private void Update() { if (listnerThread != null) { print(listnerThread.ThreadState + "상태"); } switch (currentState) { case ClientNetworkState.Matching: if (targetIp.Length != 0) { string newTartget; lock (listenerLocker) { newTartget = targetIp; } if (newTartget == "0") { BindPlayerServer(); } else { ConnectToPlayerServer(); } } break; case ClientNetworkState.InGame: // 메세지큐 수신 처리 { while (networkReceivedList.Count > 0) { byte[] recievedBuf; lock (listenerLocker) { recievedBuf = networkReceivedList.Dequeue(); } switch ((CTCType)recievedBuf[0]) { case CTCType.AttackSuccess: { byte[] realBuf = new byte[recievedBuf.Length - 1]; for (int i = 0; i < recievedBuf.Length - 1; ++i) { realBuf[i] = recievedBuf[i + 1]; } CM_AttackSuccess msg = MyTool.BytesToStruct <CM_AttackSuccess>(realBuf); GameMain.GetInstance().Attack((msg.type == CharacterType.Local ? CharacterType.Enemy : CharacterType.Local), msg.damage, true); } break; case CTCType.SendTime: { byte[] realBuf = new byte[recievedBuf.Length - 1]; for (int i = 0; i < recievedBuf.Length - 1; ++i) { realBuf[i] = recievedBuf[i + 1]; } CM_SendTime msg = MyTool.BytesToStruct <CM_SendTime>(realBuf); GameMain.GetInstance().timer = msg.timer - (float)(DateTime.Now - DateTime.Parse(msg.dateTime)).TotalSeconds; } break; case CTCType.Disconnect: { ChangeState(ClientNetworkState.Matching); return; } break; case CTCType.NoticeDeath: { byte[] realBuf = new byte[recievedBuf.Length - 1]; for (int i = 0; i < recievedBuf.Length - 1; ++i) { realBuf[i] = recievedBuf[i + 1]; } CM_NoticeDeath msg = MyTool.BytesToStruct <CM_NoticeDeath>(realBuf); GameMain.GetInstance().Death((msg.characterType == CharacterType.Local ? CharacterType.Enemy : CharacterType.Local), msg.position, true); } break; case CTCType.UpdatePosition: { byte[] realBuf = new byte[recievedBuf.Length - 1]; for (int i = 0; i < recievedBuf.Length - 1; ++i) { realBuf[i] = recievedBuf[i + 1]; } CM_UpdatePosition msg = MyTool.BytesToStruct <CM_UpdatePosition>(realBuf); Enemy.GetInstance().UpdatePosition(msg.position, msg.velocity); } break; case CTCType.UseSkill: { byte[] realBuf = new byte[recievedBuf.Length - 1]; for (int i = 0; i < recievedBuf.Length - 1; ++i) { realBuf[i] = recievedBuf[i + 1]; } CM_UseSkill msg = MyTool.BytesToStruct <CM_UseSkill>(realBuf); LocalCharacter.GetInstance().InstantiateMissle(msg.skillType, msg.position, msg.rotation, true); } break; } } } // 메세지 전송 처리 { for (int i = 0; i < networkSendList.Count; ++i) { SendToServer(networkSendList[i]); } networkSendList.Clear(); } break; } if (matchingFlag) { if (currentState != ClientNetworkState.Ready) { ChangeState(ClientNetworkState.Matching); } matchingFlag = false; } if (refreshThread && listnerThread.ThreadState == ThreadState.Stopped) { listnerThread.Start(); refreshThread = true; } }