public override void update(IEntity entity) { KeysPressed keysPressed = entity.getKeysPressed(); if (!keysPressed.actionButtonOne) { entity.getTransform().gameObject.GetComponent <Player>().isDefending = false; IBehaviourStateFactory behaviourStateFactory = entity.getBehaviourStateFactory(); entity.setState(((BehaviourStateFactory)behaviourStateFactory).getIdleState(entity)); } }
protected virtual void switchState(IEntity entity, KeysPressed keysPressed, Gravity gravity, IGravityClient gravityClient) { if (!keysPressed.jump) { if (gravity.Y_velocity >= 0.0f && (gravityClient.getJumpForce() * 0.85f) > gravity.Y_velocity) { gravity.Y_velocity = -0.01f; } } if (gravity.isFalling() || gravity.isStanding()) { gravity.Jumping = false; IBehaviourStateFactory behaviourStateFactory = entity.getBehaviourStateFactory(); entity.setState(behaviourStateFactory.getFallState(entity)); } }
public override void update(IEntity entity) { Gravity gravity = entity.getGravity(); KeysPressed keysPressed = entity.getKeysPressed(); if (keysPressed.attack) { Player player = entity.getTransform().gameObject.GetComponent <Player>(); IBehaviourStateFactory behaviourStateFactory = entity.getBehaviourStateFactory(); if (player != null && player.IsNearShop) { if (keysPressed.actionButtonOne) { entity.setState(((BehaviourStateFactory)behaviourStateFactory).getShopState(entity)); } } else { int direction = (!keysPressed.left && !keysPressed.right && !keysPressed.up && !keysPressed.down) ? -1 : getDirection(keysPressed); entity.setState(((BehaviourStateFactory)behaviourStateFactory).getAttackState(entity, direction)); } } else { IGravityClient gravityClient = entity.getGravityClient(); bool moving = false; moving = moveEntityUp(entity, keysPressed, gravity, entity.getMovementSpeed()); if (!moving) { moving = moveEntityDown(entity, keysPressed, gravity, entity.getMovementSpeed()); } if (moveEntity(entity, keysPressed, gravity, entity.getMovementSpeed())) { moving = true; } entity.setMoving(moving); if (!keysPressed.left && !keysPressed.right && !keysPressed.up && !keysPressed.down) { goIdle(entity); } } }
public override void update(IEntity entity) { Gravity gravity = entity.getGravity(); KeysPressed keysPressed = entity.getKeysPressed(); IBehaviourStateFactory behaviourStateFactory = entity.getBehaviourStateFactory(); if (keysPressed.jump && gravity.isStanding() && entity.getJumpedReleased()) { entity.setState(behaviourStateFactory.getJumpUpState(entity)); } else if (gravity.isStanding() && ((keysPressed.left && !keysPressed.right) || (!keysPressed.left && keysPressed.right))) { entity.setState(behaviourStateFactory.getMoveState(entity)); } else if (!gravity.isStanding()) { entity.setState(behaviourStateFactory.getFallState(entity)); } }
public override void update(IEntity entity) { Gravity gravity = entity.getGravity(); KeysPressed keysPressed = entity.getKeysPressed(); moveEntity(entity, keysPressed, gravity, entity.getMovementSpeed()); if (gravity.isStanding() || gravity.isNotFalling()) { entity.playAudio(AudioAttributes.LANDING_SOUND); IBehaviourStateFactory behaviourStateFactory = entity.getBehaviourStateFactory(); if (!keysPressed.left && !keysPressed.right) { entity.setState(behaviourStateFactory.getIdleState(entity)); } else { entity.setState(behaviourStateFactory.getMoveState(entity)); } } }
public override void update(IEntity entity) { Gravity gravity = entity.getGravity(); KeysPressed keysPressed = entity.getKeysPressed(); IGravityClient gravityClient = entity.getGravityClient(); #if USE_3D_RAYS gravityClient.getRayInformation3D().checkRaysFront(gravityClient, 0.0f, entity.getTransform().eulerAngles.z + 0.0f, entity.getGravityClient().getLayerToIgnore()); #else gravityClient.getRayInformation().checkRaysFront(gravityClient, 0.0f, entity.getTransform().eulerAngles.z + 0.0f, layermask); #endif if (keysPressed.jump && (gravity.isStanding() || #if USE_3D_RAYS (gravityClient.getRayHitboxes().DistanceBelow <= (gravityClient.getRayInformation3D().MinimalSpaceBetweenTileBelow))) && #else (gravityClient.getRayHitboxes().DistanceBelow <= (gravityClient.getRayInformation().MinimalSpaceBetweenTileBelow))) && #endif entity.getJumpedReleased()) { IBehaviourStateFactory behaviourStateFactory = entity.getBehaviourStateFactory(); entity.setState(behaviourStateFactory.getJumpUpState(entity)); moveEntity(entity, keysPressed, gravity, entity.getMovementSpeed()); }
public override void update(IEntity entity) { Gravity gravity = entity.getGravity(); KeysPressed keysPressed = entity.getKeysPressed(); Player player = entity.getTransform().gameObject.GetComponent <Player>(); IBehaviourStateFactory behaviourStateFactory = entity.getBehaviourStateFactory(); if (gravity.isStanding() && (keysPressed.down || keysPressed.up || keysPressed.left || keysPressed.right)) { entity.setState(behaviourStateFactory.getMoveState(entity)); } if (player != null && player.IsNearShop) { if (keysPressed.actionButtonOne) { entity.setState(((BehaviourStateFactory)behaviourStateFactory).getShopState(entity)); } } else { if (keysPressed.attack) { entity.setState(((BehaviourStateFactory)behaviourStateFactory).getAttackState(entity, Move.getDirection(keysPressed))); } else if (keysPressed.actionButtonOne) { entity.setState(((BehaviourStateFactory)behaviourStateFactory).getDefendState(entity)); } else { base.update(entity); } } }
protected void setEntity(IBehaviourStateFactory behaviourStateFactory) { entity = behaviourStateFactory.getBehaviourStateForPlayer(this); entity.setBehaviourStateFactory(behaviourStateFactory); state = behaviourStateFactory.getIdleState(entity); }
public override void update(IEntity entity) { KeysPressed keysPressed = entity.getKeysPressed(); GameObject shopCursor = entity.getTransform().gameObject.GetComponent <Player>().shopCursor; Sun sun = GameObject.FindGameObjectWithTag("Sun").GetComponent <Sun>(); entity.getTransform().gameObject.GetComponent <Player>().notForSale[0].SetActive((!sun.canRest)); if (!keysPressed.down && !keysPressed.up && !keysPressed.actionButtonOne && !keysPressed.attack) { cursorMoved = false; setCursor(shopCursor, entity.getTransform().position); } if (!cursorMoved && keysPressed.down && cursorState < EXIT) { ++cursorState; cursorMoved = true; setCursor(shopCursor, entity.getTransform().position); } else if (!cursorMoved && keysPressed.up && cursorState > REST) { --cursorState; cursorMoved = true; } switch (cursorState) { case 0: if ( //keysPressed.actionButtonOne || keysPressed.attack) { entity.getTransform().gameObject.GetComponent <Player>().resetVitality(); sun.reset(); } break; case 1: if ((sun.amountOfBlood >= (10 + (entity.getTransform().gameObject.GetComponent <Player>().extraVitality * 2))) && ( //keysPressed.actionButtonOne || keysPressed.attack)) { sun.amountOfBlood -= (10 + (entity.getTransform().gameObject.GetComponent <Player>().extraVitality * 2)); entity.getTransform().gameObject.GetComponent <Player>().extraVitality += 1; entity.getTransform().gameObject.GetComponent <Player>().notForSale[1].SetActive(!(sun.amountOfBlood >= (10 + (entity.getTransform().gameObject.GetComponent <Player>().extraVitality * 2)))); entity.getTransform().gameObject.GetComponent <Player>().notForSale[2].SetActive(!(sun.amountOfBlood >= (10 + (entity.getTransform().gameObject.GetComponent <Player>().extraPower * 2)))); } break; case 2: if ((sun.amountOfBlood >= (10 + (entity.getTransform().gameObject.GetComponent <Player>().extraPower * 2))) && ( //keysPressed.actionButtonOne || keysPressed.attack)) { sun.amountOfBlood -= (10 + (entity.getTransform().gameObject.GetComponent <Player>().extraPower * 2)); entity.getTransform().gameObject.GetComponent <Player>().extraPower += 1; entity.getTransform().gameObject.GetComponent <Player>().notForSale[1].SetActive(!(sun.amountOfBlood >= (10 + (entity.getTransform().gameObject.GetComponent <Player>().extraVitality * 2)))); entity.getTransform().gameObject.GetComponent <Player>().notForSale[2].SetActive(!(sun.amountOfBlood >= (10 + (entity.getTransform().gameObject.GetComponent <Player>().extraPower * 2)))); } break; case 3: if ( //keysPressed.actionButtonOne || keysPressed.attack) { IBehaviourStateFactory behaviourStateFactory = entity.getBehaviourStateFactory(); entity.setState(((BehaviourStateFactory)behaviourStateFactory).getIdleState(entity)); Player player = entity.getTransform().gameObject.GetComponent <Player>(); player.backGroundShop.SetActive(false); } break; default: break; } }
public void setBehaviourStateFactory(IBehaviourStateFactory behaviourStateFactory) { this.behaviourStateFactory = behaviourStateFactory; }