static void Main(string[] args) { //Asignamos un metodo anonimo al delegado DelVoid dv = delegate() { Console.WriteLine("Soy un metodo Anonimo"); }; // Agregamos el metodo saludar al mismo delegado dv += Saludar; dv(); // llamada al delegado // Asignamos un metodo anonimo que retorna valor //y recibe parametros DelIntRes dir = delegate(int b) { return(b * b); // b al cuadrado }; // Agregamos el metodo duplicar a ese dir += Duplicar; Console.WriteLine(dir(5)); }
public void Hide(DelVoid endDel = null) { if (_coroutine != null) { StopCoroutine(_coroutine); } /* _rect.pivot = _showPivot; * _rect.anchoredPosition = Vector2.zero;*/ _coroutine = GoZeroPos(_hidePivot, endDel); StartCoroutine(_coroutine); }
private IEnumerator FadeAlpha(float targetAlpha, DelVoid del = null) { var color = m_background.color; while (Mathf.Abs(color.a - targetAlpha) > .1f) { color.a = Mathf.MoveTowards(color.a, targetAlpha, hTime.deltaTime * 2); m_background.color = color; yield return(null); } color.a = targetAlpha; m_background.color = color; m_curCoroutine = null; del?.Invoke(); }
public InfoBox(string m, DelVoid cb, bool removable) { Content = new ContentManager(GameResources.GameServices, "Content"); background = new GameGraphic("InfoBox", Content); font = Content.Load<SpriteFont>("Fonts/Philo14"); callback = cb; message = m; oldKeyState = Keyboard.GetState(); newKeyState = Keyboard.GetState(); oldGamePadState = GamePad.GetState(PlayerIndex.One); newGamePadState = GamePad.GetState(PlayerIndex.One); isRemovable = removable; if (isRemovable) instruction = "A/Enter: Okay"; else instruction = ""; }
private IEnumerator GoZeroPos(Vector2 pivot, DelVoid endDel) { Vector2 size = _rect.rect.size; Vector2 deltaPivot = _rect.pivot - pivot; Vector2 deltaPosition = new Vector2(deltaPivot.x * size.x, deltaPivot.y * size.y); _rect.pivot = pivot; _rect.anchoredPosition -= deltaPosition; while (_rect.anchoredPosition.magnitude > 0) { _rect.anchoredPosition = Vector2.MoveTowards(_rect.anchoredPosition, Vector2.zero, _speed * Time.deltaTime); yield return(null); } _rect.anchoredPosition = Vector2.zero; _coroutine = null; endDel?.Invoke(); }
float WALL_JUMP_V_Y; //y-component of velocity when jumping off a wall. (Pixels/sec) #endregion Fields #region Constructors /// <summary> /// Creates a new Player object /// </summary> public Player(ContentManager content, DelVoid saveMethod, DelRoom roomMethod, DelSB hudMethod) : base("Player", content) { isSpawned = false; JUMP_V = (float)(-Math.Sqrt(-2 * PhysicsEngine.GRAVITY * MAX_JUMP_HEIGHT)); WALL_JUMP_V_X = (float)(JUMP_V * 0.7071); WALL_JUMP_V_Y = (float)(JUMP_V * 0.7071); itemArray = new bool[GameResources.NUM_ITEMS]; for (int i = 0; i < itemArray.Length; i++) itemArray[i] = false; itemArray[0] = true; soundEngine = new AudioEngine(content, "Player"); saveCallback = saveMethod; hudCallback = hudMethod; roomCallback = roomMethod; lifeCollisionXs = new short[collisionXs.Length]; lifeCollisionYs = new short[collisionYs.Length]; deathCollisionXs = new short[collisionYs.Length]; deathCollisionYs = new short[collisionXs.Length]; Array.Copy(collisionXs, lifeCollisionXs, collisionXs.Length); Array.Copy(collisionYs, lifeCollisionYs, collisionYs.Length); Array.Copy(collisionXs, deathCollisionYs, collisionXs.Length); Array.Copy(collisionYs, deathCollisionXs, collisionYs.Length); }
/// <summary> /// Constructor call /// </summary> public GameManager(DelVoid exitDel) { isPaused = false; inGame = false; exitCallback = exitDel; }