public void CreatePin(ActorFacade actorFacade) { GameObject pinPrefab; switch (actorFacade.Actor.Type) { case Type.Battle.ActorType.Submarine: pinPrefab = actorFacade.IsMine ? playerPinPrefab : enemyPinPrefab; break; case Type.Battle.ActorType.Torpedo: pinPrefab = torpedoPinPrefab; break; case Type.Battle.ActorType.Watcher: pinPrefab = watcherPinPrefab; break; default: throw new NotImplementedException("Unsupported actor type: " + actorFacade.Actor.Type); } var pin = Instantiate(pinPrefab).GetComponent <RectTransform>(); pin.SetParent(pinContainer, true); pinsByActor.Add(actorFacade, pin); }
public bool TryDestroyActor(long actorId, out ActorFacade actor) { if (TryGet(actorId, out actor)) { actors.Remove(actorId); actor.Dispose(); return(true); } return(false); }
public void DestroyPin(ActorFacade actorFacade) { RectTransform pin; if (pinsByActor.TryGetValue(actorFacade, out pin)) { Destroy(pin.gameObject); pinsByActor.Remove(actorFacade); } }
void OnActorDestroy(ActorFacade actorFacade) { view.DestroyPin(actorFacade); }
void OnActorCreate(ActorFacade actorFacade) { view.CreatePin(actorFacade); }
public bool TryGet(long actorId, out ActorFacade actorFacade) { return(actors.TryGetValue(actorId, out actorFacade)); }
Quaternion GetRadarRotation(ActorFacade actorFacade) { var eulerAngles = new Vector3(0f, 0f, actorFacade.View.ActorDirection - 90f); return(Quaternion.Euler(eulerAngles)); }
Vector3 GetRadarPosition(ActorFacade actorFacade) { var position = actorFacade.View.ActorPosition; return(matrixForRadarPosition.MultiplyPoint3x4(new Vector3(position.x, position.y))); }