public void CanGripItem(HavingLocation item) //CanGripItem과 Grip을 합침 위의 두개는 유니티에서 필요없으면 삭제합니다 { if (isTouched(this, item) && item is Item) // 터치하고 터치한게 아이템이라면 { playerItem = item as Item; //item(HavingLocation)을 Item형으로 캐스팅 } }
public void GripItem(HavingLocation item) { if (isTouched(this, item) && item is Item) { playerItem = (item as Item); } else { playerItem = null; } }
//public double CalculateDistance(Player player, HavingLocation @object) //{ // double distance = (player.X - @object.X) * (player.X - @object.X) + (player.Y - @object.Y) * (player.Y - @object.Y) + (player.Z - @object.Z) * (player.Z - @object.Z); // return Math.Sqrt(distance); //} public bool isTouched(Player player, HavingLocation @object) // 물건을 집거나 문을 열거나 할때 사용 { double distance = (player.X - @object.X) * (player.X - @object.X) + (player.Y - @object.Y) * (player.Y - @object.Y) + (player.Z - @object.Z) * (player.Z - @object.Z); return((player.Range + @object.Range) > distance); }
public bool isTouched(HavingLocation @object) { double distance = Math.Sqrt(((X - @object.X) * (X - @object.X)) + ((Y - @object.Y) * (Y - @object.Y)) + ((Z - @object.Z) * (Z - @object.Z))); return((Range + @object.Range) >= distance); }
public bool isTouched(Player player, HavingLocation @object) { double distance = Math.Sqrt(((X - @object.X) * (player.X - @object.X)) + ((player.Y - @object.Y) * (player.Y - @object.Y)) + ((player.Z - @object.Z) * (player.Z - @object.Z))); return((player.Range + @object.Range) >= distance); }