Я лучше тебя
-
Автор темы
- #1
Сливаю классы для шутера >>
Они уже года полтора как актуальны.
С чем и как жевать много лет как расписано в паблике.
Пожалуйста, авторизуйтесь для просмотра ссылки.
<<.Они уже года полтора как актуальны.
С чем и как жевать много лет как расписано в паблике.
Код:
using System;
using UnityEngine;
public class GameClass : MonoBehaviour
{
CColiderLine pLine;
int GetTeam(int i)
{
return PlayerControll.Player[i].Team;
}
bool IsDead(int i)
{
return PlayerControll.Player[i].DeadFlag == 1 ? true : false;
}
string PlayerName(int i)
{
return PlayerControll.Player[i].Name;
}
bool IsHavePlayer(int i)
{
return PlayerControll.Player[i] != null ? true : false;
}
Vector3 GetPlayerPos(int i)
{
return PlayerControll.Player[i].currPos;
}
GameObject GetPlayer(int i)
{
GameObject gameObject2 = GameObject.Find(PlayerControll.Player[i].go.name);
return gameObject2;
}
Vector3 World2Screen(Vector3 StartPos)
{
return Camera.main.WorldToScreenPoint(StartPos);
}
float Distance(Vector3 start, Vector3 end)
{
return Vector3.Distance(start, end);
}
Vector2 ScreenCenter()
{
return new Vector2(Screen.width / 2F, Screen.height / 2F);
}
//Магнит игроков, выстраивает в ряд
void Magnit()
{
if (Input.GetKey(KeyCode.LeftAlt))
{
int i = 0;
for (int id = 0; id < PlayerControll.Player.Length; id++)
{
if (PlayerControll.Player[id] == null)
continue;
if (GetTeam(id) == GetTeam(Client.ID))
continue;
if (IsDead(id))
continue;
if (i < 20)
{
PlayerControll.Player[id].position = Camera.main.transform.position + new Vector3(i++, 0f, 0f);
PlayerControll.Player[id].oldpos = Camera.main.transform.position + new Vector3(i++, 0f, 0f);
PlayerControll.Player[id].currPos = Camera.main.transform.position + new Vector3(i++, 0f, 0f);
PlayerControll.Player[id].go.transform.position = Camera.main.transform.position + new Vector3(i++, 0f, 0f);
}
else
if (i == 20)
{
i = 1;
}
}
}
}
public void DrawBone(Vector3 Base, Vector3 Tip, Color color)
{
if (Base == Vector3.zero)
return;
if (Tip == Vector3.zero)
return;
Vector3 start = Camera.main.WorldToScreenPoint(Base);
if (start.z < 0f)
return;
Vector3 end = Camera.main.WorldToScreenPoint(Tip);
if (end.z < 0f)
return;
this.pLine.Line(start, end, color);
}
void OnGUI()
{
this.pLine = new CColiderLine();
if (Input.GetKey(KeyCode.Mouse0))
{
//бесконечные патроны
if (BasePlayer.currweapon != null)
{
int ammotype = BasePlayer.currweapon.data.ammoType;
int num = BasePlayer.currweapon.data.maxClip;
if (BasePlayer.currweapon.data.wid == 9 || BasePlayer.currweapon.data.wid == 16)
{
BasePlayer.ammo[ammotype] = 99;
BasePlayer.currweapon.clip = 99;
}
else
{
BasePlayer.ammo[ammotype] = 99;
BasePlayer.currweapon.clip = 99;
}
BasePlayer.currweapon.sClip = BasePlayer.currweapon.clip.ToString();
BasePlayer.sAmmo[ammotype] = BasePlayer.ammo[ammotype].ToString();
}
}
if (sMenu.flyHack)
{
//флайхак, по такому принципу в куче юнити игр пашет. везде где есть Input на статике
if (Input.GetKey(KeyCode.Space))
{
Vector3 zPos = vp_FPInput.cs.Player.Position.Get();
Vector3 endPos = new Vector3(zPos.x, zPos.y + 0.224f, zPos.z);
vp_FPInput.cs.Player.Position.Set(endPos);
vp_FPInput.cs.Player.FallImpact.Send(0);
}
}
if (sMenu.ShotPistol)
{
//стрельба пистолетом без интервала задержки
vp_FPInput.CanPistolFire = true;
vp_FPInput.LastFireTime = 9;
}
for (int id = 0; id < PlayerControll.Player.Length; id++)
{
//спидхак
if (sMenu.speedHack)
{
if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.W))
{
vp_FPInput.cs.transform.Translate(Vector3.forward * Time.deltaTime * 1.3f);
}
}
//отсеиваем игрока если его НЕТ в мосиве.
if (PlayerControll.Player[id] == null)
continue;
//отсеиваем тимейтов
if (GetTeam(id) == GetTeam(Client.ID))
continue;
//отсеиваем мертвых
if (IsDead(id))
continue;
//получаем позицию игрока в пространстве
Vector3 vPos = GetPlayerPos(id);
//инициализируем бокс
BoundingBox2D WorldToScreen = new BoundingBox2D(vPos);
if (WorldToScreen.Validate)
{
//визибл чек
bool visible = PlayerControll.vp[id];
//телепорт к игроку
if (Input.GetKey(KeyCode.E))
{
Vector3 zPos = new Vector3(vPos.x - 0.3f, vPos.y + 0.5f, vPos.z);
vp_FPInput.cs.Player.Position.Set(zPos);
}
//аим бот
Vector3 origin = vp_HitscanBullet.lastray.origin;
Vector3 point = vp_HitscanBullet.lasthit.point;
Vector3 pCamera = PlayerControll.Player[id].collider.transform.position;
if (sMenu.AimOnlyShow)
{
if (visible)
if (Input.GetKey(KeyCode.Mouse0))
Client.cs.send_takedamage((byte)id, 1, 200, origin.x, origin.y, origin.z, point.x, point.y, point.z);
}
//получаем ник и ранг
string NickName = PlayerControll.Player[id].Name;
int Rank = PlayerControll.Player[id].level;
//рисуем есп.
if (sMenu.Esp2D)
DrawBoxOutlines(new Vector2(WorldToScreen.x, WorldToScreen.y), new Vector2(WorldToScreen.w, WorldToScreen.h), 1f, visible ? Color.red : Color.green);
if (sMenu.EspName)
DrawString(new Vector2(WorldToScreen.x + WorldToScreen.w / 2f, WorldToScreen.y - 22f), Color.white, TextFlags.TEXT_FLAG_CENTERED, string.Format("{0}", NickName));
if (sMenu.EspRank)
DrawString(new Vector2(WorldToScreen.x + WorldToScreen.w / 2f, WorldToScreen.y - 37f), Color.white, TextFlags.TEXT_FLAG_CENTERED, string.Format("Rank: {0}", Rank));
if (sMenu.EspDistance)
DrawString(new Vector2(WorldToScreen.x + WorldToScreen.w / 2f, WorldToScreen.y - 55f), Color.white, TextFlags.TEXT_FLAG_CENTERED, string.Format("Distance: {0}", Distance(vp_FPInput.cs.Player.Position.Get(), GetPlayerPos(id))));
}
}
}
}
Класс BoundingBox2D:
Код:
using UnityEngine;
public class BoundingBox2D
{
public float w { get; set; }
public float h { get; set; }
public float x { get; set; }
public float y { get; set; }
public bool Validate { get; set; }
public BoundingBox2D(Vector3 Character)
{
Vector3 vector_1 = Camera.main.WorldToScreenPoint(Character + new Vector3(0f, 1.8f, 0f)); // 4.5f
Vector3 vector_2 = Camera.main.WorldToScreenPoint(Character);
if ((double)vector_1.z > 0.0 && (double)vector_2.z > 0.0)
{
vector_1.y = (float)Screen.height - (vector_1.y + 1f);
vector_2.y = (float)Screen.height - (vector_2.y + 1f);
this.h = vector_2.y + 10f - vector_1.y;
this.w = this.h / 2f;
this.x = vector_1.x - this.w / 2f;
this.y = vector_1.y;
this.Validate = true;
}
else
this.Validate = false;
}
}
Класс CColiderLine:
Код:
using System;
using UnityEngine;
public class CColiderLine : MonoBehaviour
{
Material line = null;
public CColiderLine()
{
if (!this.line)
{
this.line = new Material("Shader \"Lines/Colored Blended\" {SubShader { Pass { Blend SrcAlpha OneMinusSrcAlpha ZWrite Off Cull Off Fog { Mode Off } ZTest Always BindChannels { Bind \"vertex\", vertex Bind \"color\", color }} } }");
this.line.hideFlags = HideFlags.HideAndDontSave;
this.line.shader.hideFlags = HideFlags.HideAndDontSave;
}
}
public void Line(Vector3 vStart, Vector3 vEnd, Color color)
{
this.line.SetPass(0);
GL.PushMatrix();
GL.LoadOrtho();
GL.Color(color);
GL.Begin(1);
GL.Vertex3(vStart.x / (float)Screen.width, vStart.y / (float)Screen.height, 0f);
GL.Vertex3(vEnd.x / (float)Screen.width, vEnd.y / (float)Screen.height, 0f);
GL.End();
GL.PopMatrix();
}
~CColiderLine()
{
this.line = null;
}
}