private void HandleInput() { var rawVert = Input.GetAxisRaw("Vertical"); var rawHorz = Input.GetAxisRaw("Horizontal"); controller.HandleVerticalInput(rawVert); controller.HandleHorizontalInput(rawHorz); if (Input.GetButtonDown("Jump")) { IJump jumper = controller as IJump; if (jumper != null) { jumper.HandleJump(); } } if (Input.GetButtonDown("Fire1")) { IMelee melee = controller as IMelee; if (melee != null) { melee.HandleMelee(); } } }
override public void Think(Bodies.BaseBody body) { IJump bodyJump = body as IJump; IMoveX bodyMoveX = body as IMoveX; IMoveY bodyMoveY = body as IMoveY; if (bodyJump != null) { if (Input.GetButtonDown(jumpButtonName)) { bodyJump.JumpBegin(); } else if (Input.GetButtonUp(jumpButtonName)) { bodyJump.JumpEnd(); } } if (bodyMoveX != null) { bodyMoveX.MoveX(Input.GetAxis(xAxisName)); } if (bodyMoveY != null) { bodyMoveY.MoveY(Input.GetAxis(yAxisName)); } }
public override void Play(AnimationTargetBase target) { var targetTransform = target.transform; // Jumping m_jumpTarget = targetTransform.GetComponent<IJump>(); m_jumpTarget.Jump(); }
private void Awake() { _input = new MobileInput(); _mover = new MoverWithVelocity(this, moveSpeed); _animation = new CharacterAnimation(GetComponent <Animator>()); _flip = new FlipWithTransform(this); _onGround = GetComponent <IOnGround>(); _jump = new JumpMulti(GetComponent <Rigidbody2D>(), _onGround); _health = GetComponent <IHealth>(); }
void Awake() { controller = GetComponent <IController2D>(); stateMachine = GetComponent <ITerrainState>(); attack = GetComponent <IAttack>(); dash = GetComponent <IDash>(); jump = GetComponent <IJump>(); move = GetComponent <IMovement>(); timeControll = GetComponent <ITimeControll>(); lockedShooting = false; }
// Update is called once per frame void Update() { if (jumpGameObject == null) { jumpGameObject = GameObject.Find("Astronaut"); jump = jumpGameObject.GetComponent(typeof(IJump)) as IJump; input = serialInputGameObject.GetComponent(typeof(SerialInput)) as SerialInput; } DetectJump(input.Value); }
private void Awake() { _health = GetComponent <IHealth>(); _move = GetComponent <IMove>(); _jump = GetComponent <IJump>(); _climb = GetComponent <IClimb>(); _inputControl = GetComponent <IBaseInput>(); _animator = GetComponent <Animator>(); _collider2D = GetComponent <BoxCollider2D>(); _rigidbody2D = GetComponent <Rigidbody2D>(); }
///<summary> /// Calculate branch offsets. ///</summary> private void CalcBranchOffsets(ArrayList actionRecord) { if (actionRecord.Count < 1) { return; } ArrayList jumpList = new ArrayList(); Hashtable labelPos = new Hashtable(); int pos = 0; for (int i = 0; i < actionRecord.Count; i++) { BaseAction action = (BaseAction)actionRecord[i]; ActionLabel label = action as ActionLabel; IJump jump = action as IJump; if (label != null) { labelPos[label.LabelId] = pos; } if (jump != null) { jumpList.Add(new JumpPos(pos, jump)); } // recursively step through function blocks ActionDefineFunction f = actionRecord[i] as ActionDefineFunction; if (f != null) { CalcBranchOffsets(f.ActionRecord); } ActionDefineFunction2 f2 = actionRecord[i] as ActionDefineFunction2; if (f2 != null) { CalcBranchOffsets(f2.ActionRecord); } pos += action.ByteCount; } for (int i = 0; i < jumpList.Count; i++) { JumpPos j = (JumpPos)jumpList[i]; int offset = (int)labelPos[j.Jump.LabelId] - j.Position - 5; j.Jump.Offset = offset; } }
private void TryToPerformJump(Field fromField, Field tofield) { IStoneJumper stoneJumper = _phutballBoard.GetStoneJumper(fromField, tofield); IJump validJump = stoneJumper.FindValidJump(); if (validJump != null) { PerformJump(tofield, validJump.GetJumpedFields()); } else { NextState = this; } }
public override void Effect(Collider c, B_Player p) { EffectDirector.instance.playInPlace(transform.position, StaticStrings.bomb); IJump jmp = c.GetComponent <IJump>(); if (jmp != null) { jmp.jump(); } if (Soundmanager.instance == null) { return; } Soundmanager.instance.PlaySeByName(StaticStrings.explosion); }
protected virtual void Update() { IMoveX bodyMoveX = body as IMoveX; IMoveY bodyMoveY = body as IMoveY; IMoveZ bodyMoveZ = body as IMoveZ; ITwist bodyTwist = body as ITwist; IJump bodyJump = body as IJump; if (bodyJump != null) { if (Input.GetButtonDown(jumpButtonName)) { bodyJump.JumpBegin(); } else if (Input.GetButtonUp(jumpButtonName)) { bodyJump.JumpEnd(); } } if (bodyMoveX != null) { bodyMoveX.MoveX(Input.GetAxis(xAxisName)); } if (bodyMoveY != null) { bodyMoveY.MoveY(Input.GetAxis(yAxisName)); } if (bodyMoveZ != null) { if (Input.GetAxis(zAxisName) < 0f) { int x = 1; x += 1; } bodyMoveZ.MoveZ(Input.GetAxis(zAxisName)); } if (bodyTwist != null) { bodyTwist.Twist(Input.GetAxis(twistAxisName) * Time.deltaTime * maxTwistSpeed); } }
// Use this for initialization void Start() { // if jump detector already exists var sm = GameObject.Find(this.gameObject.name); if (sm != null && sm != this.gameObject) { Destroy(this.gameObject); } // init buffers buffer = new RingBuffer <float>(bufferSize); fftBuffer = new Complex[bufferSize]; jump = jumpGameObject.GetComponent(typeof(IJump)) as IJump; input = serialInputGameObject.GetComponent(typeof(SerialInput)) as SerialInput; }
protected virtual void Update() { IMoveX bodyMoveX = body as IMoveX; IMoveY bodyMoveY = body as IMoveY; IMoveZ bodyMoveZ = body as IMoveZ; ITwist bodyTwist = body as ITwist; IJump bodyJump = body as IJump; // For the sake of following the target, we need to see if they're // distant from us. This is going to be a pretty dumb follow // function and doesn't care how high-up they are. Thus, we will // project both our position and the target's position onto the // same plane. Then any heigh-difference gets ignored. // // If needed, we could also calculate the height pretty easily. // Just take the difference of the actual positions with their // respective projected positions, and these are their heights // relative to the plane. With this knowledge, we could calculate // the height relative to one another. Vector3 currentProjectedPos = Vector3.ProjectOnPlane(transform.position, transform.up); Vector3 targetProjectedPos = Vector3.ProjectOnPlane(target.position, transform.up); if ((targetProjectedPos - currentProjectedPos).sqrMagnitude > maxDist * maxDist) { if (bodyMoveZ != null) { walkingSpeed = Mathf.Clamp01(walkingSpeed + Time.deltaTime); bodyMoveZ.MoveZ(walkingSpeed); } if (bodyTwist != null) { bodyTwist.TwistToward(target.position); } } else { walkingSpeed = 0f; } }
/// <summary> /// create <see cref="SwfOp.ByteCode.Actions.ActionLabel">ActionLabel</see> pseudo actions for branch labels /// </summary> private void CreateBranchLabels(ArrayList actionRecord) { SortedList labelList = new SortedList(); int idx = 0; while (idx < actionRecord.Count) { // read action BaseAction a = (BaseAction)actionRecord[idx]; // check if action is branch if (a as IJump != null) { IJump jump = (IJump)a; int offset = jump.Offset; int sidx = idx; if (offset < 0) { // back branch offset += a.ByteCount; while (offset < 0) { sidx--; if (sidx < 0) { break; } BaseAction ac = (BaseAction)actionRecord[sidx]; offset += ac.ByteCount; } if (!labelList.ContainsKey(sidx)) { this.LabelId++; labelList[sidx] = this.LabelId; jump.LabelId = this.LabelId; } else { jump.LabelId = (int)labelList[sidx]; } } else { if (offset == 0) { sidx = idx + 1; if (!labelList.ContainsKey(sidx)) { this.LabelId++; labelList[sidx] = this.LabelId; jump.LabelId = this.LabelId; } else { jump.LabelId = (int)labelList[sidx]; } } else { // offset>0 do { sidx++; if (sidx >= actionRecord.Count) { break; } BaseAction ac = (BaseAction)actionRecord[sidx]; offset -= ac.ByteCount; } while (offset > 0); sidx++; if (!labelList.ContainsKey(sidx)) { this.LabelId++; labelList[sidx] = this.LabelId; jump.LabelId = this.LabelId; } else { jump.LabelId = (int)labelList[sidx]; } } } } idx++; } ArrayList lines = new ArrayList(labelList.GetKeyList()); foreach (int line in lines) { int label = (int)labelList[line]; if (line < actionRecord.Count) { BaseAction a = (BaseAction)actionRecord[line]; actionRecord[line] = new ActionContainer( new BaseAction[2] { new ActionLabel(label), a } ); } else { actionRecord.Add(new ActionLabel(label)); } } idx = 0; while (idx < actionRecord.Count) { BaseAction a = (BaseAction)actionRecord[idx]; if (a is ActionContainer) { BaseAction[] bl = ((ActionContainer)a).ActionList; actionRecord.RemoveAt(idx); int j = 0; while (j < bl.Length) { actionRecord.Insert(idx, bl[j]); j++; idx++; } continue; } idx++; } }
void Awake() { controller = GetComponent <IController2D>(); stateMachine = GetComponent <ITerrainState>(); jump = GetComponent <IJump>(); }
public JumpPos(int pos, IJump j) { Position = pos; Jump = j; }
public JumpPos(int pos,IJump j) { Position = pos; Jump = j; }