示例#1
0
    public bool ExecuteAttack(Vector3 attackDirection)
    {
        Vector3 actorPos = actorPosition.position;

        actorPos.y -= 0.5f;
        Vector3Int gridDirection = grid.WorldToCell(attackDirection);
        Vector3Int actorTile     = grid.WorldToCell(actorPosition.position);

        actorTile.y    -= 1;
        gridDirection.z = actorTile.z;
        Vector3 spawnPoint = TileSystem.AdjacentTile(gridDirection, actorTile, actorPosition.position);

        spawnPoint.y -= 0.5f;

        ThrownDestructable t = GameObject.Instantiate(thrownDestructable, spawnPoint, new Quaternion());

        return(true);
    }
示例#2
0
    public bool RangedAttack(Vector3 attackDirection, Projectile projectile)
    {
        Vector3 actorPos = actorPosition.position;

        actorPos.y -= 0.5f;
        Vector3Int gridDirection = grid.WorldToCell(attackDirection);
        Vector3Int actorTile     = grid.WorldToCell(actorPosition.position);

        actorTile.y    -= 1;
        gridDirection.z = actorTile.z;
        Vector3 spawnPoint = TileSystem.AdjacentTile(gridDirection, actorTile, actorPosition.position);

        spawnPoint.y -= 0.5f;

        Vector3 rotatedVectorToTarget = Quaternion.Euler(0, 0, -45) * (spawnPoint - actorPos);

        Quaternion targetRotation = Quaternion.LookRotation(forward: Vector3.forward, upwards: rotatedVectorToTarget);

        Projectile p = GameObject.Instantiate(projectile, spawnPoint, targetRotation);

        EventManager.RaiseCombatSpawn(p);

        return(true);
    }