示例#1
0
            public void OnTriggerEnter(Collider other)
            {
                if (other.gameObject.layer == hurtBox)
                {
                    Debug.Log(other.gameObject);
                    Debug.Log("Hitbox hit a hurtbox");

                    InGameEntity gameEntity = other.gameObject.GetComponentInParent <InGameEntity>();
                    if (gameEntity != null && !hitEntities.Contains(gameEntity))
                    {
                        hitEntities.Add(gameEntity);
                        HitInfo hitInfo = new HitInfo(this, gameEntity, transform.position + transform.rotation * localHitLocation, -1);
                        onHurtBoxEnter?.Invoke(hitInfo);
                    }
                }
                else if (other.gameObject.layer == hitBox)
                {
                    Debug.Log(other.gameObject);
                    Debug.Log("Hitbox hit other hitbox");
                    InGameEntity gameEntity = other.gameObject.GetComponentInParent <InGameEntity>();
                    if (gameEntity != null && !hitEntities.Contains(gameEntity))
                    {
                        hitEntities.Add(gameEntity);
                        HitInfo hitInfo = new HitInfo(this, gameEntity, transform.position + transform.rotation * localHitLocation, -1);
                        onHitBoxEnter?.Invoke(hitInfo);
                    }
                }
            }
示例#2
0
    public InGameEntity GetFacedEntity()
    {
        Vector3 characterFacedObject_Position = Character.transform.position;

        switch (Character.facingDirection)
        {
        case Direction.UP:
            characterFacedObject_Position += new Vector3(0, 1, 0);
            break;

        case Direction.DOWN:
            characterFacedObject_Position += new Vector3(0, -1, 0);
            break;

        case Direction.RIGHT:
            characterFacedObject_Position += new Vector3(1, 0, 0);
            break;

        case Direction.LEFT:
            characterFacedObject_Position += new Vector3(-1, 0, 0);
            break;
        }
        InGameEntity entity = interactableItems.interactableEntities.Find(x => x.transform.position == characterFacedObject_Position);

        return(entity);
    }
示例#3
0
 public HitInfo(HitBox hitBox, InGameEntity hitEntity, Vector3 position, int damage)
 {
     this.hitBox    = hitBox;
     this.hitEntity = hitEntity;
     this.position  = position;
     this.damage    = damage;
 }
示例#4
0
 public void Move(InGameEntity toMove, Direction direction, bool forced = false)
 {
     if ((moveStack.Count > 0 || lockedAction) && !forced)
     {
         return;
     }
     moveStack.Add(new MoveStackArguments(toMove, direction));
 }
示例#5
0
    IEnumerator MoveAction(MoveStackArguments arguments)
    {
        Direction    direction = arguments.direction;
        InGameEntity entity    = arguments.toMove;
        Transform    toMove    = entity.transform;

        lockedAction = true;

        Vector3 vectorDirection = Vector3.zero;

        switch (direction)
        {
        case Direction.UP:
            vectorDirection = new Vector3(0, 1, 0);
            break;

        case Direction.DOWN:
            vectorDirection = new Vector3(0, -1, 0);
            break;

        case Direction.RIGHT:
            vectorDirection = new Vector3(1, 0, 0);
            break;

        case Direction.LEFT:
            vectorDirection = new Vector3(-1, 0, 0);
            break;

        case Direction.STOP:
            moveStack.Clear();
            lockedAction = false;
            yield break;
        }

        Vector3 basePosition  = arguments.toMove.transform.position;
        Vector3 finalPosition = vectorDirection + arguments.toMove.transform.position;

        entity.facingDirection = direction;

        if (GridRules.Instance.blockedPosition.Contains(finalPosition))
        {
            lockedAction = false;
            yield break;
        }

        GridRules.Instance.blockPosition((int)finalPosition.x, (int)finalPosition.y);
        for (int i = 0; i < steps; i++)
        {
            toMove.position += vectorDirection / steps;
            yield return(new WaitForEndOfFrame());
        }
        GridRules.Instance.unblockPosition((int)basePosition.x, (int)basePosition.y);
        toMove.position = finalPosition;

        lockedAction = false;
    }
示例#6
0
    public bool TryDialogInteraction(InGameEntity entity)
    {
        EntityDialog entityHasDialog = entity.transform.GetComponent <EntityDialog> ();

        if (entityHasDialog != null && !dialogStarted)
        {
            LoadDialog(entityHasDialog);
            StartCoroutine(Dialog());
            return(true);
        }
        return(false);
    }
示例#7
0
 public void InteractWithEntity(InGameEntity interactableEntity)
 {
     if (interactableEntity == null)
     {
         Debug.Log("No interactable entity found");
     }
     if (interactableEntity)
     {
         if (dialogEvent.TryDialogInteraction(interactableEntity) || dialogEvent.TryContinueDialog() || dialogEvent.TryAccelerateDialog())
         {
             Player_Gamestate.player_gameState = GAMESTATE.DIALOG;
         }
         else
         {
             Player_Gamestate.player_gameState = GAMESTATE.WORLDMAP;
         }
     }
 }
示例#8
0
 public MoveStackArguments(InGameEntity _toMove, Direction _direction)
 {
     toMove    = _toMove;
     direction = _direction;
 }