public static Scene2D SpinStateKeyBoardTest() { const string SPIN_CW = "Spin CW"; const string SPIN_CCW = "Spin CCW"; const float delta = (float)(-360.0f * Math.PI / 180.0); State spinCWState = new State(SPIN_CW); spinCWState.Add(new ActionSpin(0.0f, 0.0f, -delta)); spinCWState.Add(new EventKeyBoard(SPIN_CCW, Keys.D)); State spinCCWState = new State(SPIN_CCW); spinCCWState.Add(new ActionSpin(0.0f, 0.0f, delta)); spinCCWState.Add(new EventKeyBoard(SPIN_CW, Keys.A)); Behavior behavior = new Behavior(); behavior.Add(spinCWState); behavior.Add(spinCCWState); Sprite sprite = new Sprite(FACE_IMAGE); sprite.Add(behavior); Scene2D scene = new Scene2D(); scene.Add(sprite); return(scene); }
private Sprite CreatePlayer() { const float FLIP_AMOUNT = (float)(180.0f * Math.PI / 180.0); const string IDLE_STATE = "Idle"; const string MOVE_LEFT_STATE = "Move Left"; const string MOVE_RIGHT_STATE = "Move Right"; const float SPEED = 2.5f; // IDLE_STATE //----------- State idleState = new State(IDLE_STATE); idleState.Add(new ActionSetRotate(FLIP_AMOUNT, 0.0f)); idleState.Add(new ActionFlipBook(new FlipBook(IDLE_IMAGE))); idleState.Add(new EventKeyBoard(MOVE_LEFT_STATE, Keys.A)); idleState.Add(new EventKeyBoard(MOVE_RIGHT_STATE, Keys.D)); // MOVE_LEFT_STATE //---------------- State moveLeftState = new State(MOVE_LEFT_STATE); moveLeftState.Add(new ActionTranslate(-SPEED)); moveLeftState.Add(new ActionSetRotate(FLIP_AMOUNT, FLIP_AMOUNT)); moveLeftState.Add(new ActionFlipBook(new FlipBook(RUN_IMAGE))); moveLeftState.Add(new EventKeyBoard(MOVE_RIGHT_STATE, Keys.D)); moveLeftState.Add(new EventKeyBoard(IDLE_STATE, Keys.S)); // MOVE_RIGHT_STATE //----------------- State moveRightState = new State(MOVE_RIGHT_STATE); moveRightState.Add(new ActionSetRotate(FLIP_AMOUNT, FLIP_AMOUNT)); moveRightState.Add(new ActionTranslate(SPEED)); moveRightState.Add(new ActionFlipBook(new FlipBook(RUN_IMAGE))); moveRightState.Add(new EventKeyBoard(MOVE_LEFT_STATE, Keys.A)); moveRightState.Add(new EventKeyBoard(IDLE_STATE, Keys.S)); // Behavior //--------- Behavior behavior = new Behavior(); behavior.Add(idleState); behavior.Add(moveLeftState); behavior.Add(moveRightState); //FlipBook flipBook = new FlipBook(IDLE_IMAGE); Sprite sprite = new Sprite(behavior); return(sprite); }
public static void AddBehavior(int _casterPlayer, Unit _target, Behavior _behavior) { Hero hero = BattleManager.heroes[_casterPlayer]; //如果已经有该行为,且不能叠加,刷新持续时间。否则添加 Behavior behavior = GetUnitBehavior(_target, _behavior); if (behavior != null && behavior.maxStackCount == 1) { Behavior originBehavior = GetBehavior(behavior.name); if (originBehavior.duration == 0) { behavior.duration = hero.power; } else if (originBehavior.duration > 0) { behavior.duration = originBehavior.duration; } } else { behavior = ScriptableObject.Instantiate(_behavior); behavior.name = _behavior.name; //设定持续时间,0则取决于英雄法力 if (behavior.duration == 0) { behavior.duration = hero.power; } _target.behaviors.Add(behavior); behavior.Init(_target); behavior.Add(); } }
//添加 public static void AddBehavior(Unit _target, Behavior _behavior) { Behavior behavior = ScriptableObject.Instantiate(_behavior); _target.behaviors.Add(behavior); behavior.Init(_target); behavior.Add(); }
public static Scene2D FlipBookTest() { const float FLIP_AMOUNT = (float)(180.0f * Math.PI / 180.0); const string FLIP_STATE = "Flip"; string[] IDLE_IMAGE = new string[] { NINJA_ACTION + "Idle__000.png", NINJA_ACTION + "Idle__001.png", NINJA_ACTION + "Idle__002.png", NINJA_ACTION + "Idle__003.png", NINJA_ACTION + "Idle__004.png", NINJA_ACTION + "Idle__005.png", NINJA_ACTION + "Idle__006.png", NINJA_ACTION + "Idle__007.png", NINJA_ACTION + "Idle__008.png", NINJA_ACTION + "Idle__009.png" }; string[] JUMP_IMAGE = new string[] { NINJA_ACTION + "Jump__000.png", NINJA_ACTION + "Jump__001.png", NINJA_ACTION + "Jump__002.png", NINJA_ACTION + "Jump__003.png", NINJA_ACTION + "Jump__004.png", NINJA_ACTION + "Jump__005.png", NINJA_ACTION + "Jump__006.png", NINJA_ACTION + "Jump__007.png", NINJA_ACTION + "Jump__008.png", NINJA_ACTION + "Jump__009.png" }; FlipBook fb = new FlipBook(IDLE_IMAGE); State state = new State(FLIP_STATE); state.Add(new ActionSetRotate(FLIP_AMOUNT, 0.0f, 0.0f)); state.Add(new ActionTranslate(0.5f)); Behavior behavior = new Behavior(); behavior.Add(state); Sprite sprite = new Sprite(fb, behavior); Scene2D scene = new Scene2D(); scene.Add(sprite); return(scene); }
private Sprite CreateChest() { const string CHEST_TEXTURE = "container2.png"; const string CHEST_PROP = "Chest"; State state = new State(CHEST_PROP); state.Add(new ActionSetDirection(0.5f, 0.0f)); Behavior behavior = new Behavior(); behavior.Add(state); return(new Sprite(IMAGES_DIR + CHEST_TEXTURE, behavior)); }
private Sprite CreatePlayer() { const string IDLE_PLAYER = "Idle"; const float FLIP_AMOUNT = (float)(180.0f * Math.PI / 180.0); State state = new State(IDLE_PLAYER); state.Add(new ActionSetRotate(FLIP_AMOUNT, 0.0f)); state.Add(new ActionTranslate(1.0f)); Behavior behavior = new Behavior(); behavior.Add(state); return(new Sprite(new FlipBook(IDLE_IMAGE), behavior)); }
public static Scene2D SpinOffTest() { const string SPIN_STATE = "Spin"; const float delta = (float)(-360.0f * Math.PI / 180.0); State spinState = new State(SPIN_STATE); spinState.Add(new ActionSpin(0.0f, 0.0f, -delta * 0.1f)); spinState.Add(new ActionTranslate(0.5f)); spinState.Add(new ActionScale(0.1f, 0.1f, 0.1f)); Behavior behavior = new Behavior(); behavior.Add(spinState); Sprite sprite = new Sprite(LEVEL1_IMAGE, behavior); Scene2D scene = new Scene2D(); scene.Add(sprite); return(scene); }
private void Initialize(IWebDriver webDriver, string baseAddress) { Return(this); Return(webDriver); Return(baseAddress).WhenNamed("BaseAddress"); WebDriver = webDriver; BaseAddress = baseAddress; Behavior.Add((r, o) => { if (o.GetType().IsValueType || o is string) { return(o); } PageFactory.InitElements(webDriver, o); return(o); }); Behavior.Add(ImportPropertiesOnLocate); }