private void SetCablePosition(ICable item) { Vector vector = new Vector(this.Parent.X - this.Target.X, this.Parent.Y - this.Target.Y); vector.Normalize(); vector *= 20; item.X = (item.NextGameObject as ICable).X + vector.X; item.Y = (item.NextGameObject as ICable).Y + vector.Y; }
static void initCharge(string region1, string region2, string phone, string port) { Enchufe enchufe = new Enchufe(region1); Cabeza cabeza = new Cabeza(region2); Celular celular = new Celular(phone, port); CableFactory cableF = new CableFactory(); enchufe.printConnect(); cabeza.printConnect(); checkAdapter(enchufe, cabeza); celular.connectCelular(); ICable cable = cableF.GetCable(celular); cable.printCable(); }
private List <ICable> RemoveCable(ICable next) { List <ICable> ret = new List <ICable>(); if (next is ICable) { ret = this.RemoveCable(next.NextGameObject as ICable); } this.Cables.Remove(next as ICable); if (next != null) { var a = next.NextGameObject; next.NextGameObject = next.Previous; next.Previous = a; ret.Insert(0, next as ICable); } return(ret); }
/// <inheritdoc/> public void Cut(ICable cable) { if (this.Mode == UtpModes.ConnectedToServer) { List <ICable> cables = new List <ICable>(); if (cable.NextGameObject is ICable) { cables = this.RemoveCable(cable.NextGameObject as ICable); } if (cables.Count > 0) { cables[0].NextGameObject = this.Parent; this.Target.AddCutedUtp(this.CutedUTP(cables)); this.First.NextGameObject = this.Target; } } this.Aback(); }
// Use this for initialization private void Start() { IsCable = false; var ListOfICable = this.GetComponents <ICable>(); foreach (ICable Cable in ListOfICable) { if (Cable.IsCable) { //Logger.Log ("Found it", Category.Electrical); RelatedCable = Cable; } } if (!(RelatedCable == null)) { Color = RelatedCable.CableType; DirectionEnd = RelatedCable.DirectionEnd; DirectionStart = RelatedCable.DirectionStart; //FIXME this breaks wires that were placed via unity editor: // need to address when we allow users to add wires at runtime SetDirection(DirectionStart, DirectionEnd); } }
/// <inheritdoc/> public void CutUtp(IUtp utp, ICable cable) { utp.Cut(cable); }