static void Main(string[] args) { Dissertation diss = new Dissertation(); IFlippable fdiss = diss; Book bdiss = diss; fdiss.CurrentPage = 42; Console.WriteLine(fdiss == bdiss); }
private void SetFlip(IFlippable flippable) { if (IsRightLooking) { flippable.FlipToRight(); } if (IsLeftLooking) { flippable.FlipToLeft(); } }
private void Update() { if (GvrControllerInput.ClickButtonUp) { GvrBasePointer pointer = GvrPointerInputModule.Pointer; UnityEngine.EventSystems.RaycastResult currentRaycastResult = pointer.CurrentRaycastResult; GameObject clickedObject = currentRaycastResult.gameObject; IFlippable flipTarget = clickedObject != null?clickedObject.GetComponent <IFlippable>() : null; if (flipTarget != null) { flipTarget.flip(force, currentRaycastResult.worldPosition); } } }
public void FlipAttempt() { GameObject heldObj = _pickupModule.heldObject; flippedThisFrame = true; timer = 0f; if (heldObj) { IFlippable _flippable = heldObj.GetComponent <ReticleObject>() as IFlippable; if (_flippable == null || !_flippable.MaxFlipCheck(false)) { _pickupModule.PutDown(); heldObj = null; } } FlipPlayerAndThings(gameObject, heldObj, rm.selectedObjs); flippedThisFrame = true; }
static void Main(string[] args) { // Two references to the same object Dissertation diss1 = new Dissertation(); Dissertation diss2 = diss1; diss1.CurrentPage = 31; diss1.Flip(); Console.WriteLine(diss1.CurrentPage); Console.WriteLine(diss2.CurrentPage); // Both print 32 // Referential equality when comparing reference types Dissertation d1 = new Dissertation(50); Dissertation d2 = new Dissertation(50); Console.WriteLine(d1 == d2); // Prints false // Value equality when comparing value types int int1 = 6; int int2 = 6; Console.WriteLine(int1 == int2); // Prints true // Reference to object with implemented interface Dissertation diss = new Dissertation(50); IFlippable f = diss; diss.Flip(); f.Flip(); Console.WriteLine(diss.Define()); // This causes an error! // Console.WriteLine(f.Define()); // Reference to object with inherited superclass Dissertation diss3 = new Dissertation(19, "Lajos Kossuth", "Shiny Happy People"); Book bdiss3 = diss3; Console.WriteLine(diss3.Author); Console.WriteLine(bdiss3.Author); Console.WriteLine(diss3.Define()); // This causes an error! // bdiss3.Define(); // Arrays of references IFlippable[] flippers = new IFlippable[] { new Dissertation(), new Diary() }; foreach (IFlippable flipper in flippers) { flipper.Flip(); } // Same reference type but different behavior (using virtual/override) Book bdiss = new Dissertation(); Book bk = new Book(); Console.WriteLine(bdiss.Stringify()); Console.WriteLine(bk.Stringify()); // Output: // "This is a Dissertation object!" // "This is a Book object!" // Null reference Diary dy = null; // Unassigned reference Diary dy2; // Unassigned references in array Diary[] dys = new Diary[5]; }
public static UndoRedoAction ItemFlipped(IFlippable item) { return new UndoRedoAction((BoardItem)item, UndoRedoType.ItemFlipped, null, null); }
public static UndoRedoAction ItemFlipped(IFlippable item) { return(new UndoRedoAction((BoardItem)item, UndoRedoType.ItemFlipped, null, null)); }
static void Main(string[] args) { //Caso 1 Diary dy1 = new Diary(5); Diary dy2 = dy1; dy2.Flip(); Console.WriteLine(dy1.CurrentPage); Console.WriteLine(dy2.CurrentPage); Console.WriteLine("\n\n"); //Caso 2 Book b1 = new Book(); Book b2 = b1; Console.WriteLine(b1 == b2); Console.WriteLine("\n\n"); //Caso 3 Dissertation diss = new Dissertation(); IFlippable fdiss = diss; Book bdiss = diss; fdiss.CurrentPage = 42; // bdiss.CurrentPage = 43; -> erro // fdiss.Stringify(); -> erro bdiss.Stringify(); Console.WriteLine(fdiss == bdiss); Console.WriteLine("\n\n"); //Caso 4: array to reference Dissertation diss1 = new Dissertation(32, "Anna Knowles-Smith", "Refugees and Theatre"); Dissertation diss2 = new Dissertation(19, "Lajos Kossuth", "Shiny Happy People"); Diary dyy1 = new Diary(48, "Anne Frank", "The Diary of a Young Girl"); Diary dyy2 = new Diary(23, "Lili Elbe", "Man into Woman"); Book[] books = new Book[] { diss1, diss2, dyy1, dyy2 }; foreach (Book bo in books) { Console.WriteLine(bo.Title); } Console.WriteLine("\n\n"); //Caso 5: Polymorphism Book bb1 = new Book(); Book bb2 = new Diary(); Console.WriteLine(bb1.Stringify()); Console.WriteLine(bb2.Stringify()); Console.WriteLine("\n\n"); //Caso 6: casting Dissertation ddiss = new Dissertation(); Diary dy = new Diary(); Book bddiss = ddiss; Book bdy = dy; Console.WriteLine($"{dy} \t {bdy} \n{ddiss} \t {bddiss}"); Console.WriteLine("\n\n"); //Caso 7: null and assigned references Book b = null; Console.WriteLine(b); Console.WriteLine(b == null); Console.WriteLine("\n\n"); /* Object o; * Console.WriteLine(o == null); //-> error CS0165: Use of unassigned local variable 'o' */ }
public FlipCommand(Transform character, IFlippable flip) : base(character) { this.flip = flip; }