public override void Deactivate() { isActive = false; movableRb = null; distanceTravelled = 0; parentMagicControllerTracker = null; }
public override void Activate() { isActive = true; if (formableMagic.Value() != null) { Debug.Log("Activating Form Magic"); magicControllerTracker = formableMagic.Value().GetComponent <MagicControllerTracker>(); if (magicControllerTracker == null) { magicControllerTracker = formableMagic.Value().gameObject.AddComponent <MagicControllerTracker>(); } magicControllerTracker.SetCurrentFormController(this); formableMagic.Value().SetShape(myForm); if (!formableMagic.Value().IsActive()) { formableMagic.Value().Activate(); } } else { Debug.LogWarning("YOOOOO, there aint no element to form the shape"); } }
public override void Activate() { isActive = true; if (movableMagic.Value() != null) { // print( "We got the current magic: " + formableMagic.Value().gameObject.name ); Debug.Log("Activating movement"); ParticleMagic pm = movableMagic.Value().GetComponent <ParticleMagic>() as ParticleMagic; if (pm != null) { pm.SetMovement(myMovement); } magicControllerTracker = movableMagic.Value().GetComponent <MagicControllerTracker>(); if (magicControllerTracker == null) { magicControllerTracker = movableMagic.Value().gameObject.AddComponent <MagicControllerTracker>(); } magicControllerTracker.SetCurrentMovementController(this); switch (myMovement) { case MovementType.Push: { if (pm != null) { Debug.Log("Pouring/pushing Movement"); relativePositionOffset = movableMagic.Value().transform.position - transform.position; if (dragMagic && movableMagic.Value().GetComponent <ParticleMagic>() != null) { parentMagicControllerTracker = movableMagic.Value().transform.parent.gameObject.GetComponent <MagicControllerTracker>(); if (parentMagicControllerTracker == null) { parentMagicControllerTracker = movableMagic.Value().transform.parent.gameObject.AddComponent <MagicControllerTracker>(); } parentMagicControllerTracker.SetCurrentMovementController(this); } } else { Debug.Log("Pushing Movement"); if ((movableRb = movableMagic.Value().GetComponent <Rigidbody2D>()) == null) { movableRb = movableMagic.Value().AddComponent <Rigidbody2D>(); } movableRb.gravityScale = 0; direction.SetDefaultValue(transform.right); movableRb.AddForce((Vector2)(initialVelocity.Value() * direction.Value().normalized), ForceMode2D.Impulse); } break; } case MovementType.Control: { Debug.Log("Controling Movement"); if ((movableRb = movableMagic.Value().GetComponent <Rigidbody2D>()) == null) { movableRb = movableMagic.Value().AddComponent <Rigidbody2D>(); } movableRb.gravityScale = 0; break; } case MovementType.Path: { Debug.Log("Using Path Movement"); if ((movableRb = movableMagic.Value().GetComponent <Rigidbody2D>()) == null) { movableRb = movableMagic.Value().AddComponent <Rigidbody2D>(); } movableRb.gravityScale = 0; break; } // case MovementType.Pour: // { // relativePositionOffset = movableMagic.Value().transform.position - transform.position; // if( dragMagic && movableMagic.Value().GetComponent<ParticleMagic>() != null ) // { // parentMagicControllerTracker = movableMagic.Value().transform.parent.gameObject.GetComponent<MagicControllerTracker>(); // if( parentMagicControllerTracker == null ) // { // parentMagicControllerTracker = movableMagic.Value().transform.parent.gameObject.AddComponent<MagicControllerTracker>(); // } // parentMagicControllerTracker.SetCurrentMovementController( this ); // } // Debug.Log("Pouring Movement"); // break; // } // TODO: add ability to compress when stopped // Currently it's just changing the shape of the form case MovementType.Stop: { // relativePositionOffset = movableMagic.Value().transform.position - transform.position; Debug.Log("Stopping Movement"); goto case MovementType.Push; break; } default: { Debug.LogWarning("Movement Type not implemented"); break; } } } else { Debug.Log("YOOOOO, there aint no element to move the object"); } }